From f9fc19d8a66e3226a26dba7d4d35c2b05048ff77 Mon Sep 17 00:00:00 2001 From: Gabriellvl Date: Thu, 15 May 2025 20:53:35 +0200 Subject: [PATCH] fix: duplicate studenten in lijst gefilterd --- backend/src/services/teachers.ts | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/backend/src/services/teachers.ts b/backend/src/services/teachers.ts index aa67f211..dd70b26c 100644 --- a/backend/src/services/teachers.ts +++ b/backend/src/services/teachers.ts @@ -112,7 +112,13 @@ export async function getStudentsByTeacher(username: string, full: boolean): Pro const classIds: string[] = classes.map((cls) => cls.id); - const students: StudentDTO[] = (await Promise.all(classIds.map(async (username) => await getClassStudentsDTO(username)))).flat(); + const students: StudentDTO[] = (await Promise.all( + classIds.map(async (classId) => await getClassStudentsDTO(classId)) + )) + .flat() + .filter((student, index, self) => + self.findIndex((s) => s.username === student.username) === index + ); if (full) { return students;