Seems to have solved some other issues
This commit is contained in:
@@ -53,6 +53,10 @@ export default function Finish({user, scores, modules, isLoading, onViewResults}
|
||||
},
|
||||
};
|
||||
|
||||
useEffect(() => {
|
||||
console.log({selectedScore, selectedModule, scores});
|
||||
}, [scores, selectedModule, selectedScore]);
|
||||
|
||||
return (
|
||||
<>
|
||||
<div className="w-full min-h-full h-fit flex flex-col items-center justify-between gap-8">
|
||||
|
||||
@@ -25,7 +25,7 @@ export default function Listening({exam, showSolutions = false, onFinish}: Props
|
||||
const [userSolutions, setUserSolutions] = useState<UserSolution[]>(exam.exercises.map((x) => defaultUserSolutions(x, exam)));
|
||||
const [showBlankModal, setShowBlankModal] = useState(false);
|
||||
|
||||
const hasExamEnded = useExamStore((state) => state.hasExamEnded);
|
||||
const [hasExamEnded, setHasExamEnded] = useExamStore((state) => [state.hasExamEnded, state.setHasExamEnded]);
|
||||
|
||||
const confirmFinishModule = (keepGoing?: boolean) => {
|
||||
if (!keepGoing) {
|
||||
@@ -33,7 +33,7 @@ export default function Listening({exam, showSolutions = false, onFinish}: Props
|
||||
return;
|
||||
}
|
||||
|
||||
onFinish(userSolutions.map((x) => ({...x, module: "reading", exam: exam.id})));
|
||||
onFinish(userSolutions.map((x) => ({...x, module: "listening", exam: exam.id})));
|
||||
};
|
||||
|
||||
const nextExercise = (solution?: UserSolution) => {
|
||||
@@ -46,11 +46,13 @@ export default function Listening({exam, showSolutions = false, onFinish}: Props
|
||||
return;
|
||||
}
|
||||
|
||||
if (!userSolutions.map((x) => x.score.missing).every((x) => x === 0) && !hasExamEnded) {
|
||||
if (!userSolutions.map((x) => x.score.missing).every((x) => x === 0) && !showSolutions && !hasExamEnded) {
|
||||
setShowBlankModal(true);
|
||||
return;
|
||||
}
|
||||
|
||||
setHasExamEnded(false);
|
||||
|
||||
if (solution) {
|
||||
onFinish(
|
||||
[...userSolutions.filter((x) => x.exercise !== solution.exercise), solution].map((x) => ({...x, module: "listening", exam: exam.id})),
|
||||
|
||||
@@ -106,7 +106,7 @@ export default function Reading({exam, showSolutions = false, onFinish}: Props)
|
||||
return;
|
||||
}
|
||||
|
||||
if (!userSolutions.map((x) => x.score.missing).every((x) => x === 0) && !hasExamEnded) {
|
||||
if (!userSolutions.map((x) => x.score.missing).every((x) => x === 0) && !showSolutions && !hasExamEnded) {
|
||||
setShowBlankModal(true);
|
||||
return;
|
||||
}
|
||||
|
||||
@@ -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})),
|
||||
|
||||
@@ -21,6 +21,8 @@ export default function Writing({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) {
|
||||
setUserSolutions((prev) => [...prev.filter((x) => x.exercise !== solution.exercise), solution]);
|
||||
@@ -33,6 +35,8 @@ export default function Writing({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: "writing", exam: exam.id})),
|
||||
|
||||
Reference in New Issue
Block a user