diff --git a/backend/package.json b/backend/package.json index 83db321f..3a89eb87 100644 --- a/backend/package.json +++ b/backend/package.json @@ -7,7 +7,7 @@ "main": "dist/app.js", "scripts": { "build": "cross-env NODE_ENV=production tsc --build", - "dev": "cross-env NODE_ENV=development tsx watch --env-file=.env.development.local src/app.ts", + "dev": "cross-env NODE_ENV=development tsx tool/seed.ts; tsx watch --env-file=.env.development.local src/app.ts", "start": "cross-env NODE_ENV=production node --env-file=.env dist/app.js", "format": "prettier --write src/", "format-check": "prettier --check src/", diff --git a/backend/src/controllers/classes.ts b/backend/src/controllers/classes.ts index a041bf22..03e88a52 100644 --- a/backend/src/controllers/classes.ts +++ b/backend/src/controllers/classes.ts @@ -28,7 +28,7 @@ export async function createClassHandler(req: Request, res: Response): Promise { @@ -40,7 +40,7 @@ export async function getClassHandler(req: Request, res: Response): Promise { diff --git a/backend/src/orm.ts b/backend/src/orm.ts index 3e6e26c8..76cd0ee9 100644 --- a/backend/src/orm.ts +++ b/backend/src/orm.ts @@ -1,10 +1,10 @@ -import { EntityManager, MikroORM } from '@mikro-orm/core'; +import { EntityManager, IDatabaseDriver, MikroORM } from '@mikro-orm/core'; import config from './mikro-orm.config.js'; import { envVars, getEnvVar } from './util/envVars.js'; import { getLogger, Logger } from './logging/initalize.js'; let orm: MikroORM | undefined; -export async function initORM(testingMode = false): Promise { +export async function initORM(testingMode = false): Promise> { const logger: Logger = getLogger(); logger.info('Initializing ORM'); @@ -25,6 +25,8 @@ export async function initORM(testingMode = false): Promise { ); } } + + return orm; } export function forkEntityManager(): EntityManager { if (!orm) { diff --git a/backend/tests/controllers/students.test.ts b/backend/tests/controllers/students.test.ts index 93f35c48..18331f2d 100644 --- a/backend/tests/controllers/students.test.ts +++ b/backend/tests/controllers/students.test.ts @@ -186,7 +186,7 @@ describe('Student controllers', () => { it('Get join request by student and class', async () => { req = { - params: { username: 'PinkFloyd', classId: 'id02' }, + params: { username: 'PinkFloyd', classId: '34d484a1-295f-4e9f-bfdc-3e7a23d86a89' }, }; await getStudentRequestHandler(req as Request, res as Response); @@ -201,7 +201,7 @@ describe('Student controllers', () => { it('Create join request', async () => { req = { params: { username: 'Noordkaap' }, - body: { classId: 'id02' }, + body: { classId: '34d484a1-295f-4e9f-bfdc-3e7a23d86a89' }, }; await createStudentRequestHandler(req as Request, res as Response); @@ -212,7 +212,7 @@ describe('Student controllers', () => { it('Create join request duplicate', async () => { req = { params: { username: 'Tool' }, - body: { classId: 'id02' }, + body: { classId: '34d484a1-295f-4e9f-bfdc-3e7a23d86a89' }, }; await expect(async () => createStudentRequestHandler(req as Request, res as Response)).rejects.toThrow(ConflictException); @@ -220,7 +220,7 @@ describe('Student controllers', () => { it('Delete join request', async () => { req = { - params: { username: 'Noordkaap', classId: 'id02' }, + params: { username: 'Noordkaap', classId: '34d484a1-295f-4e9f-bfdc-3e7a23d86a89' }, }; await deleteClassJoinRequestHandler(req as Request, res as Response); diff --git a/backend/tests/controllers/teachers.test.ts b/backend/tests/controllers/teachers.test.ts index bee23987..cdcb6229 100644 --- a/backend/tests/controllers/teachers.test.ts +++ b/backend/tests/controllers/teachers.test.ts @@ -104,9 +104,9 @@ describe('Teacher controllers', () => { const result = jsonMock.mock.lastCall?.[0]; const teacherUsernames = result.teachers.map((s: TeacherDTO) => s.username); - expect(teacherUsernames).toContain('FooFighters'); + expect(teacherUsernames).toContain('testleerkracht1'); - expect(result.teachers).toHaveLength(4); + expect(result.teachers).toHaveLength(5); }); it('Deleting non-existent student', async () => { @@ -117,7 +117,7 @@ describe('Teacher controllers', () => { it('Get teacher classes', async () => { req = { - params: { username: 'FooFighters' }, + params: { username: 'testleerkracht1' }, query: { full: 'true' }, }; @@ -132,7 +132,7 @@ describe('Teacher controllers', () => { it('Get teacher students', async () => { req = { - params: { username: 'FooFighters' }, + params: { username: 'testleerkracht1' }, query: { full: 'true' }, }; @@ -169,7 +169,7 @@ describe('Teacher controllers', () => { it('Get join requests by class', async () => { req = { query: { username: 'LimpBizkit' }, - params: { classId: 'id02' }, + params: { classId: '34d484a1-295f-4e9f-bfdc-3e7a23d86a89' }, }; await getStudentJoinRequestHandler(req as Request, res as Response); @@ -184,7 +184,7 @@ describe('Teacher controllers', () => { it('Update join request status', async () => { req = { query: { username: 'LimpBizkit', studentUsername: 'PinkFloyd' }, - params: { classId: 'id02' }, + params: { classId: '34d484a1-295f-4e9f-bfdc-3e7a23d86a89' }, body: { accepted: 'true' }, }; diff --git a/backend/tests/data/assignments/assignments.test.ts b/backend/tests/data/assignments/assignments.test.ts index c26fb5ba..c2bdbeef 100644 --- a/backend/tests/data/assignments/assignments.test.ts +++ b/backend/tests/data/assignments/assignments.test.ts @@ -15,7 +15,7 @@ describe('AssignmentRepository', () => { }); it('should return the requested assignment', async () => { - const class_ = await classRepository.findById('id02'); + const class_ = await classRepository.findById('34d484a1-295f-4e9f-bfdc-3e7a23d86a89'); const assignment = await assignmentRepository.findByClassAndId(class_!, 2); expect(assignment).toBeTruthy(); @@ -23,7 +23,7 @@ describe('AssignmentRepository', () => { }); it('should return all assignments for a class', async () => { - const class_ = await classRepository.findById('id02'); + const class_ = await classRepository.findById('34d484a1-295f-4e9f-bfdc-3e7a23d86a89'); const assignments = await assignmentRepository.findAllAssignmentsInClass(class_!); expect(assignments).toBeTruthy(); diff --git a/backend/tests/data/assignments/groups.test.ts b/backend/tests/data/assignments/groups.test.ts index 96684d68..f7fb3046 100644 --- a/backend/tests/data/assignments/groups.test.ts +++ b/backend/tests/data/assignments/groups.test.ts @@ -18,7 +18,7 @@ describe('GroupRepository', () => { }); it('should return the requested group', async () => { - const class_ = await classRepository.findById('id01'); + const class_ = await classRepository.findById('8764b861-90a6-42e5-9732-c0d9eb2f55f9'); const assignment = await assignmentRepository.findByClassAndId(class_!, 1); const group = await groupRepository.findByAssignmentAndGroupNumber(assignment!, 1); @@ -27,7 +27,7 @@ describe('GroupRepository', () => { }); it('should return all groups for assignment', async () => { - const class_ = await classRepository.findById('id01'); + const class_ = await classRepository.findById('8764b861-90a6-42e5-9732-c0d9eb2f55f9'); const assignment = await assignmentRepository.findByClassAndId(class_!, 1); const groups = await groupRepository.findAllGroupsForAssignment(assignment!); @@ -37,7 +37,7 @@ describe('GroupRepository', () => { }); it('should not find removed group', async () => { - const class_ = await classRepository.findById('id02'); + const class_ = await classRepository.findById('34d484a1-295f-4e9f-bfdc-3e7a23d86a89'); const assignment = await assignmentRepository.findByClassAndId(class_!, 2); await groupRepository.deleteByAssignmentAndGroupNumber(assignment!, 1); diff --git a/backend/tests/data/assignments/submissions.test.ts b/backend/tests/data/assignments/submissions.test.ts index 85e1bc11..37d0f2ee 100644 --- a/backend/tests/data/assignments/submissions.test.ts +++ b/backend/tests/data/assignments/submissions.test.ts @@ -50,7 +50,7 @@ describe('SubmissionRepository', () => { it('should find the most recent submission for a group', async () => { const id = new LearningObjectIdentifier('id03', Language.English, 1); - const class_ = await classRepository.findById('id01'); + const class_ = await classRepository.findById('8764b861-90a6-42e5-9732-c0d9eb2f55f9'); const assignment = await assignmentRepository.findByClassAndId(class_!, 1); const group = await groupRepository.findByAssignmentAndGroupNumber(assignment!, 1); const submission = await submissionRepository.findMostRecentSubmissionForGroup(id, group!); diff --git a/backend/tests/data/classes/class-join-request.test.ts b/backend/tests/data/classes/class-join-request.test.ts index cd53bf05..afb83766 100644 --- a/backend/tests/data/classes/class-join-request.test.ts +++ b/backend/tests/data/classes/class-join-request.test.ts @@ -26,7 +26,7 @@ describe('ClassJoinRequestRepository', () => { }); it('should list all requests to a single class', async () => { - const class_ = await cassRepository.findById('id02'); + const class_ = await cassRepository.findById('34d484a1-295f-4e9f-bfdc-3e7a23d86a89'); const requests = await classJoinRequestRepository.findAllOpenRequestsTo(class_!); expect(requests).toBeTruthy(); @@ -35,7 +35,7 @@ describe('ClassJoinRequestRepository', () => { it('should not find a removed request', async () => { const student = await studentRepository.findByUsername('SmashingPumpkins'); - const class_ = await cassRepository.findById('id03'); + const class_ = await cassRepository.findById('80dcc3e0-1811-4091-9361-42c0eee91cfa'); await classJoinRequestRepository.deleteBy(student!, class_!); const request = await classJoinRequestRepository.findAllRequestsBy(student!); diff --git a/backend/tests/data/classes/classes.test.ts b/backend/tests/data/classes/classes.test.ts index 22306ba6..f87f83ed 100644 --- a/backend/tests/data/classes/classes.test.ts +++ b/backend/tests/data/classes/classes.test.ts @@ -18,16 +18,16 @@ describe('ClassRepository', () => { }); it('should return requested class', async () => { - const classVar = await classRepository.findById('id01'); + const classVar = await classRepository.findById('8764b861-90a6-42e5-9732-c0d9eb2f55f9'); expect(classVar).toBeTruthy(); expect(classVar?.displayName).toBe('class01'); }); it('class should be gone after deletion', async () => { - await classRepository.deleteById('id04'); + await classRepository.deleteById('33d03536-83b8-4880-9982-9bbf2f908ddf'); - const classVar = await classRepository.findById('id04'); + const classVar = await classRepository.findById('33d03536-83b8-4880-9982-9bbf2f908ddf'); expect(classVar).toBeNull(); }); diff --git a/backend/tests/data/classes/teacher-invitation.test.ts b/backend/tests/data/classes/teacher-invitation.test.ts index dd03634a..f8afa36d 100644 --- a/backend/tests/data/classes/teacher-invitation.test.ts +++ b/backend/tests/data/classes/teacher-invitation.test.ts @@ -34,7 +34,7 @@ describe('ClassRepository', () => { }); it('should return all invitations for a class', async () => { - const class_ = await classRepository.findById('id02'); + const class_ = await classRepository.findById('34d484a1-295f-4e9f-bfdc-3e7a23d86a89'); const invitations = await teacherInvitationRepository.findAllInvitationsForClass(class_!); expect(invitations).toBeTruthy(); @@ -42,7 +42,7 @@ describe('ClassRepository', () => { }); it('should not find a removed invitation', async () => { - const class_ = await classRepository.findById('id01'); + const class_ = await classRepository.findById('8764b861-90a6-42e5-9732-c0d9eb2f55f9'); const sender = await teacherRepository.findByUsername('FooFighters'); const receiver = await teacherRepository.findByUsername('LimpBizkit'); await teacherInvitationRepository.deleteBy(class_!, sender!, receiver!); diff --git a/backend/tests/test_assets/classes/classes.testdata.ts b/backend/tests/test_assets/classes/classes.testdata.ts index e4372015..0f223ec4 100644 --- a/backend/tests/test_assets/classes/classes.testdata.ts +++ b/backend/tests/test_assets/classes/classes.testdata.ts @@ -4,11 +4,11 @@ import { Student } from '../../../src/entities/users/student.entity'; import { Teacher } from '../../../src/entities/users/teacher.entity'; export function makeTestClasses(em: EntityManager, students: Student[], teachers: Teacher[]): Class[] { - const studentsClass01 = students.slice(0, 7); - const teacherClass01: Teacher[] = teachers.slice(0, 1); + const studentsClass01 = students.slice(0, 8); + const teacherClass01: Teacher[] = teachers.slice(4, 5); const class01 = em.create(Class, { - classId: 'id01', + classId: '8764b861-90a6-42e5-9732-c0d9eb2f55f9', displayName: 'class01', teachers: teacherClass01, students: studentsClass01, @@ -18,7 +18,7 @@ export function makeTestClasses(em: EntityManager, students: Student[], teachers const teacherClass02: Teacher[] = teachers.slice(1, 2); const class02 = em.create(Class, { - classId: 'id02', + classId: '34d484a1-295f-4e9f-bfdc-3e7a23d86a89', displayName: 'class02', teachers: teacherClass02, students: studentsClass02, @@ -28,7 +28,7 @@ export function makeTestClasses(em: EntityManager, students: Student[], teachers const teacherClass03: Teacher[] = teachers.slice(2, 3); const class03 = em.create(Class, { - classId: 'id03', + classId: '80dcc3e0-1811-4091-9361-42c0eee91cfa', displayName: 'class03', teachers: teacherClass03, students: studentsClass03, @@ -38,7 +38,7 @@ export function makeTestClasses(em: EntityManager, students: Student[], teachers const teacherClass04: Teacher[] = teachers.slice(2, 3); const class04 = em.create(Class, { - classId: 'id04', + classId: '33d03536-83b8-4880-9982-9bbf2f908ddf', displayName: 'class04', teachers: teacherClass04, students: studentsClass04, diff --git a/backend/tests/test_assets/users/students.testdata.ts b/backend/tests/test_assets/users/students.testdata.ts index 5cd75787..7a1fe191 100644 --- a/backend/tests/test_assets/users/students.testdata.ts +++ b/backend/tests/test_assets/users/students.testdata.ts @@ -11,6 +11,8 @@ export const TEST_STUDENTS = [ { username: 'TheDoors', firstName: 'Jim', lastName: 'Morisson' }, // ⚠️ Deze mag niet gebruikt worden in elke test! { username: 'Nirvana', firstName: 'Kurt', lastName: 'Cobain' }, + // Makes sure when logged in as leerling1, there exists a corresponding user + { username: 'testleerling1', firstName: 'Gerald', lastName: 'Schmittinger' }, ]; // 🏗️ Functie die ORM entities maakt uit de data array diff --git a/backend/tests/test_assets/users/teachers.testdata.ts b/backend/tests/test_assets/users/teachers.testdata.ts index 8e791bb1..db726dcf 100644 --- a/backend/tests/test_assets/users/teachers.testdata.ts +++ b/backend/tests/test_assets/users/teachers.testdata.ts @@ -27,5 +27,12 @@ export function makeTestTeachers(em: EntityManager): Teacher[] { lastName: 'Cappelle', }); - return [teacher01, teacher02, teacher03, teacher04]; + // Makes sure when logged in as testleerkracht1, there exists a corresponding user + const teacher05 = em.create(Teacher, { + username: 'testleerkracht1', + firstName: 'Bob', + lastName: 'Dylan', + }); + + return [teacher01, teacher02, teacher03, teacher04, teacher05]; } diff --git a/backend/tool/seed.ts b/backend/tool/seed.ts new file mode 100644 index 00000000..33344234 --- /dev/null +++ b/backend/tool/seed.ts @@ -0,0 +1,72 @@ +import { forkEntityManager, initORM } from '../src/orm.js'; +import dotenv from 'dotenv'; +import { makeTestAssignemnts } from '../tests/test_assets/assignments/assignments.testdata.js'; +import { makeTestGroups } from '../tests/test_assets/assignments/groups.testdata.js'; +import { makeTestSubmissions } from '../tests/test_assets/assignments/submission.testdata.js'; +import { makeTestClassJoinRequests } from '../tests/test_assets/classes/class-join-requests.testdata.js'; +import { makeTestClasses } from '../tests/test_assets/classes/classes.testdata.js'; +import { makeTestTeacherInvitations } from '../tests/test_assets/classes/teacher-invitations.testdata.js'; +import { makeTestAttachments } from '../tests/test_assets/content/attachments.testdata.js'; +import { makeTestLearningObjects } from '../tests/test_assets/content/learning-objects.testdata.js'; +import { makeTestLearningPaths } from '../tests/test_assets/content/learning-paths.testdata.js'; +import { makeTestAnswers } from '../tests/test_assets/questions/answers.testdata.js'; +import { makeTestQuestions } from '../tests/test_assets/questions/questions.testdata.js'; +import { makeTestStudents } from '../tests/test_assets/users/students.testdata.js'; +import { makeTestTeachers } from '../tests/test_assets/users/teachers.testdata.js'; +import { getLogger, Logger } from '../src/logging/initalize.js'; + +const logger: Logger = getLogger(); + +export async function seedDatabase(): Promise { + dotenv.config({ path: '.env.development.local' }); + const orm = await initORM(); + await orm.schema.clearDatabase(); + + const em = forkEntityManager(); + + logger.info('seeding database...'); + + const students = makeTestStudents(em); + const teachers = makeTestTeachers(em); + const learningObjects = makeTestLearningObjects(em); + const learningPaths = makeTestLearningPaths(em); + const classes = makeTestClasses(em, students, teachers); + const assignments = makeTestAssignemnts(em, classes); + const groups = makeTestGroups(em, students, assignments); + + assignments[0].groups = groups.slice(0, 3); + assignments[1].groups = groups.slice(3, 4); + + const teacherInvitations = makeTestTeacherInvitations(em, teachers, classes); + const classJoinRequests = makeTestClassJoinRequests(em, students, classes); + const attachments = makeTestAttachments(em, learningObjects); + + learningObjects[1].attachments = attachments; + + const questions = makeTestQuestions(em, students); + const answers = makeTestAnswers(em, teachers, questions); + const submissions = makeTestSubmissions(em, students, groups); + + // Persist all entities + await em.persistAndFlush([ + ...students, + ...teachers, + ...learningObjects, + ...learningPaths, + ...classes, + ...assignments, + ...groups, + ...teacherInvitations, + ...classJoinRequests, + ...attachments, + ...questions, + ...answers, + ...submissions, + ]); + + logger.info('Development database seeded successfully!'); + + await orm.close(); +} + +seedDatabase().catch(logger.error); diff --git a/frontend/src/controllers/base-controller.ts b/frontend/src/controllers/base-controller.ts index 72d71819..0262d352 100644 --- a/frontend/src/controllers/base-controller.ts +++ b/frontend/src/controllers/base-controller.ts @@ -10,7 +10,7 @@ export abstract class BaseController { } private static assertSuccessResponse(response: AxiosResponse): void { - if (response.status / 100 !== 2) { + if (response.status < 200 || response.status >= 300) { throw new HttpErrorResponseException(response); } } diff --git a/frontend/src/controllers/controllers.ts b/frontend/src/controllers/controllers.ts index 39392a7d..d8dbc9e2 100644 --- a/frontend/src/controllers/controllers.ts +++ b/frontend/src/controllers/controllers.ts @@ -1,6 +1,7 @@ import { ThemeController } from "@/controllers/themes.ts"; import { LearningObjectController } from "@/controllers/learning-objects.ts"; import { LearningPathController } from "@/controllers/learning-paths.ts"; +import { ClassController } from "@/controllers/classes.ts"; export function controllerGetter(factory: new () => T): () => T { let instance: T | undefined; @@ -16,3 +17,4 @@ export function controllerGetter(factory: new () => T): () => T { export const getThemeController = controllerGetter(ThemeController); export const getLearningObjectController = controllerGetter(LearningObjectController); export const getLearningPathController = controllerGetter(LearningPathController); +export const getClassController = controllerGetter(ClassController); diff --git a/frontend/src/controllers/students.ts b/frontend/src/controllers/students.ts index f74f02da..e9da9c74 100644 --- a/frontend/src/controllers/students.ts +++ b/frontend/src/controllers/students.ts @@ -70,7 +70,7 @@ export class StudentController extends BaseController { } async createJoinRequest(username: string, classId: string): Promise { - return this.post(`/${username}/joinRequests}`, classId); + return this.post(`/${username}/joinRequests`, { classId }); } async deleteJoinRequest(username: string, classId: string): Promise { diff --git a/frontend/src/i18n/locale/de.json b/frontend/src/i18n/locale/de.json index d20154a4..d7bded04 100644 --- a/frontend/src/i18n/locale/de.json +++ b/frontend/src/i18n/locale/de.json @@ -17,6 +17,11 @@ "inclusive": "Inclusiv", "sociallyRelevant": "Gesellschaftlich relevant", "translate": "übersetzen", + "joinClass": "Klasse beitreten", + "JoinClassExplanation": "Geben Sie den Code ein, den Ihnen die Lehrkraft mitgeteilt hat, um der Klasse beizutreten.", + "invalidFormat": "Ungültiges Format", + "submitCode": "senden", + "members": "Mitglieder", "themes": "Themen", "choose-theme": "Wähle ein thema", "choose-age": "Alter auswählen", @@ -51,5 +56,24 @@ "noLearningPathsFoundDescription": "Es gibt keine Lernpfade, die zu Ihrem Suchbegriff passen.", "legendNotCompletedYet": "Noch nicht fertig", "legendCompleted": "Fertig", - "legendTeacherExclusive": "Information für Lehrkräfte" + "legendTeacherExclusive": "Information für Lehrkräfte", + "code": "code", + "class": "Klasse", + "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.", + "classname": "Klassenname", + "EnterNameOfClass": "einen Klassennamen eingeben.", + "create": "erstellen", + "sender": "Absender", + "nameIsMandatory": "Der Klassenname ist ein Pflichtfeld", + "onlyUse": "nur Buchstaben, Zahlen, Bindestriche (-) und Unterstriche (_) verwenden", + "close": "schließen", + "copied": "kopiert!", + "accept": "akzeptieren", + "deny": "ablehnen", + "sent": "sent", + "failed": "gescheitert", + "wrong": "etwas ist schief gelaufen", + "created": "erstellt" } diff --git a/frontend/src/i18n/locale/en.json b/frontend/src/i18n/locale/en.json index 8d7ed775..171eb1f8 100644 --- a/frontend/src/i18n/locale/en.json +++ b/frontend/src/i18n/locale/en.json @@ -29,6 +29,11 @@ "sociallyRelevant": "Socially relevant", "login": "log in", "translate": "translate", + "joinClass": "Join class", + "JoinClassExplanation": "Enter the code the teacher has given you to join the class.", + "invalidFormat": "Invalid format.", + "submitCode": "submit", + "members": "members", "themes": "Themes", "choose-theme": "Select a theme", "choose-age": "Select age", @@ -51,5 +56,24 @@ "high-school": "16-18 years old", "older": "18 and older" }, - "read-more": "Read more" + "read-more": "Read more", + "code": "code", + "class": "class", + "invitations": "invitations", + "createClass": "create class", + "classname": "classname", + "EnterNameOfClass": "Enter a classname.", + "create": "create", + "sender": "sender", + "nameIsMandatory": "classname is mandatory", + "onlyUse": "only use letters, numbers, dashes (-) and underscores (_)", + "close": "close", + "copied": "copied!", + "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", + "failed": "failed", + "wrong": "something went wrong", + "created": "created" } diff --git a/frontend/src/i18n/locale/fr.json b/frontend/src/i18n/locale/fr.json index 2dfbb949..a3d3d89b 100644 --- a/frontend/src/i18n/locale/fr.json +++ b/frontend/src/i18n/locale/fr.json @@ -29,6 +29,11 @@ "inclusive": "Inclusif", "sociallyRelevant": "Socialement pertinent", "translate": "traduire", + "joinClass": "Rejoindre une classe", + "JoinClassExplanation": "Entrez le code que l'enseignant vous a donné pour rejoindre la classe.", + "invalidFormat": "Format non valide.", + "submitCode": "envoyer", + "members": "membres", "themes": "Thèmes", "choose-theme": "Choisis un thème", "choose-age": "Choisis un âge", @@ -51,5 +56,24 @@ "high-school": "16-18 ans", "older": "18 et plus" }, - "read-more": "En savoir plus" + "read-more": "En savoir plus", + "code": "code", + "class": "classe", + "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", + "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", + "deny": "refuser", + "sent": "envoyé", + "failed": "échoué", + "wrong": "quelque chose n'a pas fonctionné", + "created": "créé" } diff --git a/frontend/src/i18n/locale/nl.json b/frontend/src/i18n/locale/nl.json index 80cdd8e1..1fbed08d 100644 --- a/frontend/src/i18n/locale/nl.json +++ b/frontend/src/i18n/locale/nl.json @@ -29,6 +29,11 @@ "sociallyRelevant": "Maatschappelijk relevant", "login": "log in", "translate": "vertalen", + "joinClass": "Word lid van een klas", + "JoinClassExplanation": "Voer de code in die je van de docent hebt gekregen om lid te worden van de klas.", + "invalidFormat": "Ongeldig formaat.", + "submitCode": "verzenden", + "members": "leden", "themes": "Lesthema's", "choose-theme": "Kies een thema", "choose-age": "Kies een leeftijd", @@ -51,5 +56,24 @@ "high-school": "3e graad secundair", "older": "Hoger onderwijs" }, - "read-more": "Lees meer" + "read-more": "Lees meer", + "code": "code", + "class": "klas", + "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", + "nameIsMandatory": "klasnaam is verplicht", + "onlyUse": "gebruik enkel letters, cijfers, dashes (-) en underscores (_)", + "close": "sluiten", + "copied": "gekopieerd!", + "accept": "accepteren", + "deny": "weigeren", + "sent": "verzonden", + "failed": "mislukt", + "wrong": "er ging iets verkeerd", + "created": "gecreëerd" } diff --git a/frontend/src/queries/students.ts b/frontend/src/queries/students.ts index 822083d9..5b01e3c5 100644 --- a/frontend/src/queries/students.ts +++ b/frontend/src/queries/students.ts @@ -19,7 +19,7 @@ import type { AssignmentsResponse } from "@/controllers/assignments.ts"; import type { GroupsResponse } from "@/controllers/groups.ts"; import type { SubmissionsResponse } from "@/controllers/submissions.ts"; import type { QuestionsResponse } from "@/controllers/questions.ts"; -import type { StudentDTO } from "@dwengo-1/interfaces/student"; +import type { StudentDTO } from "@dwengo-1/common/interfaces/student"; const studentController = new StudentController(); @@ -179,7 +179,7 @@ export function useCreateJoinRequestMutation(): UseMutationReturnType< mutationFn: async ({ username, classId }) => studentController.createJoinRequest(username, classId), onSuccess: async (newJoinRequest) => { await queryClient.invalidateQueries({ - queryKey: studentJoinRequestsQueryKey(newJoinRequest.request.requester), + queryKey: studentJoinRequestsQueryKey(newJoinRequest.request.requester.username), }); }, }); @@ -196,7 +196,7 @@ export function useDeleteJoinRequestMutation(): UseMutationReturnType< return useMutation({ mutationFn: async ({ username, classId }) => studentController.deleteJoinRequest(username, classId), onSuccess: async (deletedJoinRequest) => { - const username = deletedJoinRequest.request.requester; + const username = deletedJoinRequest.request.requester.username; const classId = deletedJoinRequest.request.class; await queryClient.invalidateQueries({ queryKey: studentJoinRequestsQueryKey(username) }); await queryClient.invalidateQueries({ queryKey: studentJoinRequestQueryKey(username, classId) }); diff --git a/frontend/src/queries/teachers.ts b/frontend/src/queries/teachers.ts index 778b2cba..50d61f6c 100644 --- a/frontend/src/queries/teachers.ts +++ b/frontend/src/queries/teachers.ts @@ -1,11 +1,17 @@ import { computed, toValue } from "vue"; import type { MaybeRefOrGetter } from "vue"; -import { useMutation, useQuery, useQueryClient, UseMutationReturnType, UseQueryReturnType } from "@tanstack/vue-query"; +import { + useMutation, + useQuery, + useQueryClient, + type UseMutationReturnType, + type UseQueryReturnType, +} from "@tanstack/vue-query"; 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/interfaces/teacher"; +import type { TeacherDTO } from "@dwengo-1/common/interfaces/teacher"; import { studentJoinRequestQueryKey, studentJoinRequestsQueryKey } from "@/queries/students.ts"; const teacherController = new TeacherController(); diff --git a/frontend/src/views/classes/SingleClass.vue b/frontend/src/views/classes/SingleClass.vue index 1a35a59f..6a6b2f12 100644 --- a/frontend/src/views/classes/SingleClass.vue +++ b/frontend/src/views/classes/SingleClass.vue @@ -1,7 +1,224 @@ - + +
+
+ +

Loading...

+
+
+

{{ currentClass!.displayName }}

+ + + + + + + {{ t("students") }} + + + + + + + {{ s.firstName + " " + s.lastName }} + + + {{ t("remove") }} + + + + + + + +
+ + + {{ t("areusure") }} - + + + + {{ t("cancel") }} + + {{ t("yes") }} + + + +
+ + diff --git a/frontend/src/views/classes/StudentClasses.vue b/frontend/src/views/classes/StudentClasses.vue index 1a35a59f..2bfdc1b8 100644 --- a/frontend/src/views/classes/StudentClasses.vue +++ b/frontend/src/views/classes/StudentClasses.vue @@ -1,7 +1,380 @@ - + +
+
+ +

Loading...

+
- +
+ mdi-alert-circle +

Error loading: {{ error.message }}

+
+
+

{{ t("classes") }}

+ + + + + + + {{ t("classes") }} + {{ t("teachers") }} + {{ t("members") }} + + + + + {{ c.displayName }} + + {{ c.teachers.length }} + + + {{ c.students.length }} + + + + + + + + + + + {{ selectedClass?.displayName }} + +
    +
  • + {{ student.firstName + " " + student.lastName }} +
  • +
+
    +
  • + {{ teacher.firstName + " " + teacher.lastName }} +
  • +
+
+ + Close + +
+
+
+
+

{{ t("joinClass") }}

+

{{ t("JoinClassExplanation") }}

+ + + + + {{ t("submitCode") }} + + +
+
+
+ + {{ snackbar.message }} + +
+ + diff --git a/frontend/src/views/classes/TeacherClasses.vue b/frontend/src/views/classes/TeacherClasses.vue index 1a35a59f..ae673d99 100644 --- a/frontend/src/views/classes/TeacherClasses.vue +++ b/frontend/src/views/classes/TeacherClasses.vue @@ -1,7 +1,404 @@ - + +
+
+ +

Loading...

+
- +
+ mdi-alert-circle +

Error loading: {{ error.message }}

+
+
+

{{ t("classes") }}

+ + + + + + + {{ t("classes") }} + + {{ t("code") }} + + {{ t("members") }} + + + + + + + {{ c.displayName }} + mdi-menu-right + + + {{ c.id }} + {{ c.students.length }} + + + + + +
+

{{ t("createClass") }}

+ + +

{{ t("createClassInstructions") }}

+ + + {{ t("create") }} + +
+ + + + code + + + +
+ {{ t("copied") }} +
+
+
+ + + + {{ t("close") }} + + +
+
+
+
+
+
+
+ +

+ {{ t("invitations") }} +

+ + + + {{ t("class") }} + {{ t("sender") }} + + + + + + + {{ (i.class as ClassDTO).displayName }} + + {{ (i.sender as TeacherDTO).firstName + " " + (i.sender as TeacherDTO).lastName }} + +
+ + {{ t("accept") }} + + + {{ t("deny") }} + +
+ + + +
+
+ + {{ snackbar.message }} + +
+ + diff --git a/frontend/src/views/classes/UserClasses.vue b/frontend/src/views/classes/UserClasses.vue index 1a35a59f..566bd02a 100644 --- a/frontend/src/views/classes/UserClasses.vue +++ b/frontend/src/views/classes/UserClasses.vue @@ -1,7 +1,17 @@ - +