From 834e991568fbcdc50eb5f5f138d433d644ca6309 Mon Sep 17 00:00:00 2001 From: Gabriellvl Date: Sun, 13 Apr 2025 19:40:20 +0200 Subject: [PATCH] fix: invitation geeft enkel classId field terug --- backend/src/interfaces/teacher-invitation.ts | 4 ++-- backend/tests/setup-tests.ts | 8 ++++++-- common/src/interfaces/teacher-invitation.ts | 2 +- frontend/src/views/classes/TeacherClasses.vue | 4 ++-- 4 files changed, 11 insertions(+), 7 deletions(-) diff --git a/backend/src/interfaces/teacher-invitation.ts b/backend/src/interfaces/teacher-invitation.ts index 98189938..bc2fd4af 100644 --- a/backend/src/interfaces/teacher-invitation.ts +++ b/backend/src/interfaces/teacher-invitation.ts @@ -10,7 +10,7 @@ export function mapToTeacherInvitationDTO(invitation: TeacherInvitation): Teache return { sender: mapToUserDTO(invitation.sender), receiver: mapToUserDTO(invitation.receiver), - class: mapToClassDTO(invitation.class), + classId: invitation.class.classId!, }; } @@ -18,7 +18,7 @@ export function mapToTeacherInvitationDTOIds(invitation: TeacherInvitation): Tea return { sender: invitation.sender.username, receiver: invitation.receiver.username, - class: invitation.class.classId!, + classId: invitation.class.classId!, }; } diff --git a/backend/tests/setup-tests.ts b/backend/tests/setup-tests.ts index 5bd2fbd6..b666fbd2 100644 --- a/backend/tests/setup-tests.ts +++ b/backend/tests/setup-tests.ts @@ -13,6 +13,7 @@ import { makeTestAttachments } from './test_assets/content/attachments.testdata. import { makeTestQuestions } from './test_assets/questions/questions.testdata.js'; import { makeTestAnswers } from './test_assets/questions/answers.testdata.js'; import { makeTestSubmissions } from './test_assets/assignments/submission.testdata.js'; +import {Collection} from "@mikro-orm/core"; export async function setupTestApp(): Promise { dotenv.config({ path: '.env.test' }); @@ -28,8 +29,8 @@ export async function setupTestApp(): Promise { const assignments = makeTestAssignemnts(em, classes); const groups = makeTestGroups(em, students, assignments); - assignments[0].groups = groups.slice(0, 3); - assignments[1].groups = groups.slice(3, 4); + assignments[0].groups = new Collection(groups.slice(0, 3)); + assignments[1].groups = new Collection(groups.slice(3, 4)); const teacherInvitations = makeTestTeacherInvitations(em, teachers, classes); const classJoinRequests = makeTestClassJoinRequests(em, students, classes); @@ -41,6 +42,9 @@ export async function setupTestApp(): Promise { const answers = makeTestAnswers(em, teachers, questions); const submissions = makeTestSubmissions(em, students, groups); + console.log("classes", classes); + console.log("invitations", teacherInvitations); + await em.persistAndFlush([ ...students, ...teachers, diff --git a/common/src/interfaces/teacher-invitation.ts b/common/src/interfaces/teacher-invitation.ts index c61f9a6a..c34f46f7 100644 --- a/common/src/interfaces/teacher-invitation.ts +++ b/common/src/interfaces/teacher-invitation.ts @@ -4,7 +4,7 @@ import { ClassDTO } from './class'; export interface TeacherInvitationDTO { sender: string | UserDTO; receiver: string | UserDTO; - class: string | ClassDTO; + classId: string; } export interface TeacherInvitationData { diff --git a/frontend/src/views/classes/TeacherClasses.vue b/frontend/src/views/classes/TeacherClasses.vue index ae673d99..010cf2e2 100644 --- a/frontend/src/views/classes/TeacherClasses.vue +++ b/frontend/src/views/classes/TeacherClasses.vue @@ -276,10 +276,10 @@ - {{ (i.class as ClassDTO).displayName }} + {{ i.classId }} {{ (i.sender as TeacherDTO).firstName + " " + (i.sender as TeacherDTO).lastName }}