From 4b82455eb9b932f02b330478104a109e7ed80366 Mon Sep 17 00:00:00 2001 From: Adriaan Jacquet Date: Sun, 30 Mar 2025 18:28:01 +0200 Subject: [PATCH] feat: frontend group controller geimplementeerd --- backend/src/routes/groups.ts | 2 +- frontend/src/controllers/groups.ts | 32 ++++++++++++++++++++++++++++++ 2 files changed, 33 insertions(+), 1 deletion(-) create mode 100644 frontend/src/controllers/groups.ts diff --git a/backend/src/routes/groups.ts b/backend/src/routes/groups.ts index 0c9692b0..93295ea1 100644 --- a/backend/src/routes/groups.ts +++ b/backend/src/routes/groups.ts @@ -11,7 +11,7 @@ router.post('/', createGroupHandler); // Information about a group (members, ... [TODO DOC]) router.get('/:groupid', getGroupHandler); -router.get('/:groupid', getGroupSubmissionsHandler); +router.get('/:groupid/submissions', getGroupSubmissionsHandler); // The list of questions a group has made router.get('/:id/questions', (req, res) => { diff --git a/frontend/src/controllers/groups.ts b/frontend/src/controllers/groups.ts new file mode 100644 index 00000000..0ec13e86 --- /dev/null +++ b/frontend/src/controllers/groups.ts @@ -0,0 +1,32 @@ +import { BaseController } from "./base-controller"; + +export class GroupController extends BaseController { + constructor(classid: string, assignmentNumber: number) { + super(`class/${classid}/assignments/${assignmentNumber}/groups`); + } + + getAll(full = true) { + return this.get<{ groups: any[] }>(`/`, { full }); + } + + getByNumber(num: number) { + return this.get<{ group: any }>(`/${num}`); + } + + createGroup(data: any) { + return this.post<{ group: any }>(`/`, data); + } + + deleteClass(num: number) { + return this.delete<{ group: any }>(`/${num}`); + } + + + getSubmissions(groupNumber: number, full = true) { + return this.get<{ groups: any[] }>(`/${groupNumber}/submissions`, { full }); + } + + getQuestions(groupNumber: number, full = true) { + return this.get<{ questions: any[] }>(`/${groupNumber}/questions`, { full }); + } +} \ No newline at end of file