Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix: Bank blocks only, restore other children (fixes #192) #193

Merged
merged 2 commits into from
Mar 5, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 6 additions & 2 deletions js/adapt-assessmentArticleModel.js
Original file line number Diff line number Diff line change
Expand Up @@ -173,6 +173,10 @@ const AssessmentModel = {
} else if (quizModels.length === 0) {
quizModels = this.getChildren().models;
logging.warn('assessment: Not enough unique questions to create a fresh assessment, using last selection');
} else {
// reattach any removed non-block children, trickle buttons etc
const outsideModels = this._originalChildModels.filter(model => model.get('_type') !== 'block')
quizModels = quizModels.concat(outsideModels)
}
this.getChildren().reset(quizModels);
this.setupCurrentQuestionComponents();
Expand Down Expand Up @@ -213,7 +217,7 @@ const AssessmentModel = {

this.findDescendantModels('block')
.filter(block => block.get('_isAvailable') && block.findDescendantModels('question').length > 0).forEach(block => {
const quizBankId = block.get('_assessment')?._quizBankId;
const quizBankId = block.get('_assessment')?._quizBankID;

const isInvalidNumber = (isNaN(quizBankId) || quizBankId < 1);
const isOutOfBounds = (quizBankId > bankSplits.length);
Expand All @@ -240,7 +244,7 @@ const AssessmentModel = {
const assessmentConfig = this.getConfig();

const randomisationModel = assessmentConfig._randomisation;
const blockModels = this.getChildren().models;
const blockModels = this.findDescendantModels('block');

let questionModels = _.shuffle(blockModels);

Expand Down