Fix student performance freeze and search users in create entities

TODO: pagination in student performance freeze
This commit is contained in:
José Lima
2025-03-04 23:12:26 +00:00
parent 655e019bf6
commit c49b1c8070
8 changed files with 220 additions and 140 deletions

View File

@@ -1,4 +1,4 @@
import {Module} from "@/interfaces";
import { Module } from "@/interfaces";
import {
Exam,
ReadingExam,
@@ -70,9 +70,9 @@ export const getExamById = async (module: Module, id: string): Promise<Exam | un
export const defaultExamUserSolutions = (exam: Exam) => {
if (exam.module === "reading" || exam.module === "listening" || exam.module === "level")
return exam.parts.flatMap((x) => x.exercises).map((x) => defaultUserSolutions(x, exam));
return (exam.parts.flatMap((x) => x.exercises) ?? []).map((x) => defaultUserSolutions(x, exam));
return exam.exercises.map((x) => defaultUserSolutions(x, exam));
return (exam.exercises ?? []).map((x) => defaultUserSolutions(x, exam));
};
export const defaultUserSolutions = (exercise: Exercise, exam: Exam): UserSolution => {
@@ -88,26 +88,26 @@ export const defaultUserSolutions = (exercise: Exercise, exam: Exam): UserSoluti
switch (exercise.type) {
case "fillBlanks":
total = exercise.text.match(/({{\d+}})/g)?.length || 0;
return {...defaultSettings, score: {correct: 0, total, missing: total}};
return { ...defaultSettings, score: { correct: 0, total, missing: total } };
case "matchSentences":
total = exercise.sentences.length;
return {...defaultSettings, score: {correct: 0, total, missing: total}};
return { ...defaultSettings, score: { correct: 0, total, missing: total } };
case "multipleChoice":
total = exercise.questions.length;
return {...defaultSettings, score: {correct: 0, total, missing: total}};
return { ...defaultSettings, score: { correct: 0, total, missing: total } };
case "writeBlanks":
total = exercise.text.match(/({{\d+}})/g)?.length || 0;
return {...defaultSettings, score: {correct: 0, total, missing: total}};
return { ...defaultSettings, score: { correct: 0, total, missing: total } };
case "trueFalse":
total = exercise.questions.length;
return {...defaultSettings, score: {correct: 0, total, missing: total}};
return { ...defaultSettings, score: { correct: 0, total, missing: total } };
case "writing":
total = 1;
return {...defaultSettings, score: {correct: 0, total, missing: total}};
return { ...defaultSettings, score: { correct: 0, total, missing: total } };
case "speaking":
total = 1;
return {...defaultSettings, score: {correct: 0, total, missing: total}};
return { ...defaultSettings, score: { correct: 0, total, missing: total } };
default:
return {...defaultSettings, score: {correct: 0, total: 0, missing: 0}};
return { ...defaultSettings, score: { correct: 0, total: 0, missing: 0 } };
}
};