diff --git a/frontend/src/views/assignments/CreateAssignment.vue b/frontend/src/views/assignments/CreateAssignment.vue index 8a5e8b9a..1324fec5 100644 --- a/frontend/src/views/assignments/CreateAssignment.vue +++ b/frontend/src/views/assignments/CreateAssignment.vue @@ -12,13 +12,21 @@ import UsingQueryResult from "@/components/UsingQueryResult.vue"; import type {LearningPath} from "@/data-objects/learning-paths/learning-path.ts"; import type {ClassesResponse} from "@/controllers/classes.ts"; import type {AssignmentDTO} from "@dwengo-1/common/interfaces/assignment"; -import {AssignmentController} from "@/controllers/assignments.ts"; import {useCreateAssignmentMutation} from "@/queries/assignments.ts"; +import {useRoute} from "vue-router"; /*** - TODO: when clicking the assign button from lp page pass the lp-object in a state: + TODO: when clicking the assign button from lp page pass the lp-hruid in a query like this: + router.push({ + path: "/assignment/create, + query: { + ...route.query, + lp: hruid, + }, + }); */ +const route = useRoute(); const router = useRouter(); const {t, locale} = useI18n(); const role = ref(auth.authState.activeRole); @@ -48,10 +56,10 @@ const classesQueryResults = useTeacherClassesQuery(username, true); const selectedClass = ref(undefined); const assignmentTitle = ref(''); -const selectedLearningPath = ref(window.history.state?.learningPath ?? null); +const selectedLearningPath = ref(route.query.lp || undefined); // Disable combobox when learningPath prop is passed -const lpIsSelected = window.history.state?.learningPath !== undefined; +const lpIsSelected = route.query.lp !== undefined; const deadline = ref(null); const description = ref(''); const groups = ref([]); diff --git a/frontend/src/views/assignments/StudentAssignment.vue b/frontend/src/views/assignments/StudentAssignment.vue index 0750ed48..b38473b4 100644 --- a/frontend/src/views/assignments/StudentAssignment.vue +++ b/frontend/src/views/assignments/StudentAssignment.vue @@ -8,6 +8,8 @@ import type {AssignmentResponse} from "@/controllers/assignments.ts"; import {asyncComputed} from "@vueuse/core"; import {useStudentsByUsernamesQuery} from "@/queries/students.ts"; import {useGroupsQuery} from "@/queries/groups.ts"; +import {useGetLearningPathQuery} from "@/queries/learning-paths.ts"; +import type {Language} from "@/data-objects/language.ts"; const props = defineProps<{ classId: string @@ -25,16 +27,16 @@ const username = asyncComputed(async () => { const assignmentQueryResult = useAssignmentQuery(() => props.classId, props.assignmentId); const submitted = ref(false);//TODO: update by fetching submissions and check if group submitted +const lpQueryResult = useGetLearningPathQuery( + computed(() => assignmentQueryResult.data.value?.assignment?.learningPath ?? ""), + computed(() => language.value as Language) +); + const groupsQueryResult = useGroupsQuery(props.classId, props.assignmentId, true); const group = computed(() => - groupsQueryResult?.data.value?.groups.find(group => - group.members?.some(m => m.username === username.value) - ) - /** For testing - return {assignment: 1, - groupNumber: 1, - members: ["testleerling1"]} - */ + groupsQueryResult?.data.value?.groups.find(group => + group.members?.some(m => m.username === username.value) + ) ); // Assuming group.value.members is a list of usernames TODO: case when it's StudentDTO's @@ -70,13 +72,18 @@ const studentQueries = useStudentsByUsernamesQuery(() => group.value?.members as {{ data.assignment.title }} - - {{ t("learning-path") }} - + + {{ t("learning-path") }} + + diff --git a/frontend/src/views/assignments/TeacherAssignment.vue b/frontend/src/views/assignments/TeacherAssignment.vue index 14c0568a..3010ba0c 100644 --- a/frontend/src/views/assignments/TeacherAssignment.vue +++ b/frontend/src/views/assignments/TeacherAssignment.vue @@ -1,13 +1,15 @@ @@ -80,7 +140,7 @@ async function deleteAssignment(): Promise { icon variant="text" class="top-right-btn" - @click="deleteAssignment" + @click="deleteAssignment(data.assignment.id, data.assignment.within)" > mdi-delete @@ -92,7 +152,7 @@ async function deleteAssignment(): Promise { v-slot="{ data: lpData }" > diff --git a/frontend/src/views/assignments/UserAssignments.vue b/frontend/src/views/assignments/UserAssignments.vue index c81d96cf..8559aaac 100644 --- a/frontend/src/views/assignments/UserAssignments.vue +++ b/frontend/src/views/assignments/UserAssignments.vue @@ -8,7 +8,7 @@ import {useStudentClassesQuery} from "@/queries/students.ts"; import {ClassController} from "@/controllers/classes.ts"; import type {ClassDTO} from "@dwengo-1/common/interfaces/class"; import {asyncComputed} from "@vueuse/core"; -import {AssignmentController} from "@/controllers/assignments.ts"; +import {useDeleteAssignmentMutation} from "@/queries/assignments.ts"; const {t} = useI18n(); const router = useRouter(); @@ -62,11 +62,15 @@ async function goToAssignmentDetails(id: number, clsId: string): Promise { await router.push(`/assignment/${clsId}/${id}`); } +const {mutate, isSuccess} = useDeleteAssignmentMutation(); -async function goToDeleteAssignment(id: number, clsId: string): Promise { - //TODO: replace with query - const controller = new AssignmentController(clsId); - await controller.deleteAssignment(id); +async function goToDeleteAssignment(num: number, clsId: string): Promise { + mutate({ + cid: clsId, + an: num + }); + + if (isSuccess) await router.push("/user/assignment"); } onMounted(async () => {