feat: verbinding tussen groepen en hun submissions

This commit is contained in:
Adriaan Jacquet 2025-03-12 15:41:56 +01:00
parent d8b97f3aea
commit e8975878aa
3 changed files with 72 additions and 2 deletions

View file

@ -1,5 +1,5 @@
import { Request, Response } from 'express';
import { getAllGroups, getGroup } from '../services/groups.js';
import { getAllGroups, getGroup, getGroupSubmissions } from '../services/groups.js';
// Typescript is annoywith with parameter forwarding from class.ts
interface GroupParams {
@ -53,3 +53,31 @@ export async function getAllGroupsHandler(
groups: groups,
});
}
export async function getGroupSubmissionsHandler(
req: Request,
res: Response,
): Promise<void> {
const classId = req.params.classid;
// const full = req.query.full === 'true';
const assignmentId = +req.params.assignmentid;
if (isNaN(assignmentId)) {
res.status(400).json({ error: 'Assignment id must be a number' });
return;
}
const groupId = +req.params.groupid!; // Can't be undefined
if (isNaN(groupId)) {
res.status(400).json({ error: 'Group id must be a number' });
return;
}
const submissions = await getGroupSubmissions(classId, assignmentId, groupId);
res.json({
submissions: submissions,
});
}