Updated the Level Exam to work based on Parts
This commit is contained in:
@@ -72,7 +72,7 @@ export default function ExamList({user}: {user: User}) {
|
||||
};
|
||||
|
||||
const getTotalExercises = (exam: Exam) => {
|
||||
if (exam.module === "reading" || exam.module === "listening") {
|
||||
if (exam.module === "reading" || exam.module === "listening" || exam.module === "level") {
|
||||
return countExercises(exam.parts.flatMap((x) => x.exercises));
|
||||
}
|
||||
|
||||
|
||||
@@ -304,7 +304,7 @@ export default function ExamPage({page}: Props) {
|
||||
};
|
||||
|
||||
const updateExamWithUserSolutions = (exam: Exam): Exam => {
|
||||
if (exam.module === "reading" || exam.module === "listening") {
|
||||
if (exam.module === "reading" || exam.module === "listening" || exam.module === "level") {
|
||||
const parts = exam.parts.map((p) =>
|
||||
Object.assign(p, {
|
||||
exercises: p.exercises.map((x) =>
|
||||
|
||||
@@ -99,10 +99,12 @@ const TaskTab = ({exam, difficulty, setExam}: {exam?: LevelExam; difficulty: Dif
|
||||
|
||||
const updatedExam = {
|
||||
...exam,
|
||||
exercises: exam.exercises.map((x) => ({
|
||||
...x,
|
||||
questions: (x as MultipleChoiceExercise).questions.map((q) => (q.id === question.id ? question : q)),
|
||||
})),
|
||||
parts: exam.parts.map((p) =>
|
||||
p.exercises.map((x) => ({
|
||||
...x,
|
||||
questions: (x as MultipleChoiceExercise).questions.map((q) => (q.id === question.id ? question : q)),
|
||||
})),
|
||||
),
|
||||
};
|
||||
console.log(updatedExam);
|
||||
setExam(updatedExam as any);
|
||||
@@ -136,7 +138,8 @@ const TaskTab = ({exam, difficulty, setExam}: {exam?: LevelExam; difficulty: Dif
|
||||
)}
|
||||
{exam && (
|
||||
<div className="flex flex-col gap-2 w-full overflow-y-scroll scrollbar-hide h-full">
|
||||
{exam.exercises
|
||||
{exam.parts
|
||||
.flatMap((x) => x.exercises)
|
||||
.filter((x) => x.type === "multipleChoice")
|
||||
.map((ex) => {
|
||||
const exercise = ex as MultipleChoiceExercise;
|
||||
|
||||
Reference in New Issue
Block a user