mirror of
https://github.com/moodle/moodle.git
synced 2025-01-19 14:27:22 +01:00
MDL-53494 tool_lp: Fix dialogue display when plan is completed
This commit is contained in:
parent
2170a2563b
commit
60a9993bce
@ -1 +1 @@
|
||||
define(["jquery","core/notification","core/str","core/ajax","core/templates","tool_lp/dialogue"],function(a,b,c,d,e,f){var g=function(b,c,d){this._regionSelector=b,this._userCompetencySelector=c,this._planId=d,a(this._regionSelector).on("click",this._userCompetencySelector,this._handleClick.bind(this))};return g.prototype._handleClick=function(c){var e=a(c.target).closest("tr"),f=a(e).data("competencyid"),g=a(e).data("userid"),h=this._planId,i=d.call([{methodname:"tool_lp_data_for_user_competency_summary_in_plan",args:{competencyid:f,planid:h},done:this._contextLoaded.bind(this),fail:b.exception}]);i[0].then(function(){d.call([{methodname:"core_competency_user_competency_viewed_in_plan",args:{competencyid:f,userid:g,planid:h},fail:b.exception}])})},g.prototype._contextLoaded=function(a){var d=this;e.render("tool_lp/user_competency_summary_in_plan",a).done(function(a,g){c.get_string("usercompetencysummary","report_competency").done(function(b){new f(b,a,e.runTemplateJS.bind(e,g),d._refresh.bind(d),!0)}).fail(b.exception)}).fail(b.exception)},g.prototype._refresh=function(){var a=this._planId;d.call([{methodname:"tool_lp_data_for_plan_page",args:{planid:a},done:this._pageContextLoaded.bind(this),fail:b.exception}])},g.prototype._pageContextLoaded=function(a){var c=this;e.render("tool_lp/plan_page",a).done(function(a,b){e.replaceNode(c._regionSelector,a,b)}).fail(b.exception)},g.prototype._regionSelector=null,g.prototype._userCompetencySelector=null,g.prototype._planId=null,g});
|
||||
define(["jquery","core/notification","core/str","core/ajax","core/templates","tool_lp/dialogue"],function(a,b,c,d,e,f){var g=function(b,c,d){this._regionSelector=b,this._userCompetencySelector=c,this._planId=d,a(this._regionSelector).on("click",this._userCompetencySelector,this._handleClick.bind(this))};return g.prototype._handleClick=function(c){c.preventDefault();var e=a(c.target).closest("tr"),f=a(e).data("competencyid"),g=a(e).data("userid"),h=this._planId,i=d.call([{methodname:"tool_lp_data_for_user_competency_summary_in_plan",args:{competencyid:f,planid:h},done:this._contextLoaded.bind(this),fail:b.exception}]);i[0].then(function(a){var c="core_competency_user_competency_viewed_in_plan";a.plan.iscompleted&&(c="core_competency_user_competency_plan_viewed"),d.call([{methodname:c,args:{competencyid:f,userid:g,planid:h},fail:b.exception}])})},g.prototype._contextLoaded=function(a){var d=this;e.render("tool_lp/user_competency_summary_in_plan",a).done(function(g,h){c.get_string("usercompetencysummary","report_competency").done(function(b){var c=null;a.plan.iscomplete||(c=e.runTemplateJS.bind(e,h)),new f(b,g,c,d._refresh.bind(d),!0)}).fail(b.exception)}).fail(b.exception)},g.prototype._refresh=function(){var a=this._planId;d.call([{methodname:"tool_lp_data_for_plan_page",args:{planid:a},done:this._pageContextLoaded.bind(this),fail:b.exception}])},g.prototype._pageContextLoaded=function(a){var c=this;e.render("tool_lp/plan_page",a).done(function(a,b){e.replaceNode(c._regionSelector,a,b)}).fail(b.exception)},g.prototype._regionSelector=null,g.prototype._userCompetencySelector=null,g.prototype._planId=null,g});
|
@ -46,6 +46,7 @@ define(['jquery', 'core/notification', 'core/str', 'core/ajax', 'core/templates'
|
||||
* @param {Event} e
|
||||
*/
|
||||
UserCompetencyPopup.prototype._handleClick = function(e) {
|
||||
e.preventDefault();
|
||||
var tr = $(e.target).closest('tr');
|
||||
var competencyId = $(tr).data('competencyid');
|
||||
var userId = $(tr).data('userid');
|
||||
@ -59,10 +60,15 @@ define(['jquery', 'core/notification', 'core/str', 'core/ajax', 'core/templates'
|
||||
}]);
|
||||
|
||||
// Log the user competency viewed in plan event.
|
||||
requests[0].then(function(){
|
||||
requests[0].then(function (result) {
|
||||
var eventMethodName = 'core_competency_user_competency_viewed_in_plan';
|
||||
// Trigger core_competency_user_competency_plan_viewed event instead if plan is already completed.
|
||||
if (result.plan.iscompleted) {
|
||||
eventMethodName = 'core_competency_user_competency_plan_viewed';
|
||||
}
|
||||
ajax.call([{
|
||||
methodname : 'core_competency_user_competency_viewed_in_plan',
|
||||
args: { competencyid: competencyId, userid: userId, planid: planId },
|
||||
methodname: eventMethodName,
|
||||
args: {competencyid: competencyId, userid: userId, planid: planId},
|
||||
fail: notification.exception
|
||||
}]);
|
||||
});
|
||||
@ -78,7 +84,12 @@ define(['jquery', 'core/notification', 'core/str', 'core/ajax', 'core/templates'
|
||||
var self = this;
|
||||
templates.render('tool_lp/user_competency_summary_in_plan', 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));
|
||||
var afterShow = null;
|
||||
// Run afterShow script if plan has not yet been completed.
|
||||
if (!context.plan.iscomplete) {
|
||||
afterShow = templates.runTemplateJS.bind(templates, js);
|
||||
}
|
||||
(new Dialogue(title, html, afterShow, self._refresh.bind(self), true));
|
||||
}).fail(notification.exception);
|
||||
}).fail(notification.exception);
|
||||
};
|
||||
|
@ -72,7 +72,7 @@ class user_competency_summary_exporter extends \core_competency\external\exporte
|
||||
'optional' => true
|
||||
),
|
||||
'usercompetencyplan' => array(
|
||||
'type' => user_competency_exporter::read_properties_definition(),
|
||||
'type' => user_competency_plan_exporter::read_properties_definition(),
|
||||
'optional' => true
|
||||
),
|
||||
'usercompetencycourse' => array(
|
||||
|
@ -127,7 +127,16 @@
|
||||
</thead>
|
||||
<tbody class="drag-parentnode">
|
||||
{{#competencies}}
|
||||
<tr class="drag-samenode" data-node="user-competency" data-id="{{competency.id}}" data-competencyid="{{usercompetency.competencyid}}" data-userid="{{usercompetency.userid}}">
|
||||
<tr class="drag-samenode" data-node="user-competency" data-id="{{competency.id}}"
|
||||
{{#plan.iscompleted}}
|
||||
data-competencyid="{{usercompetencyplan.id}}"
|
||||
data-userid="{{usercompetencyplan.userid}}"
|
||||
{{/plan.iscompleted}}
|
||||
{{^plan.iscompleted}}
|
||||
data-competencyid="{{usercompetency.competencyid}}"
|
||||
data-userid="{{usercompetency.userid}}"
|
||||
{{/plan.iscompleted}}
|
||||
>
|
||||
<td>
|
||||
{{#plan.canbeedited}}
|
||||
<span class="drag-handlecontainer pull-left"></span>
|
||||
|
Loading…
x
Reference in New Issue
Block a user