Updated the Speaking to also work the with exam session persistence

This commit is contained in:
Tiago Ribeiro
2024-02-07 17:15:41 +00:00
parent 65fe1ec8ed
commit 2a9e204041
8 changed files with 177 additions and 58 deletions

View File

@@ -98,13 +98,22 @@ export default function ExamPage({page}: Props) {
}, [exams, setUserSolutions, userSolutions]);
useEffect(() => {
if (sessionId.length > 0 && userSolutions.length > 0 && selectedModules.length > 0 && exams.length > 0 && !!exam && timeSpent > 0)
if (
sessionId.length > 0 &&
userSolutions.length > 0 &&
selectedModules.length > 0 &&
exams.length > 0 &&
!!exam &&
timeSpent > 0 &&
!showSolutions &&
moduleIndex < selectedModules.length
)
saveSession();
// eslint-disable-next-line react-hooks/exhaustive-deps
}, [assignment, exam, exams, moduleIndex, selectedModules, sessionId, userSolutions, user, exerciseIndex, partIndex, questionIndex]);
useEffect(() => {
if (timeSpent % 20 === 0 && timeSpent > 0) saveSession();
if (timeSpent % 20 === 0 && timeSpent > 0 && moduleIndex < selectedModules.length && !showSolutions) saveSession();
// eslint-disable-next-line react-hooks/exhaustive-deps
}, [timeSpent]);
@@ -282,7 +291,6 @@ export default function ExamPage({page}: Props) {
setUserSolutions([...userSolutions.filter((x) => !solutionIds.includes(x.exercise)), ...solutions]);
setModuleIndex(moduleIndex + 1);
// TODO: Solve the issue for the listening where it should start with -1
setPartIndex(-1);
setExerciseIndex(-1);
setQuestionIndex(0);