Overview
src/app/store/quizStore.ts uses Zustand without a persist middleware. A user mid-quiz who refreshes the page loses all their answers, timing data, and current question index. This forces users to restart quizzes from scratch and creates a frustrating experience especially on poor network connections where refreshes are common.
Specifications
Features:
- Active quiz state is persisted to
sessionStorage so a page refresh resumes the quiz
- Completed quiz results are persisted to
localStorage for review
Tasks:
- Add Zustand
persist middleware to quizStore using sessionStorage as the storage engine
- Persist:
currentQuiz, currentQuestionIndex, answers, startTime, reviewMode
- On
endQuiz, move completed quiz data to a separate localStorage key for history
- Add a test that simulates store rehydration and asserts the quiz resumes correctly
Impacted Files:
src/app/store/quizStore.ts
Acceptance Criteria
- Refreshing the browser during a quiz restores the current question and all answers
- Completed quiz results are accessible after the quiz session ends
- Quiz state is cleared from
sessionStorage after a quiz is submitted
Overview
src/app/store/quizStore.tsuses Zustand without apersistmiddleware. A user mid-quiz who refreshes the page loses all their answers, timing data, and current question index. This forces users to restart quizzes from scratch and creates a frustrating experience especially on poor network connections where refreshes are common.Specifications
Features:
sessionStorageso a page refresh resumes the quizlocalStoragefor reviewTasks:
persistmiddleware toquizStoreusingsessionStorageas the storage enginecurrentQuiz,currentQuestionIndex,answers,startTime,reviewModeendQuiz, move completed quiz data to a separatelocalStoragekey for historyImpacted Files:
src/app/store/quizStore.tsAcceptance Criteria
sessionStorageafter a quiz is submitted