feat: endpoint voor alle groepen van een assignment geimplementeerd

This commit is contained in:
Adriaan Jacquet 2025-03-09 13:39:53 +01:00
parent 3f62ab70e1
commit 7e051d412a
4 changed files with 62 additions and 13 deletions

View file

@ -33,4 +33,35 @@ export async function getGroup(
}
return mapToGroupDTOId(group);
}
export async function getAllGroups(
classId: string,
assignmentNumber: number,
full: boolean,
): Promise<GroupDTO[]> {
const classRepository = getClassRepository();
const cls = await classRepository.findById(classId);
if (!cls) {
return [];
}
const assignmentRepository = getAssignmentRepository();
const assignment = await assignmentRepository.findByClassAndId(cls, assignmentNumber);
if (!assignment) {
return [];
}
const groupRepository = getGroupRepository();
const groups = await groupRepository.findAllGroupsForAssignment(assignment);
if (full) {
console.log('full');
console.log(groups);
return groups.map(mapToGroupDTO);
}
return groups.map(mapToGroupDTOId);
}