From 195e19259880b1f0e25c1d2069594042a7ff86c9 Mon Sep 17 00:00:00 2001 From: Joyelle Ndagijimana Date: Sun, 4 May 2025 13:26:19 +0200 Subject: [PATCH] feat: leerkracht kan progress van groepen zien --- frontend/src/components/GroupProgressRow.vue | 45 ++++++++++++ .../views/assignments/SingleAssignment.vue | 35 +++++----- .../views/assignments/StudentAssignment.vue | 8 +-- .../views/assignments/TeacherAssignment.vue | 70 ++++++++----------- 4 files changed, 96 insertions(+), 62 deletions(-) create mode 100644 frontend/src/components/GroupProgressRow.vue diff --git a/frontend/src/components/GroupProgressRow.vue b/frontend/src/components/GroupProgressRow.vue new file mode 100644 index 00000000..022e07c5 --- /dev/null +++ b/frontend/src/components/GroupProgressRow.vue @@ -0,0 +1,45 @@ + + + diff --git a/frontend/src/views/assignments/SingleAssignment.vue b/frontend/src/views/assignments/SingleAssignment.vue index 3d9f7f0a..cf7b48e6 100644 --- a/frontend/src/views/assignments/SingleAssignment.vue +++ b/frontend/src/views/assignments/SingleAssignment.vue @@ -19,35 +19,33 @@ function useGroupsWithProgress( groups: Ref, hruid: Ref, - language: Ref, - ): { groupProgressMap: Map } { - const groupProgressMap: Map = new Map(); + language: Ref, + ): { groupProgressMap: Map; } { + const groupProgressMap = ref(new Map()); watchEffect(() => { // Clear existing entries to avoid stale data - groupProgressMap.clear(); + groupProgressMap.value.clear(); - const lang = ref(language.value as Language); - - groups.value.forEach((group) => { + groups?.value.forEach((group) => { const groupKey = group.groupNumber; - const forGroup = ref({ - forGroup: groupKey, - assignmentNo: assignmentId, - classId: classId, - }); - - const query = useGetLearningPathQuery(hruid.value, lang, forGroup); + const query = useGetLearningPathQuery( + hruid, + language, + () => ({ + forGroup: groupKey, + assignmentNo: assignmentId.value, + classId: classId.value, + }) + ); const data = query.data.value; - groupProgressMap.set(groupKey, data ? calculateProgress(data) : 0); + groupProgressMap.value.set(groupKey, data ? calculateProgress(data) : 0); }); }); - return { - groupProgressMap, - }; + return { groupProgressMap: groupProgressMap.value }; } function calculateProgress(lp: LearningPath): number { @@ -59,7 +57,6 @@ diff --git a/frontend/src/views/assignments/StudentAssignment.vue b/frontend/src/views/assignments/StudentAssignment.vue index fb81a265..fdb33a82 100644 --- a/frontend/src/views/assignments/StudentAssignment.vue +++ b/frontend/src/views/assignments/StudentAssignment.vue @@ -22,8 +22,8 @@ ) => { groupProgressMap: Map }; }>(); - const { t, locale } = useI18n(); - const language = ref(locale.value as Language); + const { t } = useI18n(); + const lang = ref(); const learningPath = ref(); // Get the user's username/id const username = asyncComputed(async () => { @@ -38,7 +38,7 @@ const lpQueryResult = useGetLearningPathQuery( computed(() => assignmentQueryResult.data.value?.assignment?.learningPath ?? ""), - computed(() => language.value), + computed(() => assignmentQueryResult.data.value?.assignment?.language as Language), ); const groupsQueryResult = useGroupsQuery(props.classId, props.assignmentId, true); @@ -100,7 +100,7 @@ language > diff --git a/frontend/src/views/assignments/TeacherAssignment.vue b/frontend/src/views/assignments/TeacherAssignment.vue index e626a8be..9ea54cf4 100644 --- a/frontend/src/views/assignments/TeacherAssignment.vue +++ b/frontend/src/views/assignments/TeacherAssignment.vue @@ -1,5 +1,5 @@