Skip to content

Commit

Permalink
Fix: Trigger assessment:restored appropriately (#187)
Browse files Browse the repository at this point in the history
  • Loading branch information
chris-steele authored Nov 22, 2023
1 parent e96a104 commit 7730e17
Showing 1 changed file with 9 additions and 6 deletions.
15 changes: 9 additions & 6 deletions js/assessment.js
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,15 @@ class Assessment extends Backbone.Controller {
'router:plugin': this._handleRoute,
'app:dataReady': this._onDataReady
});

this.triggerAssessmentsRestored();
}

async triggerAssessmentsRestored() {
await data.whenReady();

// all assessments have now registered and we can determine state
Adapt.trigger('assessment:restored', this.getState());
}

_onAssessmentsComplete(state) {
Expand Down Expand Up @@ -287,12 +296,6 @@ class Assessment extends Backbone.Controller {
this._setPageProgress();

this._setupQuestionNumbering();

if (this._restoredCount === this._assessments.length) {
// Since all assessments have been stored, broadcast an
// event which has the collated state.
Adapt.trigger('assessment:restored', this.getState());
}
}

get(id) {
Expand Down

0 comments on commit 7730e17

Please sign in to comment.