From 1a0704c16fd748d2f6e0e50d08735fd9baff5228 Mon Sep 17 00:00:00 2001 From: Tibo De Peuter Date: Mon, 31 Mar 2025 19:09:23 +0200 Subject: [PATCH] refactor(common): Group --- backend/src/controllers/groups.ts | 3 ++- backend/src/interfaces/group.ts | 10 ++-------- backend/src/interfaces/submission.ts | 3 ++- backend/src/services/groups.ts | 3 ++- backend/src/services/students.ts | 3 ++- common/src/interfaces/assignment.d.ts | 2 +- common/src/interfaces/group.d.ts | 7 +++++++ 7 files changed, 18 insertions(+), 13 deletions(-) create mode 100644 common/src/interfaces/group.d.ts diff --git a/backend/src/controllers/groups.ts b/backend/src/controllers/groups.ts index 38d5d5d0..c7da61d8 100644 --- a/backend/src/controllers/groups.ts +++ b/backend/src/controllers/groups.ts @@ -1,6 +1,7 @@ import { Request, Response } from 'express'; import { createGroup, getAllGroups, getGroup, getGroupSubmissions } from '../services/groups.js'; -import { GroupDTO } from '../interfaces/group.js'; + +import { GroupDTO } from 'dwengo-1-common/src/interfaces/group'; // Typescript is annoywith with parameter forwarding from class.ts interface GroupParams { diff --git a/backend/src/interfaces/group.ts b/backend/src/interfaces/group.ts index 93701dce..9f71e3f7 100644 --- a/backend/src/interfaces/group.ts +++ b/backend/src/interfaces/group.ts @@ -1,13 +1,7 @@ import { Group } from '../entities/assignments/group.entity.js'; import { mapToAssignmentDTO } from './assignment.js'; -import { mapToStudentDTO, StudentDTO } from './student.js'; -import { AssignmentDTO } from 'dwengo-1-common/src/interfaces/assignment'; - -export interface GroupDTO { - assignment: number | AssignmentDTO; - groupNumber: number; - members: string[] | StudentDTO[]; -} +import { mapToStudentDTO } from './student.js'; +import { GroupDTO } from 'dwengo-1-common/src/interfaces/group'; export function mapToGroupDTO(group: Group): GroupDTO { return { diff --git a/backend/src/interfaces/submission.ts b/backend/src/interfaces/submission.ts index 98cc4f22..95afee70 100644 --- a/backend/src/interfaces/submission.ts +++ b/backend/src/interfaces/submission.ts @@ -1,8 +1,9 @@ import { Submission } from '../entities/assignments/submission.entity.js'; import { Language } from '../entities/content/language.js'; -import { GroupDTO, mapToGroupDTO } from './group.js'; +import { mapToGroupDTO } from './group.js'; import { mapToStudent, mapToStudentDTO, StudentDTO } from './student.js'; import { LearningObjectIdentifier } from './learning-content.js'; +import { GroupDTO } from 'dwengo-1-common/src/interfaces/group'; export interface SubmissionDTO { learningObjectIdentifier: LearningObjectIdentifier; diff --git a/backend/src/services/groups.ts b/backend/src/services/groups.ts index 4a1cbbf0..df8f02b7 100644 --- a/backend/src/services/groups.ts +++ b/backend/src/services/groups.ts @@ -6,8 +6,9 @@ import { getSubmissionRepository, } from '../data/repositories.js'; import { Group } from '../entities/assignments/group.entity.js'; -import { GroupDTO, mapToGroupDTO, mapToGroupDTOId } from '../interfaces/group.js'; +import { mapToGroupDTO, mapToGroupDTOId } from '../interfaces/group.js'; import { mapToSubmissionDTO, mapToSubmissionDTOId, SubmissionDTO, SubmissionDTOId } from '../interfaces/submission.js'; +import { GroupDTO } from 'dwengo-1-common/src/interfaces/group'; export async function getGroup(classId: string, assignmentNumber: number, groupNumber: number, full: boolean): Promise { const classRepository = getClassRepository(); diff --git a/backend/src/services/students.ts b/backend/src/services/students.ts index 931162ff..b8ab4650 100644 --- a/backend/src/services/students.ts +++ b/backend/src/services/students.ts @@ -1,11 +1,12 @@ import { getClassRepository, getGroupRepository, getStudentRepository, getSubmissionRepository } from '../data/repositories.js'; import { mapToClassDTO } from '../interfaces/class.js'; -import { GroupDTO, mapToGroupDTO, mapToGroupDTOId } from '../interfaces/group.js'; +import { mapToGroupDTO, mapToGroupDTOId } from '../interfaces/group.js'; import { mapToStudent, mapToStudentDTO, StudentDTO } from '../interfaces/student.js'; import { mapToSubmissionDTO, mapToSubmissionDTOId, SubmissionDTO, SubmissionDTOId } from '../interfaces/submission.js'; import { getAllAssignments } from './assignments.js'; import { AssignmentDTO } from 'dwengo-1-common/src/interfaces/assignment'; import { ClassDTO } from 'dwengo-1-common/src/interfaces/class'; +import { GroupDTO } from 'dwengo-1-common/src/interfaces/group'; export async function getAllStudents(full: boolean): Promise { const studentRepository = getStudentRepository(); diff --git a/common/src/interfaces/assignment.d.ts b/common/src/interfaces/assignment.d.ts index 88bf10c6..8ad1649b 100644 --- a/common/src/interfaces/assignment.d.ts +++ b/common/src/interfaces/assignment.d.ts @@ -1,4 +1,4 @@ -import { GroupDTO } from 'dwengo-1-backend/src/interfaces/group.js'; +import { GroupDTO } from './group'; export interface AssignmentDTO { id: number; diff --git a/common/src/interfaces/group.d.ts b/common/src/interfaces/group.d.ts new file mode 100644 index 00000000..45523461 --- /dev/null +++ b/common/src/interfaces/group.d.ts @@ -0,0 +1,7 @@ +import { AssignmentDTO } from './assignment'; + +export interface GroupDTO { + assignment: number | AssignmentDTO; + groupNumber: number; + members: string[] | StudentDTO[]; +}