Skip to content

Commit

Permalink
Fix: Inline feedback normalisation across course and component config (
Browse files Browse the repository at this point in the history
  • Loading branch information
oliverfoster committed Apr 6, 2023
1 parent e3d18e4 commit f03b1ee
Showing 1 changed file with 14 additions and 11 deletions.
25 changes: 14 additions & 11 deletions js/adapt-contrib-tutor.js
Original file line number Diff line number Diff line change
Expand Up @@ -9,25 +9,28 @@ class Tutor extends Backbone.Controller {
initialize() {
this.listenTo(Adapt, {
'componentView:postRender': this.onComponentViewPostRender,
'questionView:showFeedback': this.onQuestionViewShowFeedback
'questionView:showFeedback': this.onQuestionViewShowFeedback,
'buttonsView:postRender': this.onButtonsViewPostRender
});
}

onComponentViewPostRender(view) {
const model = view.model;
const { model } = view;
if (!model.isTypeGroup('question')) return;
const config = model.get('_tutor');
if (!config) return;
const type = TUTOR_TYPE(config._type?.toUpperCase());
if (type !== TUTOR_TYPE.INLINE) return;
this.listenToOnce(Adapt, 'buttonsView:postRender', this.onButtonsViewPostRender);
if (model.get('_canShowFeedback') && model.get('_isSubmitted')) {
model.setupFeedback();
Adapt.trigger('questionView:showFeedback', view);
}
const shouldShowFeedback = (model.get('_canShowFeedback') && model.get('_isSubmitted'));
if (!shouldShowFeedback) return;
model.setupFeedback();
Adapt.trigger('questionView:showFeedback', view);
}

onButtonsViewPostRender(view) {
const { model } = view;
const config = (!model.get('_tutor') || (model.get('_tutor')?._isInherited ?? true))
? Adapt.course.get('_tutor')
: model.get('_tutor');
if (!config) return;
const type = TUTOR_TYPE(config._type?.toUpperCase());
if (type !== TUTOR_TYPE.INLINE) return;
const $btnAction = view.$('.js-btn-action');
const $btnFeedback = view.$('.js-btn-feedback');
const $btnMarking = view.$('.js-btn-marking');
Expand Down

0 comments on commit f03b1ee

Please sign in to comment.