feat: poging tot precomputen van check of leerobjecten vragen hebben
This commit is contained in:
parent
e07c206ef1
commit
103742db31
1 changed files with 26 additions and 3 deletions
|
@ -20,7 +20,7 @@
|
||||||
import type { QuestionData, QuestionDTO } from "@dwengo-1/common/interfaces/question";
|
import type { QuestionData, QuestionDTO } from "@dwengo-1/common/interfaces/question";
|
||||||
import {useStudentAssignmentsQuery, useStudentGroupsQuery} from "@/queries/students"
|
import {useStudentAssignmentsQuery, useStudentGroupsQuery} from "@/queries/students"
|
||||||
import type { AssignmentDTO } from "@dwengo-1/common/interfaces/assignment";
|
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 router = useRouter();
|
||||||
const route = useRoute();
|
const route = useRoute();
|
||||||
|
@ -192,9 +192,32 @@
|
||||||
} else {
|
} else {
|
||||||
alert("Please type a question before submitting.") // TODO: i18n
|
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>
|
</script>
|
||||||
|
|
||||||
<template>
|
<template>
|
||||||
|
@ -273,7 +296,7 @@
|
||||||
></v-icon>
|
></v-icon>
|
||||||
</template>
|
</template>
|
||||||
<template v-slot:append>
|
<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>
|
<div>{{ node.estimatedTime }}'</div>
|
||||||
</template>
|
</template>
|
||||||
</v-list-item>
|
</v-list-item>
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue