Skip to content

Fix quiz answer reset bug. - #319

Merged
SilasBerger merged 4 commits into
mainfrom
fix/quiz-answer-reset
Sep 9, 2026
Merged

SilasBerger merged 4 commits into
mainfrom
fix/quiz-answer-reset

Conversation

@SilasBerger

@SilasBerger SilasBerger commented Sep 8, 2026

Copy link
Copy Markdown
Contributor

Fixes a bug that lead to quiz answers getting lost.

Fix explanation

The likely cause lies in iAssessable#_checkIntegrity(), where the iAssessable self-destructs if it can't find its own question ID in the parent quiz' question IDs. This helps us get rid of orphaned question documents, but only as long as we are looking at the actual quiz' question IDs. It seems like there can be a case where we are looking at maybe a dummy, which has an empty set of question IDs, which would lead to an iAssessable prematurely destroying itself, including a DELETE request to the API.

This fix uses the heuristic "a real quiz has at least one question ID" to prevent this cleanup mechanism from firing prematurely. My testing suggests that it does solve the problem, but further investigation into the logic of how and when we can rely on a document to be "the real deal" might be useful.

Original bug

Steps to reproduce:

  1. Go to https://teaching-dev.gbsl.website/docs/gallery/persistable-documents/answer/choice-answer/#quizzes.
  2. Solve and assess the quiz.
  3. Navigate to a different chapter.
  4. Reload the page (from within that different chapter).
  5. Navigate back to https://teaching-dev.gbsl.website/docs/gallery/persistable-documents/answer/choice-answer/#quizzes.
  6. Likely, some or all quiz answers will have been reset.

What doesn't trigger the reset:

  • Reload from the quiz page.
  • Navigation without reload.

@SilasBerger
SilasBerger requested a review from a team September 8, 2026 14:34
@bolt-new-by-stackblitz

Copy link
Copy Markdown

Review PR in StackBlitz Codeflow Run & review this pull request in StackBlitz Codeflow.

@netlify

netlify Bot commented Sep 8, 2026

Copy link
Copy Markdown

Deploy Preview for teaching-dev ready!

Name Link
🔨 Latest commit 59f0d11
🔍 Latest deploy log https://app.netlify.com/projects/teaching-dev/deploys/6aa1082e8253920008240e39
😎 Deploy Preview https://deploy-preview-319--teaching-dev.netlify.app
📱 Preview on mobile
Toggle QR Code...

QR Code

Use your smartphone camera to open QR code link.

To edit notification comments on pull requests, go to your Netlify project configuration.

- [ ] Für Prüfungen könnte es nützlich sein, das Konzept des Quiz zu erweitern, um nicht nur `ChoiceAnswer`-Fragen zu unterstützen, sondern auch andere Fragetypen wie z.B. `TextAnswer` oder `CodeAnswer`. So könnte eine Prüfung aus einem einzigen Quiz bestehen, in dem auch Fragen vorkommen, die nicht automatisch korrigiert werden können. Der Vorteil dabei wäre, dass so auch diese Fragen in die Randomisierung der Reihenfolge mit einbezogen werden könnten. Zudem könnte ein Report (PDF, druckbar) generiert werden, der die Ergebnisse aller automatisch korrigierten Fragen enthält, und für das Feedback zu den manuell zu korrigierenden Fragen einen Platzhalter lässt. No newline at end of file
- [ ] Für Prüfungen könnte es nützlich sein, das Konzept des Quiz zu erweitern, um nicht nur `ChoiceAnswer`-Fragen zu unterstützen, sondern auch andere Fragetypen wie z.B. `TextAnswer` oder `CodeAnswer`. So könnte eine Prüfung aus einem einzigen Quiz bestehen, in dem auch Fragen vorkommen, die nicht automatisch korrigiert werden können. Der Vorteil dabei wäre, dass so auch diese Fragen in die Randomisierung der Reihenfolge mit einbezogen werden könnten. Zudem könnte ein Report (PDF, druckbar) generiert werden, der die Ergebnisse aller automatisch korrigierten Fragen enthält, und für das Feedback zu den manuell zu korrigierenden Fragen einen Platzhalter lässt.

## Testing Only

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This section can be deleted before merging. It is just there to show that new quizzes (ones that the testers haven't yet created documents for) still work.

@SilasBerger SilasBerger changed the title [WIP] Try to fix quiz answer reset bug. Fix quiz answer reset bug. Sep 8, 2026

@lebalz lebalz left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM, thanks for the investigation and the proposed fix 👍 Beside the suggested change: ready to merge

Comment thread src/models/documents/Assessable/iAssessable.ts Outdated
Co-authored-by: Balthasar Hofer <lebalz@outlook.com>
@SilasBerger

Copy link
Copy Markdown
Contributor Author

As dicussed offline: Merging this fix for now; further (more general) investigation advised.

@SilasBerger
SilasBerger merged commit 9719e13 into main Sep 9, 2026
5 checks passed
@SilasBerger
SilasBerger deleted the fix/quiz-answer-reset branch September 9, 2026 07:22
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants