diff --git a/backend/package.json b/backend/package.json index 83db321f..b4ef9df2 100644 --- a/backend/package.json +++ b/backend/package.json @@ -16,6 +16,7 @@ "test:unit": "vitest --run" }, "dependencies": { + "@dwengo-1/common": "^0.1.1", "@mikro-orm/core": "6.4.9", "@mikro-orm/knex": "6.4.9", "@mikro-orm/postgresql": "6.4.9", diff --git a/frontend/src/i18n/locale/de.json b/frontend/src/i18n/locale/de.json index d20154a4..a20ef738 100644 --- a/frontend/src/i18n/locale/de.json +++ b/frontend/src/i18n/locale/de.json @@ -51,5 +51,17 @@ "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", + "new-assignment": "Neue Aufgabe", + "edit-assignment": "Zuordnung bearbeiten", + "groups": "Gruppen", + "learning-path": "Lernpfad", + "choose-lp": "Einen lernpfad auswählen", + "choose-classes": "Klassen wählen", + "create-groups": "Gruppen erstellen", + "title": "Titel", + "pick-class": "Wählen Sie eine klasse", + "choose-students": "Studenten auswählen", + "create-group": "Gruppe erstellen", + "class": "klasse" } diff --git a/frontend/src/i18n/locale/en.json b/frontend/src/i18n/locale/en.json index ab651ad7..4bdcb843 100644 --- a/frontend/src/i18n/locale/en.json +++ b/frontend/src/i18n/locale/en.json @@ -54,8 +54,6 @@ "read-more": "Read more", "new-assignment": "New Assignment", "edit-assignment": "Edit Assignment", - "next": "next", - "previous": "previous", "groups": "Groups", "learning-path": "Learning path", "choose-lp": "Select a learning path", diff --git a/frontend/src/i18n/locale/fr.json b/frontend/src/i18n/locale/fr.json index 54b3ebca..a49bffea 100644 --- a/frontend/src/i18n/locale/fr.json +++ b/frontend/src/i18n/locale/fr.json @@ -54,8 +54,6 @@ "read-more": "En savoir plus", "new-assignment": "Nouveau travail", "edit-assignment": "Modifier le travail", - "next": "suivant", - "previous": "précédent", "groups": "Groupes", "learning-path": "Parcours d'apprentissage", "choose-lp": "Choisissez un parcours d'apprentissage", diff --git a/frontend/src/i18n/locale/nl.json b/frontend/src/i18n/locale/nl.json index 9ed98789..66275907 100644 --- a/frontend/src/i18n/locale/nl.json +++ b/frontend/src/i18n/locale/nl.json @@ -54,8 +54,6 @@ "read-more": "Lees meer", "new-assignment": "Nieuwe opdracht", "edit-assignment": "Opdracht bewerken", - "next": "volgende", - "previous": "vorige", "groups": "Groepen", "learning-path": "Leerpad", "choose-lp": "Kies een leerpad", diff --git a/frontend/src/router/index.ts b/frontend/src/router/index.ts index 23695680..1225d119 100644 --- a/frontend/src/router/index.ts +++ b/frontend/src/router/index.ts @@ -9,7 +9,7 @@ import CreateDiscussion from "@/views/discussions/CreateDiscussion.vue"; import CallbackPage from "@/views/CallbackPage.vue"; import UserDiscussions from "@/views/discussions/UserDiscussions.vue"; import UserClasses from "@/views/classes/UserClasses.vue"; -import UserAssignments from "@/views/classes/UserAssignments.vue"; +import UserAssignments from "@/views/assignments/UserAssignments.vue"; import authState from "@/services/auth/auth-service.ts"; import LearningPathPage from "@/views/learning-paths/LearningPathPage.vue"; import LearningPathSearchPage from "@/views/learning-paths/LearningPathSearchPage.vue"; @@ -79,10 +79,20 @@ const router = createRouter({ meta: { requiresAuth: true }, }, { - path: "/assignment/:id", - name: "SingleAssigment", - component: SingleAssignment, - meta: { requiresAuth: true }, + path: "/assignment", + meta: {requiresAuth: true}, + children: [ + { + path: "create", + name: "CreateAssigment", + component: CreateAssignment, + }, + { + path: ":id", + name: "SingleAssigment", + component: SingleAssignment, + }, + ] }, { path: "/class/create", diff --git a/frontend/src/utils/assignmentForm.ts b/frontend/src/utils/assignmentForm.ts index d02ba4f2..da4d584f 100644 --- a/frontend/src/utils/assignmentForm.ts +++ b/frontend/src/utils/assignmentForm.ts @@ -1,42 +1,46 @@ + /** * Submits the form data to the backend. * * @param assignmentTitle - The title of the assignment. * @param selectedLearningPath - The selected learning path, containing hruid and title. - * @param selectedClasses - The selected classes, an array of class objects. + * @param selectedClass - The selected classes, an array of class objects. * @param groups - An array of groups, each containing student IDs. * @param deadline - The deadline of the assignment in ISO format. - * @param description - The description of the aasignment + * @param description - The description of the assignment * Sends a POST request to the backend with the form data. */ + +import {AssignmentController} from "@/controllers/assignments.ts"; +import type {AssignmentDTO} from "@dwengo-1/common/interfaces/assignment"; + export const submitForm = async ( assignmentTitle: string, selectedLearningPath: any, - selectedClasses: any[], + selectedClass: string, groups: string[][], deadline: string, - description: string + description: string, + currentLanguage: string ) => { - const formData = { + const formData: AssignmentDTO = { + id: 0, + class: selectedClass, title: assignmentTitle, - hruid: selectedLearningPath?.hruid, - classes: selectedClasses.map(cl => cl.value), - groups: groups, - deadline: deadline, - description: description + description: description, + learningPath: selectedLearningPath, + language: currentLanguage, + groups: [], + //deadline: deadline, }; - try { - const response = await fetch(/*"http://localhost:3000/api/assignment"*/"", { - method: "POST", - headers: { "Content-Type": "application/json" }, - body: JSON.stringify(formData) - }); - const data = await response.json(); - console.log("Form submitted successfully:", data); - } catch (error) { - console.error("Error submitting form:", error); - } + console.log(formData); + + const controller: AssignmentController = new AssignmentController(selectedClass); + + const response = await controller.createAssignment(formData); + console.log(response); + }; /** @@ -70,9 +74,9 @@ export const learningPathRules = [ * * Ensures that at least one class is selected. */ -export const classesRules = [ - (value: any[]) => { - if (value?.length >= 1) return true; +export const classRules = [ + (value: string) => { + if (value) return true; return 'You must select at least one class.'; }, ]; diff --git a/frontend/src/utils/tempData.ts b/frontend/src/utils/tempData.ts index 6a17b64c..d49c304e 100644 --- a/frontend/src/utils/tempData.ts +++ b/frontend/src/utils/tempData.ts @@ -29,7 +29,7 @@ const teacher02: Student = {username: "id12", firstName: "John", lastName: "Hiat const teacher03: Student = {username: "id13", firstName: "Aaron", lastName: "Lewis", classes: []}; const class01: Class = { - id: "class01", + id: "34d484a1-295f-4e9f-bfdc-3e7a23d86a89", displayName: "class 01", teachers: [teacher01], students: [student01, student02], diff --git a/frontend/src/views/assignments/CreateAssignment.vue b/frontend/src/views/assignments/CreateAssignment.vue index 336a6551..2e7865c7 100644 --- a/frontend/src/views/assignments/CreateAssignment.vue +++ b/frontend/src/views/assignments/CreateAssignment.vue @@ -5,7 +5,7 @@ import {classes} from "@/utils/tempData.ts"; import { assignmentTitleRules, - classesRules, + classRules, descriptionRules, learningPathRules, submitForm @@ -97,7 +97,7 @@ const { valid } = await form.value.validate(); // Don't submit thr form if all rules don't apply if (!valid) return; - submitForm(assignmentTitle.value, selectedLearningPath.value, selectedClass.value, groups.value, deadline.value, description.value); + submitForm(assignmentTitle.value, selectedLearningPath.value?.hruid, selectedClass.value.value, groups.value, deadline.value, description.value, locale.value); }; @@ -109,7 +109,7 @@ - @@ -136,7 +136,7 @@ v-model="selectedClass" :items="allClasses" :label="t('pick-class')" - :rules="classesRules" + :rules="classRules" variant="outlined" clearable hide-details diff --git a/frontend/src/views/assignments/UserAssignments.vue b/frontend/src/views/assignments/UserAssignments.vue index 38f567cc..2fa41e94 100644 --- a/frontend/src/views/assignments/UserAssignments.vue +++ b/frontend/src/views/assignments/UserAssignments.vue @@ -1,11 +1,11 @@