fix(quiz): give each question its own countdown instead of one shared… - #11
Merged
Conversation
… clock QuizPage and PostJobPage rendered every question at once via questions.map, so all QuestionCards mounted in the same tick and their countdowns ran in parallel from the same start time. The question never changed, so the card's per-question effect never re-ran: by the time a candidate reached question 2 its clock had already been running for the whole of question 1. All timers also expired together, so the expired.size >= questions.length auto-submit fired once, ~limit seconds after load. Both rounds were really on a single 75s clock while the UI advertised "75s per question". Render only the active question and advance through them one at a time: - currentIndex selects the mounted question; moving on remounts the next card, which starts a fresh limit-second countdown. - advance() goes to the next question, or submits on the last one. - handleExpire() locks the answer as-is and moves straight on, so expiry auto-submit now fires per question rather than for the round as a whole. - The set-based auto-submit effect is gone; advance() owns the commit path. Advancing is one-way, so leftover time on a question is forfeited rather than bankable — the clock is only meaningful if it cannot be carried over. PostJobPage additionally passes questionNumber/totalQuestions, which it previously omitted; the position label matters once the cards are not stacked. QuestionCard itself was already correct and is unchanged. Verified by mounting both pages under jsdom with fetch stubbed: advancing shows the timer back at full, expiry mid-round advances with a fresh clock, and the last question expiring submits exactly once with per-question seconds_left recorded. Co-Authored-By: Claude Opus 5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_014U4ypgHVqMaSPtaJvFeCko
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
… clock
QuizPage and PostJobPage rendered every question at once via questions.map, so all QuestionCards mounted in the same tick and their countdowns ran in parallel from the same start time. The question never changed, so the card's per-question effect never re-ran: by the time a candidate reached question 2 its clock had already been running for the whole of question 1.
All timers also expired together, so the expired.size >= questions.length auto-submit fired once, ~limit seconds after load. Both rounds were really on a single 75s clock while the UI advertised "75s per question".
Render only the active question and advance through them one at a time:
Advancing is one-way, so leftover time on a question is forfeited rather than bankable — the clock is only meaningful if it cannot be carried over. PostJobPage additionally passes questionNumber/totalQuestions, which it previously omitted; the position label matters once the cards are not stacked.
QuestionCard itself was already correct and is unchanged.
Verified by mounting both pages under jsdom with fetch stubbed: advancing shows the timer back at full, expiry mid-round advances with a fresh clock, and the last question expiring submits exactly once with per-question seconds_left recorded.
Claude-Session: https://claude.ai/code/session_014U4ypgHVqMaSPtaJvFeCko