diff --git a/backend/src/controllers/submissions.ts b/backend/src/controllers/submissions.ts index a117d7bf..012636ea 100644 --- a/backend/src/controllers/submissions.ts +++ b/backend/src/controllers/submissions.ts @@ -62,6 +62,11 @@ export async function getAllSubmissionsHandler(req: Request, res: Response): Pro // TODO: gerald moet nog dingen toevoegen aan de databank voor dat dit gefinaliseerd kan worden export async function createSubmissionHandler(req: Request, res: Response): Promise { + const submitter = req.body.submitter; + const usernameSubmitter = req.body.submitter.username; + const group = req.body.group; + requireFields({ group, submitter, usernameSubmitter }); + const submissionDTO = req.body as SubmissionDTO; const submission = await createSubmission(submissionDTO); 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/entities/assignments/assignment.entity.ts b/backend/src/entities/assignments/assignment.entity.ts index a12ffbac..88c3160f 100644 --- a/backend/src/entities/assignments/assignment.entity.ts +++ b/backend/src/entities/assignments/assignment.entity.ts @@ -26,6 +26,9 @@ export class Assignment { @Property({ type: 'string' }) learningPathHruid!: string; + @Property({ type: 'datetime', nullable: true }) + deadline?: Date; + @Enum({ items: () => Language, }) diff --git a/backend/src/interfaces/assignment.ts b/backend/src/interfaces/assignment.ts index 7c5a0909..2dc158d2 100644 --- a/backend/src/interfaces/assignment.ts +++ b/backend/src/interfaces/assignment.ts @@ -20,6 +20,7 @@ export function mapToAssignmentDTO(assignment: Assignment): AssignmentDTO { description: assignment.description, learningPath: assignment.learningPathHruid, language: assignment.learningPathLanguage, + deadline: assignment.deadline ?? new Date(), groups: assignment.groups.map((group) => mapToGroupDTO(group, assignment.within)), }; } @@ -31,6 +32,7 @@ export function mapToAssignment(assignmentData: AssignmentDTO, cls: Class): Assi description: assignmentData.description, learningPathHruid: assignmentData.learningPath, learningPathLanguage: languageMap[assignmentData.language], + deadline: assignmentData.deadline, groups: [], }); } 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/learning-paths/database-learning-path-provider.ts b/backend/src/services/learning-paths/database-learning-path-provider.ts index fe05dda1..eb980fa1 100644 --- a/backend/src/services/learning-paths/database-learning-path-provider.ts +++ b/backend/src/services/learning-paths/database-learning-path-provider.ts @@ -4,7 +4,7 @@ import { getLearningPathRepository } from '../../data/repositories.js'; import learningObjectService from '../learning-objects/learning-object-service.js'; import { LearningPathNode } from '../../entities/content/learning-path-node.entity.js'; import { LearningPathTransition } from '../../entities/content/learning-path-transition.entity.js'; -import { getLastSubmissionForGroup, isTransitionPossible } from './learning-path-personalization-util.js'; +import { getLastSubmissionForGroup, idFromLearningPathNode, isTransitionPossible } from './learning-path-personalization-util.js'; import { FilteredLearningObject, LearningObjectNode, @@ -95,7 +95,7 @@ async function convertNode( personalizedFor: Group | undefined, nodesToLearningObjects: Map ): Promise { - const lastSubmission = personalizedFor ? await getLastSubmissionForGroup(node, personalizedFor) : null; + const lastSubmission = personalizedFor ? await getLastSubmissionForGroup(idFromLearningPathNode(node), personalizedFor) : null; const transitions = node.transitions .filter( (trans) => diff --git a/backend/src/services/learning-paths/dwengo-api-learning-path-provider.ts b/backend/src/services/learning-paths/dwengo-api-learning-path-provider.ts index c59c616a..6f2548c0 100644 --- a/backend/src/services/learning-paths/dwengo-api-learning-path-provider.ts +++ b/backend/src/services/learning-paths/dwengo-api-learning-path-provider.ts @@ -3,11 +3,33 @@ import { DWENGO_API_BASE } from '../../config.js'; import { LearningPathProvider } from './learning-path-provider.js'; import { getLogger, Logger } from '../../logging/initalize.js'; import { LearningPath, LearningPathResponse } from '@dwengo-1/common/interfaces/learning-content'; +import { Group } from '../../entities/assignments/group.entity.js'; +import { getLastSubmissionForGroup, idFromLearningObjectNode } from './learning-path-personalization-util.js'; const logger: Logger = getLogger(); +/** + * Adds progress information to the learning path. Modifies the learning path in-place. + * @param learningPath The learning path to add progress to. + * @param personalizedFor The group whose progress should be shown. + * @returns the modified learning path. + */ +async function addProgressToLearningPath(learningPath: LearningPath, personalizedFor: Group): Promise { + await Promise.all( + learningPath.nodes.map(async (node) => { + const lastSubmission = personalizedFor ? await getLastSubmissionForGroup(idFromLearningObjectNode(node), personalizedFor) : null; + node.done = Boolean(lastSubmission); + }) + ); + + learningPath.num_nodes = learningPath.nodes.length; + learningPath.num_nodes_left = learningPath.nodes.filter((it) => !it.done).length; + + return learningPath; +} + const dwengoApiLearningPathProvider: LearningPathProvider = { - async fetchLearningPaths(hruids: string[], language: string, source: string): Promise { + async fetchLearningPaths(hruids: string[], language: string, source: string, personalizedFor: Group): Promise { if (hruids.length === 0) { return { success: false, @@ -32,17 +54,23 @@ const dwengoApiLearningPathProvider: LearningPathProvider = { }; } + await Promise.all(learningPaths?.map(async (it) => addProgressToLearningPath(it, personalizedFor))); + return { success: true, source, data: learningPaths, }; }, - async searchLearningPaths(query: string, language: string): Promise { + async searchLearningPaths(query: string, language: string, personalizedFor: Group): Promise { const apiUrl = `${DWENGO_API_BASE}/learningPath/search`; const params = { all: query, language }; const searchResults = await fetchRemote(apiUrl, `Search learning paths with query "${query}"`, { params }); + + if (searchResults) { + await Promise.all(searchResults?.map(async (it) => addProgressToLearningPath(it, personalizedFor))); + } return searchResults ?? []; }, }; diff --git a/backend/src/services/learning-paths/learning-path-personalization-util.ts b/backend/src/services/learning-paths/learning-path-personalization-util.ts index a10d5ead..7651baa3 100644 --- a/backend/src/services/learning-paths/learning-path-personalization-util.ts +++ b/backend/src/services/learning-paths/learning-path-personalization-util.ts @@ -5,18 +5,36 @@ import { getSubmissionRepository } from '../../data/repositories.js'; import { LearningObjectIdentifier } from '../../entities/content/learning-object-identifier.js'; import { LearningPathTransition } from '../../entities/content/learning-path-transition.entity.js'; import { JSONPath } from 'jsonpath-plus'; +import { LearningObjectNode } from '@dwengo-1/common/interfaces/learning-content'; /** * Returns the last submission for the learning object associated with the given node and for the group */ -export async function getLastSubmissionForGroup(node: LearningPathNode, pathFor: Group): Promise { +export async function getLastSubmissionForGroup(learningObjectId: LearningObjectIdentifier, pathFor: Group): Promise { const submissionRepo = getSubmissionRepository(); - const learningObjectId: LearningObjectIdentifier = { + return await submissionRepo.findMostRecentSubmissionForGroup(learningObjectId, pathFor); +} + +/** + * Creates a LearningObjectIdentifier describing the specified node. + */ +export function idFromLearningObjectNode(node: LearningObjectNode): LearningObjectIdentifier { + return { + hruid: node.learningobject_hruid, + language: node.language, + version: node.version, + }; +} + +/** + * Creates a LearningObjectIdentifier describing the specified node. + */ +export function idFromLearningPathNode(node: LearningPathNode): LearningObjectIdentifier { + return { hruid: node.learningObjectHruid, language: node.language, version: node.version, }; - return await submissionRepo.findMostRecentSubmissionForGroup(learningObjectId, pathFor); } /** diff --git a/backend/src/services/students.ts b/backend/src/services/students.ts index 77ec6648..809b23e4 100644 --- a/backend/src/services/students.ts +++ b/backend/src/services/students.ts @@ -42,7 +42,7 @@ export async function fetchStudent(username: string): Promise { const user = await studentRepository.findByUsername(username); if (!user) { - throw new NotFoundException('Student with username not found'); + throw new NotFoundException(`Student with username ${username} not found`); } return user; diff --git a/backend/src/services/teachers.ts b/backend/src/services/teachers.ts index 4fdb15be..2666be8c 100644 --- a/backend/src/services/teachers.ts +++ b/backend/src/services/teachers.ts @@ -1,12 +1,5 @@ -import { - getClassJoinRequestRepository, - getClassRepository, - getLearningObjectRepository, - getQuestionRepository, - getTeacherRepository, -} from '../data/repositories.js'; +import { getClassJoinRequestRepository, getClassRepository, 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 +8,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 +15,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 +107,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/backend/tests/controllers/assignments.test.ts b/backend/tests/controllers/assignments.test.ts new file mode 100644 index 00000000..88cac366 --- /dev/null +++ b/backend/tests/controllers/assignments.test.ts @@ -0,0 +1,76 @@ +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 { NotFoundException } from '../../src/exceptions/not-found-exception'; +import { getClass01 } from '../test_assets/classes/classes.testdata'; +import { getAssignment01 } from '../test_assets/assignments/assignments.testdata'; + +function createRequestObject( + classid: string, + assignmentid: string +): { + query: { full: string }; + params: { classid: string; id: string }; +} { + return { + params: { + classid: classid, + id: assignmentid, + }, + query: { + full: 'true', + }, + }; +} + +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('return error non-existing assignment', async () => { + req = createRequestObject('doesnotexist', '43000'); // Should not exist + + await expect(async () => getAssignmentHandler(req as Request, res as Response)).rejects.toThrow(NotFoundException); + }); + + it('should return an assignment', async () => { + const assignment = getAssignment01(); + req = createRequestObject(assignment.within.classId as string, (assignment.id ?? 1).toString()); + + await getAssignmentHandler(req as Request, res as Response); + expect(jsonMock).toHaveBeenCalledWith(expect.objectContaining({ assignment: expect.anything() })); + }); + + it('should return a list of assignments', async () => { + req = createRequestObject(getClass01().classId as string, 'irrelevant'); + + await getAllAssignmentsHandler(req as Request, res as Response); + expect(jsonMock).toHaveBeenCalledWith(expect.objectContaining({ assignments: expect.anything() })); + }); + + it('should return a list of submissions for an assignment', async () => { + const assignment = getAssignment01(); + req = createRequestObject(assignment.within.classId as string, (assignment.id ?? 1).toString()); + + await getAssignmentsSubmissionsHandler(req as Request, res as Response); + expect(jsonMock).toHaveBeenCalledWith(expect.objectContaining({ submissions: expect.anything() })); + }); +}); diff --git a/backend/tests/controllers/classes.test.ts b/backend/tests/controllers/classes.test.ts index ab941773..d9614a3b 100644 --- a/backend/tests/controllers/classes.test.ts +++ b/backend/tests/controllers/classes.test.ts @@ -1,8 +1,17 @@ import { setupTestApp } from '../setup-tests.js'; import { describe, it, expect, beforeAll, beforeEach, vi, Mock } from 'vitest'; +import { + createClassHandler, + deleteClassHandler, + getAllClassesHandler, + getClassHandler, + getClassStudentsHandler, + getTeacherInvitationsHandler, +} from '../../src/controllers/classes.js'; import { Request, Response } from 'express'; -import { createClassHandler, deleteClassHandler } from '../../src/controllers/classes'; - +import { NotFoundException } from '../../src/exceptions/not-found-exception'; +import { BadRequestException } from '../../src/exceptions/bad-request-exception'; +import { getClass01 } from '../test_assets/classes/classes.testdata'; describe('Class controllers', () => { let req: Partial; let res: Partial; @@ -44,4 +53,71 @@ describe('Class controllers', () => { expect(jsonMock).toHaveBeenCalledWith(expect.objectContaining({ class: expect.anything() })); }); + + it('Error class not found', async () => { + req = { + params: { id: 'doesnotexist' }, + }; + + await expect(async () => getClassHandler(req as Request, res as Response)).rejects.toThrow(NotFoundException); + }); + + it('Error create a class without name', async () => { + req = { + body: {}, + }; + + await expect(async () => createClassHandler(req as Request, res as Response)).rejects.toThrow(BadRequestException); + }); + + it('return list of students', async () => { + req = { + params: { id: getClass01().classId as string }, + query: {}, + }; + + await getClassStudentsHandler(req as Request, res as Response); + + expect(jsonMock).toHaveBeenCalledWith(expect.objectContaining({ students: expect.anything() })); + }); + + it('Error students on a non-existent class', async () => { + req = { + params: { id: 'doesnotexist' }, + query: {}, + }; + + await expect(async () => getClassStudentsHandler(req as Request, res as Response)).rejects.toThrow(NotFoundException); + }); + + it('should return 200 and a list of teacher-invitations', async () => { + const classId = getClass01().classId as string; + req = { + params: { id: classId }, + query: {}, + }; + + await getTeacherInvitationsHandler(req as Request, res as Response); + + expect(jsonMock).toHaveBeenCalledWith(expect.objectContaining({ invitations: expect.anything() })); + }); + + it('Error teacher-invitations on a non-existent class', async () => { + req = { + params: { id: 'doesnotexist' }, + query: {}, + }; + + await expect(async () => getTeacherInvitationsHandler(req as Request, res as Response)).rejects.toThrow(NotFoundException); + }); + + it('should return a list of classes', async () => { + req = { + query: {}, + }; + + await getAllClassesHandler(req as Request, res as Response); + + expect(jsonMock).toHaveBeenCalledWith(expect.objectContaining({ classes: expect.anything() })); + }); }); diff --git a/backend/tests/controllers/groups.test.ts b/backend/tests/controllers/groups.test.ts new file mode 100644 index 00000000..f9e35cea --- /dev/null +++ b/backend/tests/controllers/groups.test.ts @@ -0,0 +1,140 @@ +import { setupTestApp } from '../setup-tests.js'; +import { describe, it, expect, beforeAll, beforeEach, vi, Mock } from 'vitest'; +import { Request, Response } from 'express'; +import { + createGroupHandler, + deleteGroupHandler, + getAllGroupsHandler, + getGroupHandler, + getGroupSubmissionsHandler, +} from '../../src/controllers/groups.js'; +import { NotFoundException } from '../../src/exceptions/not-found-exception'; +import { getClass01 } from '../test_assets/classes/classes.testdata'; +import { getAssignment01, getAssignment02 } from '../test_assets/assignments/assignments.testdata'; +import { getTestGroup01 } from '../test_assets/assignments/groups.testdata'; + +function createRequestObject( + classid: string, + assignmentid: string, + groupNumber: string +): { + query: { full: string }; + params: { classid: string; groupid: string; assignmentid: string }; +} { + return { + params: { + classid: classid, + assignmentid: assignmentid, + groupid: groupNumber, + }, + query: { + full: 'true', + }, + }; +} + +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('Error not found on a non-existing group', async () => { + req = { + params: { + classid: 'id01', + assignmentid: '1', + groupid: '154981', // Should not exist + }, + query: {}, + }; + + await expect(async () => getGroupHandler(req as Request, res as Response)).rejects.toThrow(NotFoundException); + }); + + 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 expect(async () => getGroupHandler(req as Request, res as Response)).rejects.toThrow(NotFoundException); + }); + + 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 expect(async () => getGroupHandler(req as Request, res as Response)).rejects.toThrow(NotFoundException); + }); + + it('should return an existing group', async () => { + const group = getTestGroup01(); + const classId = getClass01().classId as string; + req = createRequestObject(classId, (group.assignment.id ?? 1).toString(), (group.groupNumber ?? 1).toString()); + + await getGroupHandler(req as Request, res as Response); + + expect(jsonMock).toHaveBeenCalledWith(expect.objectContaining({ group: expect.anything() })); + }); + + it('Create and delete', async () => { + const assignment = getAssignment02(); + const classId = assignment.within.classId as string; + req = createRequestObject(classId, (assignment.id ?? 1).toString(), '1'); + req.body = { + members: ['Noordkaap', 'DireStraits'], + }; + + await createGroupHandler(req as Request, res as Response); + + await deleteGroupHandler(req as Request, res as Response); + + expect(jsonMock).toHaveBeenCalledWith(expect.objectContaining({ group: expect.anything() })); + }); + + it('should return the submissions for a group', async () => { + const group = getTestGroup01(); + const classId = getClass01().classId as string; + req = createRequestObject(classId, (group.assignment.id ?? 1).toString(), (group.groupNumber ?? 1).toString()); + + await getGroupSubmissionsHandler(req as Request, res as Response); + + expect(jsonMock).toHaveBeenCalledWith(expect.objectContaining({ submissions: expect.anything() })); + }); + + it('should return a list of groups for an assignment', async () => { + const assignment = getAssignment01(); + const classId = assignment.within.classId as string; + req = createRequestObject(classId, (assignment.id ?? 1).toString(), '1'); + + await getAllGroupsHandler(req as Request, res as Response); + + expect(jsonMock).toHaveBeenCalledWith(expect.objectContaining({ groups: expect.anything() })); + }); +}); diff --git a/backend/tests/controllers/submissions.test.ts b/backend/tests/controllers/submissions.test.ts new file mode 100644 index 00000000..942b51f8 --- /dev/null +++ b/backend/tests/controllers/submissions.test.ts @@ -0,0 +1,61 @@ +import { setupTestApp } from '../setup-tests.js'; +import { describe, it, expect, beforeAll, beforeEach, vi, Mock } from 'vitest'; +import { getSubmissionHandler, getAllSubmissionsHandler } from '../../src/controllers/submissions.js'; +import { Request, Response } from 'express'; +import { NotFoundException } from '../../src/exceptions/not-found-exception'; +import { getClass02 } from '../test_assets/classes/classes.testdata'; + +function createRequestObject( + hruid: string, + submissionNumber: string +): { + query: { language: string; version: string }; + params: { hruid: string; id: string }; +} { + return { + params: { + hruid: hruid, + id: submissionNumber, + }, + query: { + language: 'en', + 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('error submission is not found', async () => { + req = createRequestObject('id01', '1000000'); + + await expect(async () => getSubmissionHandler(req as Request, res as Response)).rejects.toThrow(NotFoundException); + }); + + it('should return a list of submissions for a learning object', async () => { + req = createRequestObject(getClass02().classId as string, 'irrelevant'); + + await getAllSubmissionsHandler(req as Request, res as Response); + + expect(jsonMock).toHaveBeenCalledWith(expect.objectContaining({ submissions: expect.anything() })); + }); +}); diff --git a/backend/tests/test_assets/assignments/assignments.testdata.ts b/backend/tests/test_assets/assignments/assignments.testdata.ts index 337ec98f..dc477828 100644 --- a/backend/tests/test_assets/assignments/assignments.testdata.ts +++ b/backend/tests/test_assets/assignments/assignments.testdata.ts @@ -6,13 +6,20 @@ import { testLearningPathWithConditions } from '../content/learning-paths.testda import { getClassWithTestleerlingAndTestleerkracht } from '../classes/classes.testdata'; 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], title: 'dire straits', description: 'reading', - learningPathHruid: 'id02', + learningPathHruid: 'un_ai', learningPathLanguage: Language.English, + deadline: today, groups: [], }); @@ -23,6 +30,7 @@ export function makeTestAssignemnts(em: EntityManager, classes: Class[]): Assign description: 'reading', learningPathHruid: 'id01', learningPathLanguage: Language.English, + deadline: futureDate, groups: [], }); @@ -33,6 +41,7 @@ export function makeTestAssignemnts(em: EntityManager, classes: Class[]): Assign description: 'will be deleted', learningPathHruid: 'id02', learningPathLanguage: Language.English, + deadline: pastDate, groups: [], }); @@ -43,6 +52,7 @@ export function makeTestAssignemnts(em: EntityManager, classes: Class[]): Assign description: 'with a description', learningPathHruid: 'id01', learningPathLanguage: Language.English, + deadline: pastDate, groups: [], }); @@ -53,6 +63,7 @@ export function makeTestAssignemnts(em: EntityManager, classes: Class[]): Assign description: 'You have to do the testing learning path with a condition.', learningPathHruid: testLearningPathWithConditions.hruid, learningPathLanguage: testLearningPathWithConditions.language as Language, + deadline: futureDate, groups: [], }); diff --git a/common/src/interfaces/assignment.ts b/common/src/interfaces/assignment.ts index fb7dfbf0..677221f1 100644 --- a/common/src/interfaces/assignment.ts +++ b/common/src/interfaces/assignment.ts @@ -7,6 +7,7 @@ export interface AssignmentDTO { description: string; learningPath: string; language: string; + deadline: Date; groups: GroupDTO[] | string[][]; } diff --git a/frontend/src/assets/common.css b/frontend/src/assets/common.css new file mode 100644 index 00000000..bcc5d39f --- /dev/null +++ b/frontend/src/assets/common.css @@ -0,0 +1,54 @@ +.h1 { + color: #0e6942; + text-transform: uppercase; + font-weight: bolder; + font-size: 50px; + padding-left: 1%; +} + +.empty-message { + text-align: center; + font-size: 18px; +} + +.header { + font-weight: bold !important; + background-color: #0e6942; + color: white; + padding: 10px; +} + +.table thead th:first-child { + border-top-left-radius: 10px; +} + +.table thead th:last-child { + border-top-right-radius: 10px; +} + +.table tbody tr:nth-child(odd) { + background-color: white; +} + +.table tbody tr:nth-child(even) { + background-color: #f6faf2; +} + +.table td, +.table th { + border-bottom: 1px solid #0e6942; + border-top: 1px solid #0e6942; +} + +.table { + width: 90%; + padding-top: 10px; + border-collapse: collapse; +} + +@media screen and (max-width: 850px) { + .h1 { + text-align: center; + padding-left: 0; + } +} 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 @@ + + + - - - - + diff --git a/frontend/src/components/assignments/DeadlineSelector.vue b/frontend/src/components/assignments/DeadlineSelector.vue index 9295eec0..304c544c 100644 --- a/frontend/src/components/assignments/DeadlineSelector.vue +++ b/frontend/src/components/assignments/DeadlineSelector.vue @@ -1,49 +1,30 @@ - - diff --git a/frontend/src/controllers/learning-paths.ts b/frontend/src/controllers/learning-paths.ts index bad54286..09a30feb 100644 --- a/frontend/src/controllers/learning-paths.ts +++ b/frontend/src/controllers/learning-paths.ts @@ -26,8 +26,8 @@ export class LearningPathController extends BaseController { }); return LearningPath.fromDTO(single(dtos)); } - async getAllByTheme(theme: string): Promise { - const dtos = await this.get("/", { theme }); + async getAllByThemeAndLanguage(theme: string, language: Language): Promise { + const dtos = await this.get("/", { theme, language }); return dtos.map((dto) => LearningPath.fromDTO(dto)); } 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/i18n/locale/de.json b/frontend/src/i18n/locale/de.json index fbdc652a..40a552f5 100644 --- a/frontend/src/i18n/locale/de.json +++ b/frontend/src/i18n/locale/de.json @@ -21,6 +21,7 @@ "JoinClassExplanation": "Geben Sie den Code ein, den Ihnen die Lehrkraft mitgeteilt hat, um der Klasse beizutreten.", "invalidFormat": "Ungültiges Format", "submitCode": "senden", + "submit": "senden", "members": "Mitglieder", "themes": "Themen", "choose-theme": "Wählen Sie ein Thema", @@ -68,10 +69,10 @@ "pick-class": "Wählen Sie eine klasse", "choose-students": "Studenten auswählen", "create-group": "Gruppe erstellen", - "class": "klasse", + "class": "Klasse", "delete": "löschen", "view-assignment": "Auftrag anzeigen", - "code": "code", + "code": "Code", "invitations": "Einladungen", "createClass": "Klasse erstellen", "createClassInstructions": "Geben Sie einen Namen für Ihre Klasse ein und klicken Sie auf „Erstellen“. Es erscheint ein Fenster mit einem Code, den Sie kopieren können. Geben Sie diesen Code an Ihre Schüler weiter und sie können Ihrer Klasse beitreten.", @@ -83,7 +84,7 @@ "onlyUse": "nur Buchstaben, Zahlen, Bindestriche (-) und Unterstriche (_) verwenden", "close": "schließen", "copied": "kopiert!", - "accept": "akzeptieren", + "accept": "Akzeptieren", "deny": "ablehnen", "sent": "sent", "failed": "fehlgeschlagen", @@ -110,7 +111,7 @@ "remove": "entfernen", "students": "Studenten", "classJoinRequests": "Beitrittsanfragen", - "reject": "ablehnen", + "reject": "Ablehnen", "areusure": "Sind Sie sicher?", "yes": "ja", "teachers": "Lehrer", @@ -121,5 +122,18 @@ "invite": "einladen", "assignmentIndicator": "AUFGABE", "searchAllLearningPathsTitle": "Alle Lernpfade durchsuchen", - "searchAllLearningPathsDescription": "Nicht gefunden, was Sie gesucht haben? Klicken Sie hier, um unsere gesamte Lernpfad-Datenbank zu durchsuchen." + "searchAllLearningPathsDescription": "Nicht gefunden, was Sie gesucht haben? Klicken Sie hier, um unsere gesamte Lernpfad-Datenbank zu durchsuchen.", + "no-students-found": "Diese Klasse hat keine Schüler.", + "no-invitations-found": "Sie haben keine ausstehenden Einladungen.", + "no-join-requests-found": "Es gibt keine ausstehenden Beitrittsanfragen für diese Klasse.", + "no-classes-found": "Sie sind noch keinem Kurs beigetreten.", + "classCreated": "Klasse erstellt!", + "success": "Erfolg", + "submitted": "eingereicht", + "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", + "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 e4042d09..70ab65c1 100644 --- a/frontend/src/i18n/locale/en.json +++ b/frontend/src/i18n/locale/en.json @@ -33,6 +33,7 @@ "JoinClassExplanation": "Enter the code the teacher has given you to join the class.", "invalidFormat": "Invalid format.", "submitCode": "submit", + "submit": "submit", "members": "Members", "themes": "Themes", "choose-theme": "Select a theme", @@ -68,21 +69,21 @@ "pick-class": "Pick a class", "choose-students": "Select students", "create-group": "Create group", - "class": "class", + "class": "Class", "delete": "delete", "view-assignment": "View assignment", - "code": "code", - "invitations": "invitations", - "createClass": "create class", + "code": "Code", + "invitations": "Invitations", + "createClass": "Create class", "classname": "classname", "EnterNameOfClass": "Enter a classname.", "create": "create", - "sender": "sender", + "sender": "Sender", "nameIsMandatory": "classname is mandatory", "onlyUse": "only use letters, numbers, dashes (-) and underscores (_)", "close": "close", "copied": "copied!", - "accept": "accept", + "accept": "Accept", "deny": "deny", "createClassInstructions": "Enter a name for your class and click on create. A window will appear with a code that you can copy. Give this code to your students and they will be able to join.", "sent": "sent", @@ -108,12 +109,12 @@ "progress": "Progress", "created": "created", "remove": "remove", - "students": "students", - "classJoinRequests": "join requests", - "reject": "reject", + "students": "Students", + "classJoinRequests": "Join requests", + "reject": "Reject", "areusure": "Are you sure?", "yes": "yes", - "teachers": "teachers", + "teachers": "Teachers", "accepted": "accepted", "rejected": "rejected", "enterUsername": "enter the username of the teacher you would like to invite", @@ -121,5 +122,18 @@ "invite": "invite", "assignmentIndicator": "ASSIGNMENT", "searchAllLearningPathsTitle": "Search all learning paths", - "searchAllLearningPathsDescription": "You didn't find what you were looking for? Click here to search our whole database of available learning paths." + "searchAllLearningPathsDescription": "You didn't find what you were looking for? Click here to search our whole database of available learning paths.", + "no-students-found": "This class has no students.", + "no-invitations-found": "You have no pending invitations.", + "no-join-requests-found": "There are no pending join requests for this class.", + "no-classes-found": "You are not yet part of a class.", + "classCreated": "class created!", + "success": "success", + "submitted": "submitted", + "see-submission": "view submission", + "view-submissions": "view submissions", + "valid-username": "please enter a valid username", + "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 b331a168..e3ba87f7 100644 --- a/frontend/src/i18n/locale/fr.json +++ b/frontend/src/i18n/locale/fr.json @@ -33,6 +33,7 @@ "JoinClassExplanation": "Entrez le code que l'enseignant vous a donné pour rejoindre la classe.", "invalidFormat": "Format non valide.", "submitCode": "envoyer", + "submit": "envoyer", "members": "Membres", "themes": "Thèmes", "choose-theme": "Choisis un thème", @@ -68,22 +69,22 @@ "pick-class": "Choisissez une classe", "choose-students": "Sélectionnez des élèves", "create-group": "Créer un groupe", - "class": "classe", + "class": "Classe", "delete": "supprimer", "view-assignment": "Voir le travail", - "code": "code", - "invitations": "invitations", - "createClass": "créer une classe", + "code": "Code", + "invitations": "Invitations", + "createClass": "Créer une classe", "createClassInstructions": "Entrez un nom pour votre classe et cliquez sur créer. Une fenêtre apparaît avec un code que vous pouvez copier. Donnez ce code à vos élèves et ils pourront rejoindre votre classe.", "classname": "nom de classe", "EnterNameOfClass": "saisir un nom de classe.", "create": "créer", - "sender": "expéditeur", + "sender": "Expéditeur", "nameIsMandatory": "le nom de classe est obligatoire", "onlyUse": "n'utiliser que des lettres, des chiffres, des tirets (-) et des traits de soulignement (_)", "close": "fermer", "copied": "copié!", - "accept": "accepter", + "accept": "Accepter", "deny": "refuser", "sent": "envoyé", "failed": "échoué", @@ -108,12 +109,13 @@ "submission": "Soumission", "progress": "Progrès", "remove": "supprimer", - "students": "étudiants", - "classJoinRequests": "demandes d'adhésion", - "reject": "rejeter", + "students": "Étudiants", + + "classJoinRequests": "Demandes d'adhésion", + "reject": "Rejeter", "areusure": "Êtes-vous sûr?", "yes": "oui", - "teachers": "enseignants", + "teachers": "Enseignants", "accepted": "acceptée", "rejected": "rejetée", "enterUsername": "entrez le nom d'utilisateur de l'enseignant que vous souhaitez inviter", @@ -121,5 +123,18 @@ "invite": "inviter", "assignmentIndicator": "DEVOIR", "searchAllLearningPathsTitle": "Rechercher tous les parcours d'apprentissage", - "searchAllLearningPathsDescription": "Vous n'avez pas trouvé ce que vous cherchiez ? Cliquez ici pour rechercher dans toute notre base de données de parcours d'apprentissage disponibles." + "searchAllLearningPathsDescription": "Vous n'avez pas trouvé ce que vous cherchiez ? Cliquez ici pour rechercher dans toute notre base de données de parcours d'apprentissage disponibles.", + "no-students-found": "Cette classe n'a pas d'élèves.", + "no-invitations-found": "Vous n'avez aucune invitation en attente.", + "no-join-requests-found": "Il n'y a aucune demande d'adhésion en attente pour cette classe.", + "no-classes-found": "Vous ne faites pas encore partie d'une classe.", + "classCreated": "Classe créée !", + "success": "succès", + "submitted": "soumis", + "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", + "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 5aa17930..18db9fba 100644 --- a/frontend/src/i18n/locale/nl.json +++ b/frontend/src/i18n/locale/nl.json @@ -33,6 +33,7 @@ "JoinClassExplanation": "Voer de code in die je van de docent hebt gekregen om lid te worden van de klas.", "invalidFormat": "Ongeldig formaat.", "submitCode": "verzenden", + "submit": "verzenden", "members": "Leden", "themes": "Lesthema's", "choose-theme": "Kies een thema", @@ -68,22 +69,22 @@ "pick-class": "Kies een klas", "choose-students": "Studenten selecteren", "create-group": "Groep aanmaken", - "class": "klas", + "class": "Klas", "delete": "verwijderen", "view-assignment": "Opdracht bekijken", - "code": "code", - "invitations": "uitnodigingen", - "createClass": "klas aanmaken", + "code": "Code", + "invitations": "Uitnodigingen", + "createClass": "Klas aanmaken", "createClassInstructions": "Voer een naam in voor je klas en klik op create. Er verschijnt een venster met een code die je kunt kopiëren. Geef deze code aan je leerlingen en ze kunnen deelnemen aan je klas.", "classname": "klasnaam", "EnterNameOfClass": "Geef een klasnaam op.", "create": "aanmaken", - "sender": "afzender", + "sender": "Afzender", "nameIsMandatory": "klasnaam is verplicht", "onlyUse": "gebruik enkel letters, cijfers, dashes (-) en underscores (_)", "close": "sluiten", "copied": "gekopieerd!", - "accept": "accepteren", + "accept": "Accepteren", "deny": "weigeren", "sent": "verzonden", "failed": "mislukt", @@ -108,12 +109,12 @@ "submission": "Indiening", "progress": "Vooruitgang", "remove": "verwijder", - "students": "studenten", - "classJoinRequests": "deelname verzoeken", - "reject": "weiger", + "students": "Studenten", + "classJoinRequests": "Deelname verzoeken", + "reject": "Weiger", "areusure": "Bent u zeker?", "yes": "ja", - "teachers": "leerkrachten", + "teachers": "Leerkrachten", "accepted": "geaccepteerd", "rejected": "geweigerd", "enterUsername": "vul de gebruikersnaam van de leerkracht die je wilt uitnodigen in", @@ -121,5 +122,18 @@ "invite": "uitnodigen", "assignmentIndicator": "OPDRACHT", "searchAllLearningPathsTitle": "Alle leerpaden doorzoeken", - "searchAllLearningPathsDescription": "Niet gevonden waar je naar op zoek was? Klik hier om onze volledige databank van beschikbare leerpaden te doorzoeken." + "searchAllLearningPathsDescription": "Niet gevonden waar je naar op zoek was? Klik hier om onze volledige databank van beschikbare leerpaden te doorzoeken.", + "no-students-found": "Deze klas heeft geen leerlingen.", + "no-invitations-found": "U heeft geen openstaande uitnodigingen.", + "no-join-requests-found": "Er zijn geen openstaande verzoeken om lid te worden van deze klas.", + "no-classes-found": "U maakt nog geen deel uit van een klas.", + "classCreated": "Klas aangemaakt!", + "success": "succes", + "submitted": "ingediend", + "see-submission": "inzending bekijken", + "view-submissions": "inzendingen bekijken", + "valid-username": "voer een geldige gebruikersnaam in", + "creationFailed": "aanmaak mislukt, probeer het opnieuw", + "no-assignments": "Er zijn momenteel geen opdrachten.", + "deadline": "deadline" } diff --git a/frontend/src/queries/learning-paths.ts b/frontend/src/queries/learning-paths.ts index 1f088c9d..6cccc37c 100644 --- a/frontend/src/queries/learning-paths.ts +++ b/frontend/src/queries/learning-paths.ts @@ -22,12 +22,13 @@ export function useGetLearningPathQuery( }); } -export function useGetAllLearningPathsByThemeQuery( +export function useGetAllLearningPathsByThemeAndLanguageQuery( theme: MaybeRefOrGetter, + language: MaybeRefOrGetter, ): UseQueryReturnType { return useQuery({ - queryKey: [LEARNING_PATH_KEY, "getAllByTheme", theme], - queryFn: async () => learningPathController.getAllByTheme(toValue(theme)), + queryKey: [LEARNING_PATH_KEY, "getAllByTheme", theme, language], + queryFn: async () => learningPathController.getAllByThemeAndLanguage(toValue(theme), toValue(language)), enabled: () => Boolean(toValue(theme)), }); } diff --git a/frontend/src/queries/teachers.ts b/frontend/src/queries/teachers.ts index 59da84f4..ed13f630 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"; @@ -33,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]; } @@ -80,17 +75,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, diff --git a/frontend/src/views/HomePage.vue b/frontend/src/views/HomePage.vue index 9b2c8acc..c0dcffaf 100644 --- a/frontend/src/views/HomePage.vue +++ b/frontend/src/views/HomePage.vue @@ -28,7 +28,7 @@ alt="Dwengo logo" style="align-self: center" /> -

{{ t("homeTitle") }}

+

{{ t("homeTitle") }}

{{ t("homeIntroduction1") }}

diff --git a/frontend/src/views/SingleTheme.vue b/frontend/src/views/SingleTheme.vue index 6924cc1c..c858ac26 100644 --- a/frontend/src/views/SingleTheme.vue +++ b/frontend/src/views/SingleTheme.vue @@ -2,10 +2,11 @@ import type { LearningPath } from "@/data-objects/learning-paths/learning-path.ts"; import LearningPathsGrid from "@/components/LearningPathsGrid.vue"; import UsingQueryResult from "@/components/UsingQueryResult.vue"; - import { useGetAllLearningPathsByThemeQuery } from "@/queries/learning-paths.ts"; + import { useGetAllLearningPathsByThemeAndLanguageQuery } from "@/queries/learning-paths.ts"; import { computed, ref } from "vue"; import { useI18n } from "vue-i18n"; import { useThemeQuery } from "@/queries/themes.ts"; + import type { Language } from "@/data-objects/language"; const props = defineProps<{ theme: string }>(); @@ -16,7 +17,10 @@ const currentThemeInfo = computed(() => themeQueryResult.data.value?.find((it) => it.key === props.theme)); - const learningPathsForThemeQueryResult = useGetAllLearningPathsByThemeQuery(() => props.theme); + const learningPathsForThemeQueryResult = useGetAllLearningPathsByThemeAndLanguageQuery( + () => props.theme, + () => locale.value as Language, + ); const { t } = useI18n(); const searchFilter = ref(""); diff --git a/frontend/src/views/assignments/CreateAssignment.vue b/frontend/src/views/assignments/CreateAssignment.vue index 32cda330..50dad4d1 100644 --- a/frontend/src/views/assignments/CreateAssignment.vue +++ b/frontend/src/views/assignments/CreateAssignment.vue @@ -48,7 +48,7 @@ // Disable combobox when learningPath prop is passed const lpIsSelected = route.query.hruid !== undefined; - const deadline = ref(null); + const deadline = ref(new Date()); const description = ref(""); const groups = ref([]); @@ -86,6 +86,7 @@ title: assignmentTitle.value, description: description.value, learningPath: lp || "", + deadline: deadline.value, language: language.value, groups: groups.value, }; @@ -96,7 +97,7 @@ diff --git a/frontend/tests/controllers/learning-paths-controller.test.ts b/frontend/tests/controllers/learning-paths-controller.test.ts index 28e4cda2..c987c3a4 100644 --- a/frontend/tests/controllers/learning-paths-controller.test.ts +++ b/frontend/tests/controllers/learning-paths-controller.test.ts @@ -15,7 +15,7 @@ describe("Test controller learning paths", () => { }); it("Can get learning path by id", async () => { - const data = await controller.getAllByTheme("kiks"); + const data = await controller.getAllByThemeAndLanguage("kiks", Language.Dutch); expect(data).to.have.length.greaterThan(0); }); }); diff --git a/package-lock.json b/package-lock.json index 9ebd6fe4..1fc51f80 100644 --- a/package-lock.json +++ b/package-lock.json @@ -1902,15 +1902,15 @@ } }, "node_modules/@modelcontextprotocol/sdk": { - "version": "1.11.2", - "resolved": "https://registry.npmjs.org/@modelcontextprotocol/sdk/-/sdk-1.11.2.tgz", - "integrity": "sha512-H9vwztj5OAqHg9GockCQC06k1natgcxWQSRpQcPJf6i5+MWBzfKkRtxGbjQf0X2ihii0ffLZCRGbYV2f2bjNCQ==", + "version": "1.11.3", + "resolved": "https://registry.npmjs.org/@modelcontextprotocol/sdk/-/sdk-1.11.3.tgz", + "integrity": "sha512-rmOWVRUbUJD7iSvJugjUbFZshTAuJ48MXoZ80Osx1GM0K/H1w7rSEvmw8m6vdWxNASgtaHIhAgre4H/E9GJiYQ==", "dev": true, "license": "MIT", "dependencies": { "content-type": "^1.0.5", "cors": "^2.8.5", - "cross-spawn": "^7.0.3", + "cross-spawn": "^7.0.5", "eventsource": "^3.0.2", "express": "^5.0.1", "express-rate-limit": "^7.5.0", @@ -3465,16 +3465,16 @@ } }, "node_modules/@vue/compiler-core": { - "version": "3.5.13", - "resolved": "https://registry.npmjs.org/@vue/compiler-core/-/compiler-core-3.5.13.tgz", - "integrity": "sha512-oOdAkwqUfW1WqpwSYJce06wvt6HljgY3fGeM9NcVA1HaYOij3mZG9Rkysn0OHuyUAGMbEbARIpsG+LPVlBJ5/Q==", + "version": "3.5.14", + "resolved": "https://registry.npmjs.org/@vue/compiler-core/-/compiler-core-3.5.14.tgz", + "integrity": "sha512-k7qMHMbKvoCXIxPhquKQVw3Twid3Kg4s7+oYURxLGRd56LiuHJVrvFKI4fm2AM3c8apqODPfVJGoh8nePbXMRA==", "license": "MIT", "dependencies": { - "@babel/parser": "^7.25.3", - "@vue/shared": "3.5.13", + "@babel/parser": "^7.27.2", + "@vue/shared": "3.5.14", "entities": "^4.5.0", "estree-walker": "^2.0.2", - "source-map-js": "^1.2.0" + "source-map-js": "^1.2.1" } }, "node_modules/@vue/compiler-core/node_modules/entities": { @@ -3490,40 +3490,40 @@ } }, "node_modules/@vue/compiler-dom": { - "version": "3.5.13", - "resolved": "https://registry.npmjs.org/@vue/compiler-dom/-/compiler-dom-3.5.13.tgz", - "integrity": "sha512-ZOJ46sMOKUjO3e94wPdCzQ6P1Lx/vhp2RSvfaab88Ajexs0AHeV0uasYhi99WPaogmBlRHNRuly8xV75cNTMDA==", + "version": "3.5.14", + "resolved": "https://registry.npmjs.org/@vue/compiler-dom/-/compiler-dom-3.5.14.tgz", + "integrity": "sha512-1aOCSqxGOea5I80U2hQJvXYpPm/aXo95xL/m/mMhgyPUsKe9jhjwWpziNAw7tYRnbz1I61rd9Mld4W9KmmRoug==", "license": "MIT", "dependencies": { - "@vue/compiler-core": "3.5.13", - "@vue/shared": "3.5.13" + "@vue/compiler-core": "3.5.14", + "@vue/shared": "3.5.14" } }, "node_modules/@vue/compiler-sfc": { - "version": "3.5.13", - "resolved": "https://registry.npmjs.org/@vue/compiler-sfc/-/compiler-sfc-3.5.13.tgz", - "integrity": "sha512-6VdaljMpD82w6c2749Zhf5T9u5uLBWKnVue6XWxprDobftnletJ8+oel7sexFfM3qIxNmVE7LSFGTpv6obNyaQ==", + "version": "3.5.14", + "resolved": "https://registry.npmjs.org/@vue/compiler-sfc/-/compiler-sfc-3.5.14.tgz", + "integrity": "sha512-9T6m/9mMr81Lj58JpzsiSIjBgv2LiVoWjIVa7kuXHICUi8LiDSIotMpPRXYJsXKqyARrzjT24NAwttrMnMaCXA==", "license": "MIT", "dependencies": { - "@babel/parser": "^7.25.3", - "@vue/compiler-core": "3.5.13", - "@vue/compiler-dom": "3.5.13", - "@vue/compiler-ssr": "3.5.13", - "@vue/shared": "3.5.13", + "@babel/parser": "^7.27.2", + "@vue/compiler-core": "3.5.14", + "@vue/compiler-dom": "3.5.14", + "@vue/compiler-ssr": "3.5.14", + "@vue/shared": "3.5.14", "estree-walker": "^2.0.2", - "magic-string": "^0.30.11", - "postcss": "^8.4.48", - "source-map-js": "^1.2.0" + "magic-string": "^0.30.17", + "postcss": "^8.5.3", + "source-map-js": "^1.2.1" } }, "node_modules/@vue/compiler-ssr": { - "version": "3.5.13", - "resolved": "https://registry.npmjs.org/@vue/compiler-ssr/-/compiler-ssr-3.5.13.tgz", - "integrity": "sha512-wMH6vrYHxQl/IybKJagqbquvxpWCuVYpoUJfCqFZwa/JY1GdATAQ+TgVtgrwwMZ0D07QhA99rs/EAAWfvG6KpA==", + "version": "3.5.14", + "resolved": "https://registry.npmjs.org/@vue/compiler-ssr/-/compiler-ssr-3.5.14.tgz", + "integrity": "sha512-Y0G7PcBxr1yllnHuS/NxNCSPWnRGH4Ogrp0tsLA5QemDZuJLs99YjAKQ7KqkHE0vCg4QTKlQzXLKCMF7WPSl7Q==", "license": "MIT", "dependencies": { - "@vue/compiler-dom": "3.5.13", - "@vue/shared": "3.5.13" + "@vue/compiler-dom": "3.5.14", + "@vue/shared": "3.5.14" } }, "node_modules/@vue/compiler-vue2": { @@ -3654,53 +3654,53 @@ } }, "node_modules/@vue/reactivity": { - "version": "3.5.13", - "resolved": "https://registry.npmjs.org/@vue/reactivity/-/reactivity-3.5.13.tgz", - "integrity": "sha512-NaCwtw8o48B9I6L1zl2p41OHo/2Z4wqYGGIK1Khu5T7yxrn+ATOixn/Udn2m+6kZKB/J7cuT9DbWWhRxqixACg==", + "version": "3.5.14", + "resolved": "https://registry.npmjs.org/@vue/reactivity/-/reactivity-3.5.14.tgz", + "integrity": "sha512-7cK1Hp343Fu/SUCCO52vCabjvsYu7ZkOqyYu7bXV9P2yyfjUMUXHZafEbq244sP7gf+EZEz+77QixBTuEqkQQw==", "license": "MIT", "dependencies": { - "@vue/shared": "3.5.13" + "@vue/shared": "3.5.14" } }, "node_modules/@vue/runtime-core": { - "version": "3.5.13", - "resolved": "https://registry.npmjs.org/@vue/runtime-core/-/runtime-core-3.5.13.tgz", - "integrity": "sha512-Fj4YRQ3Az0WTZw1sFe+QDb0aXCerigEpw418pw1HBUKFtnQHWzwojaukAs2X/c9DQz4MQ4bsXTGlcpGxU/RCIw==", + "version": "3.5.14", + "resolved": "https://registry.npmjs.org/@vue/runtime-core/-/runtime-core-3.5.14.tgz", + "integrity": "sha512-w9JWEANwHXNgieAhxPpEpJa+0V5G0hz3NmjAZwlOebtfKyp2hKxKF0+qSh0Xs6/PhfGihuSdqMprMVcQU/E6ag==", "license": "MIT", "dependencies": { - "@vue/reactivity": "3.5.13", - "@vue/shared": "3.5.13" + "@vue/reactivity": "3.5.14", + "@vue/shared": "3.5.14" } }, "node_modules/@vue/runtime-dom": { - "version": "3.5.13", - "resolved": "https://registry.npmjs.org/@vue/runtime-dom/-/runtime-dom-3.5.13.tgz", - "integrity": "sha512-dLaj94s93NYLqjLiyFzVs9X6dWhTdAlEAciC3Moq7gzAc13VJUdCnjjRurNM6uTLFATRHexHCTu/Xp3eW6yoog==", + "version": "3.5.14", + "resolved": "https://registry.npmjs.org/@vue/runtime-dom/-/runtime-dom-3.5.14.tgz", + "integrity": "sha512-lCfR++IakeI35TVR80QgOelsUIdcKjd65rWAMfdSlCYnaEY5t3hYwru7vvcWaqmrK+LpI7ZDDYiGU5V3xjMacw==", "license": "MIT", "dependencies": { - "@vue/reactivity": "3.5.13", - "@vue/runtime-core": "3.5.13", - "@vue/shared": "3.5.13", + "@vue/reactivity": "3.5.14", + "@vue/runtime-core": "3.5.14", + "@vue/shared": "3.5.14", "csstype": "^3.1.3" } }, "node_modules/@vue/server-renderer": { - "version": "3.5.13", - "resolved": "https://registry.npmjs.org/@vue/server-renderer/-/server-renderer-3.5.13.tgz", - "integrity": "sha512-wAi4IRJV/2SAW3htkTlB+dHeRmpTiVIK1OGLWV1yeStVSebSQQOwGwIq0D3ZIoBj2C2qpgz5+vX9iEBkTdk5YA==", + "version": "3.5.14", + "resolved": "https://registry.npmjs.org/@vue/server-renderer/-/server-renderer-3.5.14.tgz", + "integrity": "sha512-Rf/ISLqokIvcySIYnv3tNWq40PLpNLDLSJwwVWzG6MNtyIhfbcrAxo5ZL9nARJhqjZyWWa40oRb2IDuejeuv6w==", "license": "MIT", "dependencies": { - "@vue/compiler-ssr": "3.5.13", - "@vue/shared": "3.5.13" + "@vue/compiler-ssr": "3.5.14", + "@vue/shared": "3.5.14" }, "peerDependencies": { - "vue": "3.5.13" + "vue": "3.5.14" } }, "node_modules/@vue/shared": { - "version": "3.5.13", - "resolved": "https://registry.npmjs.org/@vue/shared/-/shared-3.5.13.tgz", - "integrity": "sha512-/hnE/qP5ZoGpol0a5mDi45bOd7t3tjYJBjsgCsivow7D48cJeV5l05RD82lPqi7gRiphZM37rnhW1l6ZoCNNnQ==", + "version": "3.5.14", + "resolved": "https://registry.npmjs.org/@vue/shared/-/shared-3.5.14.tgz", + "integrity": "sha512-oXTwNxVfc9EtP1zzXAlSlgARLXNC84frFYkS0HHz0h3E4WZSP9sywqjqzGCP9Y34M8ipNmd380pVgmMuwELDyQ==", "license": "MIT" }, "node_modules/@vue/test-utils": { @@ -5106,9 +5106,9 @@ "license": "MIT" }, "node_modules/electron-to-chromium": { - "version": "1.5.153", - "resolved": "https://registry.npmjs.org/electron-to-chromium/-/electron-to-chromium-1.5.153.tgz", - "integrity": "sha512-4bwluTFwjXZ0/ei1qDpHDGzVveuBfx4wiZ9VQ8j/30+T2JxSF2TfZ00d1X+wNMeDyUdZXgLkJFbarJdAMtd+/w==", + "version": "1.5.155", + "resolved": "https://registry.npmjs.org/electron-to-chromium/-/electron-to-chromium-1.5.155.tgz", + "integrity": "sha512-ps5KcGGmwL8VaeJlvlDlu4fORQpv3+GIcF5I3f9tUKUlJ/wsysh6HU8P5L1XWRYeXfA0oJd4PyM8ds8zTFf6Ng==", "dev": true, "license": "ISC" }, @@ -11516,16 +11516,16 @@ "license": "MIT" }, "node_modules/vue": { - "version": "3.5.13", - "resolved": "https://registry.npmjs.org/vue/-/vue-3.5.13.tgz", - "integrity": "sha512-wmeiSMxkZCSc+PM2w2VRsOYAZC8GdipNFRTsLSfodVqI9mbejKeXEGr8SckuLnrQPGe3oJN5c3K0vpoU9q/wCQ==", + "version": "3.5.14", + "resolved": "https://registry.npmjs.org/vue/-/vue-3.5.14.tgz", + "integrity": "sha512-LbOm50/vZFG6Mhy6KscQYXZMQ0LMCC/y40HDJPPvGFQ+i/lUH+PJHR6C3assgOQiXdl6tAfsXHbXYVBZZu65ew==", "license": "MIT", "dependencies": { - "@vue/compiler-dom": "3.5.13", - "@vue/compiler-sfc": "3.5.13", - "@vue/runtime-dom": "3.5.13", - "@vue/server-renderer": "3.5.13", - "@vue/shared": "3.5.13" + "@vue/compiler-dom": "3.5.14", + "@vue/compiler-sfc": "3.5.14", + "@vue/runtime-dom": "3.5.14", + "@vue/server-renderer": "3.5.14", + "@vue/shared": "3.5.14" }, "peerDependencies": { "typescript": "*"