From 136be2d9370e9e6f06d2a71c2e87a24df171a327 Mon Sep 17 00:00:00 2001 From: Adriaan Jacquet Date: Sun, 23 Mar 2025 16:12:14 +0100 Subject: [PATCH 01/54] feat: tests voor backend/controllers/classes.ts geimplementeerd (FALEN NOG DOOR FOUTEN IN CODE) --- backend/tests/controllers/classes.test.ts | 149 ++++++++++++++++++++++ 1 file changed, 149 insertions(+) create mode 100644 backend/tests/controllers/classes.test.ts diff --git a/backend/tests/controllers/classes.test.ts b/backend/tests/controllers/classes.test.ts new file mode 100644 index 00000000..03952e53 --- /dev/null +++ b/backend/tests/controllers/classes.test.ts @@ -0,0 +1,149 @@ +import { setupTestApp } from '../setup-tests.js'; +import { describe, it, expect, beforeAll, beforeEach, vi, Mock } from 'vitest'; +import { createClassHandler, getClassHandler, getClassStudentsHandler, getTeacherInvitationsHandler } from '../../src/controllers/classes.js'; +import { Request, Response } from 'express'; +import { getClassTeacherInvitations } from '../../src/services/class.js'; + +async function fetchClass(id: string) { + const data = await fetch(`localhost:3000/class/${id}`); + return data; +} + +vi.mock('./getClass', () => ({ + getClass: vi.fn(), +})); + +describe('Class controllers', () => { + let req: Partial; + let res: Partial; + + let jsonMock: Mock; + let statusMock: Mock; + + beforeAll(async () => { + await setupTestApp(); + }); + + beforeEach(async () => { + jsonMock = vi.fn(); + statusMock = vi.fn().mockReturnThis(); + + res = { + json: jsonMock, + status: statusMock, + }; + }); + + it('should return 404 and error if class is not found', async () => { + req = { + params: { id: 'doesnotexist'}, + } + + await getClassHandler(req as Request, res as Response); + + expect(statusMock).toHaveBeenCalledWith(404); + expect(jsonMock).toHaveBeenCalledWith({ error: 'Class not found' }); + }); + + it('should return 200 if class is not found', async () => { + req = { + params: { id: 'id01'}, + } + + await getClassHandler(req as Request, res as Response); + + // status can either not be called or called with code 200 + expect( + statusMock.mock.calls.length === 0 || statusMock.mock.calls.some(([arg]) => arg === 200) + ).toBe(true); + }); + + it('should return 201 for creating a new class', async () => { + req = { + body: { displayName: 'coolenieuweklas' }, + }; + + await createClassHandler(req as Request, res as Response); + + expect(statusMock).toHaveBeenCalledWith(201); + // TODO: return json should be a classDTO and not named (fixed in #130) + //expect(jsonMock).toHaveBeenCalledWith(); + + // TODO: check if class is actually added to db + }); + it.todo('return json should be a classDTO and not named (fixed in #130)') + it.todo('check if class is actually added to db'); + + it('should return 400 for trying to create a class without name', async () => { + req = { + body: {}, + }; + + await createClassHandler(req as Request, res as Response); + + expect(statusMock).toHaveBeenCalledWith(400); + expect(jsonMock).toHaveBeenCalledWith({ error: 'Missing one or more required fields: displayName' }); + }); + + it('should return a list of students when calling getClassStudentsHandler', async () => { + req = { + params: { id: 'id01' }, + query: {}, + }; + + await getClassStudentsHandler(req as Request, res as Response); + + expect(jsonMock).toHaveBeenCalledWith({ students: [ + 'DireStraits', + 'Nirvana', + 'Noordkaap', + 'PinkFloyd', + 'SmashingPumpkins', + 'TheDoors', + 'Tool' + ]}); + }); + + it('should return 404 not found when calling getClassStudentsHandler on a non-existent class', async () => { + req = { + params: { id: 'doesnotexist' }, + query: {}, + }; + + await getClassStudentsHandler(req as Request, res as Response); + + // will fail until code is fixed + expect(statusMock).toHaveBeenCalledWith(404); + expect(jsonMock).toHaveBeenCalledWith({ error: 'Class not found' }); + }); + + it('should return 200 and a list of teacher-invitations', async () => { + req = { + params: { id: 'id01' }, + query: {}, + }; + + await getTeacherInvitationsHandler(req as Request, res as Response); + + expect(jsonMock).toHaveBeenCalledWith({"invitations": [ + { + "class": "id01", + "receiver": "LimpBizkit", + "sender": "FooFighters", + } + ]}); + }); + + it('should return 404 not found when calling teacher-invitations on a non-existent class', async () => { + req = { + params: { id: 'doesnotexist' }, + query: {}, + }; + + await getTeacherInvitationsHandler(req as Request, res as Response); + + // will fail until code is fixed + expect(statusMock).toHaveBeenCalledWith(404); + expect(jsonMock).toHaveBeenCalledWith({ error: 'Class not found' }); + }); +}) \ No newline at end of file From 9648f31cfdcff65f17d2a8d38cfbc630743d050b Mon Sep 17 00:00:00 2001 From: Adriaan Jacquet Date: Sun, 23 Mar 2025 18:55:08 +0100 Subject: [PATCH 02/54] feat: tests voor backend/controllers/groups.ts geimplementeerd (4 FAILS) --- backend/src/controllers/groups.ts | 9 +- backend/tests/controllers/classes.test.ts | 22 ++- backend/tests/controllers/group.test.ts | 157 ++++++++++++++++++++++ 3 files changed, 174 insertions(+), 14 deletions(-) create mode 100644 backend/tests/controllers/group.test.ts diff --git a/backend/src/controllers/groups.ts b/backend/src/controllers/groups.ts index b7bfd212..da1cde39 100644 --- a/backend/src/controllers/groups.ts +++ b/backend/src/controllers/groups.ts @@ -2,14 +2,7 @@ import { Request, Response } from 'express'; import { createGroup, getAllGroups, getGroup, getGroupSubmissions } from '../services/groups.js'; import { GroupDTO } from '../interfaces/group.js'; -// Typescript is annoywith with parameter forwarding from class.ts -interface GroupParams { - classid: string; - assignmentid: string; - groupid?: string; -} - -export async function getGroupHandler(req: Request, res: Response): Promise { +export async function getGroupHandler(req: Request, res: Response): Promise { const classId = req.params.classid; const full = req.query.full === 'true'; const assignmentId = +req.params.assignmentid; diff --git a/backend/tests/controllers/classes.test.ts b/backend/tests/controllers/classes.test.ts index 03952e53..b20abae5 100644 --- a/backend/tests/controllers/classes.test.ts +++ b/backend/tests/controllers/classes.test.ts @@ -1,18 +1,14 @@ import { setupTestApp } from '../setup-tests.js'; import { describe, it, expect, beforeAll, beforeEach, vi, Mock } from 'vitest'; -import { createClassHandler, getClassHandler, getClassStudentsHandler, getTeacherInvitationsHandler } from '../../src/controllers/classes.js'; +import { createClassHandler, getAllClassesHandler, getClassHandler, getClassStudentsHandler, getTeacherInvitationsHandler } from '../../src/controllers/classes.js'; import { Request, Response } from 'express'; -import { getClassTeacherInvitations } from '../../src/services/class.js'; +import { getAllClasses } from '../../src/services/class.js'; async function fetchClass(id: string) { const data = await fetch(`localhost:3000/class/${id}`); return data; } -vi.mock('./getClass', () => ({ - getClass: vi.fn(), -})); - describe('Class controllers', () => { let req: Partial; let res: Partial; @@ -146,4 +142,18 @@ describe('Class controllers', () => { expect(statusMock).toHaveBeenCalledWith(404); expect(jsonMock).toHaveBeenCalledWith({ error: 'Class not found' }); }); + + it('should return a list of classes', async () => { + req = { + query: {}, + }; + + await getAllClassesHandler(req as Request, res as Response); + + expect(jsonMock).toHaveBeenCalled(); + + const result = jsonMock.mock.lastCall![0]; + + expect("classes" in result).toBeTruthy(); + }) }) \ No newline at end of file diff --git a/backend/tests/controllers/group.test.ts b/backend/tests/controllers/group.test.ts new file mode 100644 index 00000000..6b4b95a4 --- /dev/null +++ b/backend/tests/controllers/group.test.ts @@ -0,0 +1,157 @@ +import { setupTestApp } from '../setup-tests.js'; +import { describe, it, expect, beforeAll, beforeEach, vi, Mock } from 'vitest'; +import { Request, Response } from 'express'; +import { createGroupHandler, getAllGroupsHandler, getGroupHandler, getGroupSubmissionsHandler } from '../../src/controllers/groups.js'; +import { G } from 'vitest/dist/chunks/reporters.66aFHiyX.js'; + +async function test404( + req: Partial> , + res: Partial, + handler: (req: Request, res: Response) => Promise, + expectedMessage: string +) { + await handler(req as Request, res as Response); + + expect(res.status).toHaveBeenCalledWith(404); + expect(res.json).toHaveBeenCalledWith({ error: expectedMessage }); +} + +function createRequestObject(classid: string, assignmentid: string, groupNumber: string) { + return { + params: { + classid: classid, + assignmentid: assignmentid, // should not exist + groupid: groupNumber, // should not exist + }, + query: {}, + }; +} + +describe('Group controllers', () => { + let req: Partial; + let res: Partial; + + let jsonMock: Mock; + let statusMock: Mock; + + beforeAll(async () => { + await setupTestApp(); + }); + + beforeEach(async () => { + jsonMock = vi.fn(); + statusMock = vi.fn().mockReturnThis(); + + res = { + json: jsonMock, + status: statusMock, + }; + }); + + it('should return 404 not found on a non-existing group', async () => { + req = { + params: { + classid: 'id01', + assignmentid: '1', + groupid: '42000', // should not exist + }, + query: {}, + }; + + await getGroupHandler(req as Request, res as Response); + + expect(statusMock).toHaveBeenCalledWith(404); + expect(jsonMock).toHaveBeenCalledWith({ error: 'Group not found' }); + }); + + it('should return 404 not found on a non-existing assignment', async () => { + req = { + params: { + classid: 'id01', + assignmentid: '1000', // should not exist + groupid: '42000', // should not exist + }, + query: {}, + }; + + await getGroupHandler(req as Request, res as Response); + + expect(statusMock).toHaveBeenCalledWith(404); + expect(jsonMock).toHaveBeenCalledWith({ error: 'Assignment not found' }); + }); + + it('should return 404 not found ont a non-existing class', async () => { + req = { + params: { + classid: 'doesnotexist', // should not exist + assignmentid: '1000', // should not exist + groupid: '42000', // should not exist + }, + query: {}, + }; + + await getGroupHandler(req as Request, res as Response); + + expect(statusMock).toHaveBeenCalledWith(404); + expect(jsonMock).toHaveBeenCalledWith({ error: 'Class not found' }); + }); + + it('should return an existing group', async () => { + req = createRequestObject('id01', '1', '1'); + + await getGroupHandler(req as Request, res as Response); + + expect(jsonMock).toHaveBeenCalledWith({ + assignment: 1, + groupNumber: 1, + members: [ 'DireStraits', 'Noordkaap' ] + }); + }); + + + it('should return a 201 when creating a group', async () => { + req = createRequestObject('id01', '1', 'irrelevant'); + req.body = { + members: [ + 'NoordKaap', + 'DireStraits', + ] + }; + + await createGroupHandler(req as Request, res as Response); + + expect(statusMock).toHaveBeenCalledWith(201); + expect(jsonMock).toHaveBeenCalled(); + + const result = jsonMock.mock.lastCall![0]; + + expect("assignment" in result).toBeTruthy(); + expect("groupNumber" in result).toBeTruthy(); + expect("members" in result).toBeTruthy(); + }); + + it('should return the submissions for a group', async () => { + req = createRequestObject('id01', '1', '1'); + + await getGroupSubmissionsHandler(req as Request, res as Response); + + expect(jsonMock).toHaveBeenCalled(); + + const result = jsonMock.mock.lastCall![0]; + + expect("submissions" in result).toBeTruthy(); + expect(typeof(result.submissions)).toBe(typeof([])); + }); + + it('should return a list of groups for an assignment', async () => { + req = createRequestObject('id01', '1', '1'); + + await getAllGroupsHandler(req as Request, res as Response); + + expect(jsonMock).toHaveBeenCalled(); + + const result = jsonMock.mock.lastCall![0]; + + expect("groups" in result).toBeTruthy(); + }); +}); From 58bfa9047441e81ce29457a5aec90aeec70863b7 Mon Sep 17 00:00:00 2001 From: Adriaan Jacquet Date: Sun, 23 Mar 2025 18:56:54 +0100 Subject: [PATCH 03/54] fix: overbodige comment verwijderd --- backend/tests/controllers/group.test.ts | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/backend/tests/controllers/group.test.ts b/backend/tests/controllers/group.test.ts index 6b4b95a4..8cfbd0d3 100644 --- a/backend/tests/controllers/group.test.ts +++ b/backend/tests/controllers/group.test.ts @@ -20,8 +20,8 @@ function createRequestObject(classid: string, assignmentid: string, groupNumber: return { params: { classid: classid, - assignmentid: assignmentid, // should not exist - groupid: groupNumber, // should not exist + assignmentid: assignmentid, + groupid: groupNumber, }, query: {}, }; From dbe7807f4aff78f730668787f8ee235301b1968a Mon Sep 17 00:00:00 2001 From: Adriaan Jacquet Date: Sun, 23 Mar 2025 20:49:09 +0100 Subject: [PATCH 04/54] feat: testen voor assignment controller geimplementeerd --- backend/tests/controllers/assignments.test.ts | 96 +++++++++++++++++++ backend/tests/controllers/classes.test.ts | 7 +- backend/tests/controllers/group.test.ts | 13 --- 3 files changed, 97 insertions(+), 19 deletions(-) create mode 100644 backend/tests/controllers/assignments.test.ts diff --git a/backend/tests/controllers/assignments.test.ts b/backend/tests/controllers/assignments.test.ts new file mode 100644 index 00000000..bb9d80ed --- /dev/null +++ b/backend/tests/controllers/assignments.test.ts @@ -0,0 +1,96 @@ +import { setupTestApp } from '../setup-tests.js'; +import { describe, it, expect, beforeAll, beforeEach, vi, Mock } from 'vitest'; +import { Request, Response } from 'express'; +import { getAssignmentHandler, getAllAssignmentsHandler, getAssignmentsSubmissionsHandler } from '../../src/controllers/assignments.js'; + +function createRequestObject(classid: string, assignmentid: string) { + return { + params: { + classid: classid, + id: assignmentid, + }, + query: {}, + }; +} + +function checkReturnList(jsonMock: Mock, listName: string) { + expect(jsonMock).toHaveBeenCalled(); + + const result = jsonMock.mock.lastCall![0]; + + expect(listName in result).toBeTruthy(); +} + +function checkReturn404(jsonMock: Mock, statusMock: Mock) { + expect(statusMock).toHaveBeenCalledWith(404); + expect(jsonMock).toHaveBeenCalled(); +} + +describe('Assignment controllers', () => { + let req: Partial; + let res: Partial; + + let jsonMock: Mock; + let statusMock: Mock; + + beforeAll(async () => { + await setupTestApp(); + }); + + beforeEach(async () => { + jsonMock = vi.fn(); + statusMock = vi.fn().mockReturnThis(); + + res = { + json: jsonMock, + status: statusMock, + }; + }); + + it('should return a 404 when trying to find a non-existent assignment', async () => { + req = createRequestObject('id01', '43000'); // should not exist + + await getAssignmentHandler(req as Request, res as Response); + + checkReturn404(jsonMock, statusMock); + }); + + it('should return a 404 when trying to find an assignment on a non-existing class', async () => { + req = createRequestObject('doesnotexist', '1'); // should not exist + + await getAssignmentHandler(req as Request, res as Response); + + checkReturn404(jsonMock, statusMock); + }); + + it('should return an assignment', async () => { + req = createRequestObject('id01', '1'); + + await getAssignmentHandler(req as Request, res as Response); + + expect(jsonMock).toHaveBeenCalledWith({ + id: 1, + class: 'id01', + title: 'dire straits', + description: 'reading', + learningPath: 'id02', + language: 'en' + }); + }); + + it('should return a list of assignments', async () => { + req = createRequestObject('id01', 'irrelevant'); + + await getAllAssignmentsHandler(req as Request, res as Response); + + checkReturnList(jsonMock, "assignments"); + }); + + it('should return a list of submissions for an assignment', async () => { + req = createRequestObject('id01', '1'); + + await getAssignmentsSubmissionsHandler(req as Request, res as Response); + + checkReturnList(jsonMock, "submissions"); + }) +}) diff --git a/backend/tests/controllers/classes.test.ts b/backend/tests/controllers/classes.test.ts index b20abae5..f91c5e67 100644 --- a/backend/tests/controllers/classes.test.ts +++ b/backend/tests/controllers/classes.test.ts @@ -4,11 +4,6 @@ import { createClassHandler, getAllClassesHandler, getClassHandler, getClassStud import { Request, Response } from 'express'; import { getAllClasses } from '../../src/services/class.js'; -async function fetchClass(id: string) { - const data = await fetch(`localhost:3000/class/${id}`); - return data; -} - describe('Class controllers', () => { let req: Partial; let res: Partial; @@ -156,4 +151,4 @@ describe('Class controllers', () => { expect("classes" in result).toBeTruthy(); }) -}) \ No newline at end of file +}) diff --git a/backend/tests/controllers/group.test.ts b/backend/tests/controllers/group.test.ts index 8cfbd0d3..5d3b3542 100644 --- a/backend/tests/controllers/group.test.ts +++ b/backend/tests/controllers/group.test.ts @@ -2,19 +2,6 @@ import { setupTestApp } from '../setup-tests.js'; import { describe, it, expect, beforeAll, beforeEach, vi, Mock } from 'vitest'; import { Request, Response } from 'express'; import { createGroupHandler, getAllGroupsHandler, getGroupHandler, getGroupSubmissionsHandler } from '../../src/controllers/groups.js'; -import { G } from 'vitest/dist/chunks/reporters.66aFHiyX.js'; - -async function test404( - req: Partial> , - res: Partial, - handler: (req: Request, res: Response) => Promise, - expectedMessage: string -) { - await handler(req as Request, res as Response); - - expect(res.status).toHaveBeenCalledWith(404); - expect(res.json).toHaveBeenCalledWith({ error: expectedMessage }); -} function createRequestObject(classid: string, assignmentid: string, groupNumber: string) { return { From 19317868c725b04c3f74d9521b03a8d1638484bc Mon Sep 17 00:00:00 2001 From: Adriaan Jacquet Date: Sun, 23 Mar 2025 20:50:52 +0100 Subject: [PATCH 05/54] fix: assignmentParam type errors gefixt --- backend/src/controllers/assignments.ts | 13 ++++--------- 1 file changed, 4 insertions(+), 9 deletions(-) diff --git a/backend/src/controllers/assignments.ts b/backend/src/controllers/assignments.ts index 03332469..6aa9eefb 100644 --- a/backend/src/controllers/assignments.ts +++ b/backend/src/controllers/assignments.ts @@ -3,12 +3,7 @@ import { createAssignment, getAllAssignments, getAssignment, getAssignmentsSubmi import { AssignmentDTO } from '../interfaces/assignment.js'; // Typescript is annoy with with parameter forwarding from class.ts -interface AssignmentParams { - classid: string; - id: string; -} - -export async function getAllAssignmentsHandler(req: Request, res: Response): Promise { +export async function getAllAssignmentsHandler(req: Request, res: Response): Promise { const classid = req.params.classid; const full = req.query.full === 'true'; @@ -19,7 +14,7 @@ export async function getAllAssignmentsHandler(req: Request, r }); } -export async function createAssignmentHandler(req: Request, res: Response): Promise { +export async function createAssignmentHandler(req: Request, res: Response): Promise { const classid = req.params.classid; const assignmentData = req.body as AssignmentDTO; @@ -40,7 +35,7 @@ export async function createAssignmentHandler(req: Request, re res.status(201).json({ assignment: assignment }); } -export async function getAssignmentHandler(req: Request, res: Response): Promise { +export async function getAssignmentHandler(req: Request, res: Response): Promise { const id = +req.params.id; const classid = req.params.classid; @@ -59,7 +54,7 @@ export async function getAssignmentHandler(req: Request, res: res.json(assignment); } -export async function getAssignmentsSubmissionsHandler(req: Request, res: Response): Promise { +export async function getAssignmentsSubmissionsHandler(req: Request, res: Response): Promise { const classid = req.params.classid; const assignmentNumber = +req.params.id; From ef8bc71018e250b20858a7cdb128ee2a338d4214 Mon Sep 17 00:00:00 2001 From: Adriaan Jacquet Date: Sat, 29 Mar 2025 20:32:39 +0100 Subject: [PATCH 06/54] fix: bestandsnaam groups.test.ts consistent gemaakt --- backend/tests/controllers/{group.test.ts => groups.test.ts} | 0 1 file changed, 0 insertions(+), 0 deletions(-) rename backend/tests/controllers/{group.test.ts => groups.test.ts} (100%) diff --git a/backend/tests/controllers/group.test.ts b/backend/tests/controllers/groups.test.ts similarity index 100% rename from backend/tests/controllers/group.test.ts rename to backend/tests/controllers/groups.test.ts From c9739a14205055344a0ef8081e89490c9cf61d12 Mon Sep 17 00:00:00 2001 From: Adriaan Jacquet Date: Sat, 29 Mar 2025 21:10:04 +0100 Subject: [PATCH 07/54] feat: qol functies toegevoegd, tests voor submissions aan het schrijven --- backend/tests/controllers/qol.ts | 12 ++++ backend/tests/controllers/submissions.test.ts | 72 +++++++++++++++++++ 2 files changed, 84 insertions(+) create mode 100644 backend/tests/controllers/qol.ts create mode 100644 backend/tests/controllers/submissions.test.ts diff --git a/backend/tests/controllers/qol.ts b/backend/tests/controllers/qol.ts new file mode 100644 index 00000000..984b7c58 --- /dev/null +++ b/backend/tests/controllers/qol.ts @@ -0,0 +1,12 @@ +export function checkReturnList(jsonMock: Mock, listName: string) { + expect(jsonMock).toHaveBeenCalled(); + + const result = jsonMock.mock.lastCall![0]; + + expect(listName in result).toBeTruthy(); +} + +export function checkReturn404(jsonMock: Mock, statusMock: Mock) { + expect(statusMock).toHaveBeenCalledWith(404); + expect(jsonMock).toHaveBeenCalled(); +} diff --git a/backend/tests/controllers/submissions.test.ts b/backend/tests/controllers/submissions.test.ts new file mode 100644 index 00000000..442f81c5 --- /dev/null +++ b/backend/tests/controllers/submissions.test.ts @@ -0,0 +1,72 @@ +import { setupTestApp } from '../setup-tests.js'; +import { describe, it, expect, beforeAll, beforeEach, vi, Mock } from 'vitest'; +import { getSubmissionHandler } from '../../src/controllers/submissions.js'; +import { Request, Response } from 'express'; +import { checkReturn404, checkReturnList } from './qol.js'; + + +function createRequestObject(hruid: string, submissionNumber: string) { + return { + params: { + hruid: hruid, + id: submissionNumber, + }, + query: { + language: 'nl', + version: '1', + }, + } +} + +describe('Submission controllers', () => { + let req: Partial; + let res: Partial; + + let jsonMock: Mock; + let statusMock: Mock; + + beforeAll(async () => { + await setupTestApp(); + }); + + beforeEach(async () => { + jsonMock = vi.fn(); + statusMock = vi.fn().mockReturnThis(); + + res = { + json: jsonMock, + status: statusMock, + }; + }); + + it('should return a 404 and error if submission is not found', async () => { + req = createRequestObject('id01', '1000000'); + + await getSubmissionHandler(req as Request, res as Response); + + checkReturn404(jsonMock, statusMock); + }); + + it('should return a 404 and error if learningobject is not found', async () => { + req = createRequestObject('doesnotexist', '1000000'); + + await getSubmissionHandler(req as Request, res as Response); + + checkReturn404(jsonMock, statusMock); + }); + + it('should return an existing submission', async () => { + req = createRequestObject('id01', '1'); + + await getSubmissionHandler(req as Request, res as Response); + + console.log(jsonMock.mock.lastCall![0]); + // TODO + }); + + it('should return a list of submissions for a learning object', async () => { + req = createRequestObject('id01', 'irrelevant'); + + }); +}); + From f0eb4822d928b8ab1f140d1c63977045193b9c19 Mon Sep 17 00:00:00 2001 From: Adriaan Jacquet Date: Sat, 29 Mar 2025 21:10:57 +0100 Subject: [PATCH 08/54] feat: getallsubmissions endpoint toegevoegd --- backend/src/controllers/submissions.ts | 21 ++++++++++++------- .../data/assignments/submission-repository.ts | 8 +++++++ backend/src/services/submissions.ts | 13 ++++++++++++ backend/tests/controllers/assignments.test.ts | 14 +------------ 4 files changed, 36 insertions(+), 20 deletions(-) diff --git a/backend/src/controllers/submissions.ts b/backend/src/controllers/submissions.ts index 1e66dbe9..ee5841d2 100644 --- a/backend/src/controllers/submissions.ts +++ b/backend/src/controllers/submissions.ts @@ -1,14 +1,9 @@ import { Request, Response } from 'express'; -import { createSubmission, deleteSubmission, getSubmission } from '../services/submissions.js'; +import { createSubmission, deleteSubmission, getAllSubmissions, getSubmission } from '../services/submissions.js'; import { Language, languageMap } from '../entities/content/language.js'; import { SubmissionDTO } from '../interfaces/submission'; -interface SubmissionParams { - hruid: string; - id: number; -} - -export async function getSubmissionHandler(req: Request, res: Response): Promise { +export async function getSubmissionHandler(req: Request, res: Response): Promise { const lohruid = req.params.hruid; const submissionNumber = +req.params.id; @@ -17,6 +12,7 @@ export async function getSubmissionHandler(req: Request, res: return; } + const lang = languageMap[req.query.language as string] || Language.Dutch; const version = (req.query.version || 1) as number; @@ -30,6 +26,17 @@ export async function getSubmissionHandler(req: Request, res: res.json(submission); } +export async function getAllSubmissionsHandler(req: Request, res: Response): Promise { + const lohruid = req.params.hruid; + + const lang = languageMap[req.query.language as string] || Language.Dutch; + const version = (req.query.version || 1) as number; + + const submissions = await getAllSubmissions(lohruid, lang, version); + + res.json({ submissions: submissions }); +} + export async function createSubmissionHandler(req: Request, res: Response) { const submissionDTO = req.body as SubmissionDTO; diff --git a/backend/src/data/assignments/submission-repository.ts b/backend/src/data/assignments/submission-repository.ts index 251823fa..e7b51e13 100644 --- a/backend/src/data/assignments/submission-repository.ts +++ b/backend/src/data/assignments/submission-repository.ts @@ -14,6 +14,14 @@ export class SubmissionRepository extends DwengoEntityRepository { }); } + public findSubmissionsByLearningObject(loId: LearningObjectIdentifier): Promise { + return this.find({ + learningObjectHruid: loId.hruid, + learningObjectLanguage: loId.language, + learningObjectVersion: loId.version, + }) + } + public findMostRecentSubmissionForStudent(loId: LearningObjectIdentifier, submitter: Student): Promise { return this.findOne( { diff --git a/backend/src/services/submissions.ts b/backend/src/services/submissions.ts index a8fa96c7..a0863375 100644 --- a/backend/src/services/submissions.ts +++ b/backend/src/services/submissions.ts @@ -21,6 +21,19 @@ export async function getSubmission( return mapToSubmissionDTO(submission); } +export async function getAllSubmissions( + lohruid: string, + language: Language, + version: number, +): Promise { + const loId = new LearningObjectIdentifier(lohruid, language, version); + + const submissionRepository = getSubmissionRepository(); + const submissions = await submissionRepository.findSubmissionsByLearningObject(loId); + + return submissions.map(mapToSubmissionDTO); +} + export async function createSubmission(submissionDTO: SubmissionDTO) { const submissionRepository = getSubmissionRepository(); const submission = mapToSubmission(submissionDTO); diff --git a/backend/tests/controllers/assignments.test.ts b/backend/tests/controllers/assignments.test.ts index bb9d80ed..38e73e17 100644 --- a/backend/tests/controllers/assignments.test.ts +++ b/backend/tests/controllers/assignments.test.ts @@ -2,6 +2,7 @@ import { setupTestApp } from '../setup-tests.js'; import { describe, it, expect, beforeAll, beforeEach, vi, Mock } from 'vitest'; import { Request, Response } from 'express'; import { getAssignmentHandler, getAllAssignmentsHandler, getAssignmentsSubmissionsHandler } from '../../src/controllers/assignments.js'; +import { checkReturn404, checkReturnList } from './qol.js' function createRequestObject(classid: string, assignmentid: string) { return { @@ -13,19 +14,6 @@ function createRequestObject(classid: string, assignmentid: string) { }; } -function checkReturnList(jsonMock: Mock, listName: string) { - expect(jsonMock).toHaveBeenCalled(); - - const result = jsonMock.mock.lastCall![0]; - - expect(listName in result).toBeTruthy(); -} - -function checkReturn404(jsonMock: Mock, statusMock: Mock) { - expect(statusMock).toHaveBeenCalledWith(404); - expect(jsonMock).toHaveBeenCalled(); -} - describe('Assignment controllers', () => { let req: Partial; let res: Partial; From 7a443c06868b3d03443e5c30470a4abf86c5d214 Mon Sep 17 00:00:00 2001 From: Adriaan Jacquet Date: Sat, 29 Mar 2025 21:56:56 +0100 Subject: [PATCH 09/54] feat: testen voor submissions geimplementeerd --- .../data/assignments/submission-repository.ts | 15 +++++++++------ backend/tests/controllers/qol.ts | 10 +++++++--- backend/tests/controllers/submissions.test.ts | 16 +++++++++++----- 3 files changed, 27 insertions(+), 14 deletions(-) diff --git a/backend/src/data/assignments/submission-repository.ts b/backend/src/data/assignments/submission-repository.ts index e7b51e13..96f196f6 100644 --- a/backend/src/data/assignments/submission-repository.ts +++ b/backend/src/data/assignments/submission-repository.ts @@ -6,12 +6,15 @@ import { Student } from '../../entities/users/student.entity.js'; export class SubmissionRepository extends DwengoEntityRepository { public findSubmissionByLearningObjectAndSubmissionNumber(loId: LearningObjectIdentifier, submissionNumber: number): Promise { - return this.findOne({ - learningObjectHruid: loId.hruid, - learningObjectLanguage: loId.language, - learningObjectVersion: loId.version, - submissionNumber: submissionNumber, - }); + return this.findOne( + { + learningObjectHruid: loId.hruid, + learningObjectLanguage: loId.language, + learningObjectVersion: loId.version, + submissionNumber: submissionNumber, + }, + { populate: ['submitter', 'onBehalfOf'] }, + ); } public findSubmissionsByLearningObject(loId: LearningObjectIdentifier): Promise { diff --git a/backend/tests/controllers/qol.ts b/backend/tests/controllers/qol.ts index 984b7c58..08f73f79 100644 --- a/backend/tests/controllers/qol.ts +++ b/backend/tests/controllers/qol.ts @@ -1,12 +1,16 @@ -export function checkReturnList(jsonMock: Mock, listName: string) { +export function checkReturnList(jsonMock: Mock, listName: string, length?: number) { expect(jsonMock).toHaveBeenCalled(); const result = jsonMock.mock.lastCall![0]; expect(listName in result).toBeTruthy(); + + if (length) { + expect(result[listName].length).toBe(length); + } } export function checkReturn404(jsonMock: Mock, statusMock: Mock) { - expect(statusMock).toHaveBeenCalledWith(404); - expect(jsonMock).toHaveBeenCalled(); + expect(statusMock).toHaveBeenCalledWith(404); + expect(jsonMock).toHaveBeenCalled(); } diff --git a/backend/tests/controllers/submissions.test.ts b/backend/tests/controllers/submissions.test.ts index 442f81c5..20e69847 100644 --- a/backend/tests/controllers/submissions.test.ts +++ b/backend/tests/controllers/submissions.test.ts @@ -1,8 +1,10 @@ import { setupTestApp } from '../setup-tests.js'; import { describe, it, expect, beforeAll, beforeEach, vi, Mock } from 'vitest'; -import { getSubmissionHandler } from '../../src/controllers/submissions.js'; +import { getSubmissionHandler, getAllSubmissionsHandler } from '../../src/controllers/submissions.js'; import { Request, Response } from 'express'; import { checkReturn404, checkReturnList } from './qol.js'; +import { getSubmission } from '../../src/services/submissions.js'; +import { Language } from '../../src/entities/content/language.js'; function createRequestObject(hruid: string, submissionNumber: string) { @@ -12,7 +14,7 @@ function createRequestObject(hruid: string, submissionNumber: string) { id: submissionNumber, }, query: { - language: 'nl', + language: 'en', version: '1', }, } @@ -60,13 +62,17 @@ describe('Submission controllers', () => { await getSubmissionHandler(req as Request, res as Response); - console.log(jsonMock.mock.lastCall![0]); - // TODO + const expectedResult = await getSubmission('id01', Language.English, 1, 1); + + expect(jsonMock.mock.lastCall![0]).toStrictEqual(expectedResult); }); it('should return a list of submissions for a learning object', async () => { - req = createRequestObject('id01', 'irrelevant'); + req = createRequestObject('id02', 'irrelevant'); + await getAllSubmissionsHandler(req as Request, res as Response); + + checkReturnList(jsonMock, 'submissions', 2); }); }); From 943dd04e977714c7ef8560240d789986aff958f6 Mon Sep 17 00:00:00 2001 From: Adriaan Jacquet Date: Sat, 29 Mar 2025 22:28:52 +0100 Subject: [PATCH 10/54] fix: gefaalde testen voor class controller gefixt --- backend/src/controllers/classes.ts | 14 ++++++++-- backend/src/data/users/student-repository.ts | 4 +++ backend/src/services/class.ts | 27 ++++++++++---------- backend/tests/controllers/classes.test.ts | 17 +++--------- 4 files changed, 33 insertions(+), 29 deletions(-) diff --git a/backend/src/controllers/classes.ts b/backend/src/controllers/classes.ts index ca2f5698..65548cf5 100644 --- a/backend/src/controllers/classes.ts +++ b/backend/src/controllers/classes.ts @@ -1,5 +1,5 @@ import { Request, Response } from 'express'; -import { createClass, getAllClasses, getClass, getClassStudents, getClassStudentsIds, getClassTeacherInvitations } from '../services/class.js'; +import { createClass, getAllClasses, getClass, getClassStudents, getClassTeacherInvitations } from '../services/class.js'; import { ClassDTO } from '../interfaces/class.js'; export async function getAllClassesHandler(req: Request, res: Response): Promise { @@ -58,7 +58,12 @@ export async function getClassStudentsHandler(req: Request, res: Response): Prom const classId = req.params.id; const full = req.query.full === 'true'; - const students = full ? await getClassStudents(classId) : await getClassStudentsIds(classId); + const students = await getClassStudents(classId, full); + + if (!students) { + res.status(404).json({ error: 'Class not found' }); + return; + } res.json({ students: students, @@ -71,6 +76,11 @@ export async function getTeacherInvitationsHandler(req: Request, res: Response): const invitations = await getClassTeacherInvitations(classId, full); + if (!invitations) { + res.status(404).json({ error: 'Class not found' }); + return; + } + res.json({ invitations: invitations, }); diff --git a/backend/src/data/users/student-repository.ts b/backend/src/data/users/student-repository.ts index 0792678d..f35fd153 100644 --- a/backend/src/data/users/student-repository.ts +++ b/backend/src/data/users/student-repository.ts @@ -1,3 +1,4 @@ +import { Class } from '../../entities/classes/class.entity.js'; import { Student } from '../../entities/users/student.entity.js'; import { User } from '../../entities/users/user.entity.js'; import { DwengoEntityRepository } from '../dwengo-entity-repository.js'; @@ -9,6 +10,9 @@ export class StudentRepository extends DwengoEntityRepository { public findByUsername(username: string): Promise { return this.findOne({ username: username }); } + public findByClass(cls: Class): Promise { + return this.find({ classes: cls }); + } public deleteByUsername(username: string): Promise { return this.deleteWhere({ username: username }); } diff --git a/backend/src/services/class.ts b/backend/src/services/class.ts index 9f6e1efe..bc2984fc 100644 --- a/backend/src/services/class.ts +++ b/backend/src/services/class.ts @@ -4,6 +4,7 @@ import { ClassDTO, mapToClassDTO } from '../interfaces/class.js'; import { mapToStudentDTO, StudentDTO } from '../interfaces/student.js'; import { mapToTeacherInvitationDTO, mapToTeacherInvitationDTOIds, TeacherInvitationDTO } from '../interfaces/teacher-invitation.js'; import { getLogger } from '../logging/initalize.js'; +import { getStudent } from './students.js'; const logger = getLogger(); @@ -60,32 +61,30 @@ export async function getClass(classId: string): Promise { return mapToClassDTO(cls); } -async function fetchClassStudents(classId: string): Promise { +export async function getClassStudents(classId: string, full: boolean): Promise { const classRepository = getClassRepository(); const cls = await classRepository.findById(classId); if (!cls) { - return []; + return null; } - return cls.students.map(mapToStudentDTO); + const studentRepository = getStudentRepository(); + const students = await studentRepository.findByClass(cls); + + if (full) { + return cls.students.map(mapToStudentDTO); + } + + return students.map((student) => student.username); } -export async function getClassStudents(classId: string): Promise { - return await fetchClassStudents(classId); -} - -export async function getClassStudentsIds(classId: string): Promise { - const students: StudentDTO[] = await fetchClassStudents(classId); - return students.map((student) => student.username); -} - -export async function getClassTeacherInvitations(classId: string, full: boolean): Promise { +export async function getClassTeacherInvitations(classId: string, full: boolean): Promise { const classRepository = getClassRepository(); const cls = await classRepository.findById(classId); if (!cls) { - return []; + return null; } const teacherInvitationRepository = getTeacherInvitationRepository(); diff --git a/backend/tests/controllers/classes.test.ts b/backend/tests/controllers/classes.test.ts index f91c5e67..a5a27a5e 100644 --- a/backend/tests/controllers/classes.test.ts +++ b/backend/tests/controllers/classes.test.ts @@ -3,6 +3,7 @@ import { describe, it, expect, beforeAll, beforeEach, vi, Mock } from 'vitest'; import { createClassHandler, getAllClassesHandler, getClassHandler, getClassStudentsHandler, getTeacherInvitationsHandler } from '../../src/controllers/classes.js'; import { Request, Response } from 'express'; import { getAllClasses } from '../../src/services/class.js'; +import { checkReturnList, checkReturn404 } from './qol.js'; describe('Class controllers', () => { let req: Partial; @@ -84,15 +85,7 @@ describe('Class controllers', () => { await getClassStudentsHandler(req as Request, res as Response); - expect(jsonMock).toHaveBeenCalledWith({ students: [ - 'DireStraits', - 'Nirvana', - 'Noordkaap', - 'PinkFloyd', - 'SmashingPumpkins', - 'TheDoors', - 'Tool' - ]}); + checkReturnList(jsonMock, 'students'); }); it('should return 404 not found when calling getClassStudentsHandler on a non-existent class', async () => { @@ -102,8 +95,7 @@ describe('Class controllers', () => { }; await getClassStudentsHandler(req as Request, res as Response); - - // will fail until code is fixed + expect(statusMock).toHaveBeenCalledWith(404); expect(jsonMock).toHaveBeenCalledWith({ error: 'Class not found' }); }); @@ -133,9 +125,8 @@ describe('Class controllers', () => { await getTeacherInvitationsHandler(req as Request, res as Response); - // will fail until code is fixed - expect(statusMock).toHaveBeenCalledWith(404); expect(jsonMock).toHaveBeenCalledWith({ error: 'Class not found' }); + expect(statusMock).toHaveBeenCalledWith(404); }); it('should return a list of classes', async () => { From bede00df8106f1a277e051c635a19c227d24ccf1 Mon Sep 17 00:00:00 2001 From: Adriaan Jacquet Date: Sat, 29 Mar 2025 23:06:03 +0100 Subject: [PATCH 11/54] fix: gefaalde testen gefixt voor group controller --- backend/src/controllers/groups.ts | 4 ++++ backend/tests/controllers/groups.test.ts | 6 +++--- 2 files changed, 7 insertions(+), 3 deletions(-) diff --git a/backend/src/controllers/groups.ts b/backend/src/controllers/groups.ts index da1cde39..81b62a49 100644 --- a/backend/src/controllers/groups.ts +++ b/backend/src/controllers/groups.ts @@ -21,6 +21,10 @@ export async function getGroupHandler(req: Request, res: Response): Promise { await getGroupHandler(req as Request, res as Response); expect(statusMock).toHaveBeenCalledWith(404); - expect(jsonMock).toHaveBeenCalledWith({ error: 'Group not found' }); + expect(jsonMock).toHaveBeenCalled(); }); it('should return 404 not found on a non-existing assignment', async () => { @@ -64,7 +64,7 @@ describe('Group controllers', () => { await getGroupHandler(req as Request, res as Response); expect(statusMock).toHaveBeenCalledWith(404); - expect(jsonMock).toHaveBeenCalledWith({ error: 'Assignment not found' }); + expect(jsonMock).toHaveBeenCalled(); }); it('should return 404 not found ont a non-existing class', async () => { @@ -80,7 +80,7 @@ describe('Group controllers', () => { await getGroupHandler(req as Request, res as Response); expect(statusMock).toHaveBeenCalledWith(404); - expect(jsonMock).toHaveBeenCalledWith({ error: 'Class not found' }); + expect(jsonMock).toHaveBeenCalled(); }); it('should return an existing group', async () => { From fe51c2d1ecb40702a4b944d3b3a717015c18f31a Mon Sep 17 00:00:00 2001 From: Adriaan Jacquet Date: Sun, 30 Mar 2025 17:00:55 +0200 Subject: [PATCH 12/54] fix: correcte error handling in question controller backend --- backend/src/controllers/questions.ts | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/backend/src/controllers/questions.ts b/backend/src/controllers/questions.ts index 00a51329..217994f6 100644 --- a/backend/src/controllers/questions.ts +++ b/backend/src/controllers/questions.ts @@ -106,13 +106,14 @@ export async function deleteQuestionHandler(req: Request, res: Response): Promis const questionId = getQuestionId(req, res); if (!questionId) { + res.json(404).json({ error: 'Question not found' }); return; } const question = await deleteQuestion(questionId); if (!question) { - res.status(400).json({ error: 'Could not find nor delete question' }); + res.status(404).json({ error: 'Could not find nor delete question' }); } else { res.json(question); } From 3360d7c5fa4124a4a285b9f23861310ec22dc7d9 Mon Sep 17 00:00:00 2001 From: Gabriellvl Date: Fri, 2 May 2025 09:49:32 +0200 Subject: [PATCH 13/54] fix: stijl + positie zoek kaart --- frontend/src/components/BrowseThemes.vue | 39 +++++++++++++----------- 1 file changed, 22 insertions(+), 17 deletions(-) diff --git a/frontend/src/components/BrowseThemes.vue b/frontend/src/components/BrowseThemes.vue index b65c4e26..7b1971d4 100644 --- a/frontend/src/components/BrowseThemes.vue +++ b/frontend/src/components/BrowseThemes.vue @@ -57,6 +57,22 @@ + + + - - - - + From a6b8b6647bbcd87d54bc261b924bee324437d785 Mon Sep 17 00:00:00 2001 From: Gabriellvl Date: Tue, 6 May 2025 09:30:47 +0200 Subject: [PATCH 14/54] fix: stijl zoekpagina --- .../learning-paths/LearningPathSearchPage.vue | 57 +++++++++++-------- 1 file changed, 33 insertions(+), 24 deletions(-) diff --git a/frontend/src/views/learning-paths/LearningPathSearchPage.vue b/frontend/src/views/learning-paths/LearningPathSearchPage.vue index 4e2c6475..47821666 100644 --- a/frontend/src/views/learning-paths/LearningPathSearchPage.vue +++ b/frontend/src/views/learning-paths/LearningPathSearchPage.vue @@ -17,32 +17,41 @@ From 2f28b801807c92816c34b0918f09f716370d4c9e Mon Sep 17 00:00:00 2001 From: Lint Action Date: Tue, 6 May 2025 07:32:26 +0000 Subject: [PATCH 15/54] style: fix linting issues met Prettier --- .../learning-paths/LearningPathSearchPage.vue | 31 +++++++++++++------ 1 file changed, 21 insertions(+), 10 deletions(-) diff --git a/frontend/src/views/learning-paths/LearningPathSearchPage.vue b/frontend/src/views/learning-paths/LearningPathSearchPage.vue index 47821666..b6d75d15 100644 --- a/frontend/src/views/learning-paths/LearningPathSearchPage.vue +++ b/frontend/src/views/learning-paths/LearningPathSearchPage.vue @@ -18,8 +18,16 @@ @@ -237,7 +227,9 @@ border-radius: 16px; box-shadow: 0 4px 12px rgba(0, 0, 0, 0.08); background-color: white; - transition: transform 0.2s, box-shadow 0.2s; + transition: + transform 0.2s, + box-shadow 0.2s; } .assignment-card:hover { transform: translateY(-2px); @@ -295,6 +287,4 @@ color: #777; padding: 3rem 0; } - - From 0809e1b52eb0a1099ea4284b9022c65b590808f8 Mon Sep 17 00:00:00 2001 From: Lint Action Date: Sun, 11 May 2025 15:43:19 +0000 Subject: [PATCH 44/54] style: fix linting issues met Prettier --- .../src/entities/assignments/assignment.entity.ts | 2 +- .../test_assets/assignments/assignments.testdata.ts | 12 ++++++------ 2 files changed, 7 insertions(+), 7 deletions(-) diff --git a/backend/src/entities/assignments/assignment.entity.ts b/backend/src/entities/assignments/assignment.entity.ts index 9c9517c2..1bddd39d 100644 --- a/backend/src/entities/assignments/assignment.entity.ts +++ b/backend/src/entities/assignments/assignment.entity.ts @@ -26,7 +26,7 @@ export class Assignment { @Property({ type: 'string' }) learningPathHruid!: string; - @Property({ type: 'datetime'}) + @Property({ type: 'datetime' }) deadline?: Date; @Enum({ diff --git a/backend/tests/test_assets/assignments/assignments.testdata.ts b/backend/tests/test_assets/assignments/assignments.testdata.ts index f3005ae6..14e08422 100644 --- a/backend/tests/test_assets/assignments/assignments.testdata.ts +++ b/backend/tests/test_assets/assignments/assignments.testdata.ts @@ -1,9 +1,9 @@ -import {EntityManager} from '@mikro-orm/core'; -import {Assignment} from '../../../src/entities/assignments/assignment.entity'; -import {Class} from '../../../src/entities/classes/class.entity'; -import {Language} from '@dwengo-1/common/util/language'; -import {testLearningPathWithConditions} from '../content/learning-paths.testdata'; -import {getClassWithTestleerlingAndTestleerkracht} from '../classes/classes.testdata'; +import { EntityManager } from '@mikro-orm/core'; +import { Assignment } from '../../../src/entities/assignments/assignment.entity'; +import { Class } from '../../../src/entities/classes/class.entity'; +import { Language } from '@dwengo-1/common/util/language'; +import { testLearningPathWithConditions } from '../content/learning-paths.testdata'; +import { getClassWithTestleerlingAndTestleerkracht } from '../classes/classes.testdata'; const futureDate = new Date(); futureDate.setDate(futureDate.getDate() + 7); From 968d38ca32da486da54245cdea8d8ed1a1dcba4c Mon Sep 17 00:00:00 2001 From: Joyelle Ndagijimana Date: Mon, 12 May 2025 22:02:44 +0200 Subject: [PATCH 45/54] fix: deadline bug in seed data --- .../entities/assignments/assignment.entity.ts | 20 +++++++++---------- .../assignments/assignments.testdata.ts | 13 +++++++----- .../src/views/assignments/UserAssignments.vue | 2 ++ 3 files changed, 20 insertions(+), 15 deletions(-) diff --git a/backend/src/entities/assignments/assignment.entity.ts b/backend/src/entities/assignments/assignment.entity.ts index 1bddd39d..6089e06c 100644 --- a/backend/src/entities/assignments/assignment.entity.ts +++ b/backend/src/entities/assignments/assignment.entity.ts @@ -1,8 +1,8 @@ -import { Cascade, Collection, Entity, Enum, ManyToOne, OneToMany, PrimaryKey, Property } from '@mikro-orm/core'; -import { Class } from '../classes/class.entity.js'; -import { Group } from './group.entity.js'; -import { Language } from '@dwengo-1/common/util/language'; -import { AssignmentRepository } from '../../data/assignments/assignment-repository.js'; +import {Cascade, Collection, Entity, Enum, ManyToOne, OneToMany, PrimaryKey, Property} from '@mikro-orm/core'; +import {Class} from '../classes/class.entity.js'; +import {Group} from './group.entity.js'; +import {Language} from '@dwengo-1/common/util/language'; +import {AssignmentRepository} from '../../data/assignments/assignment-repository.js'; @Entity({ repository: () => AssignmentRepository, @@ -14,19 +14,19 @@ export class Assignment { }) within!: Class; - @PrimaryKey({ type: 'integer', autoincrement: true }) + @PrimaryKey({type: 'integer', autoincrement: true}) id?: number; - @Property({ type: 'string' }) + @Property({type: 'string'}) title!: string; - @Property({ type: 'text' }) + @Property({type: 'text'}) description!: string; - @Property({ type: 'string' }) + @Property({type: 'string'}) learningPathHruid!: string; - @Property({ type: 'datetime' }) + @Property({type: 'datetime'}) deadline?: Date; @Enum({ diff --git a/backend/tests/test_assets/assignments/assignments.testdata.ts b/backend/tests/test_assets/assignments/assignments.testdata.ts index 14e08422..5e08da30 100644 --- a/backend/tests/test_assets/assignments/assignments.testdata.ts +++ b/backend/tests/test_assets/assignments/assignments.testdata.ts @@ -5,12 +5,15 @@ import { Language } from '@dwengo-1/common/util/language'; import { testLearningPathWithConditions } from '../content/learning-paths.testdata'; import { getClassWithTestleerlingAndTestleerkracht } from '../classes/classes.testdata'; -const futureDate = new Date(); -futureDate.setDate(futureDate.getDate() + 7); -const pastDate = new Date(); -pastDate.setDate(pastDate.getDate() - 7); + export function makeTestAssignemnts(em: EntityManager, classes: Class[]): Assignment[] { + const futureDate = new Date(); + futureDate.setDate(futureDate.getDate() + 7); + const pastDate = new Date(); + pastDate.setDate(pastDate.getDate() - 7); + const today = new Date(); + today.setHours(23, 59); assignment01 = em.create(Assignment, { id: 21000, within: classes[0], @@ -18,7 +21,7 @@ export function makeTestAssignemnts(em: EntityManager, classes: Class[]): Assign description: 'reading', learningPathHruid: 'un_ai', learningPathLanguage: Language.English, - deadline: new Date(), + deadline: today, groups: [], }); diff --git a/frontend/src/views/assignments/UserAssignments.vue b/frontend/src/views/assignments/UserAssignments.vue index 84131d52..eee70f8d 100644 --- a/frontend/src/views/assignments/UserAssignments.vue +++ b/frontend/src/views/assignments/UserAssignments.vue @@ -101,6 +101,8 @@ day: "2-digit", month: "long", year: "numeric", + hour: "numeric", + minute: "2-digit", }); } From ae9f7a140a763bdf2b3fea3a09da2f485be3ba6a Mon Sep 17 00:00:00 2001 From: Lint Action Date: Mon, 12 May 2025 20:10:49 +0000 Subject: [PATCH 46/54] style: fix linting issues met Prettier --- .../entities/assignments/assignment.entity.ts | 20 +++++++++---------- .../assignments/assignments.testdata.ts | 2 -- 2 files changed, 10 insertions(+), 12 deletions(-) diff --git a/backend/src/entities/assignments/assignment.entity.ts b/backend/src/entities/assignments/assignment.entity.ts index 6089e06c..1bddd39d 100644 --- a/backend/src/entities/assignments/assignment.entity.ts +++ b/backend/src/entities/assignments/assignment.entity.ts @@ -1,8 +1,8 @@ -import {Cascade, Collection, Entity, Enum, ManyToOne, OneToMany, PrimaryKey, Property} from '@mikro-orm/core'; -import {Class} from '../classes/class.entity.js'; -import {Group} from './group.entity.js'; -import {Language} from '@dwengo-1/common/util/language'; -import {AssignmentRepository} from '../../data/assignments/assignment-repository.js'; +import { Cascade, Collection, Entity, Enum, ManyToOne, OneToMany, PrimaryKey, Property } from '@mikro-orm/core'; +import { Class } from '../classes/class.entity.js'; +import { Group } from './group.entity.js'; +import { Language } from '@dwengo-1/common/util/language'; +import { AssignmentRepository } from '../../data/assignments/assignment-repository.js'; @Entity({ repository: () => AssignmentRepository, @@ -14,19 +14,19 @@ export class Assignment { }) within!: Class; - @PrimaryKey({type: 'integer', autoincrement: true}) + @PrimaryKey({ type: 'integer', autoincrement: true }) id?: number; - @Property({type: 'string'}) + @Property({ type: 'string' }) title!: string; - @Property({type: 'text'}) + @Property({ type: 'text' }) description!: string; - @Property({type: 'string'}) + @Property({ type: 'string' }) learningPathHruid!: string; - @Property({type: 'datetime'}) + @Property({ type: 'datetime' }) deadline?: Date; @Enum({ diff --git a/backend/tests/test_assets/assignments/assignments.testdata.ts b/backend/tests/test_assets/assignments/assignments.testdata.ts index 5e08da30..dc477828 100644 --- a/backend/tests/test_assets/assignments/assignments.testdata.ts +++ b/backend/tests/test_assets/assignments/assignments.testdata.ts @@ -5,8 +5,6 @@ import { Language } from '@dwengo-1/common/util/language'; import { testLearningPathWithConditions } from '../content/learning-paths.testdata'; import { getClassWithTestleerlingAndTestleerkracht } from '../classes/classes.testdata'; - - export function makeTestAssignemnts(em: EntityManager, classes: Class[]): Assignment[] { const futureDate = new Date(); futureDate.setDate(futureDate.getDate() + 7); From 17620434f24ca4ae64efadac8ca0c8318ccb843b Mon Sep 17 00:00:00 2001 From: Gabriellvl Date: Mon, 12 May 2025 23:09:13 +0200 Subject: [PATCH 47/54] refactor: delete endpoint back and frontend --- backend/src/controllers/teachers.ts | 11 ------- .../content/learning-object-repository.ts | 8 ----- backend/src/routes/teachers.ts | 3 -- backend/src/services/teachers.ts | 30 ------------------- frontend/src/controllers/teachers.ts | 5 ---- frontend/src/queries/teachers.ts | 12 -------- 6 files changed, 69 deletions(-) diff --git a/backend/src/controllers/teachers.ts b/backend/src/controllers/teachers.ts index c8063f80..6d8ab0bc 100644 --- a/backend/src/controllers/teachers.ts +++ b/backend/src/controllers/teachers.ts @@ -7,7 +7,6 @@ import { getJoinRequestsByClass, getStudentsByTeacher, getTeacher, - getTeacherQuestions, updateClassJoinRequestStatus, } from '../services/teachers.js'; import { requireFields } from './error-helper.js'; @@ -70,16 +69,6 @@ export async function getTeacherStudentHandler(req: Request, res: Response): Pro res.json({ students }); } -export async function getTeacherQuestionHandler(req: Request, res: Response): Promise { - const username = req.params.username; - const full = req.query.full === 'true'; - requireFields({ username }); - - const questions = await getTeacherQuestions(username, full); - - res.json({ questions }); -} - export async function getStudentJoinRequestHandler(req: Request, res: Response): Promise { const classId = req.params.classId; requireFields({ classId }); diff --git a/backend/src/data/content/learning-object-repository.ts b/backend/src/data/content/learning-object-repository.ts index 889a1594..c9f1f189 100644 --- a/backend/src/data/content/learning-object-repository.ts +++ b/backend/src/data/content/learning-object-repository.ts @@ -2,7 +2,6 @@ import { DwengoEntityRepository } from '../dwengo-entity-repository.js'; import { LearningObject } from '../../entities/content/learning-object.entity.js'; import { LearningObjectIdentifier } from '../../entities/content/learning-object-identifier.js'; import { Language } from '@dwengo-1/common/util/language'; -import { Teacher } from '../../entities/users/teacher.entity.js'; export class LearningObjectRepository extends DwengoEntityRepository { public async findByIdentifier(identifier: LearningObjectIdentifier): Promise { @@ -32,11 +31,4 @@ export class LearningObjectRepository extends DwengoEntityRepository { - return this.find( - { admins: teacher }, - { populate: ['admins'] } // Make sure to load admin relations - ); - } } diff --git a/backend/src/routes/teachers.ts b/backend/src/routes/teachers.ts index 44d3064b..b858102d 100644 --- a/backend/src/routes/teachers.ts +++ b/backend/src/routes/teachers.ts @@ -6,7 +6,6 @@ import { getStudentJoinRequestHandler, getTeacherClassHandler, getTeacherHandler, - getTeacherQuestionHandler, getTeacherStudentHandler, updateStudentJoinRequestHandler, } from '../controllers/teachers.js'; @@ -27,8 +26,6 @@ router.get('/:username/classes', getTeacherClassHandler); router.get('/:username/students', getTeacherStudentHandler); -router.get('/:username/questions', getTeacherQuestionHandler); - router.get('/:username/joinRequests/:classId', getStudentJoinRequestHandler); router.put('/:username/joinRequests/:classId/:studentUsername', updateStudentJoinRequestHandler); diff --git a/backend/src/services/teachers.ts b/backend/src/services/teachers.ts index 4fdb15be..161e6b40 100644 --- a/backend/src/services/teachers.ts +++ b/backend/src/services/teachers.ts @@ -1,12 +1,9 @@ import { getClassJoinRequestRepository, getClassRepository, - getLearningObjectRepository, - getQuestionRepository, getTeacherRepository, } from '../data/repositories.js'; import { mapToClassDTO } from '../interfaces/class.js'; -import { mapToQuestionDTO, mapToQuestionDTOId } from '../interfaces/question.js'; import { mapToTeacher, mapToTeacherDTO } from '../interfaces/teacher.js'; import { Teacher } from '../entities/users/teacher.entity.js'; import { fetchStudent } from './students.js'; @@ -15,10 +12,6 @@ import { mapToStudentRequestDTO } from '../interfaces/student-request.js'; import { TeacherRepository } from '../data/users/teacher-repository.js'; import { ClassRepository } from '../data/classes/class-repository.js'; import { Class } from '../entities/classes/class.entity.js'; -import { LearningObjectRepository } from '../data/content/learning-object-repository.js'; -import { LearningObject } from '../entities/content/learning-object.entity.js'; -import { QuestionRepository } from '../data/questions/question-repository.js'; -import { Question } from '../entities/questions/question.entity.js'; import { ClassJoinRequestRepository } from '../data/classes/class-join-request-repository.js'; import { Student } from '../entities/users/student.entity.js'; import { NotFoundException } from '../exceptions/not-found-exception.js'; @@ -26,7 +19,6 @@ import { addClassStudent, fetchClass, getClassStudentsDTO } from './classes.js'; import { TeacherDTO } from '@dwengo-1/common/interfaces/teacher'; import { ClassDTO } from '@dwengo-1/common/interfaces/class'; import { StudentDTO } from '@dwengo-1/common/interfaces/student'; -import { QuestionDTO, QuestionId } from '@dwengo-1/common/interfaces/question'; import { ClassJoinRequestDTO } from '@dwengo-1/common/interfaces/class-join-request'; import { ClassStatus } from '@dwengo-1/common/util/class-join-request'; import { ConflictException } from '../exceptions/conflict-exception.js'; @@ -119,28 +111,6 @@ export async function getStudentsByTeacher(username: string, full: boolean): Pro return students.map((student) => student.username); } -export async function getTeacherQuestions(username: string, full: boolean): Promise { - const teacher: Teacher = await fetchTeacher(username); - - // Find all learning objects that this teacher manages - const learningObjectRepository: LearningObjectRepository = getLearningObjectRepository(); - const learningObjects: LearningObject[] = await learningObjectRepository.findAllByTeacher(teacher); - - if (!learningObjects || learningObjects.length === 0) { - return []; - } - - // Fetch all questions related to these learning objects - const questionRepository: QuestionRepository = getQuestionRepository(); - const questions: Question[] = await questionRepository.findAllByLearningObjects(learningObjects); - - if (full) { - return questions.map(mapToQuestionDTO); - } - - return questions.map(mapToQuestionDTOId); -} - export async function getJoinRequestsByClass(classId: string): Promise { const classRepository: ClassRepository = getClassRepository(); const cls: Class | null = await classRepository.findById(classId); diff --git a/frontend/src/controllers/teachers.ts b/frontend/src/controllers/teachers.ts index a97cf11f..a7adce18 100644 --- a/frontend/src/controllers/teachers.ts +++ b/frontend/src/controllers/teachers.ts @@ -1,6 +1,5 @@ import { BaseController } from "@/controllers/base-controller.ts"; import type { JoinRequestResponse, JoinRequestsResponse, StudentsResponse } from "@/controllers/students.ts"; -import type { QuestionsResponse } from "@/controllers/questions.ts"; import type { ClassesResponse } from "@/controllers/classes.ts"; import type { TeacherDTO } from "@dwengo-1/common/interfaces/teacher"; @@ -40,10 +39,6 @@ export class TeacherController extends BaseController { return this.get(`/${username}/students`, { full }); } - async getQuestions(username: string, full = false): Promise { - return this.get(`/${username}/questions`, { full }); - } - async getStudentJoinRequests(username: string, classId: string): Promise { return this.get(`/${username}/joinRequests/${classId}`); } diff --git a/frontend/src/queries/teachers.ts b/frontend/src/queries/teachers.ts index 59da84f4..fe2794cb 100644 --- a/frontend/src/queries/teachers.ts +++ b/frontend/src/queries/teachers.ts @@ -10,7 +10,6 @@ import { import { TeacherController, type TeacherResponse, type TeachersResponse } from "@/controllers/teachers.ts"; import type { ClassesResponse } from "@/controllers/classes.ts"; import type { JoinRequestResponse, JoinRequestsResponse, StudentsResponse } from "@/controllers/students.ts"; -import type { QuestionsResponse } from "@/controllers/questions.ts"; import type { TeacherDTO } from "@dwengo-1/common/interfaces/teacher"; import { studentJoinRequestQueryKey, studentJoinRequestsQueryKey } from "@/queries/students.ts"; @@ -80,17 +79,6 @@ export function useTeacherStudentsQuery( }); } -export function useTeacherQuestionsQuery( - username: MaybeRefOrGetter, - full: MaybeRefOrGetter = false, -): UseQueryReturnType { - return useQuery({ - queryKey: computed(() => teacherQuestionsQueryKey(toValue(username)!, toValue(full))), - queryFn: async () => teacherController.getQuestions(toValue(username)!, toValue(full)), - enabled: () => Boolean(toValue(username)), - }); -} - export function useTeacherJoinRequestsQuery( username: MaybeRefOrGetter, classId: MaybeRefOrGetter, From 17c258a2948d09232ecc34aaabffbefb639645cc Mon Sep 17 00:00:00 2001 From: Lint Action Date: Mon, 12 May 2025 21:15:15 +0000 Subject: [PATCH 48/54] style: fix linting issues met Prettier --- backend/src/services/teachers.ts | 6 +----- 1 file changed, 1 insertion(+), 5 deletions(-) diff --git a/backend/src/services/teachers.ts b/backend/src/services/teachers.ts index 161e6b40..2666be8c 100644 --- a/backend/src/services/teachers.ts +++ b/backend/src/services/teachers.ts @@ -1,8 +1,4 @@ -import { - getClassJoinRequestRepository, - getClassRepository, - getTeacherRepository, -} from '../data/repositories.js'; +import { getClassJoinRequestRepository, getClassRepository, getTeacherRepository } from '../data/repositories.js'; import { mapToClassDTO } from '../interfaces/class.js'; import { mapToTeacher, mapToTeacherDTO } from '../interfaces/teacher.js'; import { Teacher } from '../entities/users/teacher.entity.js'; From 56e992f67cb5948511be078c2eb4ae68d3585552 Mon Sep 17 00:00:00 2001 From: Gabriellvl Date: Mon, 12 May 2025 23:16:52 +0200 Subject: [PATCH 49/54] fix: lint --- frontend/src/queries/teachers.ts | 4 ---- 1 file changed, 4 deletions(-) diff --git a/frontend/src/queries/teachers.ts b/frontend/src/queries/teachers.ts index fe2794cb..ed13f630 100644 --- a/frontend/src/queries/teachers.ts +++ b/frontend/src/queries/teachers.ts @@ -32,10 +32,6 @@ function teacherStudentsQueryKey(username: string, full: boolean): [string, stri return ["teacher-students", username, full]; } -function teacherQuestionsQueryKey(username: string, full: boolean): [string, string, boolean] { - return ["teacher-questions", username, full]; -} - export function teacherClassJoinRequests(classId: string): [string, string] { return ["teacher-class-join-requests", classId]; } From e227e8d59cdf995d22a8fbc298c76b146a7e18a4 Mon Sep 17 00:00:00 2001 From: Joyelle Ndagijimana Date: Tue, 13 May 2025 08:37:18 +0200 Subject: [PATCH 50/54] fix: comma in json files --- frontend/src/i18n/locale/de.json | 2 +- frontend/src/i18n/locale/en.json | 2 +- frontend/src/i18n/locale/fr.json | 2 +- frontend/src/i18n/locale/nl.json | 2 +- 4 files changed, 4 insertions(+), 4 deletions(-) diff --git a/frontend/src/i18n/locale/de.json b/frontend/src/i18n/locale/de.json index 301b2ff9..40a552f5 100644 --- a/frontend/src/i18n/locale/de.json +++ b/frontend/src/i18n/locale/de.json @@ -133,7 +133,7 @@ "see-submission": "Einsendung anzeigen", "view-submissions": "Einsendungen anzeigen", "valid-username": "Bitte geben Sie einen gültigen Benutzernamen ein", - "creationFailed": "Erstellung fehlgeschlagen, bitte versuchen Sie es erneut" + "creationFailed": "Erstellung fehlgeschlagen, bitte versuchen Sie es erneut", "no-assignments": "Derzeit gibt es keine Zuweisungen.", "deadline": "deadline" } diff --git a/frontend/src/i18n/locale/en.json b/frontend/src/i18n/locale/en.json index c98646c6..70ab65c1 100644 --- a/frontend/src/i18n/locale/en.json +++ b/frontend/src/i18n/locale/en.json @@ -133,7 +133,7 @@ "see-submission": "view submission", "view-submissions": "view submissions", "valid-username": "please enter a valid username", - "creationFailed": "creation failed, please try again" + "creationFailed": "creation failed, please try again", "no-assignments": "There are currently no assignments.", "deadline": "deadline" } diff --git a/frontend/src/i18n/locale/fr.json b/frontend/src/i18n/locale/fr.json index 50519675..e3ba87f7 100644 --- a/frontend/src/i18n/locale/fr.json +++ b/frontend/src/i18n/locale/fr.json @@ -134,7 +134,7 @@ "see-submission": "voir la soumission", "view-submissions": "voir les soumissions", "valid-username": "veuillez entrer un nom d'utilisateur valide", - "creationFailed": "échec de la création, veuillez réessayer" + "creationFailed": "échec de la création, veuillez réessayer", "no-assignments": "Il n'y a actuellement aucun travail.", "deadline": "délai" } diff --git a/frontend/src/i18n/locale/nl.json b/frontend/src/i18n/locale/nl.json index c69a01e3..18db9fba 100644 --- a/frontend/src/i18n/locale/nl.json +++ b/frontend/src/i18n/locale/nl.json @@ -133,7 +133,7 @@ "see-submission": "inzending bekijken", "view-submissions": "inzendingen bekijken", "valid-username": "voer een geldige gebruikersnaam in", - "creationFailed": "aanmaak mislukt, probeer het opnieuw" + "creationFailed": "aanmaak mislukt, probeer het opnieuw", "no-assignments": "Er zijn momenteel geen opdrachten.", "deadline": "deadline" } From 24c8a395d61043128d2642b34b4a31bfdb312ad1 Mon Sep 17 00:00:00 2001 From: Joyelle Ndagijimana Date: Tue, 13 May 2025 08:42:36 +0200 Subject: [PATCH 51/54] fix: kleine lijn in css weg --- frontend/src/views/assignments/UserAssignments.vue | 1 - 1 file changed, 1 deletion(-) diff --git a/frontend/src/views/assignments/UserAssignments.vue b/frontend/src/views/assignments/UserAssignments.vue index 2749ba52..1a097149 100644 --- a/frontend/src/views/assignments/UserAssignments.vue +++ b/frontend/src/views/assignments/UserAssignments.vue @@ -227,7 +227,6 @@ box-shadow 0.2s; } .assignment-card:hover { - transform: translateY(-2px); box-shadow: 0 6px 16px rgba(0, 0, 0, 0.12); } From db55a9bea42a2c489be9a3f5f9979998fcccde00 Mon Sep 17 00:00:00 2001 From: Joyelle Ndagijimana Date: Tue, 13 May 2025 09:09:46 +0200 Subject: [PATCH 52/54] fix: deadline nullable maken om errors te vermijden --- backend/src/entities/assignments/assignment.entity.ts | 2 +- frontend/src/views/assignments/UserAssignments.vue | 10 ++++------ 2 files changed, 5 insertions(+), 7 deletions(-) diff --git a/backend/src/entities/assignments/assignment.entity.ts b/backend/src/entities/assignments/assignment.entity.ts index 1bddd39d..88c3160f 100644 --- a/backend/src/entities/assignments/assignment.entity.ts +++ b/backend/src/entities/assignments/assignment.entity.ts @@ -26,7 +26,7 @@ export class Assignment { @Property({ type: 'string' }) learningPathHruid!: string; - @Property({ type: 'datetime' }) + @Property({ type: 'datetime', nullable: true }) deadline?: Date; @Enum({ diff --git a/frontend/src/views/assignments/UserAssignments.vue b/frontend/src/views/assignments/UserAssignments.vue index 1a097149..476ee197 100644 --- a/frontend/src/views/assignments/UserAssignments.vue +++ b/frontend/src/views/assignments/UserAssignments.vue @@ -109,15 +109,13 @@ function getDeadlineClass(deadline?: string | Date): string { if (!deadline) return ""; + const date = new Date(deadline); const now = new Date(); - const isToday = - date.getDate() === now.getDate() && - date.getMonth() === now.getMonth() && - date.getFullYear() === now.getFullYear(); + const in24Hours = new Date(now.getTime() + 24 * 60 * 60 * 1000); if (date.getTime() < now.getTime()) return "deadline-passed"; - if (isToday) return "deadline-today"; + if (date.getTime() <= in24Hours.getTime()) return "deadline-in24hours"; return "deadline-upcoming"; } @@ -259,7 +257,7 @@ font-weight: bold; } - .assignment-deadline.deadline-today { + .assignment-deadline.deadline-in24hours { color: #f57c00; font-weight: bold; } From 0d8a28b20318e554f57a5c2bea9e217e6619ef59 Mon Sep 17 00:00:00 2001 From: Gabriellvl Date: Tue, 13 May 2025 09:21:21 +0200 Subject: [PATCH 53/54] fix: error query --- backend/tests/controllers/assignments.test.ts | 4 ++++ backend/tests/controllers/groups.test.ts | 4 ++++ 2 files changed, 8 insertions(+) diff --git a/backend/tests/controllers/assignments.test.ts b/backend/tests/controllers/assignments.test.ts index 26f2869d..fa884595 100644 --- a/backend/tests/controllers/assignments.test.ts +++ b/backend/tests/controllers/assignments.test.ts @@ -10,6 +10,7 @@ function createRequestObject( classid: string, assignmentid: string ): { + query: {full: string}, params: { classid: string; id: string }; } { return { @@ -17,6 +18,9 @@ function createRequestObject( classid: classid, id: assignmentid, }, + query: { + full: 'true' + } }; } diff --git a/backend/tests/controllers/groups.test.ts b/backend/tests/controllers/groups.test.ts index 2cbe28f0..88b7dd7c 100644 --- a/backend/tests/controllers/groups.test.ts +++ b/backend/tests/controllers/groups.test.ts @@ -18,6 +18,7 @@ function createRequestObject( assignmentid: string, groupNumber: string ): { + query: { full: string } params: { classid: string; groupid: string; assignmentid: string }; } { return { @@ -26,6 +27,9 @@ function createRequestObject( assignmentid: assignmentid, groupid: groupNumber, }, + query: { + full: 'true' + } }; } From b3e83850ae367a5f9bfde5a72c9111a14f3c0449 Mon Sep 17 00:00:00 2001 From: Lint Action Date: Tue, 13 May 2025 07:22:24 +0000 Subject: [PATCH 54/54] style: fix linting issues met Prettier --- backend/tests/controllers/assignments.test.ts | 6 +++--- backend/tests/controllers/groups.test.ts | 6 +++--- 2 files changed, 6 insertions(+), 6 deletions(-) diff --git a/backend/tests/controllers/assignments.test.ts b/backend/tests/controllers/assignments.test.ts index fa884595..88cac366 100644 --- a/backend/tests/controllers/assignments.test.ts +++ b/backend/tests/controllers/assignments.test.ts @@ -10,7 +10,7 @@ function createRequestObject( classid: string, assignmentid: string ): { - query: {full: string}, + query: { full: string }; params: { classid: string; id: string }; } { return { @@ -19,8 +19,8 @@ function createRequestObject( id: assignmentid, }, query: { - full: 'true' - } + full: 'true', + }, }; } diff --git a/backend/tests/controllers/groups.test.ts b/backend/tests/controllers/groups.test.ts index 88b7dd7c..f9e35cea 100644 --- a/backend/tests/controllers/groups.test.ts +++ b/backend/tests/controllers/groups.test.ts @@ -18,7 +18,7 @@ function createRequestObject( assignmentid: string, groupNumber: string ): { - query: { full: string } + query: { full: string }; params: { classid: string; groupid: string; assignmentid: string }; } { return { @@ -28,8 +28,8 @@ function createRequestObject( groupid: groupNumber, }, query: { - full: 'true' - } + full: 'true', + }, }; }