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 01a9843eb0..0ab153626f 100644 --- a/kolibri/plugins/coach/assets/src/views/plan/CreateExamPage/ResourceSelection.vue +++ b/kolibri/plugins/coach/assets/src/views/plan/CreateExamPage/ResourceSelection.vue @@ -111,9 +111,16 @@ marginTop: '2em', marginBottom: '2em', backgroundColor: $themePalette.grey.v_100, + position: 'sticky', + insetBlockStart: '0', + zIndex: '4', }" > - {{ cannotSelectSomeTopicWarning$({ count: maxSectionQuestionOptions }) }} + {{ + cannotSelectSomeTopicWarning$({ + count: Math.max(maxSectionQuestionOptions, workingPoolUnusedQuestions), + }) + }} - + {{ tooManyQuestions$({ count: maxSectionQuestionOptions, @@ -663,7 +673,7 @@ } const workingPoolHasChanged = computed(() => { - return workingResourcePool.value.length; + return Boolean(workingResourcePool.value.length); }); const workingPoolUnusedQuestions = computed(() => { @@ -672,6 +682,16 @@ }, 0); }); + const tooManyQuestions = computed(() => { + // Always allow one resource to be selected, just in case + // the exercise a user wants to use exceeds the maxSectionQuestionOptions + // with only its own unused questions. + return ( + workingResourcePool.value.length !== 1 && + workingPoolUnusedQuestions.value > maxSectionQuestionOptions.value + ); + }); + const disableSave = computed(() => { if (selectPracticeQuiz.value) { return !workingPoolHasChanged.value; @@ -680,7 +700,7 @@ !workingPoolHasChanged.value || workingPoolUnusedQuestions.value < questionCount.value || questionCount.value < 1 || - workingPoolUnusedQuestions.value > maxSectionQuestionOptions.value + tooManyQuestions.value ); }); @@ -709,6 +729,7 @@ handleSelectAll, toggleSelected, workingPoolHasChanged, + tooManyQuestions, handleConfirmClose, handleCancelClose, topic,