MDL-69134 competencies: Behat fails randomly opening dialogues

This commit is contained in:
Andrew Nicols 2020-06-25 09:01:58 +08:00
parent 49a9e8b07d
commit 63a66eb2ce
15 changed files with 66 additions and 27 deletions

View File

@ -1,2 +1,2 @@
define ("tool_lp/dialogue",["core/yui"],function(a){var b=function(b,c,d,e,f){this.yuiDialogue=null;var g=this;if("undefined"==typeof f){f=!1}a.use("moodle-core-notification","timers",function(){var h="480px";if(f){h="800px"}g.yuiDialogue=new M.core.dialogue({headerContent:b,bodyContent:c,draggable:!0,visible:!1,center:!0,modal:!0,width:h});g.yuiDialogue.after("visibleChange",function(b){if(b.newVal){if("undefined"!=typeof d){a.soon(function(){d(g);g.yuiDialogue.centerDialogue()})}}else{if("undefined"!=typeof e){a.soon(function(){e(g)})}}});g.yuiDialogue.show()})};b.prototype.close=function(){this.yuiDialogue.hide();this.yuiDialogue.destroy()};b.prototype.getContent=function(){return this.yuiDialogue.bodyNode.getDOMNode()};return b});
define ("tool_lp/dialogue",["core/yui"],function(a){var b=function(b,c,d,e,f){M.util.js_pending("tool_lp/dialogue:dialogue");this.yuiDialogue=null;var g=this;if("undefined"==typeof f){f=!1}a.use("moodle-core-notification","timers",function(){var h="480px";if(f){h="800px"}g.yuiDialogue=new M.core.dialogue({headerContent:b,bodyContent:c,draggable:!0,visible:!1,center:!0,modal:!0,width:h});g.yuiDialogue.before("visibleChange",function(){M.util.js_pending("tool_lp/dialogue:before:visibleChange")});g.yuiDialogue.after("visibleChange",function(b){if(b.newVal){if("undefined"!=typeof d){a.soon(function(){d(g);g.yuiDialogue.centerDialogue();M.util.js_complete("tool_lp/dialogue:before:visibleChange")})}else{M.util.js_complete("tool_lp/dialogue:before:visibleChange")}}else{if("undefined"!=typeof e){a.soon(function(){e(g);M.util.js_complete("tool_lp/dialogue:before:visibleChange")})}else{M.util.js_complete("tool_lp/dialogue:before:visibleChange")}}});g.yuiDialogue.show();M.util.js_complete("tool_lp/dialogue:dialogue")})};b.prototype.close=function(){this.yuiDialogue.hide();this.yuiDialogue.destroy()};b.prototype.getContent=function(){return this.yuiDialogue.bodyNode.getDOMNode()};return b});
//# sourceMappingURL=dialogue.min.js.map

File diff suppressed because one or more lines are too long

View File

@ -1,2 +1,2 @@
define ("tool_lp/grade_dialogue",["jquery","core/notification","core/templates","tool_lp/dialogue","tool_lp/event_base","core/str"],function(a,b,c,d,e,f){var g=function(a){e.prototype.constructor.apply(this,[]);this._ratingOptions=a};g.prototype=Object.create(e.prototype);g.prototype._popup=null;g.prototype._ratingOptions=null;g.prototype._afterRender=function(){var b=this._find("[data-action=\"rate\"]"),c=this._find("[name=\"rating\"]"),d=this._find("[name=\"comment\"]");this._find("[data-action=\"cancel\"]").click(function(a){a.preventDefault();this._trigger("cancelled");this.close()}.bind(this));c.change(function(){var c=a(this);if(!c.val()){b.prop("disabled",!0)}else{b.prop("disabled",!1)}}).change();b.click(function(a){a.preventDefault();var b=c.val();if(!b){return}this._trigger("rated",{rating:b,note:d.val()});this.close()}.bind(this))};g.prototype.close=function(){this._popup.close();this._popup=null};g.prototype.display=function(){return a.when(f.get_string("rate","tool_lp"),this._render()).then(function(a,b){this._popup=new d(a,b[0],this._afterRender.bind(this));return this._popup}.bind(this)).catch(b.exception)};g.prototype._find=function(b){return a(this._popup.getContent()).find(b)};g.prototype._render=function(){var a={cangrade:this._canGrade,ratings:this._ratingOptions};return c.render("tool_lp/competency_grader",a)};return g});
define ("tool_lp/grade_dialogue",["jquery","core/notification","core/templates","tool_lp/dialogue","tool_lp/event_base","core/str"],function(a,b,c,d,e,f){var g=function(a){e.prototype.constructor.apply(this,[]);this._ratingOptions=a};g.prototype=Object.create(e.prototype);g.prototype._popup=null;g.prototype._ratingOptions=null;g.prototype._afterRender=function(){var b=this._find("[data-action=\"rate\"]"),c=this._find("[name=\"rating\"]"),d=this._find("[name=\"comment\"]");this._find("[data-action=\"cancel\"]").click(function(a){a.preventDefault();this._trigger("cancelled");this.close()}.bind(this));c.change(function(){var c=a(this);if(!c.val()){b.prop("disabled",!0)}else{b.prop("disabled",!1)}}).change();b.click(function(a){a.preventDefault();var b=c.val();if(!b){return}this._trigger("rated",{rating:b,note:d.val()});this.close()}.bind(this))};g.prototype.close=function(){this._popup.close();this._popup=null};g.prototype.display=function(){M.util.js_pending("tool_lp/grade_dialogue:display");return a.when(f.get_string("rate","tool_lp"),this._render()).then(function(a,b){this._popup=new d(a,b[0],function(){this._afterRender();M.util.js_complete("tool_lp/grade_dialogue:display")}.bind(this));return this._popup}.bind(this)).catch(b.exception)};g.prototype._find=function(b){return a(this._popup.getContent()).find(b)};g.prototype._render=function(){var a={cangrade:this._canGrade,ratings:this._ratingOptions};return c.render("tool_lp/competency_grader",a)};return g});
//# sourceMappingURL=grade_dialogue.min.js.map

File diff suppressed because one or more lines are too long

View File

@ -1,2 +1,2 @@
define ("tool_lp/grade_user_competency_inline",["jquery","core/notification","core/ajax","core/log","tool_lp/grade_dialogue","tool_lp/event_base","tool_lp/scalevalues"],function(a,b,c,d,e,f,g){var h=function(b,c,d,e,g,h,i){f.prototype.constructor.apply(this,[]);var j=a(b);if(!j.length){throw new Error("Could not find the trigger")}this._scaleId=c;this._competencyId=d;this._userId=e;this._planId=g;this._courseId=h;this._chooseStr=i;this._setUp();j.click(function(a){a.preventDefault();this._dialogue.display()}.bind(this));if(this._planId){this._methodName="core_competency_grade_competency_in_plan";this._args={competencyid:this._competencyId,planid:this._planId}}else if(this._courseId){this._methodName="core_competency_grade_competency_in_course";this._args={competencyid:this._competencyId,courseid:this._courseId,userid:this._userId}}else{this._methodName="core_competency_grade_competency";this._args={userid:this._userId,competencyid:this._competencyId}}};h.prototype=Object.create(f.prototype);h.prototype._setUp=function(){var a=[],d=this,f=g.get_values(d._scaleId);f.then(function(b){a.push({value:"",name:d._chooseStr});for(var c=0,e;c<b.length;c++){e=b[c];a.push({value:e.id,name:e.name})}return a}).then(function(a){return new e(a)}).then(function(a){a.on("rated",function(a,e){var f=d._args;f.grade=e.rating;f.note=e.note;c.call([{methodname:d._methodName,args:f,done:function done(a){d._trigger("competencyupdated",{args:f,evidence:a})},fail:b.exception}])});return a}).then(function(a){d._dialogue=a}).fail(b.exception)};h.prototype._scaleId=null;h.prototype._competencyId=null;h.prototype._userId=null;h.prototype._planId=null;h.prototype._courseId=null;h.prototype._chooseStr=null;h.prototype._dialogue=null;return h});
define ("tool_lp/grade_user_competency_inline",["jquery","core/notification","core/ajax","core/log","tool_lp/grade_dialogue","tool_lp/event_base","tool_lp/scalevalues"],function(a,b,c,d,e,f,g){var h=function(b,c,d,e,g,h,i){f.prototype.constructor.apply(this,[]);var j=a(b);if(!j.length){throw new Error("Could not find the trigger")}this._scaleId=c;this._competencyId=d;this._userId=e;this._planId=g;this._courseId=h;this._chooseStr=i;this._setUp();j.click(function(a){a.preventDefault();this._dialogue.display()}.bind(this));if(this._planId){this._methodName="core_competency_grade_competency_in_plan";this._args={competencyid:this._competencyId,planid:this._planId}}else if(this._courseId){this._methodName="core_competency_grade_competency_in_course";this._args={competencyid:this._competencyId,courseid:this._courseId,userid:this._userId}}else{this._methodName="core_competency_grade_competency";this._args={userid:this._userId,competencyid:this._competencyId}}};h.prototype=Object.create(f.prototype);h.prototype._setUp=function(){var a=[],d=this;M.util.js_pending("tool_lp/grade_user_competency_inline:_setUp");var f=g.get_values(d._scaleId);f.then(function(b){a.push({value:"",name:d._chooseStr});for(var c=0,e;c<b.length;c++){e=b[c];a.push({value:e.id,name:e.name})}return a}).then(function(a){return new e(a)}).then(function(a){a.on("rated",function(a,e){var f=d._args;f.grade=e.rating;f.note=e.note;c.call([{methodname:d._methodName,args:f,done:function done(a){d._trigger("competencyupdated",{args:f,evidence:a})},fail:b.exception}])});return a}).then(function(a){d._dialogue=a;M.util.js_complete("tool_lp/grade_user_competency_inline:_setUp")}).fail(b.exception)};h.prototype._scaleId=null;h.prototype._competencyId=null;h.prototype._userId=null;h.prototype._planId=null;h.prototype._courseId=null;h.prototype._chooseStr=null;h.prototype._dialogue=null;return h});
//# sourceMappingURL=grade_user_competency_inline.min.js.map

File diff suppressed because one or more lines are too long

View File

@ -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).
*/
var dialogue = function(title, content, afterShow, afterHide, wide) {
M.util.js_pending('tool_lp/dialogue:dialogue');
this.yuiDialogue = null;
var parent = this;
@ -59,6 +61,10 @@ define(['core/yui'], function(Y) {
width: width
});
parent.yuiDialogue.before('visibleChange', function() {
M.util.js_pending('tool_lp/dialogue:before:visibleChange');
});
parent.yuiDialogue.after('visibleChange', function(e) {
if (e.newVal) {
// Delay the callback call to the next tick, otherwise it can happen that it is
@ -67,18 +73,25 @@ define(['core/yui'], function(Y) {
Y.soon(function() {
afterShow(parent);
parent.yuiDialogue.centerDialogue();
M.util.js_complete('tool_lp/dialogue:before:visibleChange');
});
} else {
M.util.js_complete('tool_lp/dialogue:before:visibleChange');
}
} else {
if ((typeof afterHide !== 'undefined')) {
Y.soon(function() {
afterHide(parent);
M.util.js_complete('tool_lp/dialogue:before:visibleChange');
});
} else {
M.util.js_complete('tool_lp/dialogue:before:visibleChange');
}
}
});
parent.yuiDialogue.show();
M.util.js_complete('tool_lp/dialogue:dialogue');
});
};

View File

@ -102,6 +102,7 @@ define(['jquery',
* @return {Promise}
*/
Grade.prototype.display = function() {
M.util.js_pending('tool_lp/grade_dialogue:display');
return $.when(
Str.get_string('rate', 'tool_lp'),
this._render()
@ -110,7 +111,10 @@ define(['jquery',
this._popup = new Dialogue(
title,
templateResult[0],
this._afterRender.bind(this)
function() {
this._afterRender();
M.util.js_complete('tool_lp/grade_dialogue:display');
}.bind(this)
);
return this._popup;

View File

@ -94,6 +94,7 @@ define(['jquery',
var options = [],
self = this;
M.util.js_pending('tool_lp/grade_user_competency_inline:_setUp');
var promise = ScaleValues.get_values(self._scaleId);
promise.then(function(scalevalues) {
options.push({
@ -134,6 +135,7 @@ define(['jquery',
.then(function(dialogue) {
self._dialogue = dialogue;
M.util.js_complete('tool_lp/grade_user_competency_inline:_setUp');
return;
})
.fail(notification.exception);

View File

@ -1,2 +1,2 @@
define ("report_competency/grading_popup",["jquery","core/notification","core/str","core/ajax","core/log","core/templates","tool_lp/dialogue"],function(a,b,c,d,f,g,h){var i=function(b,c){this._regionSelector=b;this._userCompetencySelector=c;a(this._regionSelector).on("click",this._userCompetencySelector,this._handleClick.bind(this))};i.prototype._handleClick=function(c){var e=a(c.target).closest(this._userCompetencySelector),g=a(e).data("competencyid"),h=a(e).data("courseid"),i=a(e).data("userid");f.debug("Clicked on cell: competencyId="+g+", courseId="+h+", userId="+i);var j=d.call([{methodname:"tool_lp_data_for_user_competency_summary_in_course",args:{userid:i,competencyid:g,courseid:h}},{methodname:"core_competency_user_competency_viewed_in_course",args:{userid:i,competencyid:g,courseid:h}}]);a.when.apply(a,j).then(function(a){this._contextLoaded.bind(this)(a)}.bind(this)).catch(b.exception)};i.prototype._contextLoaded=function(a){var d=this;a.displayuser=!0;g.render("tool_lp/user_competency_summary_in_course",a).done(function(a,e){c.get_string("usercompetencysummary","report_competency").done(function(b){new h(b,a,g.runTemplateJS.bind(g,e),d._refresh.bind(d),!0)}).fail(b.exception)}).fail(b.exception)};i.prototype._refresh=function(){var c=a(this._regionSelector),e=c.data("courseid"),f=c.data("moduleid"),g=c.data("userid");if(""===f){f=0}d.call([{methodname:"report_competency_data_for_report",args:{courseid:e,userid:g,moduleid:f},done:this._pageContextLoaded.bind(this),fail:b.exception}])};i.prototype._pageContextLoaded=function(a){var c=this;g.render("report_competency/report",a).done(function(a,b){g.replaceNode(c._regionSelector,a,b)}).fail(b.exception)};i.prototype._regionSelector=null;i.prototype._userCompetencySelector=null;return i});
define ("report_competency/grading_popup",["jquery","core/notification","core/str","core/ajax","core/log","core/templates","tool_lp/dialogue"],function(a,b,c,d,f,g,h){var i=function(b,c){this._regionSelector=b;this._userCompetencySelector=c;a(this._regionSelector).on("click",this._userCompetencySelector,this._handleClick.bind(this))};i.prototype._handleClick=function(c){var e=a(c.target).closest(this._userCompetencySelector),g=a(e).data("competencyid"),h=a(e).data("courseid"),i=a(e).data("userid");f.debug("Clicked on cell: competencyId="+g+", courseId="+h+", userId="+i);var j=d.call([{methodname:"tool_lp_data_for_user_competency_summary_in_course",args:{userid:i,competencyid:g,courseid:h}},{methodname:"core_competency_user_competency_viewed_in_course",args:{userid:i,competencyid:g,courseid:h}}]);a.when(j[0],j[1]).then(this._contextLoaded.bind(this)).catch(b.exception)};i.prototype._contextLoaded=function(b){b.displayuser=!0;M.util.js_pending("report_competency/grading_popup:_contextLoaded");return a.when(c.get_string("usercompetencysummary","report_competency"),g.render("tool_lp/user_competency_summary_in_course",b)).then(function(a,b){return new h(a,b[0],function(){g.runTemplateJS(b[1]);M.util.js_complete("report_competency/grading_popup:_contextLoaded")},this._refresh.bind(this),!0)}.bind(this))};i.prototype._refresh=function(){var c=a(this._regionSelector),e=c.data("courseid"),f=c.data("moduleid"),g=c.data("userid");if(""===f){f=0}return d.call([{methodname:"report_competency_data_for_report",args:{courseid:e,userid:g,moduleid:f},done:this._pageContextLoaded.bind(this),fail:b.exception}])};i.prototype._pageContextLoaded=function(a){g.render("report_competency/report",a).then(function(a,b){g.replaceNode(this._regionSelector,a,b)}.bind(this)).catch(b.exception)};i.prototype._regionSelector=null;i.prototype._userCompetencySelector=null;return i});
//# sourceMappingURL=grading_popup.min.js.map

File diff suppressed because one or more lines are too long

View File

@ -1,2 +1,2 @@
define ("report_competency/user_course_navigation",["jquery"],function(a){var b=function(b,c,d,e,f,g){this._baseUrl=d;this._userId=e+"";this._courseId=f;this._moduleId=g;a(b).on("change",this._userChanged.bind(this));a(c).on("change",this._moduleChanged.bind(this))};b.prototype._userChanged=function(b){var c=a(b.target).val(),d="?user="+c+"&id="+this._courseId+"&mod="+this._moduleId;document.location=this._baseUrl+d};b.prototype._moduleChanged=function(b){var c=a(b.target).val(),d="?mod="+c+"&id="+this._courseId+"&user="+this._userId;document.location=this._baseUrl+d};b.prototype._userId=null;b.prototype._moduleId=null;b.prototype._courseId=null;b.prototype._baseUrl=null;return b});
define ("report_competency/user_course_navigation",["jquery"],function(a){var b=function(b,c,d,e,f,g){this._baseUrl=d;this._userId=e+"";this._courseId=f;this._moduleId=g;a(b).on("change",this._userChanged.bind(this));a(c).on("change",this._moduleChanged.bind(this))};b.prototype._userChanged=function(b){M.util.js_pending("report_competency/user_course_navigation:_userChanged");var c=a(b.target).val(),d="?user="+c+"&id="+this._courseId+"&mod="+this._moduleId;document.location=this._baseUrl+d};b.prototype._moduleChanged=function(b){M.util.js_pending("report_competency/user_course_navigation:_moduleChanged");var c=a(b.target).val(),d="?mod="+c+"&id="+this._courseId+"&user="+this._userId;document.location=this._baseUrl+d};b.prototype._userId=null;b.prototype._moduleId=null;b.prototype._courseId=null;b.prototype._baseUrl=null;return b});
//# sourceMappingURL=user_course_navigation.min.js.map

File diff suppressed because one or more lines are too long

View File

@ -59,10 +59,9 @@ define(['jquery', 'core/notification', 'core/str', 'core/ajax', 'core/log', 'cor
args: {userid: userId, competencyid: competencyId, courseid: courseId},
}]);
$.when.apply($, requests).then(function(context) {
this._contextLoaded.bind(this)(context);
return;
}.bind(this)).catch(notification.exception);
$.when(requests[0], requests[1])
.then(this._contextLoaded.bind(this))
.catch(notification.exception);
};
/**
@ -70,23 +69,37 @@ define(['jquery', 'core/notification', 'core/str', 'core/ajax', 'core/log', 'cor
*
* @method _contextLoaded
* @param {Object} context
* @returns {Promise}
*/
GradingPopup.prototype._contextLoaded = function(context) {
var self = this;
// We have to display user info in popup.
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) {
(new Dialogue(title, html, templates.runTemplateJS.bind(templates, js), self._refresh.bind(self), true));
}).fail(notification.exception);
}).fail(notification.exception);
M.util.js_pending('report_competency/grading_popup:_contextLoaded');
return $.when(
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.
*
* @method _refresh
* @returns {Promise}
*/
GradingPopup.prototype._refresh = function() {
var region = $(this._regionSelector);
@ -99,7 +112,7 @@ define(['jquery', 'core/notification', 'core/str', 'core/ajax', 'core/log', 'cor
moduleId = 0;
}
ajax.call([{
return ajax.call([{
methodname: 'report_competency_data_for_report',
args: {courseid: courseId, userid: userId, moduleid: moduleId},
done: this._pageContextLoaded.bind(this),
@ -114,10 +127,13 @@ define(['jquery', 'core/notification', 'core/str', 'core/ajax', 'core/log', 'cor
* @param {Object} context
*/
GradingPopup.prototype._pageContextLoaded = function(context) {
var self = this;
templates.render('report_competency/report', context).done(function(html, js) {
templates.replaceNode(self._regionSelector, html, js);
}).fail(notification.exception);
templates.render('report_competency/report', context)
.then(function(html, js) {
templates.replaceNode(this._regionSelector, html, js);
return;
}.bind(this))
.catch(notification.exception);
};
/** @type {String} The selector for the region with the user competencies */

View File

@ -50,6 +50,8 @@ define(['jquery'], function($) {
* @param {Event} e the event
*/
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 queryStr = '?user=' + newUserId + '&id=' + this._courseId + '&mod=' + this._moduleId;
document.location = this._baseUrl + queryStr;
@ -62,6 +64,8 @@ define(['jquery'], function($) {
* @param {Event} e the event
*/
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 queryStr = '?mod=' + newModuleId + '&id=' + this._courseId + '&user=' + this._userId;
document.location = this._baseUrl + queryStr;