Skip to content

Commit

Permalink
fix: sorting questions randomly
Browse files Browse the repository at this point in the history
  • Loading branch information
MarcoEscaleira committed Feb 21, 2024
1 parent d31747a commit 301e455
Showing 1 changed file with 3 additions and 2 deletions.
5 changes: 3 additions & 2 deletions src/state/attemptStore.ts
Original file line number Diff line number Diff line change
Expand Up @@ -37,10 +37,10 @@ export const useAttemptStore = create<AttemptState>()(
toggleStartQuizDialog();
handleQuizAccordion(0);

// TODO: sort questions and options on attempt start
const tempQuestions = [...questions];
return {
isAttemptRunning: true,
questions: questions,
questions: tempQuestions.sort(() => Math.random() - 0.5),
currentQuestion: 0,
startTime,
};
Expand All @@ -59,6 +59,7 @@ export const useAttemptStore = create<AttemptState>()(
if (data?.addAttempt?.id) {
await router.navigate(`/game/quiz/${quizId}/attempt/${data.addAttempt.id}`);
toast.success("Your quiz attempt has been submitted successfully.");

getState().resetAttempt();
} else {
toast.error("Failed to submit the quiz attempt. Please try again.");
Expand Down

0 comments on commit 301e455

Please sign in to comment.