Question presented to candidate: "Build a short multiple-choice quiz. Show one question at a time with four options, a Next button and a countdown for each question. If time runs out, record the question as unanswered and move on. At the end, show the score and a review of every question with the correct answer, and let the user restart."
Requirements:
- Intro screen, then questions one at a time with "Question N of M" and a progress bar, then a review screen.
- Select an option (mouse or keys 1-4), then Next (or Enter); Next is disabled until something is selected; the last button says Finish.
- A 10-second timer per question that does not drift and auto-advances with the answer recorded as "time ran out".
- Review: score as
X / Nand a percentage, each question marked right or wrong with your answer and the correct one; Restart resets everything. - Focus moves to the new question heading so screen-reader users hear each question.
What a strong answer should cover:
- Modelling the flow as a state machine (
intro,question,review) with the index, the current selection and an answers array. - Score as derived data computed from answers, never stored separately.
- A timer measured against a deadline, cleared when the question changes or the component unmounts, and protected against a late tick skipping the next question.
- Global keyboard shortcuts added and removed with the lifecycle, without hijacking Enter on buttons.
- Accessibility: native radios in a
fieldset,role="timer", focus management between questions.
Clarifying questions expected:
- "Should answers be revealed after each question or only at the end?"
- "Can users go back to change an answer?"
- "Are questions loaded from an API, and should their order or options be shuffled?"
Code / implementation expected: Yes. A working quiz with timer, keyboard support, review and restart.