Skip to content

Commit

Permalink
Fix bug not beign able to update resources
Browse files Browse the repository at this point in the history
  • Loading branch information
AlexVelezLl committed May 29, 2024
1 parent 81f3194 commit 7bb7603
Showing 1 changed file with 10 additions and 12 deletions.
22 changes: 10 additions & 12 deletions kolibri/plugins/coach/assets/src/composables/useQuizCreation.js
Original file line number Diff line number Diff line change
Expand Up @@ -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) {
Expand Down

0 comments on commit 7bb7603

Please sign in to comment.