You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
[Feature] Preserve in-progress quiz answers across modal close and page refresh #38
All quiz answers live only in React component state, so a single page refresh, accidental back-button, or closing the modal throws away the attempt in progress.
Details
frontend/src/components/DayModal.jsx keeps answers and step in useState. handleAnswer auto-advances and only calls onSubmit on the last question — so for any quiz longer than a couple of questions there is a real window where a refresh loses everything.
Closing the modal unmounts the component and resets all state.
The backend allows exactly one scored attempt per quiz (quizController.submitQuiz returns 409 [CONFLICT] This quiz can only be submitted once.), so the user's only option after a refresh is to start the quiz over from scratch and lose whatever they had selected.
Tasks / Requirements
Persist the in-progress draft (selected answers + current step) to sessionStorage keyed by quiz/day id, and restore it when the modal reopens or the page reloads.
Clear the draft immediately after a successful submit (and on "Start over", if offered) so a stale draft can never be replayed against a taken quiz.
Never send the draft to the server — the one-attempt rule and server-side grading in quizController.submitQuiz must stay authoritative.
Guard against corrupted/older drafts (question count changed, malformed JSON) by falling back to a fresh attempt.
Keep the existing "already attempted → results view" behaviour for quizzes in progress.attemptedQuizIds.
Thanks for volunteering, @adityamukesh! Assigning this to you. Please go ahead with the persistence approach. Just make sure the draft only clears on a genuinely successful submit, and validate/ignore stale or malformed drafts. Feel free to open a WIP PR if you want early feedback
Activity
adityamukesh commentedon Oct 8, 2026
Hey team! I can implement persistence for in-progress quiz answers to prevent accidental data loss.
Proposed Implementation:
frontend/src/components/DayModal.jsx, synchronizeanswersandstepstate withlocalStorage(keyed byquiz_progress_${quizId}_${userId}).This will protect students from lost progress on modal close or browser reload. May I be assigned this issue?
spandan11106 commentedon Oct 9, 2026
Thanks for volunteering, @adityamukesh! Assigning this to you. Please go ahead with the persistence approach. Just make sure the draft only clears on a genuinely successful submit, and validate/ignore stale or malformed drafts. Feel free to open a WIP PR if you want early feedback
spandan11106 commentedon Oct 21, 2026
@adityamukesh any updates on this. Also before you raise a pr register on the Hacktober website to get on the leaderboard.
Preserve in-progress quiz answers across modal close and reload