Quiz exercises: Fix 'Invalid Input' persisting after deleting and restoring the only question#12544
Quiz exercises: Fix 'Invalid Input' persisting after deleting and restoring the only question#12544MaximilianAnzinger wants to merge 1 commit intodevelopfrom
Quiz exercises: Fix 'Invalid Input' persisting after deleting and restoring the only question#12544Conversation
When all questions were deleted and the quiz was restored via "Reset Quiz", the "Invalid Input" badge persisted because resetAll() did not call cacheValidation(). Add the call so quizIsValid and invalidReasons are refreshed after the quiz is restored from savedEntity. Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
Quiz exercise: Fix 'Invalid Input' persisting after deleting and restoring the only question
Quiz exercise: Fix 'Invalid Input' persisting after deleting and restoring the only questionQuiz exercises: Fix 'Invalid Input' persisting after deleting and restoring the only question
|
@MaximilianAnzinger Test coverage has been automatically updated in the PR description. |
WalkthroughThe changes address a validation state bug in quiz re-evaluation by ensuring that the Changes
Estimated code review effort🎯 2 (Simple) | ⏱️ ~10 minutes 🚥 Pre-merge checks | ✅ 5✅ Passed checks (5 passed)
✏️ Tip: You can configure your own custom pre-merge checks in the settings. ✨ Finishing Touches📝 Generate docstrings
🧪 Generate unit tests (beta)
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
End-to-End Test Results
Test Strategy: Two-phase execution
Overall: ❌ Phase 2 (remaining tests) failed 🔗 Workflow Run · 📊 Test Report |
Claudia-Anthropica
left a comment
There was a problem hiding this comment.
@MaximilianAnzinger Clean fix — resetAll() was the only mutation missing the cacheValidation() call. The new test covers the exact bug scenario nicely. Approving as-is.
SedaOran
left a comment
There was a problem hiding this comment.
Hi @MaximilianAnzinger ,
Thanks for the clean fix, the validation issue and the added test make sense.
I had one question regarding the behavior after clicking Reset Quiz: once the questions are restored, the Save button remains disabled if no further changes are made. Only after modifying the quiz again does it become enabled.
Is this the expected behavior (i.e., no changes → nothing to save), or should resetting also mark the quiz as having pending changes so it can be saved immediately? Just wanted to clarify whether this is intentional or something we might want to revisit.
Thanks!
Summary
Fixes #12475. When re-evaluating a quiz, deleting all questions (or the only question) and then clicking Reset Quiz to restore them left the "Invalid Input" badge permanently visible — even though the quiz was fully valid again after the reset.
Checklist
General
Client
Motivation and Context
Fixes #12475.
In the re-evaluate flow (
QuizReEvaluateComponent), theresetAll()method clonessavedEntityback intoquizExercise— effectively restoring any questions that were previously deleted. However, it never calledcacheValidation(), so the cached validation state (quizIsValid,invalidReasons) remained stale from when the questions were deleted. As a result, the "Invalid Input" badge kept showing the "The quiz has no questions" message even after the questions had been restored.Description
Root cause:
resetAll()inquiz-re-evaluate.component.tsonly restoredquizExercisefromsavedEntitybut omitted thecacheValidation(this.changeDetector)call that updatesquizIsValidandinvalidReasons.Fix: Added
this.cacheValidation(this.changeDetector)at the end ofresetAll(). This is a one-line change mirroring what every other mutation in this component already does (e.g.deleteQuestion,onQuestionUpdated).Test added: A new Vitest test in
quiz-re-evaluate.component.spec.tsthat:quizIsValid === falseresetAll()→ asserts questions are restored andquizIsValid === trueSteps for Testing
Prerequisites:
Testserver States
You can manage test servers using Helios. Check environment statuses in the environment list. To deploy to a test server, go to the CI/CD page, find your PR or branch, and trigger the deployment.
Review Progress
Performance Review
Code Review
Manual Tests
Test Coverage
Client
Last updated: 2026-04-16 09:34:21 UTC