Skip to content

[Tech-debt] quizStore has no persistence — quiz state is lost on page refresh #755

Description

@RUKAYAT-CODER

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

Metadata

Metadata

Assignees

Labels

Stellar WaveIssues in the Stellar wave programtech-debtTechnical debt cleanup

Type

No type

Fields

No fields configured for issues without a type.

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions