From 06f1d03b29b45a601520081e8f4b1566008b423d Mon Sep 17 00:00:00 2001 From: Alex Velez Date: Tue, 28 May 2024 16:29:01 -0500 Subject: [PATCH 1/6] Add not enough resources modal --- .../NotEnoughResourcesModal.vue | 81 +++++++++++++++++++ .../plan/CreateExamPage/ReplaceQuestions.vue | 22 +++++ .../strings/enhancedQuizManagementStrings.js | 27 +++++++ 3 files changed, 130 insertions(+) create mode 100644 kolibri/plugins/coach/assets/src/views/plan/CreateExamPage/NotEnoughResourcesModal.vue diff --git a/kolibri/plugins/coach/assets/src/views/plan/CreateExamPage/NotEnoughResourcesModal.vue b/kolibri/plugins/coach/assets/src/views/plan/CreateExamPage/NotEnoughResourcesModal.vue new file mode 100644 index 00000000000..abbc676ead3 --- /dev/null +++ b/kolibri/plugins/coach/assets/src/views/plan/CreateExamPage/NotEnoughResourcesModal.vue @@ -0,0 +1,81 @@ + + + + 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 6e2d4e34396..78c987806d2 100644 --- a/kolibri/plugins/coach/assets/src/views/plan/CreateExamPage/ReplaceQuestions.vue +++ b/kolibri/plugins/coach/assets/src/views/plan/CreateExamPage/ReplaceQuestions.vue @@ -122,6 +122,13 @@ + diff --git a/packages/kolibri-common/strings/enhancedQuizManagementStrings.js b/packages/kolibri-common/strings/enhancedQuizManagementStrings.js index cecbae54603..9200a901767 100644 --- a/packages/kolibri-common/strings/enhancedQuizManagementStrings.js +++ b/packages/kolibri-common/strings/enhancedQuizManagementStrings.js @@ -200,4 +200,31 @@ export const enhancedQuizManagementStrings = createTranslator('EnhancedQuizManag allSectionsEmptyWarning: { message: "You don't have any questions in the quiz", }, + notEnoughReplacementsTitle: { + message: 'Not enough replacements available', + context: + 'Title of modal when a user tries to replace more questions than are available in the pool', + }, + notEnoughReplacementsMessage: { + message: + "You've selected { selected } questions to replace, but only has { 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 more resources to this section.', + 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 only select up to { available } questions to be replaced.', + context: + 'Message of modal when a user tries to replace more questions than are available in the pool', + }, + addResourcesAction: { + message: 'Add resources', + }, + goBackAction: { + message: 'Go back', + }, }); From 0144bc7579ec76cc8ca547679dc5545072c77c68 Mon Sep 17 00:00:00 2001 From: Alex Velez Date: Tue, 28 May 2024 16:41:53 -0500 Subject: [PATCH 2/6] Fix message --- .../kolibri-common/strings/enhancedQuizManagementStrings.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/packages/kolibri-common/strings/enhancedQuizManagementStrings.js b/packages/kolibri-common/strings/enhancedQuizManagementStrings.js index 9200a901767..751d06cfc4d 100644 --- a/packages/kolibri-common/strings/enhancedQuizManagementStrings.js +++ b/packages/kolibri-common/strings/enhancedQuizManagementStrings.js @@ -207,7 +207,7 @@ export const enhancedQuizManagementStrings = createTranslator('EnhancedQuizManag }, notEnoughReplacementsMessage: { message: - "You've selected { selected } questions to replace, but only has { available } questions available to replace them with.", + "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', }, From 81f3194939b76044ba71f47e0f7a7e307d489216 Mon Sep 17 00:00:00 2001 From: Alex Velez Date: Tue, 28 May 2024 16:47:04 -0500 Subject: [PATCH 3/6] Fix message --- .../kolibri-common/strings/enhancedQuizManagementStrings.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/packages/kolibri-common/strings/enhancedQuizManagementStrings.js b/packages/kolibri-common/strings/enhancedQuizManagementStrings.js index 751d06cfc4d..8b7747fa853 100644 --- a/packages/kolibri-common/strings/enhancedQuizManagementStrings.js +++ b/packages/kolibri-common/strings/enhancedQuizManagementStrings.js @@ -217,7 +217,7 @@ export const enhancedQuizManagementStrings = createTranslator('EnhancedQuizManag }, addMoreResourcesWithNonEmptyPool: { message: - 'Please add more resources to this section, or go back and only select up to { available } questions to be replaced.', + 'Please add more resources to this section, or go back and only select up to { available, number } { available, plural, one { question } other { questions } } to be replaced.', context: 'Message of modal when a user tries to replace more questions than are available in the pool', }, From 7bb76032cfc538ed7e44d646082819653acf0031 Mon Sep 17 00:00:00 2001 From: Alex Velez Date: Wed, 29 May 2024 11:18:41 -0500 Subject: [PATCH 4/6] Fix bug not beign able to update resources --- .../assets/src/composables/useQuizCreation.js | 22 +++++++++---------- 1 file changed, 10 insertions(+), 12 deletions(-) diff --git a/kolibri/plugins/coach/assets/src/composables/useQuizCreation.js b/kolibri/plugins/coach/assets/src/composables/useQuizCreation.js index c88d18829b5..b03d11c0a4f 100644 --- a/kolibri/plugins/coach/assets/src/composables/useQuizCreation.js +++ b/kolibri/plugins/coach/assets/src/composables/useQuizCreation.js @@ -117,19 +117,17 @@ export default function useQuizCreation() { }, [] ); - if (removedResourceQuestionIds.length === 0) { - // If no resources were removed, we don't need to update the questions - return; + if (removedResourceQuestionIds.length !== 0) { + const questionsToKeep = originalQuestions.filter( + q => !removedResourceQuestionIds.includes(q.id) + ); + const numReplacementsNeeded = + (question_count || originalQuestionCount) - questionsToKeep.length; + updates.questions = [ + ...questionsToKeep, + ...selectRandomQuestionsFromResources(numReplacementsNeeded, resource_pool), + ]; } - const questionsToKeep = originalQuestions.filter( - q => !removedResourceQuestionIds.includes(q.id) - ); - const numReplacementsNeeded = - (question_count || originalQuestionCount) - questionsToKeep.length; - updates.questions = [ - ...questionsToKeep, - ...selectRandomQuestionsFromResources(numReplacementsNeeded, resource_pool), - ]; } } } else if (question_count !== originalQuestionCount) { From 794f9aad5829d2d7b57aa4f30bccc3e7fa6615a0 Mon Sep 17 00:00:00 2001 From: Alex Velez Date: Thu, 30 May 2024 17:51:26 -0500 Subject: [PATCH 5/6] ClosePanel on close no enough resources modal --- .../src/views/plan/CreateExamPage/ReplaceQuestions.vue | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) 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 78c987806d2..1a7de6495fb 100644 --- a/kolibri/plugins/coach/assets/src/views/plan/CreateExamPage/ReplaceQuestions.vue +++ b/kolibri/plugins/coach/assets/src/views/plan/CreateExamPage/ReplaceQuestions.vue @@ -126,7 +126,7 @@ v-if="showNoEnoughResources" :selectedQuestions="selectedActiveQuestions" :availableResources="replacementQuestionPool" - @close="showNoEnoughResources = false" + @close="closeNoEnoughResourcesModal" @addResources="redirectToSelectResources" /> Date: Fri, 31 May 2024 09:50:38 -0700 Subject: [PATCH 6/6] Add "add" to addMoreResourcesWithEmptyPool --- .../kolibri-common/strings/enhancedQuizManagementStrings.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/packages/kolibri-common/strings/enhancedQuizManagementStrings.js b/packages/kolibri-common/strings/enhancedQuizManagementStrings.js index 8b7747fa853..630588a55ba 100644 --- a/packages/kolibri-common/strings/enhancedQuizManagementStrings.js +++ b/packages/kolibri-common/strings/enhancedQuizManagementStrings.js @@ -212,7 +212,7 @@ export const enhancedQuizManagementStrings = createTranslator('EnhancedQuizManag 'Message of modal when a user tries to replace more questions than are available in the pool', }, addMoreResourcesWithEmptyPool: { - message: 'Please more resources to this section.', + message: 'Please add more resources to this section.', context: 'Message of modal when a user tries to replace questions but the pool is empty', }, addMoreResourcesWithNonEmptyPool: {