Corrected the behaviour of the exam after the timer has ended
This commit is contained in:
@@ -101,6 +101,11 @@ export default function Level({ exam, showSolutions = false, onFinish, preview =
|
|||||||
|
|
||||||
const [showSolutionsSave, setShowSolutionsSave] = useState(showSolutions ? userSolutions.filter((x) => x.module === "level") : undefined)
|
const [showSolutionsSave, setShowSolutionsSave] = useState(showSolutions ? userSolutions.filter((x) => x.module === "level") : undefined)
|
||||||
|
|
||||||
|
useEffect(() => {
|
||||||
|
if (hasExamEnded) onFinish(userSolutions)
|
||||||
|
// eslint-disable-next-line react-hooks/exhaustive-deps
|
||||||
|
}, [hasExamEnded]);
|
||||||
|
|
||||||
useEffect(() => {
|
useEffect(() => {
|
||||||
if (typeof currentSolution !== "undefined") {
|
if (typeof currentSolution !== "undefined") {
|
||||||
setUserSolutions([...userSolutions.filter((x) => x.exercise !== currentSolution.exercise), { ...currentSolution, module: "level" as Module, exam: exam.id, shuffleMaps: exam.shuffle ? [...shuffles.find((x) => x.exerciseID == currentExercise?.id)?.shuffles!] : [] }]);
|
setUserSolutions([...userSolutions.filter((x) => x.exercise !== currentSolution.exercise), { ...currentSolution, module: "level" as Module, exam: exam.id, shuffleMaps: exam.shuffle ? [...shuffles.find((x) => x.exerciseID == currentExercise?.id)?.shuffles!] : [] }]);
|
||||||
|
|||||||
@@ -145,10 +145,9 @@ export default function Listening({ exam, showSolutions = false, preview = false
|
|||||||
}, []);
|
}, []);
|
||||||
|
|
||||||
useEffect(() => {
|
useEffect(() => {
|
||||||
if (hasExamEnded && exerciseIndex === -1) {
|
if (hasExamEnded) onFinish(userSolutions)
|
||||||
setExerciseIndex(exerciseIndex + 1);
|
// eslint-disable-next-line react-hooks/exhaustive-deps
|
||||||
}
|
}, [hasExamEnded]);
|
||||||
}, [hasExamEnded, exerciseIndex, setExerciseIndex]);
|
|
||||||
|
|
||||||
const confirmFinishModule = (keepGoing?: boolean) => {
|
const confirmFinishModule = (keepGoing?: boolean) => {
|
||||||
if (!keepGoing) {
|
if (!keepGoing) {
|
||||||
|
|||||||
@@ -173,10 +173,9 @@ export default function Reading({ exam, showSolutions = false, preview = false,
|
|||||||
}, []);
|
}, []);
|
||||||
|
|
||||||
useEffect(() => {
|
useEffect(() => {
|
||||||
if (hasExamEnded && exerciseIndex === -1) {
|
if (hasExamEnded) onFinish(userSolutions)
|
||||||
setExerciseIndex(exerciseIndex + 1);
|
// eslint-disable-next-line react-hooks/exhaustive-deps
|
||||||
}
|
}, [hasExamEnded]);
|
||||||
}, [hasExamEnded, exerciseIndex, setExerciseIndex]);
|
|
||||||
|
|
||||||
const confirmFinishModule = (keepGoing?: boolean) => {
|
const confirmFinishModule = (keepGoing?: boolean) => {
|
||||||
if (!keepGoing) {
|
if (!keepGoing) {
|
||||||
|
|||||||
@@ -53,10 +53,9 @@ export default function Speaking({ exam, showSolutions = false, onFinish, previe
|
|||||||
}, [exerciseIndex]);
|
}, [exerciseIndex]);
|
||||||
|
|
||||||
useEffect(() => {
|
useEffect(() => {
|
||||||
if (hasExamEnded && exerciseIndex === -1) {
|
if (hasExamEnded) onFinish(userSolutions)
|
||||||
setExerciseIndex(exerciseIndex + 1);
|
// eslint-disable-next-line react-hooks/exhaustive-deps
|
||||||
}
|
}, [hasExamEnded]);
|
||||||
}, [hasExamEnded, exerciseIndex, setExerciseIndex]);
|
|
||||||
|
|
||||||
const scrollToTop = () => Array.from(document.getElementsByTagName("body")).forEach((body) => body.scrollTo(0, 0));
|
const scrollToTop = () => Array.from(document.getElementsByTagName("body")).forEach((body) => body.scrollTo(0, 0));
|
||||||
|
|
||||||
|
|||||||
@@ -34,10 +34,9 @@ export default function Writing({ exam, showSolutions = false, preview = false,
|
|||||||
const [showPartDivider, setShowPartDivider] = useState<boolean>(typeof exam.exercises[0].intro === "string" && exam.exercises[0].intro !== "");
|
const [showPartDivider, setShowPartDivider] = useState<boolean>(typeof exam.exercises[0].intro === "string" && exam.exercises[0].intro !== "");
|
||||||
|
|
||||||
useEffect(() => {
|
useEffect(() => {
|
||||||
if (hasExamEnded && exerciseIndex === -1) {
|
if (hasExamEnded) onFinish(userSolutions)
|
||||||
setExerciseIndex(exerciseIndex + 1);
|
// eslint-disable-next-line react-hooks/exhaustive-deps
|
||||||
}
|
}, [hasExamEnded]);
|
||||||
}, [hasExamEnded, exerciseIndex, setExerciseIndex]);
|
|
||||||
|
|
||||||
const scrollToTop = () => Array.from(document.getElementsByTagName("body")).forEach((body) => body.scrollTo(0, 0));
|
const scrollToTop = () => Array.from(document.getElementsByTagName("body")).forEach((body) => body.scrollTo(0, 0));
|
||||||
|
|
||||||
|
|||||||
@@ -110,7 +110,7 @@ export default function ExamList({user, entities}: {user: User; entities: Entity
|
|||||||
setExams([exam]);
|
setExams([exam]);
|
||||||
setSelectedModules([module]);
|
setSelectedModules([module]);
|
||||||
|
|
||||||
router.push("/exercises");
|
router.push("/exam");
|
||||||
};
|
};
|
||||||
|
|
||||||
const privatizeExam = async (exam: Exam) => {
|
const privatizeExam = async (exam: Exam) => {
|
||||||
|
|||||||
Reference in New Issue
Block a user