feat: checken of leerpaden assignments zijn

This commit is contained in:
Timo De Meyst 2025-04-21 21:51:54 +02:00
parent fb02300274
commit ad63cde3b4

View file

@ -12,6 +12,9 @@
import UsingQueryResult from "@/components/UsingQueryResult.vue"; import UsingQueryResult from "@/components/UsingQueryResult.vue";
import authService from "@/services/auth/auth-service.ts"; import authService from "@/services/auth/auth-service.ts";
import { LearningPathNode } from "@/data-objects/learning-paths/learning-path-node.ts"; import { LearningPathNode } from "@/data-objects/learning-paths/learning-path-node.ts";
import { useStudentAssignmentsQuery } from "@/queries/students";
import type { AssignmentDTO } from "@dwengo-1/common/interfaces/assignment";
import { watch } from "vue";
const route = useRoute(); const route = useRoute();
const { t } = useI18n(); const { t } = useI18n();
@ -98,6 +101,43 @@
} }
return "notCompleted"; return "notCompleted";
} }
//TODO: berekenen of het een assignment is voor de student werkt nog niet zoals het hoort...
const studentAssignmentsQuery = useStudentAssignmentsQuery(authService.authState.user?.profile?.preferred_username);
watch(
() => authService.authState.user?.profile?.preferred_username,
(newUsername) => {
if (newUsername) {
studentAssignmentsQuery.refetch();
}
}
);
const isAssignmentForStudent = computed(() => {
// Check if the user is a student
const isStudent = authService.authState.activeRole === "student";
if (isStudent && studentAssignmentsQuery.isSuccess) {
// Use the query to fetch assignments for the current student
console.log("Query Result:", studentAssignmentsQuery.data?.value);
// Check if the query is successful and contains the current learning path
const isAssignment = (studentAssignmentsQuery.data?.value?.assignments as AssignmentDTO[]).some(
(assignment: AssignmentDTO) => {
console.log(assignment.learningPath)
return assignment.learningPath === props.hruid
}
);
// Return true only if the user is a student and the learning path is an assignment
return isAssignment;
}
return false;
});
</script> </script>
<template> <template>
@ -169,7 +209,7 @@
</using-query-result> </using-query-result>
</div> </div>
<v-divider></v-divider> <v-divider></v-divider>
<div v-if="true" class="assignment-indicator"> <div v-if="isAssignmentForStudent" class="assignment-indicator">
ASSIGNMENT ASSIGNMENT
</div> </div>
</v-navigation-drawer> </v-navigation-drawer>