From 20173169b749f9cfd577a4bb7af771f21c6a469f Mon Sep 17 00:00:00 2001 From: laurejablonski Date: Sun, 4 May 2025 10:25:02 +0200 Subject: [PATCH] feat: edit assignments --- frontend/src/assets/assignment.css | 18 +- .../views/assignments/TeacherAssignment.vue | 483 ++++++++++++------ 2 files changed, 331 insertions(+), 170 deletions(-) diff --git a/frontend/src/assets/assignment.css b/frontend/src/assets/assignment.css index 029dec22..35e50792 100644 --- a/frontend/src/assets/assignment.css +++ b/frontend/src/assets/assignment.css @@ -18,12 +18,22 @@ font-size: 1.1rem; } -.top-right-btn { - position: absolute; - right: 2%; - color: red; +.top-buttons-wrapper { + display: flex; + justify-content: space-between; + align-items: center; + padding: 1rem; + position: relative; } +.right-buttons { + display: flex; + gap: 0.5rem; + align-items: center; + color: #0e6942 +} + + .group-section { margin-top: 2rem; } diff --git a/frontend/src/views/assignments/TeacherAssignment.vue b/frontend/src/views/assignments/TeacherAssignment.vue index caec311c..04fea1a6 100644 --- a/frontend/src/views/assignments/TeacherAssignment.vue +++ b/frontend/src/views/assignments/TeacherAssignment.vue @@ -4,12 +4,12 @@ import { useAssignmentQuery, useDeleteAssignmentMutation } from "@/queries/assignments.ts"; import UsingQueryResult from "@/components/UsingQueryResult.vue"; import { useGroupsQuery } from "@/queries/groups.ts"; - import { useGetLearningPathQuery } from "@/queries/learning-paths.ts"; + import { useGetAllLearningPaths, useGetLearningPathQuery } from "@/queries/learning-paths.ts"; import type { Language } from "@/data-objects/language.ts"; import type { AssignmentResponse } from "@/controllers/assignments.ts"; import type { GroupDTO } from "@dwengo-1/common/interfaces/group"; -import type { AssignmentDTO } from "@dwengo-1/common/interfaces/assignment"; -import type { StudentDTO } from "@dwengo-1/common/interfaces/student"; + import type { StudentDTO } from "@dwengo-1/common/interfaces/student"; + import type { LearningPath } from "@/data-objects/learning-paths/learning-path"; const props = defineProps<{ classId: string; @@ -21,19 +21,43 @@ import type { StudentDTO } from "@dwengo-1/common/interfaces/student"; ) => { groupProgressMap: Map }; }>(); + const isEditing = ref(false); + const { t, locale } = useI18n(); const language = computed(() => locale.value); const groups = ref(); const learningPath = ref(); + const editingLearningPath = ref(learningPath); + const description = ref(""); const assignmentQueryResult = useAssignmentQuery(props.classId, props.assignmentId); learningPath.value = assignmentQueryResult.data.value?.assignment?.learningPath; + const learningPathsQueryResults = useGetAllLearningPaths(language); + // Get learning path object const lpQueryResult = useGetLearningPathQuery( computed(() => assignmentQueryResult.data.value?.assignment?.learningPath ?? ""), computed(() => language.value as Language), ); + const learningPathRules = [ + (value: { hruid: string; title: string }): string | boolean => { + if (value && value.hruid) { + return true; // Valid if hruid is present + } + return "You must select a learning path."; + }, + ]; + + const descriptionRules = [ + (value: string): string | boolean => { + if (!value || value.trim() === "") { + return "Description cannot be empty."; + } + return true; + }, + ]; + // Get all the groups withing the assignment const groupsQueryResult = useGroupsQuery(props.classId, props.assignmentId, true); groups.value = groupsQueryResult.data.value?.groups; @@ -84,6 +108,13 @@ Const {groupProgressMap} = props.useGroupsWithProgress( }, ); } + + function saveChanges() { + //TODO + const new_learningpath = editingLearningPath.value; + const new_description = description.value; + isEditing.value = false; + }