Skip to content

Commit

Permalink
Handle practice quizzes longer than "MAX_QUESTIONS" by spreading them…
Browse files Browse the repository at this point in the history
… across multiple sections.
  • Loading branch information
rtibbles committed Jun 13, 2024
1 parent f784ebe commit 8b263bd
Showing 1 changed file with 17 additions and 6 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -234,6 +234,7 @@
selectAllQuestions,
allQuestionsInQuiz,
activeQuestions,
addSection,
} = injectQuizCreation();
const showCloseConfirmation = ref(false);
const maxQuestions = computed(() => MAX_QUESTIONS - activeQuestions.value.length);
Expand Down Expand Up @@ -589,6 +590,7 @@
return {
activeSectionIndex,
activeQuestions,
addSection,
allResourceMap,
allQuestionsInQuiz,
selectAllChecked,
Expand Down Expand Up @@ -749,12 +751,21 @@
if (this.workingResourcePool.length !== 1) {
throw new Error('Only one resource can be selected for a practice quiz');
}
const questions = exerciseToQuestionArray(this.workingResourcePool[0]);
this.updateSection({
sectionIndex: this.activeSectionIndex,
questions,
resourcePool: this.workingResourcePool,
});
const remainder = exerciseToQuestionArray(this.workingResourcePool[0]);
let sectionIndex = this.activeSectionIndex;
while (remainder.length) {
if (sectionIndex !== this.activeSectionIndex) {
this.addSection();
}
const questions = remainder.splice(0, MAX_QUESTIONS);
this.updateSection({
sectionIndex,
questions,
resourcePool: this.workingResourcePool,
});
sectionIndex++;
}
} else {
this.addQuestionsToSectionFromResources({
sectionIndex: this.activeSectionIndex,
Expand Down

0 comments on commit 8b263bd

Please sign in to comment.