From dfeea15c90aef709c43b818183bc0029bd0f971d Mon Sep 17 00:00:00 2001 From: Jacob Pierce Date: Fri, 23 Feb 2024 12:54:07 -0800 Subject: [PATCH 01/67] questions are replaced successfully & select all logic fixed --- .../assets/src/composables/useQuizCreation.js | 29 ++- .../plan/CreateExamPage/ReplaceQuestions.vue | 234 +++++++++++++++++- 2 files changed, 247 insertions(+), 16 deletions(-) diff --git a/kolibri/plugins/coach/assets/src/composables/useQuizCreation.js b/kolibri/plugins/coach/assets/src/composables/useQuizCreation.js index 7ee8fdd9fae..7bd4aa8ca94 100644 --- a/kolibri/plugins/coach/assets/src/composables/useQuizCreation.js +++ b/kolibri/plugins/coach/assets/src/composables/useQuizCreation.js @@ -356,9 +356,13 @@ export default function useQuizCreation(DEBUG = false) { } } + function clearSelectedQuestions() { + set(_selectedQuestionIds, []); + } + function selectAllQuestions() { if (get(allQuestionsSelected)) { - set(_selectedQuestionIds, []); + clearSelectedQuestions(); } else { set( _selectedQuestionIds, @@ -431,11 +435,14 @@ export default function useQuizCreation(DEBUG = false) { /** @type {ComputedRef} Whether all active questions are selected */ const allQuestionsSelected = computed(() => { - return isEqual( - get(selectedActiveQuestions).sort(), - get(activeQuestions) - .map(q => q.question_id) - .sort() + return ( + get(selectedActiveQuestions).length && + isEqual( + get(selectedActiveQuestions).sort(), + get(activeQuestions) + .map(q => q.question_id) + .sort() + ) ); }); @@ -478,6 +485,7 @@ export default function useQuizCreation(DEBUG = false) { provide('updateQuiz', updateQuiz); provide('addQuestionToSelection', addQuestionToSelection); provide('removeQuestionFromSelection', removeQuestionFromSelection); + provide('clearSelectedQuestions', clearSelectedQuestions); provide('channels', channels); provide('quiz', quiz); provide('allSections', allSections); @@ -488,6 +496,8 @@ export default function useQuizCreation(DEBUG = false) { provide('activeQuestionsPool', activeQuestionsPool); provide('activeQuestions', activeQuestions); provide('selectedActiveQuestions', selectedActiveQuestions); + provide('allQuestionsSelected', allQuestionsSelected); + provide('selectAllIsIndeterminate', selectAllIsIndeterminate); provide('replacementQuestionPool', replacementQuestionPool); provide('selectAllQuestions', selectAllQuestions); provide('deleteActiveSelectedQuestions', deleteActiveSelectedQuestions); @@ -503,6 +513,7 @@ export default function useQuizCreation(DEBUG = false) { setActiveSection, initializeQuiz, updateQuiz, + clearSelectedQuestions, addQuestionToSelection, removeQuestionFromSelection, @@ -545,6 +556,7 @@ export function injectQuizCreation() { const updateQuiz = inject('updateQuiz'); const addQuestionToSelection = inject('addQuestionToSelection'); const removeQuestionFromSelection = inject('removeQuestionFromSelection'); + const clearSelectedQuestions = inject('clearSelectedQuestions'); const channels = inject('channels'); const quiz = inject('quiz'); const allSections = inject('allSections'); @@ -554,6 +566,8 @@ export function injectQuizCreation() { const activeResourceMap = inject('activeResourceMap'); const activeQuestionsPool = inject('activeQuestionsPool'); const activeQuestions = inject('activeQuestions'); + const allQuestionsSelected = inject('allQuestionsSelected'); + const selectAllIsIndeterminate = inject('selectAllIsIndeterminate'); const selectedActiveQuestions = inject('selectedActiveQuestions'); const replacementQuestionPool = inject('replacementQuestionPool'); const selectAllQuestions = inject('selectAllQuestions'); @@ -572,11 +586,14 @@ export function injectQuizCreation() { setActiveSection, initializeQuiz, updateQuiz, + clearSelectedQuestions, addQuestionToSelection, removeQuestionFromSelection, toggleQuestionInSelection, // Computed + allQuestionsSelected, + selectAllIsIndeterminate, channels, quiz, allSections, diff --git a/kolibri/plugins/coach/assets/src/views/plan/CreateExamPage/ReplaceQuestions.vue b/kolibri/plugins/coach/assets/src/views/plan/CreateExamPage/ReplaceQuestions.vue index 84aa74a48c8..39c349a38bc 100644 --- a/kolibri/plugins/coach/assets/src/views/plan/CreateExamPage/ReplaceQuestions.vue +++ b/kolibri/plugins/coach/assets/src/views/plan/CreateExamPage/ReplaceQuestions.vue @@ -1,15 +1,124 @@ @@ -17,19 +126,124 @@ From 229d8c21fc72ae1b52752a4642048627352b5ef0 Mon Sep 17 00:00:00 2001 From: Jacob Pierce Date: Sun, 25 Feb 2024 21:42:33 -0800 Subject: [PATCH 02/67] fix checkbox logic on replacement list --- .../views/plan/CreateExamPage/ReplaceQuestions.vue | 12 +++++++++--- 1 file changed, 9 insertions(+), 3 deletions(-) diff --git a/kolibri/plugins/coach/assets/src/views/plan/CreateExamPage/ReplaceQuestions.vue b/kolibri/plugins/coach/assets/src/views/plan/CreateExamPage/ReplaceQuestions.vue index 39c349a38bc..a3445fda6a4 100644 --- a/kolibri/plugins/coach/assets/src/views/plan/CreateExamPage/ReplaceQuestions.vue +++ b/kolibri/plugins/coach/assets/src/views/plan/CreateExamPage/ReplaceQuestions.vue @@ -28,7 +28,7 @@ ref="selectAllCheckbox" class="select-all-box" :label="selectAllLabel$()" - :checked="replacements.length === replacementQuestionPool.length" + :checked="replacements.length && replacements.length === selectedActiveQuestions.length" :indeterminate="selectAllIsIndeterminate" @change="() => selectAllQuestions()" /> @@ -127,7 +127,7 @@ + + + From 1dab3c1f1aed76dc7e1931003c6963455aace377 Mon Sep 17 00:00:00 2001 From: Jacob Pierce Date: Thu, 29 Feb 2024 13:36:25 -0800 Subject: [PATCH 14/67] align "Add section" button --- .../views/plan/CreateExamPage/CreateQuizSection.vue | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/kolibri/plugins/coach/assets/src/views/plan/CreateExamPage/CreateQuizSection.vue b/kolibri/plugins/coach/assets/src/views/plan/CreateExamPage/CreateQuizSection.vue index 522fbec9d1d..bcce3df78a9 100644 --- a/kolibri/plugins/coach/assets/src/views/plan/CreateExamPage/CreateQuizSection.vue +++ b/kolibri/plugins/coach/assets/src/views/plan/CreateExamPage/CreateQuizSection.vue @@ -35,8 +35,8 @@ {{ addSectionLabel$() }} From c784ee233fd5cd7e48d5424a00faf1ac13ff0bd7 Mon Sep 17 00:00:00 2001 From: Jacob Pierce Date: Thu, 29 Feb 2024 15:24:52 -0800 Subject: [PATCH 15/67] misc style updates, fix duplicate back arrow in side panel --- .../plan/CreateExamPage/ResourceSelection.vue | 27 +++---------------- .../plan/CreateExamPage/SectionEditor.vue | 5 +--- 2 files changed, 4 insertions(+), 28 deletions(-) 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 16e2fe8a3b7..b680cf38406 100644 --- a/kolibri/plugins/coach/assets/src/views/plan/CreateExamPage/ResourceSelection.vue +++ b/kolibri/plugins/coach/assets/src/views/plan/CreateExamPage/ResourceSelection.vue @@ -5,26 +5,9 @@
- - - - - - -
- {{ selectFoldersOrExercises$() }} -
-
-
+
+ {{ selectFoldersOrExercises$() }} +
@@ -560,9 +543,6 @@ focusFirstEl() { this.$refs.textbox.focus(); }, - goBack() { - return this.$router.go(-1); - }, contentLink(content) { if (this.showBookmarks) { return this.$route; @@ -636,7 +616,6 @@ .select-resource { padding-bottom: 6em; - margin-top: -4em; } .title-style { diff --git a/kolibri/plugins/coach/assets/src/views/plan/CreateExamPage/SectionEditor.vue b/kolibri/plugins/coach/assets/src/views/plan/CreateExamPage/SectionEditor.vue index b9373a129d4..bbe4d18dd4d 100644 --- a/kolibri/plugins/coach/assets/src/views/plan/CreateExamPage/SectionEditor.vue +++ b/kolibri/plugins/coach/assets/src/views/plan/CreateExamPage/SectionEditor.vue @@ -415,6 +415,7 @@ } .section-settings-top-heading { + margin-top: 0; margin-bottom: 0.5em; font-size: 18px; font-weight: 600; @@ -492,8 +493,4 @@ text-align: right; } - .section-settings-content { - margin-top: -50px; - } - From d67e319fe7005219ea2025c3dfd3cd6fb8ff1a32 Mon Sep 17 00:00:00 2001 From: Jacob Pierce Date: Sat, 2 Mar 2024 21:20:55 -0800 Subject: [PATCH 16/67] fix delete section in section editor; add --- .../plan/CreateExamPage/SectionEditor.vue | 37 +++++++++++++++---- 1 file changed, 30 insertions(+), 7 deletions(-) diff --git a/kolibri/plugins/coach/assets/src/views/plan/CreateExamPage/SectionEditor.vue b/kolibri/plugins/coach/assets/src/views/plan/CreateExamPage/SectionEditor.vue index bbe4d18dd4d..aa5976ff408 100644 --- a/kolibri/plugins/coach/assets/src/views/plan/CreateExamPage/SectionEditor.vue +++ b/kolibri/plugins/coach/assets/src/views/plan/CreateExamPage/SectionEditor.vue @@ -197,7 +197,7 @@ >
+
@@ -251,19 +256,34 @@ allSections, updateSection, updateQuiz, - deleteSection, + removeSection, } = injectQuizCreation(); - const showConfirmationModal = ref(false); + const showCloseConfirmation = ref(false); function handleCancelClose() { - showConfirmationModal.value = false; + showCloseConfirmation.value = false; } function handleConfirmClose() { context.emit('closePanel'); } + const showDeleteConfirmation = ref(false); + + function handleCancelDelete() { + showDeleteConfirmation.value = false; + } + + function handleConfirmDelete() { + context.emit('closePanel'); + removeSection(showDeleteConfirmation.value); + } + + function handleDeleteSection(section_id) { + showDeleteConfirmation.value = section_id; + } + /* Note that the use of snake_case here is to map directly to the API */ const learners_see_fixed_order = ref(activeSection.value.learners_see_fixed_order); const question_count = ref(activeSection.value.question_count); @@ -310,15 +330,18 @@ return { formDataHasChanged, - showConfirmationModal, + showCloseConfirmation, + showDeleteConfirmation, handleCancelClose, handleConfirmClose, + handleCancelDelete, + handleConfirmDelete, // useQuizCreation activeSection, allSections, updateSection, updateQuiz, - deleteSection, + handleDeleteSection, // Form models learners_see_fixed_order, question_count, From 6cb417d4369e3e482e191fd938ca8b41d15bb571 Mon Sep 17 00:00:00 2001 From: Jacob Pierce Date: Sat, 2 Mar 2024 21:33:01 -0800 Subject: [PATCH 17/67] update & clean-up strings; replace ConfirmCancellationModal w/ KModals --- .../ConfirmCancellationModal.vue | 61 ----------------- .../plan/CreateExamPage/ReplaceQuestions.vue | 34 ++++++---- .../plan/CreateExamPage/ResourceSelection.vue | 25 +++---- .../plan/CreateExamPage/SectionEditor.vue | 50 +++++++------- .../plan/CreateExamPage/SectionSidePanel.vue | 66 ++++++++++--------- .../strings/enhancedQuizManagementStrings.js | 16 +++++ 6 files changed, 115 insertions(+), 137 deletions(-) delete mode 100644 kolibri/plugins/coach/assets/src/views/plan/CreateExamPage/ConfirmCancellationModal.vue diff --git a/kolibri/plugins/coach/assets/src/views/plan/CreateExamPage/ConfirmCancellationModal.vue b/kolibri/plugins/coach/assets/src/views/plan/CreateExamPage/ConfirmCancellationModal.vue deleted file mode 100644 index e60e3640bb0..00000000000 --- a/kolibri/plugins/coach/assets/src/views/plan/CreateExamPage/ConfirmCancellationModal.vue +++ /dev/null @@ -1,61 +0,0 @@ - - - - diff --git a/kolibri/plugins/coach/assets/src/views/plan/CreateExamPage/ReplaceQuestions.vue b/kolibri/plugins/coach/assets/src/views/plan/CreateExamPage/ReplaceQuestions.vue index 9eaa37e0a05..b7ef1dfac4c 100644 --- a/kolibri/plugins/coach/assets/src/views/plan/CreateExamPage/ReplaceQuestions.vue +++ b/kolibri/plugins/coach/assets/src/views/plan/CreateExamPage/ReplaceQuestions.vue @@ -125,11 +125,16 @@
- + @submit="handleConfirmClose" + > + {{ closeConfirmationMessage$() }} + @@ -140,24 +145,26 @@ import { enhancedQuizManagementStrings } from 'kolibri-common/strings/enhancedQuizManagementStrings'; import { computed, ref } from 'kolibri.lib.vueCompositionApi'; import { get } from '@vueuse/core'; + import commonCoreStrings from 'kolibri.coreVue.mixins.commonCoreStrings'; import { injectQuizCreation } from '../../../composables/useQuizCreation'; import AccordionItem from './AccordionItem'; import AccordionContainer from './AccordionContainer'; - import ConfirmCancellationModal from './ConfirmCancellationModal'; export default { name: 'ReplaceQuestions', components: { AccordionContainer, AccordionItem, - ConfirmCancellationModal, }, + mixins: [commonCoreStrings], setup(_, context) { const { replaceQuestions$, deleteSectionLabel$, replaceAction$, selectAllLabel$, + closeConfirmationMessage$, + closeConfirmationTitle$, replaceQuestionsExplaination$, numberOfSelectedReplacements$, } = enhancedQuizManagementStrings; @@ -177,10 +184,10 @@ updateSection, } = injectQuizCreation(); - const showConfirmationModal = ref(false); + const showCloseConfirmation = ref(false); function handleCancelClose() { - showConfirmationModal.value = false; + showCloseConfirmation.value = false; } function handleConfirmClose() { @@ -230,8 +237,8 @@ selectAllIsIndeterminate, replaceSelectedQuestions, activeResourceMap, + showCloseConfirmation, - showConfirmationModal, handleCancelClose, handleConfirmClose, clearSelectedQuestions, @@ -245,6 +252,8 @@ selectAllLabel$, replaceQuestionsExplaination$, numberOfSelectedReplacements$, + closeConfirmationMessage$, + closeConfirmationTitle$, }; }, computed: { @@ -258,8 +267,11 @@ }, }, beforeRouteLeave(_, __, next) { - if (!this.showConfirmationModal && this.formDataHasChanged) { - this.showConfirmationModal = true; + if ( + !this.showCloseConfirmation && + this.replacements.length !== this.selectedActiveQuestions.length + ) { + this.showCloseConfirmation = true; next(false); } else { next(); 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 b680cf38406..382353f249b 100644 --- a/kolibri/plugins/coach/assets/src/views/plan/CreateExamPage/ResourceSelection.vue +++ b/kolibri/plugins/coach/assets/src/views/plan/CreateExamPage/ResourceSelection.vue @@ -95,11 +95,16 @@ - + @submit="handleConfirmClose" + > + yes? + @@ -121,7 +126,6 @@ import { injectQuizCreation } from '../../../composables/useQuizCreation'; import LessonsSearchBox from '../LessonResourceSelectionPage/SearchTools/LessonsSearchBox.vue'; import ContentCardList from './../LessonResourceSelectionPage/ContentCardList.vue'; - import ConfirmCancellationModal from './ConfirmCancellationModal.vue'; import ResourceSelectionBreadcrumbs from './../LessonResourceSelectionPage/SearchTools/ResourceSelectionBreadcrumbs.vue'; export default { @@ -131,7 +135,6 @@ BookmarkIcon, LessonsSearchBox, ResourceSelectionBreadcrumbs, - ConfirmCancellationModal, }, mixins: [commonCoreStrings], setup(_, context) { @@ -144,7 +147,7 @@ const showBookmarks = computed(() => route.value.query.showBookmarks); const searchQuery = computed(() => route.value.query.search); const { updateSection, activeResourcePool, selectAllQuestions } = injectQuizCreation(); - const showConfirmationModal = ref(false); + const showCloseConfirmation = ref(false); const prevRoute = ref({ name: PageNames.EXAM_CREATION_ROOT }); @@ -431,7 +434,7 @@ } function handleCancelClose() { - showConfirmationModal.value = false; + showCloseConfirmation.value = false; } function handleConfirmClose() { @@ -459,7 +462,7 @@ topicId, contentList, resources, - showConfirmationModal, + showCloseConfirmation, hasCheckbox, loading, hasMore, @@ -525,8 +528,8 @@ }); }, beforeRouteLeave(_, __, next) { - if (!this.showConfirmationModal && this.workingPoolHasChanged) { - this.showConfirmationModal = true; + if (!this.showCloseConfirmation && this.workingPoolHasChanged) { + this.showCloseConfirmation = true; next(false); } else { next(); diff --git a/kolibri/plugins/coach/assets/src/views/plan/CreateExamPage/SectionEditor.vue b/kolibri/plugins/coach/assets/src/views/plan/CreateExamPage/SectionEditor.vue index aa5976ff408..d64fc0ecb26 100644 --- a/kolibri/plugins/coach/assets/src/views/plan/CreateExamPage/SectionEditor.vue +++ b/kolibri/plugins/coach/assets/src/views/plan/CreateExamPage/SectionEditor.vue @@ -214,16 +214,26 @@ - - + {{ closeConfirmationMessage$() }} + + + @submit="handleConfirmDelete" + > + {{ deleteConfirmation$({ section_title: activeSection.section_title }) }} + @@ -235,21 +245,21 @@ import pick from 'lodash/pick'; import { computed, ref } from 'kolibri.lib.vueCompositionApi'; import { enhancedQuizManagementStrings } from 'kolibri-common/strings/enhancedQuizManagementStrings'; + import commonCoreStrings from 'kolibri.coreVue.mixins.commonCoreStrings'; import useKResponsiveWindow from 'kolibri-design-system/lib/useKResponsiveWindow'; import Draggable from 'kolibri.coreVue.components.Draggable'; import DragContainer from 'kolibri.coreVue.components.DragContainer'; import DragHandle from 'kolibri.coreVue.components.DragHandle'; import { injectQuizCreation } from '../../../composables/useQuizCreation'; - import ConfirmCancellationModal from './ConfirmCancellationModal.vue'; export default { name: 'SectionEditor', components: { - ConfirmCancellationModal, Draggable, DragContainer, DragHandle, }, + mixins: [commonCoreStrings], setup(_, context) { const { activeSection, @@ -276,8 +286,8 @@ } function handleConfirmDelete() { - context.emit('closePanel'); removeSection(showDeleteConfirmation.value); + context.emit('closePanel'); } function handleDeleteSection(section_id) { @@ -326,6 +336,9 @@ randomizedOptionDescription$, fixedLabel$, fixedOptionDescription$, + closeConfirmationMessage$, + closeConfirmationTitle$, + deleteConfirmation$, } = enhancedQuizManagementStrings; return { @@ -360,6 +373,9 @@ currentSection$, deleteSectionLabel$, applySettings$, + closeConfirmationTitle$, + closeConfirmationMessage$, + deleteConfirmation$, changeResources$, sectionOrder$, questionOrder$, @@ -394,9 +410,9 @@ }; }, }, - beforeRouteLeave(_, __, next) { - if (!this.showConfirmationModal && this.formDataHasChanged) { - this.showConfirmationModal = true; + beforeRouteLeave(to, __, next) { + if (!this.showCloseConfirmation && this.formDataHasChanged && !this.showDeleteConfirmation) { + this.showCloseConfirmation = true; next(false); } else { next(); @@ -472,12 +488,6 @@ float: right; } - .change-resource-button-style { - display: block; - width: 100%; - margin-bottom: 1.5em; - } - .section-order-style { font-size: 1em; } @@ -508,10 +518,6 @@ width: 100%; } - /deep/ .KButton-noKey-0_1xktocf { - width: 100%; - } - .current-section-text { text-align: right; } diff --git a/kolibri/plugins/coach/assets/src/views/plan/CreateExamPage/SectionSidePanel.vue b/kolibri/plugins/coach/assets/src/views/plan/CreateExamPage/SectionSidePanel.vue index debfaf40b46..7cb22aca09c 100644 --- a/kolibri/plugins/coach/assets/src/views/plan/CreateExamPage/SectionSidePanel.vue +++ b/kolibri/plugins/coach/assets/src/views/plan/CreateExamPage/SectionSidePanel.vue @@ -5,7 +5,7 @@ ref="resourcePanel" alignment="right" sidePanelWidth="700px" - :closeButtonIconType="closeIcon" + :closeButtonIconType="closeBackIcon" @closePanel="handleClosePanel" @shouldFocusFirstEl="findFirstEl()" > @@ -18,7 +18,7 @@