Updated the reading to a new format

This commit is contained in:
Tiago Ribeiro
2023-09-28 14:43:43 +01:00
parent a568950aa9
commit 169ae2c959
9 changed files with 100 additions and 31 deletions

View File

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