Seems to have solved some other issues

This commit is contained in:
Tiago Ribeiro
2023-07-27 15:41:34 +01:00
parent 77692d270e
commit d38ca76182
5 changed files with 17 additions and 4 deletions

View File

@@ -20,6 +20,7 @@ interface Props {
export default function Speaking({exam, showSolutions = false, onFinish}: Props) {
const [exerciseIndex, setExerciseIndex] = useState(0);
const [userSolutions, setUserSolutions] = useState<UserSolution[]>(exam.exercises.map((x) => defaultUserSolutions(x, exam)));
const [hasExamEnded, setHasExamEnded] = useExamStore((state) => [state.hasExamEnded, state.setHasExamEnded]);
const nextExercise = (solution?: UserSolution) => {
if (solution) {
@@ -33,6 +34,8 @@ export default function Speaking({exam, showSolutions = false, onFinish}: Props)
if (exerciseIndex >= exam.exercises.length) return;
setHasExamEnded(false);
if (solution) {
onFinish(
[...userSolutions.filter((x) => x.exercise !== solution.exercise), solution].map((x) => ({...x, module: "speaking", exam: exam.id})),