ls1intum / Apollon

UML Modeling Editor written in React
https://apollon-library.readthedocs.io
MIT License
65 stars 22 forks source link

Fix assessment subscription in `apollon-editor.ts` #295

Closed pal03377 closed 1 year ago

pal03377 commented 1 year ago

Checklist

Motivation and Context

We have a bug in Artemis where all tutor assessments get lost on save. Artemis sometimes does not get events for new assessments. Therefore, assessments can often get lost, especially in Safari.

Description

Change .splice(i) (which removes all elements in the array starting from i) with an object-key-based approach. This additionally prevents problems from occurring when indexes shift because of splice.

Also, a subscription to this.store in apollon-editor.ts did sometimes not work because this.store was still undefined when it was called. I added code to automatically retry the subscription when if fails because of that.

Steps for Testing

  1. Deploy https://github.com/ls1intum/Artemis/pull/6901 (has version of the npm package with this fix in it)
  2. Assess modeling exercise participation
  3. Assess components
  4. Press "Save" or "Override Assessment"
  5. Assessments are no longer lost. They were gone previously.

For better reproducibility, test in Safari. In Safari, the bug occurs more often (closer to 100% of the time). In Chrome, the issue sometimes does not appear at all.

Test Coverage

File Line
apollon-editor.ts 79.59 %