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 @@ >