From 672237d976820841609cdfd683bbd4423a790fa0 Mon Sep 17 00:00:00 2001 From: Richard Tibbles Date: Sun, 16 Jun 2024 16:31:13 -0700 Subject: [PATCH] Only reuse necessary params from the route. Update strings for replacements modal to reflect updated workflow. --- .../plan/CreateExamPage/CreateQuizSection.vue | 33 ++++++++++++++----- .../NotEnoughResourcesModal.vue | 33 ++++++++++--------- .../plan/CreateExamPage/ReplaceQuestions.vue | 6 +++- .../views/reports/ReportsQuizBaseListPage.vue | 6 +++- .../strings/enhancedQuizManagementStrings.js | 13 +++++--- 5 files changed, 62 insertions(+), 29 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 be1785c0418..1c1bddd34b2 100644 --- a/kolibri/plugins/coach/assets/src/views/plan/CreateExamPage/CreateQuizSection.vue +++ b/kolibri/plugins/coach/assets/src/views/plan/CreateExamPage/CreateQuizSection.vue @@ -312,7 +312,7 @@ @@ -567,6 +567,13 @@ } }, methods: { + getCurrentRouteParams() { + return { + classId: this.$route.params.classId, + quizId: this.$route.params.quizId, + sectionIndex: this.$route.params.sectionIndex, + }; + }, setActiveSection(sectionIndex = null) { if (sectionIndex === null) { sectionIndex = 0; @@ -575,7 +582,10 @@ throw new Error(`Section with id ${sectionIndex} not found; cannot be set as active.`); } if (sectionIndex !== this.activeSectionIndex) { - this.$router.push({ ...this.$route, params: { ...this.$route.params, sectionIndex } }); + this.$router.push({ + ...this.$route, + params: { ...this.getCurrentRouteParams(), sectionIndex }, + }); } }, handleConfirmDelete() { @@ -598,21 +608,28 @@ if (this.replacementQuestionPool.length < this.selectedActiveQuestions.length) { this.showNotEnoughResourcesModal = true; } else { - const sectionIndex = this.activeSectionIndex; - this.$router.push({ name: PageNames.QUIZ_REPLACE_QUESTIONS, params: { sectionIndex } }); + this.$router.push({ + name: PageNames.QUIZ_REPLACE_QUESTIONS, + params: this.getCurrentRouteParams(), + }); } }, handleActiveSectionAction(opt) { - const sectionIndex = this.activeSectionIndex; switch (opt.id) { case 'edit': - this.$router.push({ name: PageNames.QUIZ_SECTION_EDITOR, params: { sectionIndex } }); + this.$router.push({ + name: PageNames.QUIZ_SECTION_EDITOR, + params: this.getCurrentRouteParams(), + }); break; case 'delete': this.showDeleteConfirmation = true; break; case 'plus': - this.$router.push({ name: PageNames.QUIZ_SELECT_RESOURCES, params: { sectionIndex } }); + this.$router.push({ + name: PageNames.QUIZ_SELECT_RESOURCES, + params: this.getCurrentRouteParams(), + }); break; } }, @@ -671,7 +688,7 @@ openSelectResources() { this.$router.push({ name: PageNames.QUIZ_SELECT_RESOURCES, - params: { ...this.$route.params }, + params: this.getCurrentRouteParams(), }); }, deleteQuestions() { diff --git a/kolibri/plugins/coach/assets/src/views/plan/CreateExamPage/NotEnoughResourcesModal.vue b/kolibri/plugins/coach/assets/src/views/plan/CreateExamPage/NotEnoughResourcesModal.vue index f675934214a..99090ec3639 100644 --- a/kolibri/plugins/coach/assets/src/views/plan/CreateExamPage/NotEnoughResourcesModal.vue +++ b/kolibri/plugins/coach/assets/src/views/plan/CreateExamPage/NotEnoughResourcesModal.vue @@ -3,23 +3,24 @@ -

+

{{ notEnoughReplacementsMessage$({ selected: selectedQuestions.length, - available: availableResources.length, + available: availableQuestions.length, }) }}

-

+

+ {{ noReplacementsMessage$() }} +

+

{{ - addMoreResourcesWithNonEmptyPool$({ - available: availableResources.length, - }) + addMoreQuestionsWithNonEmptyPool$() }}

- {{ addMoreResourcesWithEmptyPool$() }} + {{ addMoreQuestionsWithEmptyPool$() }}

@@ -50,19 +51,21 @@ setup() { const { goBackAction$, - addResourcesAction$, + addQuestions$, notEnoughReplacementsTitle$, notEnoughReplacementsMessage$, - addMoreResourcesWithEmptyPool$, - addMoreResourcesWithNonEmptyPool$, + addMoreQuestionsWithEmptyPool$, + addMoreQuestionsWithNonEmptyPool$, + noReplacementsMessage$, } = enhancedQuizManagementStrings; return { goBackAction$, - addResourcesAction$, + addQuestions$, notEnoughReplacementsTitle$, notEnoughReplacementsMessage$, - addMoreResourcesWithEmptyPool$, - addMoreResourcesWithNonEmptyPool$, + addMoreQuestionsWithEmptyPool$, + addMoreQuestionsWithNonEmptyPool$, + noReplacementsMessage$, }; }, props: { @@ -70,7 +73,7 @@ type: Array, required: true, }, - availableResources: { + availableQuestions: { type: Array, required: true, }, 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 3cde0ec96af..2026fc32769 100644 --- a/kolibri/plugins/coach/assets/src/views/plan/CreateExamPage/ReplaceQuestions.vue +++ b/kolibri/plugins/coach/assets/src/views/plan/CreateExamPage/ReplaceQuestions.vue @@ -239,7 +239,11 @@ clearSelectedQuestions(); router.replace({ name: PageNames.EXAM_CREATION_ROOT, - params: { ...this.$route.params }, + params: { + classId: this.$route.params.classId, + quizId: this.$route.params.quizId, + sectionIndex: this.$route.params.sectionIndex, + }, }); this.$store.dispatch('createSnackbar', numberOfQuestionsReplaced$({ count })); } diff --git a/kolibri/plugins/coach/assets/src/views/reports/ReportsQuizBaseListPage.vue b/kolibri/plugins/coach/assets/src/views/reports/ReportsQuizBaseListPage.vue index 301add2ea4c..1c60b69968c 100644 --- a/kolibri/plugins/coach/assets/src/views/reports/ReportsQuizBaseListPage.vue +++ b/kolibri/plugins/coach/assets/src/views/reports/ReportsQuizBaseListPage.vue @@ -142,7 +142,11 @@ if (option === 'EDIT_DETAILS') { this.$router.push({ name: PageNames.EXAM_CREATION_ROOT, - params: { ...this.$route.params }, + params: { + classId: this.$route.params.classId, + quizId: this.$route.params.quizId, + sectionIndex: 0, + }, query: this.defaultBackLinkQuery, }); } diff --git a/packages/kolibri-common/strings/enhancedQuizManagementStrings.js b/packages/kolibri-common/strings/enhancedQuizManagementStrings.js index d09cfbd9e9d..13a1ae11305 100644 --- a/packages/kolibri-common/strings/enhancedQuizManagementStrings.js +++ b/packages/kolibri-common/strings/enhancedQuizManagementStrings.js @@ -241,18 +241,23 @@ export const enhancedQuizManagementStrings = createTranslator('EnhancedQuizManag context: 'Title of modal when a user tries to replace more questions than are available in the pool', }, + noReplacementsMessage: { + message: + 'There are no more similar questions available to replace the selected questions with.', + }, notEnoughReplacementsMessage: { message: "You've selected { selected, number } { selected, plural, one { question } other { questions } } to replace, but {available, plural, =0 { don't have questions } one { only have 1 question } other { only have { available } questions } } available to replace them with.", context: 'Message of modal when a user tries to replace more questions than are available in the pool', }, - addMoreResourcesWithEmptyPool: { - message: 'Please add more resources to this section.', + addMoreQuestionsWithEmptyPool: { + message: 'You can add more questions, or delete existing questions.', context: 'Message of modal when a user tries to replace questions but the pool is empty', }, - addMoreResourcesWithNonEmptyPool: { - message: 'Please add more resources to this section, or go back and select fewer questions', + addMoreQuestionsWithNonEmptyPool: { + message: + 'You can add more questions, delete existing questions, or go back and select fewer questions', context: 'Message of modal when a user tries to replace more questions than are available in the pool', },