diff --git a/kolibri/plugins/coach/assets/src/composables/useQuizCreation.js b/kolibri/plugins/coach/assets/src/composables/useQuizCreation.js index 31a6b05b95..91190f47ea 100644 --- a/kolibri/plugins/coach/assets/src/composables/useQuizCreation.js +++ b/kolibri/plugins/coach/assets/src/composables/useQuizCreation.js @@ -486,6 +486,7 @@ export default function useQuizCreation() { }); provide('saveQuiz', saveQuiz); + provide('allQuestionsInQuiz', allQuestionsInQuiz); provide('updateSection', updateSection); provide('handleReplacement', handleReplacement); provide('replaceSelectedQuestions', replaceSelectedQuestions); @@ -548,6 +549,7 @@ export default function useQuizCreation() { allSectionsEmpty, allQuestionsSelected, noQuestionsSelected, + allQuestionsInQuiz, }; /* @@ -562,6 +564,7 @@ export default function useQuizCreation() { export function injectQuizCreation() { const saveQuiz = inject('saveQuiz'); + const allQuestionsInQuiz = inject('allQuestionsInQuiz'); const updateSection = inject('updateSection'); const handleReplacement = inject('handleReplacement'); const replaceSelectedQuestions = inject('replaceSelectedQuestions'); @@ -611,6 +614,7 @@ export function injectQuizCreation() { // Computed allQuestionsSelected, + allQuestionsInQuiz, selectAllIsIndeterminate, channels, replacements, diff --git a/kolibri/plugins/coach/assets/src/views/plan/CreateExamPage/ResourceSelection.vue b/kolibri/plugins/coach/assets/src/views/plan/CreateExamPage/ResourceSelection.vue index 8e8a5598ef..c770819eab 100644 --- a/kolibri/plugins/coach/assets/src/views/plan/CreateExamPage/ResourceSelection.vue +++ b/kolibri/plugins/coach/assets/src/views/plan/CreateExamPage/ResourceSelection.vue @@ -68,7 +68,11 @@ @changeselectall="handleSelectAll" @change_content_card="toggleSelected" @moreresults="fetchMoreResources" - /> + > + +
@@ -146,7 +150,12 @@ // to be added to Quiz Section. const showBookmarks = computed(() => route.value.query.showBookmarks); const searchQuery = computed(() => route.value.query.search); - const { updateSection, activeResourcePool, selectAllQuestions } = injectQuizCreation(); + const { + updateSection, + activeResourcePool, + selectAllQuestions, + allQuestionsInQuiz, + } = injectQuizCreation(); const showCloseConfirmation = ref(false); const prevRoute = ref({ name: PageNames.EXAM_CREATION_ROOT }); @@ -451,6 +460,7 @@ }); return { + allQuestionsInQuiz, selectAllChecked, selectAllIndeterminate, showSelectAll, @@ -541,6 +551,27 @@ } }, methods: { + cardNoticeContent(content) { + if (content.kind === ContentNodeKinds.EXERCISE) { + const questionCount = content.assessmentmetadata.assessment_item_ids.length; + const questionItems = content.assessmentmetadata.assessment_item_ids.map( + aid => `${content.id}:${aid}` + ); + const questionsItemsAlreadyUsed = this.allQuestionsInQuiz + .map(q => q.item) + .filter(i => questionItems.includes(i)); + const questionItemsAvailable = questionItems.length - questionsItemsAlreadyUsed.length; + + if (questionsItemsAlreadyUsed.length) { + return `${questionItemsAvailable} of ${questionCount} questions available, + ${questionsItemsAlreadyUsed.length} questions are used in other sections`; + } else { + return `${questionCount} questions`; + } + } else { + return ''; + } + }, showTopicSizeWarningCard(content) { return !this.hasCheckbox(content) && content.kind === ContentNodeKinds.TOPIC; }, @@ -598,6 +629,7 @@ }); this.$store.dispatch('createSnackbar', this.changesSavedSuccessfully$()); }, + // The message put onto the content's card when listed selectionMetadata(content) { if (content.kind === ContentNodeKinds.TOPIC) { const total = content.num_exercises; @@ -612,8 +644,9 @@ count: numberOfresourcesSelected, total: total, }); + } else { + // content is an exercise } - return ''; }, handleSearchTermChange(searchTerm) { const query = {