Skip to content

Commit

Permalink
Fix: Ensure question number is configured when restoring (fixes #200) (
Browse files Browse the repository at this point in the history
…#201)

* Fix: Ensure question number is configured when restoring (fixes #200)

* Setup question number on restore last attempt also

* Ensure specific subject models are set as partofassessment only
  • Loading branch information
oliverfoster authored Jul 8, 2024
1 parent 70d9851 commit fe8bdd3
Showing 1 changed file with 8 additions and 5 deletions.
13 changes: 8 additions & 5 deletions js/adapt-assessmentArticleModel.js
Original file line number Diff line number Diff line change
Expand Up @@ -87,7 +87,7 @@ const AssessmentModel = {
}
// save original children
this._originalChildModelsStore = this.getChildren().models;
this._setAssessmentOwnershipOnChildrenModels();
this._setAssessmentOwnershipOnChildrenModels(this._originalChildModelsStore);
return this._originalChildModelsStore;
}
});
Expand All @@ -108,18 +108,18 @@ const AssessmentModel = {
});
},

_setAssessmentOwnershipOnChildrenModels() {
_setAssessmentOwnershipOnChildrenModels(childModels) {
// mark all children components as belonging to an assessment
const assessmentConfig = this.get('_assessment');
const childConfig = {
_isPartOfAssessment: true,
_assessmentId: assessmentConfig._id
};

for (const blockModel of this._originalChildModels) {
blockModel.set(childConfig);
for (const childModel of childModels) {
childModel.set(childConfig);
// make sure components are set to _isPartOfAssessment for plp checking
blockModel.setOnChildren(childConfig);
childModel.setOnChildren(childConfig);
}
},

Expand Down Expand Up @@ -184,6 +184,7 @@ const AssessmentModel = {
quizModels = quizModels.concat(outsideModels);
}
this.getChildren().reset(quizModels);
this._setAssessmentOwnershipOnChildrenModels(quizModels);
this.setupCurrentQuestionComponents();
if (shouldResetAssessment || shouldResetQuestions) {
this._resetFilter();
Expand Down Expand Up @@ -748,6 +749,8 @@ const AssessmentModel = {

if (_isAssessmentComplete) this._checkIsPass();

this._setAssessmentOwnershipOnChildrenModels(blocks);

Adapt.trigger('assessments:restored', this.getState(), this);

},
Expand Down

0 comments on commit fe8bdd3

Please sign in to comment.