feat: verbinding tussen groepen en hun submissions
This commit is contained in:
parent
d8b97f3aea
commit
e8975878aa
3 changed files with 72 additions and 2 deletions
|
@ -2,12 +2,14 @@ import {
|
|||
getAssignmentRepository,
|
||||
getClassRepository,
|
||||
getGroupRepository,
|
||||
getSubmissionRepository,
|
||||
} from '../data/repositories.js';
|
||||
import {
|
||||
GroupDTO,
|
||||
mapToGroupDTO,
|
||||
mapToGroupDTOId,
|
||||
} from '../interfaces/group.js';
|
||||
import { mapToSubmissionDTO, SubmissionDTO } from '../interfaces/submission.js';
|
||||
|
||||
export async function getGroup(
|
||||
classId: string,
|
||||
|
@ -82,3 +84,41 @@ export async function getAllGroups(
|
|||
|
||||
return groups.map(mapToGroupDTOId);
|
||||
}
|
||||
|
||||
export async function getGroupSubmissions(
|
||||
classId: string,
|
||||
assignmentNumber: number,
|
||||
groupNumber: number,
|
||||
): Promise<SubmissionDTO[]> {
|
||||
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 group = await groupRepository.findByAssignmentAndGroupNumber(
|
||||
assignment,
|
||||
groupNumber
|
||||
);
|
||||
|
||||
if (!group) {
|
||||
return [];
|
||||
}
|
||||
|
||||
const submissionRepository = getSubmissionRepository();
|
||||
const submissions = await submissionRepository.findAllSubmissionsForGroup(group);
|
||||
|
||||
return submissions.map(mapToSubmissionDTO);
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue