May have solved a bug made in the writing and speaking evaluation

This commit is contained in:
Tiago Ribeiro
2023-10-24 14:47:01 +01:00
parent cf5a9c9780
commit 729204a095
2 changed files with 51 additions and 35 deletions

View File

@@ -46,6 +46,9 @@ export default function ExamPage({page}: Props) {
const router = useRouter();
useEffect(() => setSessionId(uuidv4()), []);
useEffect(() => {
console.log({userSolutions});
}, [userSolutions]);
useEffect(() => {
selectedModules.length > 0 && timeSpent === 0 && !showSolutions;
@@ -134,24 +137,22 @@ export default function ExamPage({page}: Props) {
Promise.all(
exam.exercises.map(async (exercise) => {
if (exercise.type === "writing")
return evaluateWritingAnswer(exercise, solutions.find((x) => x.exercise === exercise.id)!).then((response) => {
if (response) {
setUserSolutions([...userSolutions.filter((x) => x.exercise !== exercise.id), response]);
}
});
if (exercise.type === "writing") {
return await evaluateWritingAnswer(exercise, solutions.find((x) => x.exercise === exercise.id)!);
}
if (exercise.type === "interactiveSpeaking" || exercise.type === "speaking")
return evaluateSpeakingAnswer(exercise, solutions.find((x) => x.exercise === exercise.id)!).then((response) => {
if (response) {
setUserSolutions([...userSolutions.filter((x) => x.exercise !== exercise.id), response]);
}
});
if (exercise.type === "interactiveSpeaking" || exercise.type === "speaking") {
return await evaluateSpeakingAnswer(exercise, solutions.find((x) => x.exercise === exercise.id)!);
}
}),
).finally(() => {
setIsEvaluationLoading(false);
setHasBeenUploaded(false);
});
)
.then((responses) => {
setUserSolutions([...userSolutions, ...responses.filter((x) => !!x)] as any);
})
.finally(() => {
setIsEvaluationLoading(false);
setHasBeenUploaded(false);
});
}
axios.get("/api/stats/update");