Commit 23a8270d authored by Andrew Nicols's avatar Andrew Nicols
Browse files

MDL-69134 competencies: Behat fails randomly opening dialogues

parent 118a1e78
File suppressed by a .gitattributes entry or the file's encoding is unsupported.
File suppressed by a .gitattributes entry or the file's encoding is unsupported.
File suppressed by a .gitattributes entry or the file's encoding is unsupported.
...@@ -35,6 +35,8 @@ define(['core/yui'], function(Y) { ...@@ -35,6 +35,8 @@ define(['core/yui'], function(Y) {
* @param {Boolean} wide Specify we want an extra wide dialogue (the size is standard, but wider than the default). * @param {Boolean} wide Specify we want an extra wide dialogue (the size is standard, but wider than the default).
*/ */
var dialogue = function(title, content, afterShow, afterHide, wide) { var dialogue = function(title, content, afterShow, afterHide, wide) {
M.util.js_pending('tool_lp/dialogue:dialogue');
this.yuiDialogue = null; this.yuiDialogue = null;
var parent = this; var parent = this;
...@@ -59,6 +61,10 @@ define(['core/yui'], function(Y) { ...@@ -59,6 +61,10 @@ define(['core/yui'], function(Y) {
width: width width: width
}); });
parent.yuiDialogue.before('visibleChange', function() {
M.util.js_pending('tool_lp/dialogue:before:visibleChange');
});
parent.yuiDialogue.after('visibleChange', function(e) { parent.yuiDialogue.after('visibleChange', function(e) {
if (e.newVal) { if (e.newVal) {
// Delay the callback call to the next tick, otherwise it can happen that it is // Delay the callback call to the next tick, otherwise it can happen that it is
...@@ -67,18 +73,25 @@ define(['core/yui'], function(Y) { ...@@ -67,18 +73,25 @@ define(['core/yui'], function(Y) {
Y.soon(function() { Y.soon(function() {
afterShow(parent); afterShow(parent);
parent.yuiDialogue.centerDialogue(); parent.yuiDialogue.centerDialogue();
M.util.js_complete('tool_lp/dialogue:before:visibleChange');
}); });
} else {
M.util.js_complete('tool_lp/dialogue:before:visibleChange');
} }
} else { } else {
if ((typeof afterHide !== 'undefined')) { if ((typeof afterHide !== 'undefined')) {
Y.soon(function() { Y.soon(function() {
afterHide(parent); afterHide(parent);
M.util.js_complete('tool_lp/dialogue:before:visibleChange');
}); });
} else {
M.util.js_complete('tool_lp/dialogue:before:visibleChange');
} }
} }
}); });
parent.yuiDialogue.show(); parent.yuiDialogue.show();
M.util.js_complete('tool_lp/dialogue:dialogue');
}); });
}; };
......
...@@ -102,6 +102,7 @@ define(['jquery', ...@@ -102,6 +102,7 @@ define(['jquery',
* @return {Promise} * @return {Promise}
*/ */
Grade.prototype.display = function() { Grade.prototype.display = function() {
M.util.js_pending('tool_lp/grade_dialogue:display');
return $.when( return $.when(
Str.get_string('rate', 'tool_lp'), Str.get_string('rate', 'tool_lp'),
this._render() this._render()
...@@ -110,7 +111,10 @@ define(['jquery', ...@@ -110,7 +111,10 @@ define(['jquery',
this._popup = new Dialogue( this._popup = new Dialogue(
title, title,
templateResult[0], templateResult[0],
this._afterRender.bind(this) function() {
this._afterRender();
M.util.js_complete('tool_lp/grade_dialogue:display');
}.bind(this)
); );
return this._popup; return this._popup;
......
...@@ -94,6 +94,7 @@ define(['jquery', ...@@ -94,6 +94,7 @@ define(['jquery',
var options = [], var options = [],
self = this; self = this;
M.util.js_pending('tool_lp/grade_user_competency_inline:_setUp');
var promise = ScaleValues.get_values(self._scaleId); var promise = ScaleValues.get_values(self._scaleId);
promise.then(function(scalevalues) { promise.then(function(scalevalues) {
options.push({ options.push({
...@@ -134,6 +135,7 @@ define(['jquery', ...@@ -134,6 +135,7 @@ define(['jquery',
.then(function(dialogue) { .then(function(dialogue) {
self._dialogue = dialogue; self._dialogue = dialogue;
M.util.js_complete('tool_lp/grade_user_competency_inline:_setUp');
return; return;
}) })
.fail(notification.exception); .fail(notification.exception);
......
File suppressed by a .gitattributes entry or the file's encoding is unsupported.
File suppressed by a .gitattributes entry or the file's encoding is unsupported.
...@@ -59,10 +59,9 @@ define(['jquery', 'core/notification', 'core/str', 'core/ajax', 'core/log', 'cor ...@@ -59,10 +59,9 @@ define(['jquery', 'core/notification', 'core/str', 'core/ajax', 'core/log', 'cor
args: {userid: userId, competencyid: competencyId, courseid: courseId}, args: {userid: userId, competencyid: competencyId, courseid: courseId},
}]); }]);
$.when.apply($, requests).then(function(context) { $.when(requests[0], requests[1])
this._contextLoaded.bind(this)(context); .then(this._contextLoaded.bind(this))
return; .catch(notification.exception);
}.bind(this)).catch(notification.exception);
}; };
/** /**
...@@ -70,23 +69,37 @@ define(['jquery', 'core/notification', 'core/str', 'core/ajax', 'core/log', 'cor ...@@ -70,23 +69,37 @@ define(['jquery', 'core/notification', 'core/str', 'core/ajax', 'core/log', 'cor
* *
* @method _contextLoaded * @method _contextLoaded
* @param {Object} context * @param {Object} context
* @returns {Promise}
*/ */
GradingPopup.prototype._contextLoaded = function(context) { GradingPopup.prototype._contextLoaded = function(context) {
var self = this;
// We have to display user info in popup. // We have to display user info in popup.
context.displayuser = true; context.displayuser = true;
templates.render('tool_lp/user_competency_summary_in_course', context).done(function(html, js) {
str.get_string('usercompetencysummary', 'report_competency').done(function(title) { M.util.js_pending('report_competency/grading_popup:_contextLoaded');
(new Dialogue(title, html, templates.runTemplateJS.bind(templates, js), self._refresh.bind(self), true));
}).fail(notification.exception); return $.when(
}).fail(notification.exception); str.get_string('usercompetencysummary', 'report_competency'),
templates.render('tool_lp/user_competency_summary_in_course', context)
)
.then(function(title, templateData) {
return new Dialogue(
title,
templateData[0],
function() {
templates.runTemplateJS(templateData[1]);
M.util.js_complete('report_competency/grading_popup:_contextLoaded');
},
this._refresh.bind(this),
true
);
}.bind(this));
}; };
/** /**
* Refresh the page. * Refresh the page.
* *
* @method _refresh * @method _refresh
* @returns {Promise}
*/ */
GradingPopup.prototype._refresh = function() { GradingPopup.prototype._refresh = function() {
var region = $(this._regionSelector); var region = $(this._regionSelector);
...@@ -99,7 +112,7 @@ define(['jquery', 'core/notification', 'core/str', 'core/ajax', 'core/log', 'cor ...@@ -99,7 +112,7 @@ define(['jquery', 'core/notification', 'core/str', 'core/ajax', 'core/log', 'cor
moduleId = 0; moduleId = 0;
} }
ajax.call([{ return ajax.call([{
methodname: 'report_competency_data_for_report', methodname: 'report_competency_data_for_report',
args: {courseid: courseId, userid: userId, moduleid: moduleId}, args: {courseid: courseId, userid: userId, moduleid: moduleId},
done: this._pageContextLoaded.bind(this), done: this._pageContextLoaded.bind(this),
...@@ -114,10 +127,13 @@ define(['jquery', 'core/notification', 'core/str', 'core/ajax', 'core/log', 'cor ...@@ -114,10 +127,13 @@ define(['jquery', 'core/notification', 'core/str', 'core/ajax', 'core/log', 'cor
* @param {Object} context * @param {Object} context
*/ */
GradingPopup.prototype._pageContextLoaded = function(context) { GradingPopup.prototype._pageContextLoaded = function(context) {
var self = this; templates.render('report_competency/report', context)
templates.render('report_competency/report', context).done(function(html, js) { .then(function(html, js) {
templates.replaceNode(self._regionSelector, html, js); templates.replaceNode(this._regionSelector, html, js);
}).fail(notification.exception);
return;
}.bind(this))
.catch(notification.exception);
}; };
/** @type {String} The selector for the region with the user competencies */ /** @type {String} The selector for the region with the user competencies */
......
...@@ -50,6 +50,8 @@ define(['jquery'], function($) { ...@@ -50,6 +50,8 @@ define(['jquery'], function($) {
* @param {Event} e the event * @param {Event} e the event
*/ */
UserCourseNavigation.prototype._userChanged = function(e) { UserCourseNavigation.prototype._userChanged = function(e) {
// Note: This change causes a page reload and is intentionally not paired with a js_complete call.
M.util.js_pending('report_competency/user_course_navigation:_userChanged');
var newUserId = $(e.target).val(); var newUserId = $(e.target).val();
var queryStr = '?user=' + newUserId + '&id=' + this._courseId + '&mod=' + this._moduleId; var queryStr = '?user=' + newUserId + '&id=' + this._courseId + '&mod=' + this._moduleId;
document.location = this._baseUrl + queryStr; document.location = this._baseUrl + queryStr;
...@@ -62,6 +64,8 @@ define(['jquery'], function($) { ...@@ -62,6 +64,8 @@ define(['jquery'], function($) {
* @param {Event} e the event * @param {Event} e the event
*/ */
UserCourseNavigation.prototype._moduleChanged = function(e) { UserCourseNavigation.prototype._moduleChanged = function(e) {
// Note: This change causes a page reload and is intentionally not paired with a js_complete call.
M.util.js_pending('report_competency/user_course_navigation:_moduleChanged');
var newModuleId = $(e.target).val(); var newModuleId = $(e.target).val();
var queryStr = '?mod=' + newModuleId + '&id=' + this._courseId + '&user=' + this._userId; var queryStr = '?mod=' + newModuleId + '&id=' + this._courseId + '&user=' + this._userId;
document.location = this._baseUrl + queryStr; document.location = this._baseUrl + queryStr;
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment