From 9a45f53062973cc2c193778aaeb9776408596c16 Mon Sep 17 00:00:00 2001 From: Tiago Ribeiro Date: Wed, 20 Sep 2023 09:57:28 +0100 Subject: [PATCH] Made it so, in the FillBlanks, it automatically goes to the next one --- src/components/Exercises/FillBlanks.tsx | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/src/components/Exercises/FillBlanks.tsx b/src/components/Exercises/FillBlanks.tsx index f9e14a2a..0d7798d3 100644 --- a/src/components/Exercises/FillBlanks.tsx +++ b/src/components/Exercises/FillBlanks.tsx @@ -81,6 +81,7 @@ export default function FillBlanks({ const [isDrawerShowing, setIsDrawerShowing] = useState(false); const hasExamEnded = useExamStore((state) => state.hasExamEnded); + const allBlanks = Array.from(text.match(/({{\d+}})/g) || []).map((x) => x.replaceAll("{", "").replaceAll("}", "")); useEffect(() => { setTimeout(() => setIsDrawerShowing(!!currentBlankId), 100); @@ -138,6 +139,10 @@ export default function FillBlanks({ onCancel={() => setCurrentBlankId(undefined)} onAnswer={(solution: string) => { setAnswers((prev) => [...prev.filter((x) => x.id !== currentBlankId), {id: currentBlankId!, solution}]); + if (allBlanks.findIndex((x) => x === currentBlankId) + 1 < allBlanks.length) { + setCurrentBlankId(allBlanks[allBlanks.findIndex((x) => x === currentBlankId) + 1]); + return; + } setCurrentBlankId(undefined); }} />