html,
self._afterRender.bind(self)
);
+ return;
}).fail(Notification.exception);
};
return self._render().then(function(html) {
self._find('[data-region="action-selector"]').replaceWith(html);
self._afterRender();
+ return;
});
};
pagerender = 'tool_lp/plan_page';
pageregion = 'plan-page';
}
-
ajax.call(requests)[requests.length - 1].then(function(context) {
- return templates.render(pagerender, context).done(function(html, js) {
- $('[data-region="' + pageregion + '"]').replaceWith(html);
- templates.runTemplateJS(js);
- });
- }, notification.exception);
+ return templates.render(pagerender, context);
+ }).then(function(html, js) {
+ $('[data-region="' + pageregion + '"]').replaceWith(html);
+ templates.runTemplateJS(js);
+ return;
+ }).catch(notification.exception);
});
}
// We're done, let's trigger a change.
self._templateLoaded = true;
self._triggerChange();
+ return;
});
};
var promises = ajax.call(calls);
promises[calls.length - 1].then(function(context) {
- return templates.render('tool_lp/related_competencies', context).done(function(html, js) {
- $('[data-region="relatedcompetencies"]').replaceWith(html);
- templates.runTemplateJS(js);
- updatedRelatedCompetencies();
- });
- }, notification.exception);
+ return templates.render('tool_lp/related_competencies', context);
+ }).then(function(html, js) {
+ $('[data-region="relatedcompetencies"]').replaceWith(html);
+ templates.runTemplateJS(js);
+ updatedRelatedCompetencies();
+ return;
+ }).catch(notification.exception);
});
}
relatedTarget.ruleconfig = config.ruleconfig;
renderCompetencySummary(relatedTarget);
}
- }, notification.exception);
+ return;
+ }).catch(notification.exception);
};
/**
type: strs[1]
};
}
- }).then(function() {
- return templates.render('tool_lp/competency_summary', context).then(function(html) {
- $('[data-region="competencyinfo"]').html(html);
- $('[data-action="deleterelation"]').on('click', deleteRelatedHandler);
- });
- }).then(function() {
+ return context;
+ }).then(function(context) {
+ return templates.render('tool_lp/competency_summary', context);
+ }).then(function(html) {
+ $('[data-region="competencyinfo"]').html(html);
+ $('[data-action="deleterelation"]').on('click', deleteRelatedHandler);
return templates.render('tool_lp/loading', {});
}).then(function(html, js) {
templates.replaceNodeContents('[data-region="relatedcompetencies"]', html, js);
- }).done(function() {
- ajax.call([{
+ return ajax.call([{
methodname: 'tool_lp_data_for_related_competencies_section',
- args: {competencyid: competency.id},
- done: function(context) {
- return templates.render('tool_lp/related_competencies', context).done(function(html, js) {
- $('[data-region="relatedcompetencies"]').replaceWith(html);
- templates.runTemplateJS(js);
- updatedRelatedCompetencies();
- });
- }
- }]);
- }).fail(notification.exception);
+ args: {competencyid: competency.id}
+ }])[0];
+ }).then(function(context) {
+ return templates.render('tool_lp/related_competencies', context);
+ }).then(function(html, js) {
+ $('[data-region="relatedcompetencies"]').replaceWith(html);
+ templates.runTemplateJS(js);
+ updatedRelatedCompetencies();
+ return;
+ }).catch(notification.exception);
};
/**
// Log Competency viewed event.
triggerCompetencyViewedEvent(competency);
}
-
strSelectedTaxonomy(level).then(function(str) {
selectedTitle.text(str);
- });
+ return;
+ }).catch(notification.exception);
strAddTaxonomy(sublevel).then(function(str) {
btn.show()
.find('[data-region="term"]')
.text(str);
- });
+ return;
+ }).catch(notification.exception);
// We handled this event so consume it.
evt.preventDefault();
if (!self._singleFramework) {
self._find('[data-action="chooseframework"]').change(function(e) {
self._frameworkId = $(e.target).val();
- self._loadCompetencies().then(self._refresh.bind(self));
+ self._loadCompetencies().then(self._refresh.bind(self)).catch(Notification.exception);
});
}
*/
Picker.prototype.display = function() {
var self = this;
- return self._render().then(function(html) {
- return Str.get_string('competencypicker', 'tool_lp').then(function(title) {
- self._popup = new Dialogue(
- title,
- html,
- self._afterRender.bind(self)
- );
- });
- }).fail(Notification.exception);
+ return $.when(Str.get_string('competencypicker', 'tool_lp'), self._render())
+ .then(function(title, render) {
+ self._popup = new Dialogue(
+ title,
+ render[0],
+ self._afterRender.bind(self)
+ );
+ return;
+ }).catch(Notification.exception);
};
/**
return self._render().then(function(html) {
self._find('[data-region="competencylinktree"]').replaceWith(html);
self._afterRender();
+ return;
});
};
if (!self._singlePlan) {
self._find('[data-action="chooseplan"]').change(function(e) {
self._planId = $(e.target).val();
- self._loadCompetencies().then(self._refresh.bind(self));
+ self._loadCompetencies().then(self._refresh.bind(self))
+ .catch(Notification.exception);
});
}
};
if (!self._competency) {
return false;
}
- return self._render().then(function(html) {
- return Str.get_string('competencyrule', 'tool_lp').then(function(title) {
- self._popup = new Dialogue(
- title,
- html,
- self._afterRender.bind(self)
- );
- });
+ return $.when(Str.get_string('competencyrule', 'tool_lp'), self._render())
+ .then(function(title, render) {
+ self._popup = new Dialogue(
+ title,
+ render[0],
+ self._afterRender.bind(self)
+ );
+ return;
}).fail(Notification.exception);
};
*/
RuleConfig.prototype._initOutcomes = function() {
var self = this;
-
return Outcomes.getAll().then(function(outcomes) {
self._outcomesOption = outcomes;
+ return;
});
};
RuleConfig.prototype._initRules = function() {
var self = this,
promises = [];
-
$.each(self._rules, function(index, rule) {
var promise = rule.init().then(function() {
rule.setTargetCompetency(self._competency);
rule.on('change', self._afterRuleConfigChange.bind(self));
+ return;
}, function() {
// Upon failure remove the rule, and resolve the promise.
self._rules.splice(index, 1);
self._afterChange();
return;
}
-
rule.injectTemplate(container).then(function() {
container.show();
- }, function() {
- container.empty().hide();
+ return;
}).always(function() {
self._afterChange();
+ }).catch(function() {
+ container.empty().hide();
});
};
}]);
promise[0].then(function() {
parent.remove();
+ return;
}).fail(Notification.exception);
}
);
includes: includes
}
}]);
-
promise[0].then(function(results) {
var promises = [],
i = 0;
i++;
});
success(results.cohorts);
+ return;
});
- }, failure);
+ }).catch(failure);
}
};
i++;
});
success(results.users);
+ return;
});
- }, failure);
+ }).catch(failure);
}
};
* @return {Promise}
*/
list: function(contextId, options) {
- var promise,
- args = {
+ var args = {
context: {
contextid: contextId
}
};
$.extend(args, typeof options === 'undefined' ? {} : options);
- promise = Ajax.call([{
+ return Ajax.call([{
methodname: 'core_competency_list_competency_frameworks',
args: args
}])[0];
-
- return promise.fail(Notification.exception);
},
/**
* @param {String} query The query string.
* @param {Function} callback A callback function receiving an array of results.
*/
+ /* eslint-disable promise/no-callback-in-promise */
transport: function(selector, query, callback) {
var el = $(selector),
contextId = el.data('contextid'),
if (!contextId) {
throw new Error('The attribute data-contextid is required on ' + selector);
}
-
this.list(contextId, {
query: query,
onlyvisible: onlyVisible,
- }).then(callback);
+ }).then(callback).catch(Notification.exception);
}
};
Str.get_string('competencyframeworkroot', 'tool_lp').then(function(rootframework) {
$(self.staticElementSelector).html(rootframework);
$(self.inputHiddenSelector).val(data.competencyId);
+ return;
}).fail(Notification.exception);
}
};
* Callback to render the region template.
*
* @param {Object} context The context for the template.
+ * @return {Promise}
*/
PlanActions.prototype._renderView = function(context) {
var self = this;
- templates.render(self._template, context)
- .done(function(newhtml, newjs) {
+ return templates.render(self._template, context)
+ .then(function(newhtml, newjs) {
$(self._region).replaceWith(newhtml);
templates.runTemplateJS(newjs);
- })
- .fail(notification.exception);
+ return;
+ });
};
/**
*/
PlanActions.prototype._callAndRefresh = function(calls, planData) {
var self = this;
-
calls.push({
methodname: self._contextMethod,
args: self._getContextArgs(planData)
});
// Apply all the promises, and refresh when the last one is resolved.
- return $.when.apply($.when, ajax.call(calls))
+ return $.when.apply($, ajax.call(calls))
.then(function() {
- self._renderView(arguments[arguments.length - 1]);
+ return self._renderView(arguments[arguments.length - 1]);
})
.fail(notification.exception);
};
done: this._contextLoaded.bind(this),
fail: notification.exception
}]);
-
// Log the user competency viewed in plan event.
requests[0].then(function(result) {
var eventMethodName = 'core_competency_user_competency_viewed_in_plan';
if (result.plan.iscompleted) {
eventMethodName = 'core_competency_user_competency_plan_viewed';
}
- ajax.call([{
+ return ajax.call([{
methodname: eventMethodName,
- args: {competencyid: competencyId, userid: userId, planid: planId},
- fail: notification.exception
- }]);
- });
+ args: {competencyid: competencyId, userid: userId, planid: planId}
+ }])[0];
+ }).catch(notification.exception);
};
/**
Ajax.call([call])[0].then(function() {
this._trigger('review-request-cancelled', data);
this._trigger('status-changed', data);
- }.bind(this), function() {
+ }.bind(this)).catch(function() {
this._trigger('error-occured', data);
}.bind(this));
};
Ajax.call([call])[0].then(function() {
this._trigger('review-requested', data);
this._trigger('status-changed', data);
- }.bind(this), function() {
+ }.bind(this)).catch(function() {
this._trigger('error-occured', data);
}.bind(this));
};
competencyid: data.competencyid
}
};
-
Ajax.call([call])[0].then(function() {
this._trigger('review-started', data);
this._trigger('status-changed', data);
- }.bind(this), function() {
+ }.bind(this)).catch(function() {
this._trigger('error-occured', data);
}.bind(this));
};
Ajax.call([call])[0].then(function() {
this._trigger('review-stopped', data);
this._trigger('status-changed', data);
- }.bind(this), function() {
+ }.bind(this)).catch(function() {
this._trigger('error-occured', data);
}.bind(this));
};
* Callback to render the region template.
*
* @param {Object} context The context for the template.
+ * @return {Promise}
*/
UserEvidenceActions.prototype._renderView = function(context) {
var self = this;
- templates.render(self._template, context)
- .done(function(newhtml, newjs) {
+ return templates.render(self._template, context)
+ .then(function(newhtml, newjs) {
templates.replaceNode($(self._region), newhtml, newjs);
- })
- .fail(notification.exception);
+ return;
+ });
};
/**
*/
UserEvidenceActions.prototype._callAndRefresh = function(calls, evidenceData) {
var self = this;
-
calls.push({
methodname: self._contextMethod,
args: self._getContextArgs(evidenceData)
// Apply all the promises, and refresh when the last one is resolved.
return $.when.apply($.when, ajax.call(calls))
.then(function() {
- self._renderView(arguments[arguments.length - 1]);
+ return self._renderView(arguments[arguments.length - 1]);
})
.fail(notification.exception);
};
var requests = ajax.call([{
methodname: 'tool_lp_data_for_user_competency_summary_in_course',
args: {userid: userId, competencyid: competencyId, courseid: courseId},
- done: this._contextLoaded.bind(this),
- fail: notification.exception
+ }, {
+ methodname: 'core_competency_user_competency_viewed_in_course',
+ args: {userid: userId, competencyid: competencyId, courseid: courseId},
}]);
- // Log the user competency viewed in course event.
- requests[0].then(function() {
- ajax.call([{
- methodname: 'core_competency_user_competency_viewed_in_course',
- args: {userid: userId, competencyid: competencyId, courseid: courseId},
- fail: notification.exception
- }]);
- });
+ $.when.apply($, requests).then(function() {
+ this._contextLoaded.bind(this);
+ return;
+ }).catch(notification.exception);
};
/**