diff --git a/src/components/Exercises/InteractiveSpeaking.tsx b/src/components/Exercises/InteractiveSpeaking.tsx index 577a0891..3b3e65aa 100644 --- a/src/components/Exercises/InteractiveSpeaking.tsx +++ b/src/components/Exercises/InteractiveSpeaking.tsx @@ -149,13 +149,10 @@ export default function InteractiveSpeaking({ }, [answers, questionIndex]); const saveAnswer = async (index: number) => { - const previousURL = answers.find((x) => x.questionIndex === questionIndex)?.blob; - const audioPath = await saveToStorage(previousURL); - const answer = { questionIndex, prompt: prompts[questionIndex].text, - blob: audioPath ? audioPath : mediaBlob!, + blob: mediaBlob!, }; setAnswers((prev) => [...prev.filter((x) => x.questionIndex !== index), answer]); @@ -199,7 +196,7 @@ export default function InteractiveSpeaking({

Record your answer:

- {status === "idle" && !mediaBlob && ( + {status === "idle" && ( <>
{status === "idle" && ( @@ -278,9 +275,9 @@ export default function InteractiveSpeaking({
)} - {((status === "stopped" && mediaBlobUrl) || (status === "idle" && mediaBlob)) && ( + {status === "stopped" && mediaBlobUrl && ( <> - +
{ - setIsLoading(true); - const storagePath = await saveToStorage(); - setIsLoading(false); - onNext({ exercise: id, - solutions: storagePath ? [{id, solution: storagePath}] : [], + solutions: mediaBlob ? [{id, solution: mediaBlob}] : [], score: {correct: 0, total: 100, missing: 0}, type, }); }; const back = async () => { - setIsLoading(true); - const storagePath = await saveToStorage(); - setIsLoading(false); - onBack({ exercise: id, - solutions: storagePath ? [{id, solution: storagePath}] : [], + solutions: mediaBlob ? [{id, solution: mediaBlob}] : [], score: {correct: 0, total: 100, missing: 0}, type, }); diff --git a/src/exams/Reading.tsx b/src/exams/Reading.tsx index f2c1ec53..f2049069 100644 --- a/src/exams/Reading.tsx +++ b/src/exams/Reading.tsx @@ -106,8 +106,6 @@ function TextComponent({part, exerciseType}: {part: ReadingPart; exerciseType: s } export default function Reading({exam, showSolutions = false, onFinish}: Props) { - const [questionIndex, setQuestionIndex] = useState(0); - const [currentQuestionIndex, setCurrentQuestionIndex] = useState(0); const [showTextModal, setShowTextModal] = useState(false); const [showBlankModal, setShowBlankModal] = useState(false); const [multipleChoicesDone, setMultipleChoicesDone] = useState<{id: string; amount: number}[]>([]); diff --git a/src/exams/Speaking.tsx b/src/exams/Speaking.tsx index e5124b5f..8dcd8709 100644 --- a/src/exams/Speaking.tsx +++ b/src/exams/Speaking.tsx @@ -20,10 +20,8 @@ interface Props { } export default function Speaking({exam, showSolutions = false, onFinish}: Props) { - const [questionIndex, setQuestionIndex] = useState(0); - const [currentQuestionIndex, setCurrentQuestionIndex] = useState(0); - const {userSolutions, setUserSolutions} = useExamStore((state) => state); + const {questionIndex, setQuestionIndex} = useExamStore((state) => state); const {hasExamEnded, setHasExamEnded} = useExamStore((state) => state); const {exerciseIndex, setExerciseIndex} = useExamStore((state) => state); @@ -34,7 +32,6 @@ export default function Speaking({exam, showSolutions = false, onFinish}: Props) if (solution) { setUserSolutions([...userSolutions.filter((x) => x.exercise !== solution.exercise), {...solution, module: "speaking", exam: exam.id}]); } - setQuestionIndex((prev) => prev + currentQuestionIndex); if (exerciseIndex + 1 < exam.exercises.length) { setExerciseIndex(exerciseIndex + 1); @@ -77,7 +74,7 @@ export default function Speaking({exam, showSolutions = false, onFinish}: Props)