From 76bed9615143fd13fe05f3cf90d37739b91915be Mon Sep 17 00:00:00 2001 From: Victor Giers Date: Wed, 7 Jan 2026 23:44:45 +0100 Subject: [PATCH] Update QuizRunner to accept and use autoStart prop --- client/src/components/QuizRunner.tsx | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/client/src/components/QuizRunner.tsx b/client/src/components/QuizRunner.tsx index cf50423..010bb79 100644 --- a/client/src/components/QuizRunner.tsx +++ b/client/src/components/QuizRunner.tsx @@ -10,6 +10,7 @@ const TOTAL_QUESTIONS = 10; interface QuizRunnerProps { defaultMode?: Mode; defaultEntryId?: string; + autoStart?: boolean; } interface TargetHit { @@ -194,7 +195,7 @@ function ExplanationPanel({ question, targets }: { question: QuizQuestionWithEnt ); } -export default function QuizRunner({ defaultMode = 'all', defaultEntryId }: QuizRunnerProps) { +export default function QuizRunner({ defaultMode = 'all', defaultEntryId, autoStart }: QuizRunnerProps) { const [entries, setEntries] = useState([]); const [loadingEntries, setLoadingEntries] = useState(true); const [mode, setMode] = useState(defaultMode); @@ -223,6 +224,13 @@ export default function QuizRunner({ defaultMode = 'all', defaultEntryId }: Quiz } }, [defaultEntryId]); + useEffect(() => { + if (autoStart && defaultEntryId && entries.length > 0) { + startQuiz(); + } + // eslint-disable-next-line react-hooks/exhaustive-deps + }, [autoStart, defaultEntryId, entries.length]); + const currentQuestion = useMemo(() => questions[currentIndex], [questions, currentIndex]); const resetQuestionState = () => {