feat: poging tot precomputen van check of leerobjecten vragen hebben

This commit is contained in:
Timo De Meyst 2025-04-24 19:36:48 +02:00
parent e07c206ef1
commit 103742db31

View file

@ -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,9 +192,32 @@
} else {
alert("Please type a question before submitting.") // TODO: i18n
}
}
const learningObjectHasQuestions = computed(() => {
const result = new Map<string, boolean>();
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;
}
</script>
<template>
@ -273,7 +296,7 @@
></v-icon>
</template>
<template v-slot:append>
<v-icon v-if="false" icon="mdi-help-circle-outline" color="red" />
<v-icon v-if="hasQuestions(node.key)" icon="mdi-help-circle-outline" color="red" />
<div>{{ node.estimatedTime }}'</div>
</template>
</v-list-item>