Skip to content

fix(quiz): shuffle options per attempt so answers can't be found by position - #226

Merged
mnaimfaizy merged 1 commit into
mainfrom
fix/quiz-shuffle-options
Oct 14, 2026
Merged

mnaimfaizy merged 1 commit into
mainfrom
fix/quiz-shuffle-options

Conversation

@mnaimfaizy

Copy link
Copy Markdown
Owner

Quiz answers could be found by position. The quiz showed options in bank order and never shuffled them. In most banks every single-choice answer was option A, and every multi-select included A. And 25 of the 41 ordering questions started with their items already in the correct order. A learner could reach the 80% milestone (ADR 0005) without reading the questions.

Fix: shuffle per attempt, in code

  • When an attempt starts, each question gets a presentation order, stored in the attempt as presentation (display position → bank index). It covers options for single-choice and multi-select, responses for matching, and the starting order of items for ordering, which never starts correct. True/false keeps its order.
  • Answers are still stored and scored in the bank's own indices and strings. Scoring, stored results and best scores don't change.
  • Attempts saved before this change have no presentation. They load and render in bank order, and a reload keeps the order.
  • The bank files are unchanged, so every current and future bank is covered.

Validation

  • npx tsc -b, lint, npm run test:run (1,538 tests in 108 files) and build pass.
  • New tests:
    • the order is a permutation;
    • an ordering question never starts correct;
    • scoring through the shuffled display matches scoring directly;
    • an old attempt still renders and scores;
    • clicking a displayed option stores the bank index;
    • across seeded attempts, no real bank's correct answer always shows first.
  • In the browser (DevOps quiz, where every answer is option A in the bank), the correct answer was shown as C. Choosing it stored bank index 0, and a reload kept the order and the selection.

Unchanged

An ordering question the learner never touches still counts as unanswered, as before. Because the start is never correct, it would be wrong either way.

🤖 Generated with Claude Code

…osition

Each new attempt draws a presentation order per question and stores it in
the attempt: options for single-choice and multi-select, responses for
matching, and the starting order of items for ordering, which never starts
correct. True/false keeps its order. Answers stay in bank indices and
strings, so scoring and stored results are unchanged. Attempts stored
without a presentation order load and render in bank order.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@mnaimfaizy
mnaimfaizy merged commit 66efb94 into main Oct 14, 2026
9 checks passed
@mnaimfaizy
mnaimfaizy deleted the fix/quiz-shuffle-options branch October 14, 2026 21:21
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