Skip to content

fix(quiz): give each question its own countdown instead of one shared… - #11

Merged
krishhimself merged 1 commit into
mainfrom
fix/per-question-timer-reset
Aug 29, 2026
Merged

fix(quiz): give each question its own countdown instead of one shared…#11
krishhimself merged 1 commit into
mainfrom
fix/per-question-timer-reset

Conversation

@krishhimself

Copy link
Copy Markdown
Owner

… 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.

Claude-Session: https://claude.ai/code/session_014U4ypgHVqMaSPtaJvFeCko

… 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
@krishhimself
krishhimself merged commit 2863330 into main Aug 29, 2026
2 checks passed
@krishhimself
krishhimself deleted the fix/per-question-timer-reset branch August 29, 2026 07:58
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.

1 participant