From 103742db3190d3a5e2ec63248f47ea76d28232cb Mon Sep 17 00:00:00 2001 From: Timo De Meyst Date: Thu, 24 Apr 2025 19:36:48 +0200 Subject: [PATCH] feat: poging tot precomputen van check of leerobjecten vragen hebben --- .../views/learning-paths/LearningPathPage.vue | 29 +++++++++++++++++-- 1 file changed, 26 insertions(+), 3 deletions(-) diff --git a/frontend/src/views/learning-paths/LearningPathPage.vue b/frontend/src/views/learning-paths/LearningPathPage.vue index 94ac74fd..d5308b12 100644 --- a/frontend/src/views/learning-paths/LearningPathPage.vue +++ b/frontend/src/views/learning-paths/LearningPathPage.vue @@ -20,7 +20,7 @@ import type { QuestionData, QuestionDTO } from "@dwengo-1/common/interfaces/question"; import {useStudentAssignmentsQuery, useStudentGroupsQuery} from "@/queries/students" import type { AssignmentDTO } from "@dwengo-1/common/interfaces/assignment"; - import type { GroupDTO } from "@dwengo-1/common/interfaces/group"; +import type { GroupDTO } from "@dwengo-1/common/interfaces/group"; const router = useRouter(); const route = useRoute(); @@ -192,8 +192,31 @@ } else { alert("Please type a question before submitting.") // TODO: i18n } - } + + const learningObjectHasQuestions = computed(() => { + const result = new Map(); + const learningObjects = learningObjectListQueryResult.data?.value ?? []; + + learningObjects.forEach((learningObject) => { + const nodeLoId: LearningObjectIdentifierDTO = { + hruid: learningObject.key, + language: learningObject.language, + version: learningObject.version + }; + + // Check if the learning object has questions + const questions = useQuestionsQuery(nodeLoId).data.value?.questions as QuestionDTO[] || []; + result.set(learningObject.key, questions.length > 0); + }); + + return result; + }); + +// Helper function to check if a learning object has questions +function hasQuestions(learningObjectKey: string): boolean { + return learningObjectHasQuestions.value.get(learningObjectKey) ?? false; +} @@ -273,7 +296,7 @@ >