Updated the way this is calculated

This commit is contained in:
Tiago Ribeiro
2023-09-28 14:51:24 +01:00
parent a47ee28ca5
commit 2a68d37de8

View File

@@ -45,8 +45,7 @@ export default function ExamList() {
router.push("/exercises"); router.push("/exercises");
}; };
const getTotalExercises = (module: Module) => { const getTotalExercises = (exam: Exam, module: Module) => {
const exam = exams.find((x) => x.module === module)!;
if (exam.module === "reading") { if (exam.module === "reading") {
return exam.parts.flatMap((x) => x.exercises).length; return exam.parts.flatMap((x) => x.exercises).length;
} }
@@ -63,7 +62,7 @@ export default function ExamList() {
header: "Module", header: "Module",
cell: (info) => <span className={CLASSES[info.getValue()]}>{capitalize(info.getValue())}</span>, cell: (info) => <span className={CLASSES[info.getValue()]}>{capitalize(info.getValue())}</span>,
}), }),
columnHelper.accessor((x) => getTotalExercises(x.module), { columnHelper.accessor((x) => getTotalExercises(x, x.module), {
header: "Exercises", header: "Exercises",
cell: (info) => info.getValue(), cell: (info) => info.getValue(),
}), }),