Skip to content

Ensure Proper Client-Side Randomization of Quiz Cards in Quiz Mode #14

Description

@seanconroy-dev

Ensure Proper Client-Side Randomization of Quiz Cards in Quiz Mode

Description

The quiz mode relies entirely on client-side logic (no backend), meaning each session is generated fresh in the browser. We need to verify that quiz cards are properly randomized on each run and that the implementation produces unbiased and non-repetitive ordering.

Objective

Ensure that the client-side shuffle logic correctly randomizes quiz cards so that:

  • Each page load or quiz start produces a new card order
  • All cards have an equal probability of appearing in any position
  • The randomness is not affected by deterministic patterns or flawed algorithms

Scope of Work

  • Review the current client-side randomization logic (e.g., array shuffling)
  • Confirm use of a proper unbiased algorithm (e.g., Fisher–Yates shuffle)
  • Validate that randomization runs on every quiz initialization (not cached or reused)
  • Test behavior across multiple page reloads and quiz restarts
  • Optionally log or simulate multiple runs to observe distribution patterns

Acceptance Criteria

  • Card order changes between page reloads and quiz restarts
  • No duplicate or missing cards within a single session
  • Distribution of card positions appears uniform over repeated trials
  • Randomization is handled entirely on the client without reliance on persisted state
  • Code is documented to explain the chosen randomization approach

Additional Notes

  • Since there is no backend, randomness depends on browser-provided APIs (e.g., Math.random()), which should be sufficient for this use case
  • Avoid using array.sort(() => Math.random() - 0.5) as it introduces bias
  • Keep implementation lightweight and performant for a static web app

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Labels

No labels
No labels

Projects

No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions