diff --git a/admin/tool/lp/amd/build/competencies.min.js b/admin/tool/lp/amd/build/competencies.min.js index fd8cb9c8b22..867ec94c464 100644 --- a/admin/tool/lp/amd/build/competencies.min.js +++ b/admin/tool/lp/amd/build/competencies.min.js @@ -1,2 +1,2 @@ -define ("tool_lp/competencies",["jquery","core/notification","core/ajax","core/templates","core/str","tool_lp/competencypicker","tool_lp/dragdrop-reorder"],function(a,b,c,d,e,f,g){var h=function(b,c,d){this.itemid=b;this.itemtype=c;this.pageContextId=d;this.pickerInstance=null;a("[data-region=\"actions\"] button").prop("disabled",!1);this.registerEvents();this.registerDragDrop()};h.prototype.registerDragDrop=function(){var a=this;e.get_string("movecompetency","tool_lp").done(function(b){g.dragdrop("movecompetency",b,{identifier:"movecompetency",component:"tool_lp"},{identifier:"movecompetencyafter",component:"tool_lp"},"drag-samenode","drag-parentnode","drag-handlecontainer",function(b,c){a.handleDrop(b,c)})}).fail(b.exception)};h.prototype.handleDrop=function(d,e){var f=a(d).data("id"),g=a(e).data("id"),h=this,i=[];if("course"==h.itemtype){i=c.call([{methodname:"core_competency_reorder_course_competency",args:{courseid:h.itemid,competencyidfrom:f,competencyidto:g}}])}else if("template"==h.itemtype){i=c.call([{methodname:"core_competency_reorder_template_competency",args:{templateid:h.itemid,competencyidfrom:f,competencyidto:g}}])}else if("plan"==h.itemtype){i=c.call([{methodname:"core_competency_reorder_plan_competency",args:{planid:h.itemid,competencyidfrom:f,competencyidto:g}}])}else{return}i[0].fail(b.exception)};h.prototype.pickCompetency=function(){var g=this,h,i,j,k;if(!g.pickerInstance){if("template"===g.itemtype||"course"===g.itemtype){k="parents"}g.pickerInstance=new f(g.pageContextId,!1,k);g.pickerInstance.on("save",function(f,e){var k=e.competencyIds;if("course"===g.itemtype){h=[];a.each(k,function(a,b){h.push({methodname:"core_competency_add_competency_to_course",args:{courseid:g.itemid,competencyid:b}})});h.push({methodname:"tool_lp_data_for_course_competencies_page",args:{courseid:g.itemid,moduleid:0}});i="tool_lp/course_competencies_page";j="coursecompetenciespage"}else if("template"===g.itemtype){h=[];a.each(k,function(a,b){h.push({methodname:"core_competency_add_competency_to_template",args:{templateid:g.itemid,competencyid:b}})});h.push({methodname:"tool_lp_data_for_template_competencies_page",args:{templateid:g.itemid,pagecontext:{contextid:g.pageContextId}}});i="tool_lp/template_competencies_page";j="templatecompetenciespage"}else if("plan"===g.itemtype){h=[];a.each(k,function(a,b){h.push({methodname:"core_competency_add_competency_to_plan",args:{planid:g.itemid,competencyid:b}})});h.push({methodname:"tool_lp_data_for_plan_page",args:{planid:g.itemid}});i="tool_lp/plan_page";j="plan-page"}c.call(h)[h.length-1].then(function(a){return d.render(i,a)}).then(function(b,c){a("[data-region=\""+j+"\"]").replaceWith(b);d.runTemplateJS(c)}).catch(b.exception)})}g.pickerInstance.display()};h.prototype.doDelete=function(e){var f=this,g=[],h="",i="";if("course"==f.itemtype){g=c.call([{methodname:"core_competency_remove_competency_from_course",args:{courseid:f.itemid,competencyid:e}},{methodname:"tool_lp_data_for_course_competencies_page",args:{courseid:f.itemid,moduleid:0}}]);h="tool_lp/course_competencies_page";i="coursecompetenciespage"}else if("template"==f.itemtype){g=c.call([{methodname:"core_competency_remove_competency_from_template",args:{templateid:f.itemid,competencyid:e}},{methodname:"tool_lp_data_for_template_competencies_page",args:{templateid:f.itemid,pagecontext:{contextid:f.pageContextId}}}]);h="tool_lp/template_competencies_page";i="templatecompetenciespage"}else if("plan"==f.itemtype){g=c.call([{methodname:"core_competency_remove_competency_from_plan",args:{planid:f.itemid,competencyid:e}},{methodname:"tool_lp_data_for_plan_page",args:{planid:f.itemid}}]);h="tool_lp/plan_page";i="plan-page"}g[1].done(function(c){d.render(h,c).done(function(b,c){a("[data-region=\""+i+"\"]").replaceWith(b);d.runTemplateJS(c)}).fail(b.exception)}).fail(b.exception)};h.prototype.deleteHandler=function(a){var d=this,f=[],g;if("course"==d.itemtype){g="unlinkcompetencycourse"}else if("template"==d.itemtype){g="unlinkcompetencytemplate"}else if("plan"==d.itemtype){g="unlinkcompetencyplan"}else{return}f=c.call([{methodname:"core_competency_read_competency",args:{id:a}}]);f[0].done(function(c){e.get_strings([{key:"confirm",component:"moodle"},{key:g,component:"tool_lp",param:c.shortname},{key:"confirm",component:"moodle"},{key:"cancel",component:"moodle"}]).done(function(c){b.confirm(c[0],c[1],c[2],c[3],function(){d.doDelete(a)})}).fail(b.exception)}).fail(b.exception)};h.prototype.registerEvents=function(){var f=this;if("course"==f.itemtype){a("[data-region=\"coursecompetenciespage\"]").on("change","select[data-field=\"ruleoutcome\"]",function(g){var e=[],h=a(g.target).data("id"),i=a(g.target).val();e=c.call([{methodname:"core_competency_set_course_competency_ruleoutcome",args:{coursecompetencyid:h,ruleoutcome:i}},{methodname:"tool_lp_data_for_course_competencies_page",args:{courseid:f.itemid,moduleid:0}}]);e[1].done(function(c){d.render("tool_lp/course_competencies_page",c).done(function(b,c){a("[data-region=\""+"coursecompetenciespage"+"\"]").replaceWith(b);d.runTemplateJS(c)}).fail(b.exception)}).fail(b.exception)})}a("[data-region=\"actions\"] button").click(function(a){a.preventDefault();f.pickCompetency()});a("[data-action=\"delete-competency-link\"]").click(function(b){b.preventDefault();var c=a(b.target).closest("[data-id]").data("id");f.deleteHandler(c)})};return h}); +define ("tool_lp/competencies",["jquery","core/notification","core/ajax","core/templates","core/str","tool_lp/competencypicker","tool_lp/dragdrop-reorder","core/pending"],function(a,b,c,d,e,f,g,h){var i=function(b,c,d){this.itemid=b;this.itemtype=c;this.pageContextId=d;this.pickerInstance=null;a("[data-region=\"actions\"] button").prop("disabled",!1);this.registerEvents();this.registerDragDrop()};i.prototype.registerDragDrop=function(){var a=this;e.get_string("movecompetency","tool_lp").done(function(b){g.dragdrop("movecompetency",b,{identifier:"movecompetency",component:"tool_lp"},{identifier:"movecompetencyafter",component:"tool_lp"},"drag-samenode","drag-parentnode","drag-handlecontainer",function(b,c){a.handleDrop(b,c)})}).fail(b.exception)};i.prototype.handleDrop=function(d,e){var f=a(d).data("id"),g=a(e).data("id"),h=this,i=[];if("course"==h.itemtype){i=c.call([{methodname:"core_competency_reorder_course_competency",args:{courseid:h.itemid,competencyidfrom:f,competencyidto:g}}])}else if("template"==h.itemtype){i=c.call([{methodname:"core_competency_reorder_template_competency",args:{templateid:h.itemid,competencyidfrom:f,competencyidto:g}}])}else if("plan"==h.itemtype){i=c.call([{methodname:"core_competency_reorder_plan_competency",args:{planid:h.itemid,competencyidfrom:f,competencyidto:g}}])}else{return}i[0].fail(b.exception)};i.prototype.pickCompetency=function(){var g=this,i,j,k,l;if(!g.pickerInstance){if("template"===g.itemtype||"course"===g.itemtype){l="parents"}g.pickerInstance=new f(g.pageContextId,!1,l);g.pickerInstance.on("save",function(f,e){var l=e.competencyIds,m=new h;if("course"===g.itemtype){i=[];a.each(l,function(a,b){i.push({methodname:"core_competency_add_competency_to_course",args:{courseid:g.itemid,competencyid:b}})});i.push({methodname:"tool_lp_data_for_course_competencies_page",args:{courseid:g.itemid,moduleid:0}});j="tool_lp/course_competencies_page";k="coursecompetenciespage"}else if("template"===g.itemtype){i=[];a.each(l,function(a,b){i.push({methodname:"core_competency_add_competency_to_template",args:{templateid:g.itemid,competencyid:b}})});i.push({methodname:"tool_lp_data_for_template_competencies_page",args:{templateid:g.itemid,pagecontext:{contextid:g.pageContextId}}});j="tool_lp/template_competencies_page";k="templatecompetenciespage"}else if("plan"===g.itemtype){i=[];a.each(l,function(a,b){i.push({methodname:"core_competency_add_competency_to_plan",args:{planid:g.itemid,competencyid:b}})});i.push({methodname:"tool_lp_data_for_plan_page",args:{planid:g.itemid}});j="tool_lp/plan_page";k="plan-page"}c.call(i)[i.length-1].then(function(a){return d.render(j,a)}).then(function(b,c){d.replaceNode(a("[data-region=\""+k+"\"]"),b,c)}).then(m.resolve).catch(b.exception)})}return g.pickerInstance.display()};i.prototype.doDelete=function(e){var f=this,g=[],h="",i="";if("course"==f.itemtype){g=c.call([{methodname:"core_competency_remove_competency_from_course",args:{courseid:f.itemid,competencyid:e}},{methodname:"tool_lp_data_for_course_competencies_page",args:{courseid:f.itemid,moduleid:0}}]);h="tool_lp/course_competencies_page";i="coursecompetenciespage"}else if("template"==f.itemtype){g=c.call([{methodname:"core_competency_remove_competency_from_template",args:{templateid:f.itemid,competencyid:e}},{methodname:"tool_lp_data_for_template_competencies_page",args:{templateid:f.itemid,pagecontext:{contextid:f.pageContextId}}}]);h="tool_lp/template_competencies_page";i="templatecompetenciespage"}else if("plan"==f.itemtype){g=c.call([{methodname:"core_competency_remove_competency_from_plan",args:{planid:f.itemid,competencyid:e}},{methodname:"tool_lp_data_for_plan_page",args:{planid:f.itemid}}]);h="tool_lp/plan_page";i="plan-page"}g[1].done(function(c){d.render(h,c).done(function(b,c){a("[data-region=\""+i+"\"]").replaceWith(b);d.runTemplateJS(c)}).fail(b.exception)}).fail(b.exception)};i.prototype.deleteHandler=function(a){var d=this,f=[],g;if("course"==d.itemtype){g="unlinkcompetencycourse"}else if("template"==d.itemtype){g="unlinkcompetencytemplate"}else if("plan"==d.itemtype){g="unlinkcompetencyplan"}else{return}f=c.call([{methodname:"core_competency_read_competency",args:{id:a}}]);f[0].done(function(c){e.get_strings([{key:"confirm",component:"moodle"},{key:g,component:"tool_lp",param:c.shortname},{key:"confirm",component:"moodle"},{key:"cancel",component:"moodle"}]).done(function(c){b.confirm(c[0],c[1],c[2],c[3],function(){d.doDelete(a)})}).fail(b.exception)}).fail(b.exception)};i.prototype.registerEvents=function(){var f=this;if("course"==f.itemtype){a("[data-region=\"coursecompetenciespage\"]").on("change","select[data-field=\"ruleoutcome\"]",function(g){var e=new h,i=[],j=a(g.target).data("id"),k=a(g.target).val();i=c.call([{methodname:"core_competency_set_course_competency_ruleoutcome",args:{coursecompetencyid:j,ruleoutcome:k}},{methodname:"tool_lp_data_for_course_competencies_page",args:{courseid:f.itemid,moduleid:0}}]);i[1].then(function(a){return d.render("tool_lp/course_competencies_page",a)}).then(function(b,c){return d.replaceNode(a("[data-region=\""+"coursecompetenciespage"+"\"]"),b,c)}).then(e.resolve).catch(b.exception)})}a("[data-region=\"actions\"] button").click(function(a){var b=new h;a.preventDefault();f.pickCompetency().then(b.resolve).catch()});a("[data-action=\"delete-competency-link\"]").click(function(b){b.preventDefault();var c=a(b.target).closest("[data-id]").data("id");f.deleteHandler(c)})};return i}); //# sourceMappingURL=competencies.min.js.map diff --git a/admin/tool/lp/amd/build/competencies.min.js.map b/admin/tool/lp/amd/build/competencies.min.js.map index aa66f0be036..b7aa8c0a283 100644 --- a/admin/tool/lp/amd/build/competencies.min.js.map +++ b/admin/tool/lp/amd/build/competencies.min.js.map @@ -1 +1 @@ -{"version":3,"sources":["../src/competencies.js"],"names":["define","$","notification","ajax","templates","str","Picker","dragdrop","competencies","itemid","itemtype","pagectxid","pageContextId","pickerInstance","prop","registerEvents","registerDragDrop","prototype","localthis","get_string","done","movestring","identifier","component","drag","drop","handleDrop","fail","exception","fromid","data","toid","requests","call","methodname","args","courseid","competencyidfrom","competencyidto","templateid","planid","pickCompetency","self","pagerender","pageregion","pageContextIncludes","on","e","compIds","competencyIds","each","index","compId","push","competencyid","moduleid","pagecontext","contextid","length","then","context","render","html","js","replaceWith","runTemplateJS","catch","display","doDelete","deleteid","deleteHandler","message","id","competency","get_strings","key","param","shortname","strings","confirm","coursecompetencyid","target","ruleoutcome","val","click","preventDefault","closest"],"mappings":"AAuBAA,OAAM,wBAAC,CAAC,QAAD,CACC,mBADD,CAEC,WAFD,CAGC,gBAHD,CAIC,UAJD,CAKC,0BALD,CAMC,0BAND,CAAD,CAOC,SAASC,CAAT,CAAYC,CAAZ,CAA0BC,CAA1B,CAAgCC,CAAhC,CAA2CC,CAA3C,CAAgDC,CAAhD,CAAwDC,CAAxD,CAAkE,CASrE,GAAIC,CAAAA,CAAY,CAAG,SAASC,CAAT,CAAiBC,CAAjB,CAA2BC,CAA3B,CAAsC,CACrD,KAAKF,MAAL,CAAcA,CAAd,CACA,KAAKC,QAAL,CAAgBA,CAAhB,CACA,KAAKE,aAAL,CAAqBD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AAA,CACpD,CA3TK,CAAN","sourcesContent":["// This file is part of Moodle - http://moodle.org/\n//\n// Moodle is free software: you can redistribute it and/or modify\n// it under the terms of the GNU General Public License as published by\n// the Free Software Foundation, either version 3 of the License, or\n// (at your option) any later version.\n//\n// Moodle is distributed in the hope that it will be useful,\n// but WITHOUT ANY WARRANTY; without even the implied warranty of\n// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the\n// GNU General Public License for more details.\n//\n// You should have received a copy of the GNU General Public License\n// along with Moodle. If not, see .\n\n/**\n * Handle add/remove competency links.\n *\n * @module tool_lp/competencies\n * @package tool_lp\n * @copyright 2015 Damyon Wiese \n * @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later\n */\ndefine(['jquery',\n 'core/notification',\n 'core/ajax',\n 'core/templates',\n 'core/str',\n 'tool_lp/competencypicker',\n 'tool_lp/dragdrop-reorder'],\n function($, notification, ajax, templates, str, Picker, dragdrop) {\n\n /**\n * Constructor\n *\n * @param {Number} itemid\n * @param {String} itemtype\n * @param {Number} pagectxid\n */\n var competencies = function(itemid, itemtype, pagectxid) {\n this.itemid = itemid;\n this.itemtype = itemtype;\n this.pageContextId = pagectxid;\n this.pickerInstance = null;\n\n $('[data-region=\"actions\"] button').prop('disabled', false);\n this.registerEvents();\n this.registerDragDrop();\n };\n\n /**\n * Initialise the drag/drop code.\n * @method registerDragDrop\n */\n competencies.prototype.registerDragDrop = function() {\n var localthis = this;\n // Init this module.\n str.get_string('movecompetency', 'tool_lp').done(\n function(movestring) {\n dragdrop.dragdrop('movecompetency',\n movestring,\n {identifier: 'movecompetency', component: 'tool_lp'},\n {identifier: 'movecompetencyafter', component: 'tool_lp'},\n 'drag-samenode',\n 'drag-parentnode',\n 'drag-handlecontainer',\n function(drag, drop) {\n localthis.handleDrop(drag, drop);\n });\n }\n ).fail(notification.exception);\n\n };\n\n /**\n * Handle a drop from a drag/drop operation.\n *\n * @method handleDrop\n * @param {DOMNode} drag The dragged node.\n * @param {DOMNode} drop The dropped on node.\n */\n competencies.prototype.handleDrop = function(drag, drop) {\n var fromid = $(drag).data('id');\n var toid = $(drop).data('id');\n var localthis = this;\n var requests = [];\n\n if (localthis.itemtype == 'course') {\n requests = ajax.call([\n {\n methodname: 'core_competency_reorder_course_competency',\n args: {courseid: localthis.itemid, competencyidfrom: fromid, competencyidto: toid}\n }\n ]);\n } else if (localthis.itemtype == 'template') {\n requests = ajax.call([\n {\n methodname: 'core_competency_reorder_template_competency',\n args: {templateid: localthis.itemid, competencyidfrom: fromid, competencyidto: toid}\n }\n ]);\n } else if (localthis.itemtype == 'plan') {\n requests = ajax.call([\n {\n methodname: 'core_competency_reorder_plan_competency',\n args: {planid: localthis.itemid, competencyidfrom: fromid, competencyidto: toid}\n }\n ]);\n } else {\n return;\n }\n\n requests[0].fail(notification.exception);\n };\n\n /**\n * Pick a competency\n *\n * @method pickCompetency\n */\n competencies.prototype.pickCompetency = function() {\n var self = this;\n var requests;\n var pagerender;\n var pageregion;\n var pageContextIncludes;\n\n if (!self.pickerInstance) {\n if (self.itemtype === 'template' || self.itemtype === 'course') {\n pageContextIncludes = 'parents';\n }\n self.pickerInstance = new Picker(self.pageContextId, false, pageContextIncludes);\n self.pickerInstance.on('save', function(e, data) {\n var compIds = data.competencyIds;\n\n if (self.itemtype === \"course\") {\n requests = [];\n\n $.each(compIds, function(index, compId) {\n requests.push({\n methodname: 'core_competency_add_competency_to_course',\n args: {courseid: self.itemid, competencyid: compId}\n });\n });\n requests.push({\n methodname: 'tool_lp_data_for_course_competencies_page',\n args: {courseid: self.itemid, moduleid: 0}\n });\n\n pagerender = 'tool_lp/course_competencies_page';\n pageregion = 'coursecompetenciespage';\n\n } else if (self.itemtype === \"template\") {\n requests = [];\n\n $.each(compIds, function(index, compId) {\n requests.push({\n methodname: 'core_competency_add_competency_to_template',\n args: {templateid: self.itemid, competencyid: compId}\n });\n });\n requests.push({\n methodname: 'tool_lp_data_for_template_competencies_page',\n args: {templateid: self.itemid, pagecontext: {contextid: self.pageContextId}}\n });\n pagerender = 'tool_lp/template_competencies_page';\n pageregion = 'templatecompetenciespage';\n } else if (self.itemtype === \"plan\") {\n requests = [];\n\n $.each(compIds, function(index, compId) {\n requests.push({\n methodname: 'core_competency_add_competency_to_plan',\n args: {planid: self.itemid, competencyid: compId}\n });\n });\n requests.push({\n methodname: 'tool_lp_data_for_plan_page',\n args: {planid: self.itemid}\n });\n pagerender = 'tool_lp/plan_page';\n pageregion = 'plan-page';\n }\n ajax.call(requests)[requests.length - 1].then(function(context) {\n return templates.render(pagerender, context);\n }).then(function(html, js) {\n $('[data-region=\"' + pageregion + '\"]').replaceWith(html);\n templates.runTemplateJS(js);\n return;\n }).catch(notification.exception);\n });\n }\n\n self.pickerInstance.display();\n };\n\n /**\n * Delete the link between competency and course, template or plan. Reload the page.\n *\n * @method doDelete\n * @param {int} deleteid The id of record to delete.\n */\n competencies.prototype.doDelete = function(deleteid) {\n var localthis = this;\n var requests = [],\n pagerender = '',\n pageregion = '';\n\n // Delete the link and reload the page template.\n if (localthis.itemtype == 'course') {\n requests = ajax.call([\n {methodname: 'core_competency_remove_competency_from_course',\n args: {courseid: localthis.itemid, competencyid: deleteid}},\n {methodname: 'tool_lp_data_for_course_competencies_page',\n args: {courseid: localthis.itemid, moduleid: 0}}\n ]);\n pagerender = 'tool_lp/course_competencies_page';\n pageregion = 'coursecompetenciespage';\n } else if (localthis.itemtype == 'template') {\n requests = ajax.call([\n {methodname: 'core_competency_remove_competency_from_template',\n args: {templateid: localthis.itemid, competencyid: deleteid}},\n {methodname: 'tool_lp_data_for_template_competencies_page',\n args: {templateid: localthis.itemid, pagecontext: {contextid: localthis.pageContextId}}}\n ]);\n pagerender = 'tool_lp/template_competencies_page';\n pageregion = 'templatecompetenciespage';\n } else if (localthis.itemtype == 'plan') {\n requests = ajax.call([\n {methodname: 'core_competency_remove_competency_from_plan',\n args: {planid: localthis.itemid, competencyid: deleteid}},\n {methodname: 'tool_lp_data_for_plan_page',\n args: {planid: localthis.itemid}}\n ]);\n pagerender = 'tool_lp/plan_page';\n pageregion = 'plan-page';\n }\n\n requests[1].done(function(context) {\n templates.render(pagerender, context).done(function(html, js) {\n $('[data-region=\"' + pageregion + '\"]').replaceWith(html);\n templates.runTemplateJS(js);\n }).fail(notification.exception);\n }).fail(notification.exception);\n\n };\n\n /**\n * Show a confirm dialogue before deleting a competency.\n *\n * @method deleteHandler\n * @param {int} deleteid The id of record to delete.\n */\n competencies.prototype.deleteHandler = function(deleteid) {\n var localthis = this;\n var requests = [];\n var message;\n\n if (localthis.itemtype == 'course') {\n message = 'unlinkcompetencycourse';\n } else if (localthis.itemtype == 'template') {\n message = 'unlinkcompetencytemplate';\n } else if (localthis.itemtype == 'plan') {\n message = 'unlinkcompetencyplan';\n } else {\n return;\n }\n\n requests = ajax.call([{\n methodname: 'core_competency_read_competency',\n args: {id: deleteid}\n }]);\n\n requests[0].done(function(competency) {\n str.get_strings([\n {key: 'confirm', component: 'moodle'},\n {key: message, component: 'tool_lp', param: competency.shortname},\n {key: 'confirm', component: 'moodle'},\n {key: 'cancel', component: 'moodle'}\n ]).done(function(strings) {\n notification.confirm(\n strings[0], // Confirm.\n strings[1], // Unlink the competency X from the course?\n strings[2], // Confirm.\n strings[3], // Cancel.\n function() {\n localthis.doDelete(deleteid);\n }\n );\n }).fail(notification.exception);\n }).fail(notification.exception);\n };\n\n /**\n * Register the javascript event handlers for this page.\n *\n * @method registerEvents\n */\n competencies.prototype.registerEvents = function() {\n var localthis = this;\n\n if (localthis.itemtype == 'course') {\n // Course completion rule handling.\n $('[data-region=\"coursecompetenciespage\"]').on('change', 'select[data-field=\"ruleoutcome\"]', function(e) {\n var requests = [];\n var pagerender = 'tool_lp/course_competencies_page';\n var pageregion = 'coursecompetenciespage';\n var coursecompetencyid = $(e.target).data('id');\n var ruleoutcome = $(e.target).val();\n requests = ajax.call([\n {methodname: 'core_competency_set_course_competency_ruleoutcome',\n args: {coursecompetencyid: coursecompetencyid, ruleoutcome: ruleoutcome}},\n {methodname: 'tool_lp_data_for_course_competencies_page',\n args: {courseid: localthis.itemid, moduleid: 0}}\n ]);\n\n requests[1].done(function(context) {\n templates.render(pagerender, context).done(function(html, js) {\n $('[data-region=\"' + pageregion + '\"]').replaceWith(html);\n templates.runTemplateJS(js);\n }).fail(notification.exception);\n }).fail(notification.exception);\n });\n }\n\n $('[data-region=\"actions\"] button').click(function(e) {\n e.preventDefault();\n localthis.pickCompetency();\n });\n $('[data-action=\"delete-competency-link\"]').click(function(e) {\n e.preventDefault();\n\n var deleteid = $(e.target).closest('[data-id]').data('id');\n localthis.deleteHandler(deleteid);\n });\n };\n\n return /** @alias module:tool_lp/competencies */ competencies;\n});\n"],"file":"competencies.min.js"} \ No newline at end of file +{"version":3,"sources":["../src/competencies.js"],"names":["define","$","notification","ajax","templates","str","Picker","dragdrop","Pending","competencies","itemid","itemtype","pagectxid","pageContextId","pickerInstance","prop","registerEvents","registerDragDrop","prototype","localthis","get_string","done","movestring","identifier","component","drag","drop","handleDrop","fail","exception","fromid","data","toid","requests","call","methodname","args","courseid","competencyidfrom","competencyidto","templateid","planid","pickCompetency","self","pagerender","pageregion","pageContextIncludes","on","e","compIds","competencyIds","pendingPromise","each","index","compId","push","competencyid","moduleid","pagecontext","contextid","length","then","context","render","html","js","replaceNode","resolve","catch","display","doDelete","deleteid","replaceWith","runTemplateJS","deleteHandler","message","id","competency","get_strings","key","param","shortname","strings","confirm","coursecompetencyid","target","ruleoutcome","val","click","preventDefault","closest"],"mappings":"AAuBAA,OAAM,wBAAC,CAAC,QAAD,CACC,mBADD,CAEC,WAFD,CAGC,gBAHD,CAIC,UAJD,CAKC,0BALD,CAMC,0BAND,CAOC,cAPD,CAAD,CAQC,SAASC,CAAT,CAAYC,CAAZ,CAA0BC,CAA1B,CAAgCC,CAAhC,CAA2CC,CAA3C,CAAgDC,CAAhD,CAAwDC,CAAxD,CAAkEC,CAAlE,CAA2E,CAS9E,GAAIC,CAAAA,CAAY,CAAG,SAASC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gB,OADzB,EAEKC,KAFL,EAGH,CAPD,EAQAnE,CAAC,CAAC,0CAAD,CAAD,CAA4CuF,KAA5C,CAAkD,SAASxC,CAAT,CAAY,CAC1DA,CAAC,CAACyC,cAAF,GAEA,GAAIlB,CAAAA,CAAQ,CAAGtE,CAAC,CAAC+C,CAAC,CAACqC,MAAH,CAAD,CAAYK,OAAZ,CAAoB,WAApB,EAAiC3D,IAAjC,CAAsC,IAAtC,CAAf,CACAZ,CAAS,CAACuD,aAAV,CAAwBH,CAAxB,CACH,CALD,CAMH,CA5CD,CA8CA,MAAiD9D,CAAAA,CACpD,CAxUK,CAAN","sourcesContent":["// This file is part of Moodle - http://moodle.org/\n//\n// Moodle is free software: you can redistribute it and/or modify\n// it under the terms of the GNU General Public License as published by\n// the Free Software Foundation, either version 3 of the License, or\n// (at your option) any later version.\n//\n// Moodle is distributed in the hope that it will be useful,\n// but WITHOUT ANY WARRANTY; without even the implied warranty of\n// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the\n// GNU General Public License for more details.\n//\n// You should have received a copy of the GNU General Public License\n// along with Moodle. If not, see .\n\n/**\n * Handle add/remove competency links.\n *\n * @module tool_lp/competencies\n * @package tool_lp\n * @copyright 2015 Damyon Wiese \n * @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later\n */\ndefine(['jquery',\n 'core/notification',\n 'core/ajax',\n 'core/templates',\n 'core/str',\n 'tool_lp/competencypicker',\n 'tool_lp/dragdrop-reorder',\n 'core/pending'],\n function($, notification, ajax, templates, str, Picker, dragdrop, Pending) {\n\n /**\n * Constructor\n *\n * @param {Number} itemid\n * @param {String} itemtype\n * @param {Number} pagectxid\n */\n var competencies = function(itemid, itemtype, pagectxid) {\n this.itemid = itemid;\n this.itemtype = itemtype;\n this.pageContextId = pagectxid;\n this.pickerInstance = null;\n\n $('[data-region=\"actions\"] button').prop('disabled', false);\n this.registerEvents();\n this.registerDragDrop();\n };\n\n /**\n * Initialise the drag/drop code.\n * @method registerDragDrop\n */\n competencies.prototype.registerDragDrop = function() {\n var localthis = this;\n // Init this module.\n str.get_string('movecompetency', 'tool_lp').done(\n function(movestring) {\n dragdrop.dragdrop('movecompetency',\n movestring,\n {identifier: 'movecompetency', component: 'tool_lp'},\n {identifier: 'movecompetencyafter', component: 'tool_lp'},\n 'drag-samenode',\n 'drag-parentnode',\n 'drag-handlecontainer',\n function(drag, drop) {\n localthis.handleDrop(drag, drop);\n });\n }\n ).fail(notification.exception);\n\n };\n\n /**\n * Handle a drop from a drag/drop operation.\n *\n * @method handleDrop\n * @param {DOMNode} drag The dragged node.\n * @param {DOMNode} drop The dropped on node.\n */\n competencies.prototype.handleDrop = function(drag, drop) {\n var fromid = $(drag).data('id');\n var toid = $(drop).data('id');\n var localthis = this;\n var requests = [];\n\n if (localthis.itemtype == 'course') {\n requests = ajax.call([\n {\n methodname: 'core_competency_reorder_course_competency',\n args: {courseid: localthis.itemid, competencyidfrom: fromid, competencyidto: toid}\n }\n ]);\n } else if (localthis.itemtype == 'template') {\n requests = ajax.call([\n {\n methodname: 'core_competency_reorder_template_competency',\n args: {templateid: localthis.itemid, competencyidfrom: fromid, competencyidto: toid}\n }\n ]);\n } else if (localthis.itemtype == 'plan') {\n requests = ajax.call([\n {\n methodname: 'core_competency_reorder_plan_competency',\n args: {planid: localthis.itemid, competencyidfrom: fromid, competencyidto: toid}\n }\n ]);\n } else {\n return;\n }\n\n requests[0].fail(notification.exception);\n };\n\n /**\n * Pick a competency\n *\n * @method pickCompetency\n * @return {Promise}\n */\n competencies.prototype.pickCompetency = function() {\n var self = this;\n var requests;\n var pagerender;\n var pageregion;\n var pageContextIncludes;\n\n if (!self.pickerInstance) {\n if (self.itemtype === 'template' || self.itemtype === 'course') {\n pageContextIncludes = 'parents';\n }\n self.pickerInstance = new Picker(self.pageContextId, false, pageContextIncludes);\n self.pickerInstance.on('save', function(e, data) {\n var compIds = data.competencyIds;\n var pendingPromise = new Pending();\n\n if (self.itemtype === \"course\") {\n requests = [];\n\n $.each(compIds, function(index, compId) {\n requests.push({\n methodname: 'core_competency_add_competency_to_course',\n args: {courseid: self.itemid, competencyid: compId}\n });\n });\n requests.push({\n methodname: 'tool_lp_data_for_course_competencies_page',\n args: {courseid: self.itemid, moduleid: 0}\n });\n\n pagerender = 'tool_lp/course_competencies_page';\n pageregion = 'coursecompetenciespage';\n\n } else if (self.itemtype === \"template\") {\n requests = [];\n\n $.each(compIds, function(index, compId) {\n requests.push({\n methodname: 'core_competency_add_competency_to_template',\n args: {templateid: self.itemid, competencyid: compId}\n });\n });\n requests.push({\n methodname: 'tool_lp_data_for_template_competencies_page',\n args: {templateid: self.itemid, pagecontext: {contextid: self.pageContextId}}\n });\n pagerender = 'tool_lp/template_competencies_page';\n pageregion = 'templatecompetenciespage';\n } else if (self.itemtype === \"plan\") {\n requests = [];\n\n $.each(compIds, function(index, compId) {\n requests.push({\n methodname: 'core_competency_add_competency_to_plan',\n args: {planid: self.itemid, competencyid: compId}\n });\n });\n requests.push({\n methodname: 'tool_lp_data_for_plan_page',\n args: {planid: self.itemid}\n });\n pagerender = 'tool_lp/plan_page';\n pageregion = 'plan-page';\n }\n ajax.call(requests)[requests.length - 1]\n .then(function(context) {\n return templates.render(pagerender, context);\n })\n .then(function(html, js) {\n templates.replaceNode($('[data-region=\"' + pageregion + '\"]'), html, js);\n return;\n })\n .then(pendingPromise.resolve)\n .catch(notification.exception);\n });\n }\n\n return self.pickerInstance.display();\n };\n\n /**\n * Delete the link between competency and course, template or plan. Reload the page.\n *\n * @method doDelete\n * @param {int} deleteid The id of record to delete.\n */\n competencies.prototype.doDelete = function(deleteid) {\n var localthis = this;\n var requests = [],\n pagerender = '',\n pageregion = '';\n\n // Delete the link and reload the page template.\n if (localthis.itemtype == 'course') {\n requests = ajax.call([\n {methodname: 'core_competency_remove_competency_from_course',\n args: {courseid: localthis.itemid, competencyid: deleteid}},\n {methodname: 'tool_lp_data_for_course_competencies_page',\n args: {courseid: localthis.itemid, moduleid: 0}}\n ]);\n pagerender = 'tool_lp/course_competencies_page';\n pageregion = 'coursecompetenciespage';\n } else if (localthis.itemtype == 'template') {\n requests = ajax.call([\n {methodname: 'core_competency_remove_competency_from_template',\n args: {templateid: localthis.itemid, competencyid: deleteid}},\n {methodname: 'tool_lp_data_for_template_competencies_page',\n args: {templateid: localthis.itemid, pagecontext: {contextid: localthis.pageContextId}}}\n ]);\n pagerender = 'tool_lp/template_competencies_page';\n pageregion = 'templatecompetenciespage';\n } else if (localthis.itemtype == 'plan') {\n requests = ajax.call([\n {methodname: 'core_competency_remove_competency_from_plan',\n args: {planid: localthis.itemid, competencyid: deleteid}},\n {methodname: 'tool_lp_data_for_plan_page',\n args: {planid: localthis.itemid}}\n ]);\n pagerender = 'tool_lp/plan_page';\n pageregion = 'plan-page';\n }\n\n requests[1].done(function(context) {\n templates.render(pagerender, context).done(function(html, js) {\n $('[data-region=\"' + pageregion + '\"]').replaceWith(html);\n templates.runTemplateJS(js);\n }).fail(notification.exception);\n }).fail(notification.exception);\n\n };\n\n /**\n * Show a confirm dialogue before deleting a competency.\n *\n * @method deleteHandler\n * @param {int} deleteid The id of record to delete.\n */\n competencies.prototype.deleteHandler = function(deleteid) {\n var localthis = this;\n var requests = [];\n var message;\n\n if (localthis.itemtype == 'course') {\n message = 'unlinkcompetencycourse';\n } else if (localthis.itemtype == 'template') {\n message = 'unlinkcompetencytemplate';\n } else if (localthis.itemtype == 'plan') {\n message = 'unlinkcompetencyplan';\n } else {\n return;\n }\n\n requests = ajax.call([{\n methodname: 'core_competency_read_competency',\n args: {id: deleteid}\n }]);\n\n requests[0].done(function(competency) {\n str.get_strings([\n {key: 'confirm', component: 'moodle'},\n {key: message, component: 'tool_lp', param: competency.shortname},\n {key: 'confirm', component: 'moodle'},\n {key: 'cancel', component: 'moodle'}\n ]).done(function(strings) {\n notification.confirm(\n strings[0], // Confirm.\n strings[1], // Unlink the competency X from the course?\n strings[2], // Confirm.\n strings[3], // Cancel.\n function() {\n localthis.doDelete(deleteid);\n }\n );\n }).fail(notification.exception);\n }).fail(notification.exception);\n };\n\n /**\n * Register the javascript event handlers for this page.\n *\n * @method registerEvents\n */\n competencies.prototype.registerEvents = function() {\n var localthis = this;\n\n if (localthis.itemtype == 'course') {\n // Course completion rule handling.\n $('[data-region=\"coursecompetenciespage\"]').on('change', 'select[data-field=\"ruleoutcome\"]', function(e) {\n var pendingPromise = new Pending();\n var requests = [];\n var pagerender = 'tool_lp/course_competencies_page';\n var pageregion = 'coursecompetenciespage';\n var coursecompetencyid = $(e.target).data('id');\n var ruleoutcome = $(e.target).val();\n requests = ajax.call([\n {methodname: 'core_competency_set_course_competency_ruleoutcome',\n args: {coursecompetencyid: coursecompetencyid, ruleoutcome: ruleoutcome}},\n {methodname: 'tool_lp_data_for_course_competencies_page',\n args: {courseid: localthis.itemid, moduleid: 0}}\n ]);\n\n requests[1].then(function(context) {\n return templates.render(pagerender, context);\n })\n .then(function(html, js) {\n return templates.replaceNode($('[data-region=\"' + pageregion + '\"]'), html, js);\n })\n .then(pendingPromise.resolve)\n .catch(notification.exception);\n });\n }\n\n $('[data-region=\"actions\"] button').click(function(e) {\n var pendingPromise = new Pending();\n e.preventDefault();\n\n localthis.pickCompetency()\n .then(pendingPromise.resolve)\n .catch();\n });\n $('[data-action=\"delete-competency-link\"]').click(function(e) {\n e.preventDefault();\n\n var deleteid = $(e.target).closest('[data-id]').data('id');\n localthis.deleteHandler(deleteid);\n });\n };\n\n return /** @alias module:tool_lp/competencies */ competencies;\n});\n"],"file":"competencies.min.js"} \ No newline at end of file diff --git a/admin/tool/lp/amd/build/competencyactions.min.js b/admin/tool/lp/amd/build/competencyactions.min.js index 5314ff2902e..838c6249d6a 100644 --- a/admin/tool/lp/amd/build/competencyactions.min.js +++ b/admin/tool/lp/amd/build/competencyactions.min.js @@ -1,2 +1,2 @@ -define ("tool_lp/competencyactions",["jquery","core/url","core/templates","core/notification","core/str","core/ajax","tool_lp/dragdrop-reorder","tool_lp/tree","tool_lp/dialogue","tool_lp/menubar","tool_lp/competencypicker","tool_lp/competency_outcomes","tool_lp/competencyruleconfig"],function(a,b,c,d,e,f,g,h,i,j,k,l,m){var n=null,o=null,p=null,q,r,s,t,u,v,w=null,x=function(){var c=a("[data-region=\"competencyactions\"]").data("competency"),f={competencyframeworkid:n.getCompetencyFrameworkId(),pagecontextid:q};if(null!==c){f.parentid=c.id}var g=function(){var c=a.param(f);window.location=b.relativeUrl("/admin/tool/lp/editcompetency.php?"+c)};if(null!==c&&n.hasRule(c.id)){e.get_strings([{key:"confirm",component:"moodle"},{key:"addingcompetencywillresetparentrule",component:"tool_lp",param:c.shortname},{key:"yes",component:"core"},{key:"no",component:"core"}]).done(function(a){d.confirm(a[0],a[1],a[2],a[3],g)}).fail(d.exception)}else{g()}},y=function(){var b=a("[data-region=\"filtercompetencies\"]").data("frameworkid"),c=f.call([{methodname:"core_competency_set_parent_competency",args:{competencyid:o,parentid:p}},{methodname:"tool_lp_data_for_competencies_manage_page",args:{competencyframeworkid:b,search:a("[data-region=\"filtercompetencies\"] input").val()}}]);c[1].done(E).fail(d.exception)},z=function(){p="undefined"==typeof p?0:p;if(p==o){return}var a=n.getCompetency(p)||{},b=n.getCompetency(o)||{},c="movecompetencywillresetrules",f=!1;if(b.parentid==p){return}if(a.path&&0<=a.path.indexOf("/"+b.id+"/")){c="movecompetencytochildofselfwillresetrules";f=f||n.hasRule(b.id)}f=f||n.hasRule(a.id)||n.hasRule(b.parentid);if(f){e.get_strings([{key:"confirm",component:"moodle"},{key:c,component:"tool_lp"},{key:"yes",component:"moodle"},{key:"no",component:"moodle"}]).done(function(a){d.confirm(a[0],a[1],a[2],a[3],y)}).fail(d.exception)}else{y()}},A=function(b){var c=a(b.getContent()),d=c.find("[data-enhance=movetree]"),e=new h(d,!1);e.on("selectionchanged",function(b,c){var d=c.selected;p=a(d).data("id")});d.show();c.on("click","[data-action=\"move\"]",function(){b.close();z()});c.on("click","[data-action=\"cancel\"]",function(){b.close()})},B=function(a,b){var c;for(c=0;cspan",O).on("dragover","li>span",P).on("dragenter","li>span",Q).on("dragleave","li>span",R).on("drop","li>span",S);b.on("selectionchanged",$);s=new m(n,v);s.on("save",L.bind(this))}}}); +define ("tool_lp/competencyactions",["jquery","core/url","core/templates","core/notification","core/str","core/ajax","tool_lp/dragdrop-reorder","tool_lp/tree","tool_lp/dialogue","tool_lp/menubar","tool_lp/competencypicker","tool_lp/competency_outcomes","tool_lp/competencyruleconfig","core/pending"],function(a,b,c,d,e,f,g,h,i,j,k,l,m,n){var o=null,p=null,q=null,r,s,t,u,v,w,x=null,y=function(){var c=a("[data-region=\"competencyactions\"]").data("competency"),f={competencyframeworkid:o.getCompetencyFrameworkId(),pagecontextid:r};if(null!==c){f.parentid=c.id}var g=function(){var c=a.param(f);window.location=b.relativeUrl("/admin/tool/lp/editcompetency.php?"+c)};if(null!==c&&o.hasRule(c.id)){e.get_strings([{key:"confirm",component:"moodle"},{key:"addingcompetencywillresetparentrule",component:"tool_lp",param:c.shortname},{key:"yes",component:"core"},{key:"no",component:"core"}]).done(function(a){d.confirm(a[0],a[1],a[2],a[3],g)}).fail(d.exception)}else{g()}},z=function(){var b=a("[data-region=\"filtercompetencies\"]").data("frameworkid"),c=f.call([{methodname:"core_competency_set_parent_competency",args:{competencyid:p,parentid:q}},{methodname:"tool_lp_data_for_competencies_manage_page",args:{competencyframeworkid:b,search:a("[data-region=\"filtercompetencies\"] input").val()}}]);c[1].done(F).fail(d.exception)},A=function(){q="undefined"==typeof q?0:q;if(q==p){return}var a=o.getCompetency(q)||{},b=o.getCompetency(p)||{},c="movecompetencywillresetrules",f=!1;if(b.parentid==q){return}if(a.path&&0<=a.path.indexOf("/"+b.id+"/")){c="movecompetencytochildofselfwillresetrules";f=f||o.hasRule(b.id)}f=f||o.hasRule(a.id)||o.hasRule(b.parentid);if(f){e.get_strings([{key:"confirm",component:"moodle"},{key:c,component:"tool_lp"},{key:"yes",component:"moodle"},{key:"no",component:"moodle"}]).done(function(a){d.confirm(a[0],a[1],a[2],a[3],z)}).fail(d.exception)}else{z()}},B=function(b){var c=a(b.getContent()),d=c.find("[data-enhance=movetree]"),e=new h(d,!1);e.on("selectionchanged",function(b,c){var d=c.selected;q=a(d).data("id")});d.show();c.on("click","[data-action=\"move\"]",function(){b.close();A()});c.on("click","[data-action=\"cancel\"]",function(){b.close()})},C=function(a,b){var c;for(c=0;cspan",P).on("dragover","li>span",Q).on("dragenter","li>span",R).on("dragleave","li>span",S).on("drop","li>span",T);b.on("selectionchanged",_);t=new m(o,w);t.on("save",M.bind(this))}}}); //# sourceMappingURL=competencyactions.min.js.map diff --git a/admin/tool/lp/amd/build/competencyactions.min.js.map b/admin/tool/lp/amd/build/competencyactions.min.js.map index baafad8e3de..3bdbdc7773f 100644 --- a/admin/tool/lp/amd/build/competencyactions.min.js.map +++ b/admin/tool/lp/amd/build/competencyactions.min.js.map @@ -1 +1 @@ -{"version":3,"sources":["../src/competencyactions.js"],"names":["define","$","url","templates","notification","str","ajax","dragdrop","Ariatree","Dialogue","menubar","Picker","Outcomes","RuleConfig","treeModel","moveSource","moveTarget","pageContextId","pickerInstance","ruleConfigInstance","relatedTarget","taxonomiesConstants","rulesModules","selectedCompetencyId","addHandler","parent","data","params","competencyframeworkid","getCompetencyFrameworkId","pagecontextid","parentid","id","relocate","queryparams","param","window","location","relativeUrl","hasRule","get_strings","key","component","shortname","done","strings","confirm","fail","exception","doMove","frameworkid","requests","call","methodname","args","competencyid","search","val","reloadPage","confirmMove","targetComp","getCompetency","sourceComp","confirmMessage","showConfirm","path","indexOf","initMovePopup","popup","body","getContent","treeRoot","find","tree","on","evt","target","selected","show","close","addCompetencyChildren","competencies","i","length","haschildren","children","moveHandler","e","preventDefault","competency","searchtext","when","apply","framework","competenciestree","onecompetency","render","editHandler","context","newhtml","newjs","replaceWith","runTemplateJS","updateSearchHandler","moveUpHandler","moveDownHandler","seeCoursesHandler","courses","html","get_string","linkedcourses","relateCompetenciesHandler","compIds","competencyIds","calls","each","index","value","push","relatedcompetencyid","promises","then","js","updatedRelatedCompetencies","catch","setDisallowedCompetencyIDs","display","ruleConfigHandler","setTargetCompetencyId","ruleConfigSaveHandler","config","update","idnumber","description","descriptionformat","ruletype","ruleoutcome","ruleconfig","promise","result","renderCompetencySummary","doDelete","success","alert","deleteCompetencyHandler","dragStart","originalEvent","dataTransfer","setData","allowDrop","dropEffect","dragEnter","addClass","dragLeave","removeClass","dropOver","getData","deleteRelatedHandler","relatedid","substr","removeRelated","triggerCompetencyViewedEvent","getTaxonomyAtLevel","level","constant","Deferred","resolve","showdeleterelatedaction","showrelatedcompetencies","showrule","pluginbaseurl","NONE","getString","name","modInfo","type","strs","rule","outcome","replaceNodeContents","strAddTaxonomy","strSelectedTaxonomy","selectionChanged","node","btn","actionMenu","selectedTitle","sublevel","closeAll","clone","remove","end","text","hide","getCompetencyLevel","parseTaxonomies","taxonomiesstr","all","split","unshift","init","model","pagectxid","taxonomies","rulesMods","enhance","bind","top"],"mappings":"AAuBAA,OAAM,6BAAC,CAAC,QAAD,CACC,UADD,CAEC,gBAFD,CAGC,mBAHD,CAIC,UAJD,CAKC,WALD,CAMC,0BAND,CAOC,cAPD,CAQC,kBARD,CASC,iBATD,CAUC,0BAVD,CAWC,6BAXD,CAYC,8BAZD,CAAD,CAaC,SAASC,CAAT,CAAYC,CAAZ,CAAiBC,CAAjB,CAA4BC,CAA5B,CAA0CC,CAA1C,CAA+CC,CAA/C,CAAqDC,CAArD,CAA+DC,CAA/D,CAAyEC,CAAzE,CAAmFC,CAAnF,CAA4FC,CAA5F,CAAoGC,CAApG,CAA8GC,CAA9G,CAA0H,IAIzHC,CAAAA,CAAS,CAAG,IAJ6G,CAMzHC,CAAU,CAAG,IAN4G,CAQzHC,CAAU,CAAG,IAR4G,CAUzHC,CAVyH,CAYzHC,CAZyH,CAczHC,CAdyH,CAgBzHC,CAhByH,CAkBzHC,CAlByH,CAoBzHC,CApByH,CAsBzHC,CAAoB,CAAG,IAtBkG,CA4BzHC,CAAU,C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C,sCAAD,CAAD,CAAwCyE,EAAxC,CAA2C,QAA3C,CAAqD6B,CAArD,EAEA,GAAIwG,CAAAA,CAAG,CAAG9M,CAAC,CAAC,8DAAD,CAAX,CACA8M,CAAG,CAACrI,EAAJ,CAAO,WAAP,CAAoB,SAApB,CAA+BuE,CAA/B,EACKvE,EADL,CACQ,UADR,CACoB,SADpB,CAC+B2E,CAD/B,EAEK3E,EAFL,CAEQ,WAFR,CAEqB,SAFrB,CAEgC6E,CAFhC,EAGK7E,EAHL,CAGQ,WAHR,CAGqB,SAHrB,CAGgC+E,CAHhC,EAIK/E,EAJL,CAIQ,MAJR,CAIgB,SAJhB,CAI2BiF,CAJ3B,EAMA8C,CAAK,CAAC/H,EAAN,CAAS,kBAAT,CAA6B4G,CAA7B,EAGAnK,CAAkB,CAAG,GAAIN,CAAAA,CAAJ,CAAeC,CAAf,CAA0BQ,CAA1B,CAArB,CACAH,CAAkB,CAACuD,EAAnB,CAAsB,MAAtB,CAA8BuD,CAAqB,CAAC6E,IAAtB,CAA2B,IAA3B,CAA9B,CACH,CA7CE,CA+CV,CAr0BK,CAAN","sourcesContent":["// This file is part of Moodle - http://moodle.org/\n//\n// Moodle is free software: you can redistribute it and/or modify\n// it under the terms of the GNU General Public License as published by\n// the Free Software Foundation, either version 3 of the License, or\n// (at your option) any later version.\n//\n// Moodle is distributed in the hope that it will be useful,\n// but WITHOUT ANY WARRANTY; without even the implied warranty of\n// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the\n// GNU General Public License for more details.\n//\n// You should have received a copy of the GNU General Public License\n// along with Moodle. If not, see .\n\n/**\n * Handle selection changes and actions on the competency tree.\n *\n * @module tool_lp/competencyactions\n * @package tool_lp\n * @copyright 2015 Damyon Wiese \n * @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later\n */\ndefine(['jquery',\n 'core/url',\n 'core/templates',\n 'core/notification',\n 'core/str',\n 'core/ajax',\n 'tool_lp/dragdrop-reorder',\n 'tool_lp/tree',\n 'tool_lp/dialogue',\n 'tool_lp/menubar',\n 'tool_lp/competencypicker',\n 'tool_lp/competency_outcomes',\n 'tool_lp/competencyruleconfig'],\n function($, url, templates, notification, str, ajax, dragdrop, Ariatree, Dialogue, menubar, Picker, Outcomes, RuleConfig) {\n\n // Private variables and functions.\n /** @var {Object} treeModel - This is an object representing the nodes in the tree. */\n var treeModel = null;\n /** @var {Node} moveSource - The start of a drag operation */\n var moveSource = null;\n /** @var {Node} moveTarget - The end of a drag operation */\n var moveTarget = null;\n /** @var {Number} pageContextId The page context ID. */\n var pageContextId;\n /** @type {Object} Picker instance. */\n var pickerInstance;\n /** @type {Object} Rule config instance. */\n var ruleConfigInstance;\n /** @type {Object} The competency we're picking a relation to. */\n var relatedTarget;\n /** @type {Object} Taxonomy constants indexed per level. */\n var taxonomiesConstants;\n /** @type {Array} The rules modules. Values are object containing type, namd and amd. */\n var rulesModules;\n /** @type {Number} the selected competency ID. */\n var selectedCompetencyId = null;\n\n /**\n * Respond to choosing the \"Add\" menu item for the selected node in the tree.\n * @method addHandler\n */\n var addHandler = function() {\n var parent = $('[data-region=\"competencyactions\"]').data('competency');\n\n var params = {\n competencyframeworkid: treeModel.getCompetencyFrameworkId(),\n pagecontextid: pageContextId\n };\n\n if (parent !== null) {\n // We are adding at a sub node.\n params.parentid = parent.id;\n }\n\n var relocate = function() {\n var queryparams = $.param(params);\n window.location = url.relativeUrl('/admin/tool/lp/editcompetency.php?' + queryparams);\n };\n\n if (parent !== null && treeModel.hasRule(parent.id)) {\n str.get_strings([\n {key: 'confirm', component: 'moodle'},\n {key: 'addingcompetencywillresetparentrule', component: 'tool_lp', param: parent.shortname},\n {key: 'yes', component: 'core'},\n {key: 'no', component: 'core'}\n ]).done(function(strings) {\n notification.confirm(\n strings[0],\n strings[1],\n strings[2],\n strings[3],\n relocate\n );\n }).fail(notification.exception);\n } else {\n relocate();\n }\n };\n\n /**\n * A source and destination has been chosen - so time to complete a move.\n * @method doMove\n */\n var doMove = function() {\n var frameworkid = $('[data-region=\"filtercompetencies\"]').data('frameworkid');\n var requests = ajax.call([{\n methodname: 'core_competency_set_parent_competency',\n args: {competencyid: moveSource, parentid: moveTarget}\n }, {\n methodname: 'tool_lp_data_for_competencies_manage_page',\n args: {competencyframeworkid: frameworkid,\n search: $('[data-region=\"filtercompetencies\"] input').val()}\n }]);\n requests[1].done(reloadPage).fail(notification.exception);\n };\n\n /**\n * Confirms a competency move.\n *\n * @method confirmMove\n */\n var confirmMove = function() {\n moveTarget = typeof moveTarget === \"undefined\" ? 0 : moveTarget;\n if (moveTarget == moveSource) {\n // No move to do.\n return;\n }\n\n var targetComp = treeModel.getCompetency(moveTarget) || {},\n sourceComp = treeModel.getCompetency(moveSource) || {},\n confirmMessage = 'movecompetencywillresetrules',\n showConfirm = false;\n\n // We shouldn't be moving the competency to the same parent.\n if (sourceComp.parentid == moveTarget) {\n return;\n }\n\n // If we are moving to a child of self.\n if (targetComp.path && targetComp.path.indexOf('/' + sourceComp.id + '/') >= 0) {\n confirmMessage = 'movecompetencytochildofselfwillresetrules';\n\n // Show a confirmation if self has rules, as they'll disappear.\n showConfirm = showConfirm || treeModel.hasRule(sourceComp.id);\n }\n\n // Show a confirmation if the current parent, or the destination have rules.\n showConfirm = showConfirm || (treeModel.hasRule(targetComp.id) || treeModel.hasRule(sourceComp.parentid));\n\n // Show confirm, and/or do the things.\n if (showConfirm) {\n str.get_strings([\n {key: 'confirm', component: 'moodle'},\n {key: confirmMessage, component: 'tool_lp'},\n {key: 'yes', component: 'moodle'},\n {key: 'no', component: 'moodle'}\n ]).done(function(strings) {\n notification.confirm(\n strings[0], // Confirm.\n strings[1], // Delete competency X?\n strings[2], // Delete.\n strings[3], // Cancel.\n doMove\n );\n }).fail(notification.exception);\n\n } else {\n doMove();\n }\n };\n\n /**\n * A move competency popup was opened - initialise the aria tree in it.\n * @method initMovePopup\n * @param {dialogue} popup The tool_lp/dialogue that was created.\n */\n var initMovePopup = function(popup) {\n var body = $(popup.getContent());\n var treeRoot = body.find('[data-enhance=movetree]');\n var tree = new Ariatree(treeRoot, false);\n tree.on('selectionchanged', function(evt, params) {\n var target = params.selected;\n moveTarget = $(target).data('id');\n });\n treeRoot.show();\n\n body.on('click', '[data-action=\"move\"]', function() {\n popup.close();\n confirmMove();\n });\n body.on('click', '[data-action=\"cancel\"]', function() {\n popup.close();\n });\n };\n\n /**\n * Turn a flat list of competencies into a tree structure (recursive).\n * @method addCompetencyChildren\n * @param {Object} parent The current parent node in the tree\n * @param {Object[]} competencies The flat list of competencies\n */\n var addCompetencyChildren = function(parent, competencies) {\n var i;\n\n for (i = 0; i < competencies.length; i++) {\n if (competencies[i].parentid == parent.id) {\n parent.haschildren = true;\n competencies[i].children = [];\n competencies[i].haschildren = false;\n parent.children[parent.children.length] = competencies[i];\n addCompetencyChildren(competencies[i], competencies);\n }\n }\n };\n\n /**\n * A node was chosen and \"Move\" was selected from the menu. Open a popup to select the target.\n * @param {Event} e\n * @method moveHandler\n */\n var moveHandler = function(e) {\n e.preventDefault();\n var competency = $('[data-region=\"competencyactions\"]').data('competency');\n\n // Remember what we are moving.\n moveSource = competency.id;\n\n // Load data for the template.\n var requests = ajax.call([\n {\n methodname: 'core_competency_search_competencies',\n args: {\n competencyframeworkid: competency.competencyframeworkid,\n searchtext: ''\n }\n }, {\n methodname: 'core_competency_read_competency_framework',\n args: {\n id: competency.competencyframeworkid\n }\n }\n ]);\n\n // When all data has arrived, continue.\n $.when.apply(null, requests).done(function(competencies, framework) {\n\n // Expand the list of competencies into a tree.\n var i;\n var competenciestree = [];\n for (i = 0; i < competencies.length; i++) {\n var onecompetency = competencies[i];\n if (onecompetency.parentid == \"0\") {\n onecompetency.children = [];\n onecompetency.haschildren = 0;\n competenciestree[competenciestree.length] = onecompetency;\n addCompetencyChildren(onecompetency, competencies);\n }\n }\n\n str.get_strings([\n {key: 'movecompetency', component: 'tool_lp', param: competency.shortname},\n {key: 'move', component: 'tool_lp'},\n {key: 'cancel', component: 'moodle'}\n ]).done(function(strings) {\n\n var context = {\n framework: framework,\n competencies: competenciestree\n };\n\n templates.render('tool_lp/competencies_move_tree', context)\n .done(function(tree) {\n new Dialogue(\n strings[0], // Move competency x.\n tree, // The move tree.\n initMovePopup\n );\n\n }).fail(notification.exception);\n\n }).fail(notification.exception);\n\n }).fail(notification.exception);\n\n };\n\n /**\n * Edit the selected competency.\n * @method editHandler\n */\n var editHandler = function() {\n var competency = $('[data-region=\"competencyactions\"]').data('competency');\n\n var params = {\n competencyframeworkid: treeModel.getCompetencyFrameworkId(),\n id: competency.id,\n parentid: competency.parentid,\n pagecontextid: pageContextId\n };\n\n var queryparams = $.param(params);\n window.location = url.relativeUrl('/admin/tool/lp/editcompetency.php?' + queryparams);\n };\n\n /**\n * Re-render the page with the latest data.\n * @param {Object} context\n * @method reloadPage\n */\n var reloadPage = function(context) {\n templates.render('tool_lp/manage_competencies_page', context)\n .done(function(newhtml, newjs) {\n $('[data-region=\"managecompetencies\"]').replaceWith(newhtml);\n templates.runTemplateJS(newjs);\n })\n .fail(notification.exception);\n };\n\n /**\n * Perform a search and render the page with the new search results.\n * @param {Event} e\n * @method updateSearchHandler\n */\n var updateSearchHandler = function(e) {\n e.preventDefault();\n\n var frameworkid = $('[data-region=\"filtercompetencies\"]').data('frameworkid');\n\n var requests = ajax.call([{\n methodname: 'tool_lp_data_for_competencies_manage_page',\n args: {competencyframeworkid: frameworkid,\n search: $('[data-region=\"filtercompetencies\"] input').val()}\n }]);\n requests[0].done(reloadPage).fail(notification.exception);\n };\n\n /**\n * Move a competency \"up\". This only affects the sort order within the same branch of the tree.\n * @method moveUpHandler\n */\n var moveUpHandler = function() {\n // We are chaining ajax requests here.\n var competency = $('[data-region=\"competencyactions\"]').data('competency');\n var requests = ajax.call([{\n methodname: 'core_competency_move_up_competency',\n args: {id: competency.id}\n }, {\n methodname: 'tool_lp_data_for_competencies_manage_page',\n args: {competencyframeworkid: competency.competencyframeworkid,\n search: $('[data-region=\"filtercompetencies\"] input').val()}\n }]);\n requests[1].done(reloadPage).fail(notification.exception);\n };\n\n /**\n * Move a competency \"down\". This only affects the sort order within the same branch of the tree.\n * @method moveDownHandler\n */\n var moveDownHandler = function() {\n // We are chaining ajax requests here.\n var competency = $('[data-region=\"competencyactions\"]').data('competency');\n var requests = ajax.call([{\n methodname: 'core_competency_move_down_competency',\n args: {id: competency.id}\n }, {\n methodname: 'tool_lp_data_for_competencies_manage_page',\n args: {competencyframeworkid: competency.competencyframeworkid,\n search: $('[data-region=\"filtercompetencies\"] input').val()}\n }]);\n requests[1].done(reloadPage).fail(notification.exception);\n };\n\n /**\n * Open a dialogue to show all the courses using the selected competency.\n * @method seeCoursesHandler\n */\n var seeCoursesHandler = function() {\n var competency = $('[data-region=\"competencyactions\"]').data('competency');\n\n var requests = ajax.call([{\n methodname: 'tool_lp_list_courses_using_competency',\n args: {id: competency.id}\n }]);\n\n requests[0].done(function(courses) {\n var context = {\n courses: courses\n };\n templates.render('tool_lp/linked_courses_summary', context).done(function(html) {\n str.get_string('linkedcourses', 'tool_lp').done(function(linkedcourses) {\n new Dialogue(\n linkedcourses, // Title.\n html, // The linked courses.\n initMovePopup\n );\n }).fail(notification.exception);\n }).fail(notification.exception);\n }).fail(notification.exception);\n };\n\n /**\n * Open a competencies popup to relate competencies.\n *\n * @method relateCompetenciesHandler\n */\n var relateCompetenciesHandler = function() {\n relatedTarget = $('[data-region=\"competencyactions\"]').data('competency');\n\n if (!pickerInstance) {\n pickerInstance = new Picker(pageContextId, relatedTarget.competencyframeworkid);\n pickerInstance.on('save', function(e, data) {\n var compIds = data.competencyIds;\n\n var calls = [];\n $.each(compIds, function(index, value) {\n calls.push({\n methodname: 'core_competency_add_related_competency',\n args: {competencyid: value, relatedcompetencyid: relatedTarget.id}\n });\n });\n\n calls.push({\n methodname: 'tool_lp_data_for_related_competencies_section',\n args: {competencyid: relatedTarget.id}\n });\n\n var promises = ajax.call(calls);\n\n promises[calls.length - 1].then(function(context) {\n return templates.render('tool_lp/related_competencies', context);\n }).then(function(html, js) {\n $('[data-region=\"relatedcompetencies\"]').replaceWith(html);\n templates.runTemplateJS(js);\n updatedRelatedCompetencies();\n return;\n }).catch(notification.exception);\n });\n }\n\n pickerInstance.setDisallowedCompetencyIDs([relatedTarget.id]);\n pickerInstance.display();\n };\n\n var ruleConfigHandler = function(e) {\n e.preventDefault();\n relatedTarget = $('[data-region=\"competencyactions\"]').data('competency');\n ruleConfigInstance.setTargetCompetencyId(relatedTarget.id);\n ruleConfigInstance.display();\n };\n\n var ruleConfigSaveHandler = function(e, config) {\n var update = {\n id: relatedTarget.id,\n shortname: relatedTarget.shortname,\n idnumber: relatedTarget.idnumber,\n description: relatedTarget.description,\n descriptionformat: relatedTarget.descriptionformat,\n ruletype: config.ruletype,\n ruleoutcome: config.ruleoutcome,\n ruleconfig: config.ruleconfig\n };\n var promise = ajax.call([{\n methodname: 'core_competency_update_competency',\n args: {competency: update}\n }]);\n promise[0].then(function(result) {\n if (result) {\n relatedTarget.ruletype = config.ruletype;\n relatedTarget.ruleoutcome = config.ruleoutcome;\n relatedTarget.ruleconfig = config.ruleconfig;\n renderCompetencySummary(relatedTarget);\n }\n return;\n }).catch(notification.exception);\n };\n\n /**\n * Delete a competency.\n * @method doDelete\n */\n var doDelete = function() {\n // We are chaining ajax requests here.\n var competency = $('[data-region=\"competencyactions\"]').data('competency');\n var requests = ajax.call([{\n methodname: 'core_competency_delete_competency',\n args: {id: competency.id}\n }, {\n methodname: 'tool_lp_data_for_competencies_manage_page',\n args: {competencyframeworkid: competency.competencyframeworkid,\n search: $('[data-region=\"filtercompetencies\"] input').val()}\n }]);\n requests[0].done(function(success) {\n if (success === false) {\n str.get_strings([\n {key: 'competencycannotbedeleted', component: 'tool_lp', param: competency.shortname},\n {key: 'cancel', component: 'moodle'}\n ]).done(function(strings) {\n notification.alert(\n null,\n strings[0]\n );\n }).fail(notification.exception);\n }\n }).fail(notification.exception);\n requests[1].done(reloadPage).fail(notification.exception);\n };\n\n /**\n * Show a confirm dialogue before deleting a competency.\n * @method deleteCompetencyHandler\n */\n var deleteCompetencyHandler = function() {\n var competency = $('[data-region=\"competencyactions\"]').data('competency'),\n confirmMessage = 'deletecompetency';\n\n if (treeModel.hasRule(competency.parentid)) {\n confirmMessage = 'deletecompetencyparenthasrule';\n }\n\n str.get_strings([\n {key: 'confirm', component: 'moodle'},\n {key: confirmMessage, component: 'tool_lp', param: competency.shortname},\n {key: 'delete', component: 'moodle'},\n {key: 'cancel', component: 'moodle'}\n ]).done(function(strings) {\n notification.confirm(\n strings[0], // Confirm.\n strings[1], // Delete competency X?\n strings[2], // Delete.\n strings[3], // Cancel.\n doDelete\n );\n }).fail(notification.exception);\n };\n\n /**\n * HTML5 implementation of drag/drop (there is an accesible alternative in the menus).\n * @method dragStart\n * @param {Event} e\n */\n var dragStart = function(e) {\n e.originalEvent.dataTransfer.setData('text', $(e.target).parent().data('id'));\n };\n\n /**\n * HTML5 implementation of drag/drop (there is an accesible alternative in the menus).\n * @method allowDrop\n * @param {Event} e\n */\n var allowDrop = function(e) {\n e.originalEvent.dataTransfer.dropEffect = 'move';\n e.preventDefault();\n };\n\n /**\n * HTML5 implementation of drag/drop (there is an accesible alternative in the menus).\n * @method dragEnter\n * @param {Event} e\n */\n var dragEnter = function(e) {\n e.preventDefault();\n $(this).addClass('currentdragtarget');\n };\n\n /**\n * HTML5 implementation of drag/drop (there is an accesible alternative in the menus).\n * @method dragLeave\n * @param {Event} e\n */\n var dragLeave = function(e) {\n e.preventDefault();\n $(this).removeClass('currentdragtarget');\n };\n\n /**\n * HTML5 implementation of drag/drop (there is an accesible alternative in the menus).\n * @method dropOver\n * @param {Event} e\n */\n var dropOver = function(e) {\n e.preventDefault();\n moveSource = e.originalEvent.dataTransfer.getData('text');\n moveTarget = $(e.target).parent().data('id');\n $(this).removeClass('currentdragtarget');\n\n confirmMove();\n };\n\n /**\n * Deletes a related competency without confirmation.\n *\n * @param {Event} e The event that triggered the action.\n * @method deleteRelatedHandler\n */\n var deleteRelatedHandler = function(e) {\n e.preventDefault();\n\n var relatedid = this.id.substr(11);\n var competency = $('[data-region=\"competencyactions\"]').data('competency');\n var removeRelated = ajax.call([\n {methodname: 'core_competency_remove_related_competency',\n args: {relatedcompetencyid: relatedid, competencyid: competency.id}},\n {methodname: 'tool_lp_data_for_related_competencies_section',\n args: {competencyid: competency.id}}\n ]);\n\n removeRelated[1].done(function(context) {\n templates.render('tool_lp/related_competencies', context).done(function(html) {\n $('[data-region=\"relatedcompetencies\"]').replaceWith(html);\n updatedRelatedCompetencies();\n }).fail(notification.exception);\n }).fail(notification.exception);\n };\n\n /**\n * Updates the competencies list (with relations) and add listeners.\n *\n * @method updatedRelatedCompetencies\n */\n var updatedRelatedCompetencies = function() {\n\n // Listeners to newly loaded related competencies.\n $('[data-action=\"deleterelation\"]').on('click', deleteRelatedHandler);\n\n };\n\n /**\n * Log the competency viewed event.\n *\n * @param {Object} competency The competency.\n * @method triggerCompetencyViewedEvent\n */\n var triggerCompetencyViewedEvent = function(competency) {\n if (competency.id !== selectedCompetencyId) {\n // Set the selected competency id.\n selectedCompetencyId = competency.id;\n ajax.call([{\n methodname: 'core_competency_competency_viewed',\n args: {id: competency.id}\n }]);\n }\n };\n\n /**\n * Return the taxonomy constant for a level.\n *\n * @param {Number} level The level.\n * @return {String}\n * @function getTaxonomyAtLevel\n */\n var getTaxonomyAtLevel = function(level) {\n var constant = taxonomiesConstants[level];\n if (!constant) {\n constant = 'competency';\n }\n return constant;\n };\n\n /**\n * Render the competency summary.\n *\n * @param {Object} competency The competency.\n */\n var renderCompetencySummary = function(competency) {\n var promise = $.Deferred().resolve().promise(),\n context = {};\n\n context.competency = competency;\n context.showdeleterelatedaction = true;\n context.showrelatedcompetencies = true;\n context.showrule = false;\n context.pluginbaseurl = url.relativeUrl('/admin/tool/lp');\n\n if (competency.ruleoutcome != Outcomes.NONE) {\n // Get the outcome and rule name.\n promise = Outcomes.getString(competency.ruleoutcome).then(function(str) {\n var name;\n $.each(rulesModules, function(index, modInfo) {\n if (modInfo.type == competency.ruletype) {\n name = modInfo.name;\n }\n });\n return [str, name];\n });\n }\n\n promise.then(function(strs) {\n if (typeof strs !== 'undefined') {\n context.showrule = true;\n context.rule = {\n outcome: strs[0],\n type: strs[1]\n };\n }\n return context;\n }).then(function(context) {\n return templates.render('tool_lp/competency_summary', context);\n }).then(function(html) {\n $('[data-region=\"competencyinfo\"]').html(html);\n $('[data-action=\"deleterelation\"]').on('click', deleteRelatedHandler);\n return templates.render('tool_lp/loading', {});\n }).then(function(html, js) {\n templates.replaceNodeContents('[data-region=\"relatedcompetencies\"]', html, js);\n return ajax.call([{\n methodname: 'tool_lp_data_for_related_competencies_section',\n args: {competencyid: competency.id}\n }])[0];\n }).then(function(context) {\n return templates.render('tool_lp/related_competencies', context);\n }).then(function(html, js) {\n $('[data-region=\"relatedcompetencies\"]').replaceWith(html);\n templates.runTemplateJS(js);\n updatedRelatedCompetencies();\n return;\n }).catch(notification.exception);\n };\n\n /**\n * Return the string \"Add \".\n *\n * @param {Number} level The level.\n * @return {String}\n * @function strAddTaxonomy\n */\n var strAddTaxonomy = function(level) {\n return str.get_string('taxonomy_add_' + getTaxonomyAtLevel(level), 'tool_lp');\n };\n\n /**\n * Return the string \"Selected \".\n *\n * @param {Number} level The level.\n * @return {String}\n * @function strSelectedTaxonomy\n */\n var strSelectedTaxonomy = function(level) {\n return str.get_string('taxonomy_selected_' + getTaxonomyAtLevel(level), 'tool_lp');\n };\n\n /**\n * Handler when a node in the aria tree is selected.\n * @method selectionChanged\n * @param {Event} evt The event that triggered the selection change.\n * @param {Object} params The parameters for the event. Contains a list of selected nodes.\n * @return {Boolean}\n */\n var selectionChanged = function(evt, params) {\n var node = params.selected,\n id = $(node).data('id'),\n btn = $('[data-region=\"competencyactions\"] [data-action=\"add\"]'),\n actionMenu = $('[data-region=\"competencyactionsmenu\"]'),\n selectedTitle = $('[data-region=\"selected-competency\"]'),\n level = 0,\n sublevel = 1;\n\n menubar.closeAll();\n\n if (typeof id === \"undefined\") {\n // Assume this is the root of the tree.\n // Here we are only getting the text from the top of the tree, to do it we clone the tree,\n // remove all children and then call text on the result.\n $('[data-region=\"competencyinfo\"]').html(node.clone().children().remove().end().text());\n $('[data-region=\"competencyactions\"]').data('competency', null);\n actionMenu.hide();\n\n } else {\n var competency = treeModel.getCompetency(id);\n\n level = treeModel.getCompetencyLevel(id);\n sublevel = level + 1;\n\n actionMenu.show();\n $('[data-region=\"competencyactions\"]').data('competency', competency);\n renderCompetencySummary(competency);\n // Log Competency viewed event.\n triggerCompetencyViewedEvent(competency);\n }\n strSelectedTaxonomy(level).then(function(str) {\n selectedTitle.text(str);\n return;\n }).catch(notification.exception);\n\n strAddTaxonomy(sublevel).then(function(str) {\n btn.show()\n .find('[data-region=\"term\"]')\n .text(str);\n return;\n }).catch(notification.exception);\n\n // We handled this event so consume it.\n evt.preventDefault();\n return false;\n };\n\n /**\n * Return the string \"Selected \".\n *\n * @function parseTaxonomies\n * @param {String} taxonomiesstr Comma separated list of taxonomies.\n * @return {Array} of level => taxonomystr\n */\n var parseTaxonomies = function(taxonomiesstr) {\n var all = taxonomiesstr.split(',');\n all.unshift(\"\");\n delete all[0];\n\n // Note we don't need to fill holes, because other functions check for empty anyway.\n return all;\n };\n\n return {\n /**\n * Initialise this page (attach event handlers etc).\n *\n * @method init\n * @param {Object} model The tree model provides some useful functions for loading and searching competencies.\n * @param {Number} pagectxid The page context ID.\n * @param {Object} taxonomies Constants indexed by level.\n * @param {Object} rulesMods The modules of the rules.\n */\n init: function(model, pagectxid, taxonomies, rulesMods) {\n treeModel = model;\n pageContextId = pagectxid;\n taxonomiesConstants = parseTaxonomies(taxonomies);\n rulesModules = rulesMods;\n\n $('[data-region=\"competencyactions\"] [data-action=\"add\"]').on('click', addHandler);\n\n menubar.enhance('.competencyactionsmenu', {\n '[data-action=\"edit\"]': editHandler,\n '[data-action=\"delete\"]': deleteCompetencyHandler,\n '[data-action=\"move\"]': moveHandler,\n '[data-action=\"moveup\"]': moveUpHandler,\n '[data-action=\"movedown\"]': moveDownHandler,\n '[data-action=\"linkedcourses\"]': seeCoursesHandler,\n '[data-action=\"relatedcompetencies\"]': relateCompetenciesHandler.bind(this),\n '[data-action=\"competencyrules\"]': ruleConfigHandler.bind(this)\n });\n $('[data-region=\"competencyactionsmenu\"]').hide();\n $('[data-region=\"competencyactions\"] [data-action=\"add\"]').hide();\n\n $('[data-region=\"filtercompetencies\"]').on('submit', updateSearchHandler);\n // Simple html5 drag drop because we already added an accessible alternative.\n var top = $('[data-region=\"managecompetencies\"] [data-enhance=\"tree\"]');\n top.on('dragstart', 'li>span', dragStart)\n .on('dragover', 'li>span', allowDrop)\n .on('dragenter', 'li>span', dragEnter)\n .on('dragleave', 'li>span', dragLeave)\n .on('drop', 'li>span', dropOver);\n\n model.on('selectionchanged', selectionChanged);\n\n // Prepare the configuration tool.\n ruleConfigInstance = new RuleConfig(treeModel, rulesModules);\n ruleConfigInstance.on('save', ruleConfigSaveHandler.bind(this));\n }\n };\n});\n"],"file":"competencyactions.min.js"} \ No newline at end of file +{"version":3,"sources":["../src/competencyactions.js"],"names":["define","$","url","templates","notification","str","ajax","dragdrop","Ariatree","Dialogue","menubar","Picker","Outcomes","RuleConfig","Pending","treeModel","moveSource","moveTarget","pageContextId","pickerInstance","ruleConfigInstance","relatedTarget","taxonomiesConstants","rulesModules","selectedCompetencyId","addHandler","parent","data","params","competencyframeworkid","getCompetencyFrameworkId","pagecontextid","parentid","id","relocate","queryparams","param","window","location","relativeUrl","hasRule","get_strings","key","component","shortname","done","strings","confirm","fail","exception","doMove","frameworkid","requests","call","methodname","args","competencyid","search","val","reloadPage","confirmMove","targetComp","getCompetency","sourceComp","confirmMessage","showConfirm","path","indexOf","initMovePopup","popup","body","getContent","treeRoot","find","tree","on","evt","target","selected","show","close","addCompetencyChildren","competencies","i","length","haschildren","children","moveHandler","e","preventDefault","competency","searchtext","when","apply","framework","competenciestree","onecompetency","render","editHandler","context","newhtml","newjs","replaceWith","runTemplateJS","updateSearchHandler","moveUpHandler","moveDownHandler","seeCoursesHandler","courses","html","get_string","linkedcourses","relateCompetenciesHandler","pendingPromise","compIds","competencyIds","calls","each","index","value","push","relatedcompetencyid","promises","then","js","updatedRelatedCompetencies","resolve","catch","setDisallowedCompetencyIDs","display","ruleConfigHandler","setTargetCompetencyId","ruleConfigSaveHandler","config","update","idnumber","description","descriptionformat","ruletype","ruleoutcome","ruleconfig","promise","result","renderCompetencySummary","doDelete","success","alert","deleteCompetencyHandler","dragStart","originalEvent","dataTransfer","setData","allowDrop","dropEffect","dragEnter","addClass","dragLeave","removeClass","dropOver","getData","deleteRelatedHandler","relatedid","substr","removeRelated","triggerCompetencyViewedEvent","getTaxonomyAtLevel","level","constant","Deferred","showdeleterelatedaction","showrelatedcompetencies","showrule","pluginbaseurl","NONE","getString","name","modInfo","type","strs","rule","outcome","replaceNodeContents","strAddTaxonomy","strSelectedTaxonomy","selectionChanged","node","btn","actionMenu","selectedTitle","sublevel","closeAll","clone","remove","end","text","hide","getCompetencyLevel","parseTaxonomies","taxonomiesstr","all","split","unshift","init","model","pagectxid","taxonomies","rulesMods","enhance","bind","top"],"mappings":"AAuBAA,OAAM,6BAAC,CAAC,QAAD,CACC,UADD,CAEC,gBAFD,CAGC,mBAHD,CAIC,UAJD,CAKC,WALD,CAMC,0BAND,CAOC,cAPD,CAQC,kBARD,CASC,iBATD,CAUC,0BAVD,CAWC,6BAXD,CAYC,8BAZD,CAaC,cAbD,CAAD,CAeC,SACKC,CADL,CACQC,CADR,CACaC,CADb,CACwBC,CADxB,CACsCC,CADtC,CAC2CC,CAD3C,CACiDC,CADjD,CAC2DC,CAD3D,CACqEC,CADrE,CAC+EC,CAD/E,CACwFC,CADxF,CACgGC,CADhG,CAC0GC,CAD1G,CACsHC,CADtH,CAEG,IAIFC,CAAAA,CAAS,CAAG,IAJV,CAMFC,CAAU,CAAG,IANX,CAQFC,CAAU,CAAG,IARX,CAUFC,CAVE,CAYFC,C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AAC,yCAAD,CAAD,CAA2CkM,IAA3C,GACAlM,CAAC,CAAC,2DAAD,CAAD,CAA2DkM,IAA3D,GAEAlM,CAAC,CAAC,sCAAD,CAAD,CAAwC0E,EAAxC,CAA2C,QAA3C,CAAqD6B,CAArD,EAEA,GAAIyG,CAAAA,CAAG,CAAGhN,CAAC,CAAC,8DAAD,CAAX,CACAgN,CAAG,CAACtI,EAAJ,CAAO,WAAP,CAAoB,SAApB,CAA+ByE,CAA/B,EACKzE,EADL,CACQ,UADR,CACoB,SADpB,CAC+B6E,CAD/B,EAEK7E,EAFL,CAEQ,WAFR,CAEqB,SAFrB,CAEgC+E,CAFhC,EAGK/E,EAHL,CAGQ,WAHR,CAGqB,SAHrB,CAGgCiF,CAHhC,EAIKjF,EAJL,CAIQ,MAJR,CAIgB,SAJhB,CAI2BmF,CAJ3B,EAMA6C,CAAK,CAAChI,EAAN,CAAS,kBAAT,CAA6B6G,CAA7B,EAGApK,CAAkB,CAAG,GAAIP,CAAAA,CAAJ,CAAeE,CAAf,CAA0BQ,CAA1B,CAArB,CACAH,CAAkB,CAACuD,EAAnB,CAAsB,MAAtB,CAA8ByD,CAAqB,CAAC4E,IAAtB,CAA2B,IAA3B,CAA9B,CACH,CA7CE,CA+CV,CA50BK,CAAN","sourcesContent":["// This file is part of Moodle - http://moodle.org/\n//\n// Moodle is free software: you can redistribute it and/or modify\n// it under the terms of the GNU General Public License as published by\n// the Free Software Foundation, either version 3 of the License, or\n// (at your option) any later version.\n//\n// Moodle is distributed in the hope that it will be useful,\n// but WITHOUT ANY WARRANTY; without even the implied warranty of\n// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the\n// GNU General Public License for more details.\n//\n// You should have received a copy of the GNU General Public License\n// along with Moodle. If not, see .\n\n/**\n * Handle selection changes and actions on the competency tree.\n *\n * @module tool_lp/competencyactions\n * @package tool_lp\n * @copyright 2015 Damyon Wiese \n * @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later\n */\ndefine(['jquery',\n 'core/url',\n 'core/templates',\n 'core/notification',\n 'core/str',\n 'core/ajax',\n 'tool_lp/dragdrop-reorder',\n 'tool_lp/tree',\n 'tool_lp/dialogue',\n 'tool_lp/menubar',\n 'tool_lp/competencypicker',\n 'tool_lp/competency_outcomes',\n 'tool_lp/competencyruleconfig',\n 'core/pending',\n ],\n function(\n $, url, templates, notification, str, ajax, dragdrop, Ariatree, Dialogue, menubar, Picker, Outcomes, RuleConfig, Pending\n ) {\n\n // Private variables and functions.\n /** @var {Object} treeModel - This is an object representing the nodes in the tree. */\n var treeModel = null;\n /** @var {Node} moveSource - The start of a drag operation */\n var moveSource = null;\n /** @var {Node} moveTarget - The end of a drag operation */\n var moveTarget = null;\n /** @var {Number} pageContextId The page context ID. */\n var pageContextId;\n /** @type {Object} Picker instance. */\n var pickerInstance;\n /** @type {Object} Rule config instance. */\n var ruleConfigInstance;\n /** @type {Object} The competency we're picking a relation to. */\n var relatedTarget;\n /** @type {Object} Taxonomy constants indexed per level. */\n var taxonomiesConstants;\n /** @type {Array} The rules modules. Values are object containing type, namd and amd. */\n var rulesModules;\n /** @type {Number} the selected competency ID. */\n var selectedCompetencyId = null;\n\n /**\n * Respond to choosing the \"Add\" menu item for the selected node in the tree.\n * @method addHandler\n */\n var addHandler = function() {\n var parent = $('[data-region=\"competencyactions\"]').data('competency');\n\n var params = {\n competencyframeworkid: treeModel.getCompetencyFrameworkId(),\n pagecontextid: pageContextId\n };\n\n if (parent !== null) {\n // We are adding at a sub node.\n params.parentid = parent.id;\n }\n\n var relocate = function() {\n var queryparams = $.param(params);\n window.location = url.relativeUrl('/admin/tool/lp/editcompetency.php?' + queryparams);\n };\n\n if (parent !== null && treeModel.hasRule(parent.id)) {\n str.get_strings([\n {key: 'confirm', component: 'moodle'},\n {key: 'addingcompetencywillresetparentrule', component: 'tool_lp', param: parent.shortname},\n {key: 'yes', component: 'core'},\n {key: 'no', component: 'core'}\n ]).done(function(strings) {\n notification.confirm(\n strings[0],\n strings[1],\n strings[2],\n strings[3],\n relocate\n );\n }).fail(notification.exception);\n } else {\n relocate();\n }\n };\n\n /**\n * A source and destination has been chosen - so time to complete a move.\n * @method doMove\n */\n var doMove = function() {\n var frameworkid = $('[data-region=\"filtercompetencies\"]').data('frameworkid');\n var requests = ajax.call([{\n methodname: 'core_competency_set_parent_competency',\n args: {competencyid: moveSource, parentid: moveTarget}\n }, {\n methodname: 'tool_lp_data_for_competencies_manage_page',\n args: {competencyframeworkid: frameworkid,\n search: $('[data-region=\"filtercompetencies\"] input').val()}\n }]);\n requests[1].done(reloadPage).fail(notification.exception);\n };\n\n /**\n * Confirms a competency move.\n *\n * @method confirmMove\n */\n var confirmMove = function() {\n moveTarget = typeof moveTarget === \"undefined\" ? 0 : moveTarget;\n if (moveTarget == moveSource) {\n // No move to do.\n return;\n }\n\n var targetComp = treeModel.getCompetency(moveTarget) || {},\n sourceComp = treeModel.getCompetency(moveSource) || {},\n confirmMessage = 'movecompetencywillresetrules',\n showConfirm = false;\n\n // We shouldn't be moving the competency to the same parent.\n if (sourceComp.parentid == moveTarget) {\n return;\n }\n\n // If we are moving to a child of self.\n if (targetComp.path && targetComp.path.indexOf('/' + sourceComp.id + '/') >= 0) {\n confirmMessage = 'movecompetencytochildofselfwillresetrules';\n\n // Show a confirmation if self has rules, as they'll disappear.\n showConfirm = showConfirm || treeModel.hasRule(sourceComp.id);\n }\n\n // Show a confirmation if the current parent, or the destination have rules.\n showConfirm = showConfirm || (treeModel.hasRule(targetComp.id) || treeModel.hasRule(sourceComp.parentid));\n\n // Show confirm, and/or do the things.\n if (showConfirm) {\n str.get_strings([\n {key: 'confirm', component: 'moodle'},\n {key: confirmMessage, component: 'tool_lp'},\n {key: 'yes', component: 'moodle'},\n {key: 'no', component: 'moodle'}\n ]).done(function(strings) {\n notification.confirm(\n strings[0], // Confirm.\n strings[1], // Delete competency X?\n strings[2], // Delete.\n strings[3], // Cancel.\n doMove\n );\n }).fail(notification.exception);\n\n } else {\n doMove();\n }\n };\n\n /**\n * A move competency popup was opened - initialise the aria tree in it.\n * @method initMovePopup\n * @param {dialogue} popup The tool_lp/dialogue that was created.\n */\n var initMovePopup = function(popup) {\n var body = $(popup.getContent());\n var treeRoot = body.find('[data-enhance=movetree]');\n var tree = new Ariatree(treeRoot, false);\n tree.on('selectionchanged', function(evt, params) {\n var target = params.selected;\n moveTarget = $(target).data('id');\n });\n treeRoot.show();\n\n body.on('click', '[data-action=\"move\"]', function() {\n popup.close();\n confirmMove();\n });\n body.on('click', '[data-action=\"cancel\"]', function() {\n popup.close();\n });\n };\n\n /**\n * Turn a flat list of competencies into a tree structure (recursive).\n * @method addCompetencyChildren\n * @param {Object} parent The current parent node in the tree\n * @param {Object[]} competencies The flat list of competencies\n */\n var addCompetencyChildren = function(parent, competencies) {\n var i;\n\n for (i = 0; i < competencies.length; i++) {\n if (competencies[i].parentid == parent.id) {\n parent.haschildren = true;\n competencies[i].children = [];\n competencies[i].haschildren = false;\n parent.children[parent.children.length] = competencies[i];\n addCompetencyChildren(competencies[i], competencies);\n }\n }\n };\n\n /**\n * A node was chosen and \"Move\" was selected from the menu. Open a popup to select the target.\n * @param {Event} e\n * @method moveHandler\n */\n var moveHandler = function(e) {\n e.preventDefault();\n var competency = $('[data-region=\"competencyactions\"]').data('competency');\n\n // Remember what we are moving.\n moveSource = competency.id;\n\n // Load data for the template.\n var requests = ajax.call([\n {\n methodname: 'core_competency_search_competencies',\n args: {\n competencyframeworkid: competency.competencyframeworkid,\n searchtext: ''\n }\n }, {\n methodname: 'core_competency_read_competency_framework',\n args: {\n id: competency.competencyframeworkid\n }\n }\n ]);\n\n // When all data has arrived, continue.\n $.when.apply(null, requests).done(function(competencies, framework) {\n\n // Expand the list of competencies into a tree.\n var i;\n var competenciestree = [];\n for (i = 0; i < competencies.length; i++) {\n var onecompetency = competencies[i];\n if (onecompetency.parentid == \"0\") {\n onecompetency.children = [];\n onecompetency.haschildren = 0;\n competenciestree[competenciestree.length] = onecompetency;\n addCompetencyChildren(onecompetency, competencies);\n }\n }\n\n str.get_strings([\n {key: 'movecompetency', component: 'tool_lp', param: competency.shortname},\n {key: 'move', component: 'tool_lp'},\n {key: 'cancel', component: 'moodle'}\n ]).done(function(strings) {\n\n var context = {\n framework: framework,\n competencies: competenciestree\n };\n\n templates.render('tool_lp/competencies_move_tree', context)\n .done(function(tree) {\n new Dialogue(\n strings[0], // Move competency x.\n tree, // The move tree.\n initMovePopup\n );\n\n }).fail(notification.exception);\n\n }).fail(notification.exception);\n\n }).fail(notification.exception);\n\n };\n\n /**\n * Edit the selected competency.\n * @method editHandler\n */\n var editHandler = function() {\n var competency = $('[data-region=\"competencyactions\"]').data('competency');\n\n var params = {\n competencyframeworkid: treeModel.getCompetencyFrameworkId(),\n id: competency.id,\n parentid: competency.parentid,\n pagecontextid: pageContextId\n };\n\n var queryparams = $.param(params);\n window.location = url.relativeUrl('/admin/tool/lp/editcompetency.php?' + queryparams);\n };\n\n /**\n * Re-render the page with the latest data.\n * @param {Object} context\n * @method reloadPage\n */\n var reloadPage = function(context) {\n templates.render('tool_lp/manage_competencies_page', context)\n .done(function(newhtml, newjs) {\n $('[data-region=\"managecompetencies\"]').replaceWith(newhtml);\n templates.runTemplateJS(newjs);\n })\n .fail(notification.exception);\n };\n\n /**\n * Perform a search and render the page with the new search results.\n * @param {Event} e\n * @method updateSearchHandler\n */\n var updateSearchHandler = function(e) {\n e.preventDefault();\n\n var frameworkid = $('[data-region=\"filtercompetencies\"]').data('frameworkid');\n\n var requests = ajax.call([{\n methodname: 'tool_lp_data_for_competencies_manage_page',\n args: {competencyframeworkid: frameworkid,\n search: $('[data-region=\"filtercompetencies\"] input').val()}\n }]);\n requests[0].done(reloadPage).fail(notification.exception);\n };\n\n /**\n * Move a competency \"up\". This only affects the sort order within the same branch of the tree.\n * @method moveUpHandler\n */\n var moveUpHandler = function() {\n // We are chaining ajax requests here.\n var competency = $('[data-region=\"competencyactions\"]').data('competency');\n var requests = ajax.call([{\n methodname: 'core_competency_move_up_competency',\n args: {id: competency.id}\n }, {\n methodname: 'tool_lp_data_for_competencies_manage_page',\n args: {competencyframeworkid: competency.competencyframeworkid,\n search: $('[data-region=\"filtercompetencies\"] input').val()}\n }]);\n requests[1].done(reloadPage).fail(notification.exception);\n };\n\n /**\n * Move a competency \"down\". This only affects the sort order within the same branch of the tree.\n * @method moveDownHandler\n */\n var moveDownHandler = function() {\n // We are chaining ajax requests here.\n var competency = $('[data-region=\"competencyactions\"]').data('competency');\n var requests = ajax.call([{\n methodname: 'core_competency_move_down_competency',\n args: {id: competency.id}\n }, {\n methodname: 'tool_lp_data_for_competencies_manage_page',\n args: {competencyframeworkid: competency.competencyframeworkid,\n search: $('[data-region=\"filtercompetencies\"] input').val()}\n }]);\n requests[1].done(reloadPage).fail(notification.exception);\n };\n\n /**\n * Open a dialogue to show all the courses using the selected competency.\n * @method seeCoursesHandler\n */\n var seeCoursesHandler = function() {\n var competency = $('[data-region=\"competencyactions\"]').data('competency');\n\n var requests = ajax.call([{\n methodname: 'tool_lp_list_courses_using_competency',\n args: {id: competency.id}\n }]);\n\n requests[0].done(function(courses) {\n var context = {\n courses: courses\n };\n templates.render('tool_lp/linked_courses_summary', context).done(function(html) {\n str.get_string('linkedcourses', 'tool_lp').done(function(linkedcourses) {\n new Dialogue(\n linkedcourses, // Title.\n html, // The linked courses.\n initMovePopup\n );\n }).fail(notification.exception);\n }).fail(notification.exception);\n }).fail(notification.exception);\n };\n\n /**\n * Open a competencies popup to relate competencies.\n *\n * @method relateCompetenciesHandler\n */\n var relateCompetenciesHandler = function() {\n relatedTarget = $('[data-region=\"competencyactions\"]').data('competency');\n\n if (!pickerInstance) {\n pickerInstance = new Picker(pageContextId, relatedTarget.competencyframeworkid);\n pickerInstance.on('save', function(e, data) {\n var pendingPromise = new Pending();\n var compIds = data.competencyIds;\n\n var calls = [];\n $.each(compIds, function(index, value) {\n calls.push({\n methodname: 'core_competency_add_related_competency',\n args: {competencyid: value, relatedcompetencyid: relatedTarget.id}\n });\n });\n\n calls.push({\n methodname: 'tool_lp_data_for_related_competencies_section',\n args: {competencyid: relatedTarget.id}\n });\n\n var promises = ajax.call(calls);\n\n promises[calls.length - 1].then(function(context) {\n return templates.render('tool_lp/related_competencies', context);\n }).then(function(html, js) {\n $('[data-region=\"relatedcompetencies\"]').replaceWith(html);\n templates.runTemplateJS(js);\n updatedRelatedCompetencies();\n return;\n })\n .then(pendingPromise.resolve)\n .catch(notification.exception);\n });\n }\n\n pickerInstance.setDisallowedCompetencyIDs([relatedTarget.id]);\n pickerInstance.display();\n };\n\n var ruleConfigHandler = function(e) {\n e.preventDefault();\n relatedTarget = $('[data-region=\"competencyactions\"]').data('competency');\n ruleConfigInstance.setTargetCompetencyId(relatedTarget.id);\n ruleConfigInstance.display();\n };\n\n var ruleConfigSaveHandler = function(e, config) {\n var update = {\n id: relatedTarget.id,\n shortname: relatedTarget.shortname,\n idnumber: relatedTarget.idnumber,\n description: relatedTarget.description,\n descriptionformat: relatedTarget.descriptionformat,\n ruletype: config.ruletype,\n ruleoutcome: config.ruleoutcome,\n ruleconfig: config.ruleconfig\n };\n var promise = ajax.call([{\n methodname: 'core_competency_update_competency',\n args: {competency: update}\n }]);\n promise[0].then(function(result) {\n if (result) {\n relatedTarget.ruletype = config.ruletype;\n relatedTarget.ruleoutcome = config.ruleoutcome;\n relatedTarget.ruleconfig = config.ruleconfig;\n renderCompetencySummary(relatedTarget);\n }\n return;\n }).catch(notification.exception);\n };\n\n /**\n * Delete a competency.\n * @method doDelete\n */\n var doDelete = function() {\n // We are chaining ajax requests here.\n var competency = $('[data-region=\"competencyactions\"]').data('competency');\n var requests = ajax.call([{\n methodname: 'core_competency_delete_competency',\n args: {id: competency.id}\n }, {\n methodname: 'tool_lp_data_for_competencies_manage_page',\n args: {competencyframeworkid: competency.competencyframeworkid,\n search: $('[data-region=\"filtercompetencies\"] input').val()}\n }]);\n requests[0].done(function(success) {\n if (success === false) {\n str.get_strings([\n {key: 'competencycannotbedeleted', component: 'tool_lp', param: competency.shortname},\n {key: 'cancel', component: 'moodle'}\n ]).done(function(strings) {\n notification.alert(\n null,\n strings[0]\n );\n }).fail(notification.exception);\n }\n }).fail(notification.exception);\n requests[1].done(reloadPage).fail(notification.exception);\n };\n\n /**\n * Show a confirm dialogue before deleting a competency.\n * @method deleteCompetencyHandler\n */\n var deleteCompetencyHandler = function() {\n var competency = $('[data-region=\"competencyactions\"]').data('competency'),\n confirmMessage = 'deletecompetency';\n\n if (treeModel.hasRule(competency.parentid)) {\n confirmMessage = 'deletecompetencyparenthasrule';\n }\n\n str.get_strings([\n {key: 'confirm', component: 'moodle'},\n {key: confirmMessage, component: 'tool_lp', param: competency.shortname},\n {key: 'delete', component: 'moodle'},\n {key: 'cancel', component: 'moodle'}\n ]).done(function(strings) {\n notification.confirm(\n strings[0], // Confirm.\n strings[1], // Delete competency X?\n strings[2], // Delete.\n strings[3], // Cancel.\n doDelete\n );\n }).fail(notification.exception);\n };\n\n /**\n * HTML5 implementation of drag/drop (there is an accesible alternative in the menus).\n * @method dragStart\n * @param {Event} e\n */\n var dragStart = function(e) {\n e.originalEvent.dataTransfer.setData('text', $(e.target).parent().data('id'));\n };\n\n /**\n * HTML5 implementation of drag/drop (there is an accesible alternative in the menus).\n * @method allowDrop\n * @param {Event} e\n */\n var allowDrop = function(e) {\n e.originalEvent.dataTransfer.dropEffect = 'move';\n e.preventDefault();\n };\n\n /**\n * HTML5 implementation of drag/drop (there is an accesible alternative in the menus).\n * @method dragEnter\n * @param {Event} e\n */\n var dragEnter = function(e) {\n e.preventDefault();\n $(this).addClass('currentdragtarget');\n };\n\n /**\n * HTML5 implementation of drag/drop (there is an accesible alternative in the menus).\n * @method dragLeave\n * @param {Event} e\n */\n var dragLeave = function(e) {\n e.preventDefault();\n $(this).removeClass('currentdragtarget');\n };\n\n /**\n * HTML5 implementation of drag/drop (there is an accesible alternative in the menus).\n * @method dropOver\n * @param {Event} e\n */\n var dropOver = function(e) {\n e.preventDefault();\n moveSource = e.originalEvent.dataTransfer.getData('text');\n moveTarget = $(e.target).parent().data('id');\n $(this).removeClass('currentdragtarget');\n\n confirmMove();\n };\n\n /**\n * Deletes a related competency without confirmation.\n *\n * @param {Event} e The event that triggered the action.\n * @method deleteRelatedHandler\n */\n var deleteRelatedHandler = function(e) {\n e.preventDefault();\n\n var relatedid = this.id.substr(11);\n var competency = $('[data-region=\"competencyactions\"]').data('competency');\n var removeRelated = ajax.call([\n {methodname: 'core_competency_remove_related_competency',\n args: {relatedcompetencyid: relatedid, competencyid: competency.id}},\n {methodname: 'tool_lp_data_for_related_competencies_section',\n args: {competencyid: competency.id}}\n ]);\n\n removeRelated[1].done(function(context) {\n templates.render('tool_lp/related_competencies', context).done(function(html) {\n $('[data-region=\"relatedcompetencies\"]').replaceWith(html);\n updatedRelatedCompetencies();\n }).fail(notification.exception);\n }).fail(notification.exception);\n };\n\n /**\n * Updates the competencies list (with relations) and add listeners.\n *\n * @method updatedRelatedCompetencies\n */\n var updatedRelatedCompetencies = function() {\n\n // Listeners to newly loaded related competencies.\n $('[data-action=\"deleterelation\"]').on('click', deleteRelatedHandler);\n\n };\n\n /**\n * Log the competency viewed event.\n *\n * @param {Object} competency The competency.\n * @method triggerCompetencyViewedEvent\n */\n var triggerCompetencyViewedEvent = function(competency) {\n if (competency.id !== selectedCompetencyId) {\n // Set the selected competency id.\n selectedCompetencyId = competency.id;\n ajax.call([{\n methodname: 'core_competency_competency_viewed',\n args: {id: competency.id}\n }]);\n }\n };\n\n /**\n * Return the taxonomy constant for a level.\n *\n * @param {Number} level The level.\n * @return {String}\n * @function getTaxonomyAtLevel\n */\n var getTaxonomyAtLevel = function(level) {\n var constant = taxonomiesConstants[level];\n if (!constant) {\n constant = 'competency';\n }\n return constant;\n };\n\n /**\n * Render the competency summary.\n *\n * @param {Object} competency The competency.\n */\n var renderCompetencySummary = function(competency) {\n var promise = $.Deferred().resolve().promise(),\n context = {};\n\n context.competency = competency;\n context.showdeleterelatedaction = true;\n context.showrelatedcompetencies = true;\n context.showrule = false;\n context.pluginbaseurl = url.relativeUrl('/admin/tool/lp');\n\n if (competency.ruleoutcome != Outcomes.NONE) {\n // Get the outcome and rule name.\n promise = Outcomes.getString(competency.ruleoutcome).then(function(str) {\n var name;\n $.each(rulesModules, function(index, modInfo) {\n if (modInfo.type == competency.ruletype) {\n name = modInfo.name;\n }\n });\n return [str, name];\n });\n }\n\n promise.then(function(strs) {\n if (typeof strs !== 'undefined') {\n context.showrule = true;\n context.rule = {\n outcome: strs[0],\n type: strs[1]\n };\n }\n return context;\n }).then(function(context) {\n return templates.render('tool_lp/competency_summary', context);\n }).then(function(html) {\n $('[data-region=\"competencyinfo\"]').html(html);\n $('[data-action=\"deleterelation\"]').on('click', deleteRelatedHandler);\n return templates.render('tool_lp/loading', {});\n }).then(function(html, js) {\n templates.replaceNodeContents('[data-region=\"relatedcompetencies\"]', html, js);\n return ajax.call([{\n methodname: 'tool_lp_data_for_related_competencies_section',\n args: {competencyid: competency.id}\n }])[0];\n }).then(function(context) {\n return templates.render('tool_lp/related_competencies', context);\n }).then(function(html, js) {\n $('[data-region=\"relatedcompetencies\"]').replaceWith(html);\n templates.runTemplateJS(js);\n updatedRelatedCompetencies();\n return;\n }).catch(notification.exception);\n };\n\n /**\n * Return the string \"Add \".\n *\n * @param {Number} level The level.\n * @return {String}\n * @function strAddTaxonomy\n */\n var strAddTaxonomy = function(level) {\n return str.get_string('taxonomy_add_' + getTaxonomyAtLevel(level), 'tool_lp');\n };\n\n /**\n * Return the string \"Selected \".\n *\n * @param {Number} level The level.\n * @return {String}\n * @function strSelectedTaxonomy\n */\n var strSelectedTaxonomy = function(level) {\n return str.get_string('taxonomy_selected_' + getTaxonomyAtLevel(level), 'tool_lp');\n };\n\n /**\n * Handler when a node in the aria tree is selected.\n * @method selectionChanged\n * @param {Event} evt The event that triggered the selection change.\n * @param {Object} params The parameters for the event. Contains a list of selected nodes.\n * @return {Boolean}\n */\n var selectionChanged = function(evt, params) {\n var node = params.selected,\n id = $(node).data('id'),\n btn = $('[data-region=\"competencyactions\"] [data-action=\"add\"]'),\n actionMenu = $('[data-region=\"competencyactionsmenu\"]'),\n selectedTitle = $('[data-region=\"selected-competency\"]'),\n level = 0,\n sublevel = 1;\n\n menubar.closeAll();\n\n if (typeof id === \"undefined\") {\n // Assume this is the root of the tree.\n // Here we are only getting the text from the top of the tree, to do it we clone the tree,\n // remove all children and then call text on the result.\n $('[data-region=\"competencyinfo\"]').html(node.clone().children().remove().end().text());\n $('[data-region=\"competencyactions\"]').data('competency', null);\n actionMenu.hide();\n\n } else {\n var competency = treeModel.getCompetency(id);\n\n level = treeModel.getCompetencyLevel(id);\n sublevel = level + 1;\n\n actionMenu.show();\n $('[data-region=\"competencyactions\"]').data('competency', competency);\n renderCompetencySummary(competency);\n // Log Competency viewed event.\n triggerCompetencyViewedEvent(competency);\n }\n strSelectedTaxonomy(level).then(function(str) {\n selectedTitle.text(str);\n return;\n }).catch(notification.exception);\n\n strAddTaxonomy(sublevel).then(function(str) {\n btn.show()\n .find('[data-region=\"term\"]')\n .text(str);\n return;\n }).catch(notification.exception);\n\n // We handled this event so consume it.\n evt.preventDefault();\n return false;\n };\n\n /**\n * Return the string \"Selected \".\n *\n * @function parseTaxonomies\n * @param {String} taxonomiesstr Comma separated list of taxonomies.\n * @return {Array} of level => taxonomystr\n */\n var parseTaxonomies = function(taxonomiesstr) {\n var all = taxonomiesstr.split(',');\n all.unshift(\"\");\n delete all[0];\n\n // Note we don't need to fill holes, because other functions check for empty anyway.\n return all;\n };\n\n return {\n /**\n * Initialise this page (attach event handlers etc).\n *\n * @method init\n * @param {Object} model The tree model provides some useful functions for loading and searching competencies.\n * @param {Number} pagectxid The page context ID.\n * @param {Object} taxonomies Constants indexed by level.\n * @param {Object} rulesMods The modules of the rules.\n */\n init: function(model, pagectxid, taxonomies, rulesMods) {\n treeModel = model;\n pageContextId = pagectxid;\n taxonomiesConstants = parseTaxonomies(taxonomies);\n rulesModules = rulesMods;\n\n $('[data-region=\"competencyactions\"] [data-action=\"add\"]').on('click', addHandler);\n\n menubar.enhance('.competencyactionsmenu', {\n '[data-action=\"edit\"]': editHandler,\n '[data-action=\"delete\"]': deleteCompetencyHandler,\n '[data-action=\"move\"]': moveHandler,\n '[data-action=\"moveup\"]': moveUpHandler,\n '[data-action=\"movedown\"]': moveDownHandler,\n '[data-action=\"linkedcourses\"]': seeCoursesHandler,\n '[data-action=\"relatedcompetencies\"]': relateCompetenciesHandler.bind(this),\n '[data-action=\"competencyrules\"]': ruleConfigHandler.bind(this)\n });\n $('[data-region=\"competencyactionsmenu\"]').hide();\n $('[data-region=\"competencyactions\"] [data-action=\"add\"]').hide();\n\n $('[data-region=\"filtercompetencies\"]').on('submit', updateSearchHandler);\n // Simple html5 drag drop because we already added an accessible alternative.\n var top = $('[data-region=\"managecompetencies\"] [data-enhance=\"tree\"]');\n top.on('dragstart', 'li>span', dragStart)\n .on('dragover', 'li>span', allowDrop)\n .on('dragenter', 'li>span', dragEnter)\n .on('dragleave', 'li>span', dragLeave)\n .on('drop', 'li>span', dropOver);\n\n model.on('selectionchanged', selectionChanged);\n\n // Prepare the configuration tool.\n ruleConfigInstance = new RuleConfig(treeModel, rulesModules);\n ruleConfigInstance.on('save', ruleConfigSaveHandler.bind(this));\n }\n };\n});\n"],"file":"competencyactions.min.js"} \ No newline at end of file diff --git a/admin/tool/lp/amd/build/competencypicker.min.js b/admin/tool/lp/amd/build/competencypicker.min.js index e9f3dff0aea..ec38fee95eb 100644 --- a/admin/tool/lp/amd/build/competencypicker.min.js +++ b/admin/tool/lp/amd/build/competencypicker.min.js @@ -1,2 +1,2 @@ -define ("tool_lp/competencypicker",["jquery","core/notification","core/ajax","core/templates","tool_lp/dialogue","core/str","tool_lp/tree"],function(a,b,c,d,e,f,g){var h=function(b,c,d,e){var f=this;f._eventNode=a("
");f._frameworks=[];f._reset();f._pageContextId=b;f._pageContextIncludes=d||"children";f._multiSelect="undefined"==typeof e||!0===e;if(c){f._frameworkId=c;f._singleFramework=!0}};h.prototype._competencies=null;h.prototype._disallowedCompetencyIDs=null;h.prototype._eventNode=null;h.prototype._frameworks=null;h.prototype._frameworkId=null;h.prototype._pageContextId=null;h.prototype._pageContextIncludes=null;h.prototype._popup=null;h.prototype._searchText="";h.prototype._selectedCompetencies=null;h.prototype._singleFramework=!1;h.prototype._multiSelect=!0;h.prototype._onlyVisible=!0;h.prototype._afterRender=function(){var c=this,d=new g(c._find("[data-enhance=linktree]"),c._multiSelect);c._find("[data-enhance=linktree]").show();d.on("selectionchanged",function(b,d){var e=d.selected;b.preventDefault();var f=[];a.each(e,function(b,d){var e=a(d).data("id"),g=!0;if("undefined"==typeof e){g=!1}else{a.each(c._disallowedCompetencyIDs,function(a,b){if(b==e){g=!1}})}if(g){f.push(e)}});c._selectedCompetencies=f;if(!c._selectedCompetencies.length){c._find("[data-region=\"competencylinktree\"] [data-action=\"add\"]").attr("disabled","disabled")}else{c._find("[data-region=\"competencylinktree\"] [data-action=\"add\"]").removeAttr("disabled")}});if(!c._singleFramework){c._find("[data-action=\"chooseframework\"]").change(function(d){c._frameworkId=a(d.target).val();c._loadCompetencies().then(c._refresh.bind(c)).catch(b.exception)})}c._find("[data-region=\"filtercompetencies\"] button").click(function(b){b.preventDefault();a(b.target).attr("disabled","disabled");c._searchText=c._find("[data-region=\"filtercompetencies\"] input").val()||"";return c._refresh().always(function(){a(b.target).removeAttr("disabled")})});c._find("[data-region=\"competencylinktree\"] [data-action=\"cancel\"]").click(function(a){a.preventDefault();c.close()});c._find("[data-region=\"competencylinktree\"] [data-action=\"add\"]").click(function(a){a.preventDefault();if(!c._selectedCompetencies.length){return}if(c._multiSelect){c._trigger("save",{competencyIds:c._selectedCompetencies})}else{c._trigger("save",{competencyId:c._selectedCompetencies[0]})}c.close()});var e=c._selectedCompetencies.slice(0);a.each(e,function(a,b){var e=c._find("[data-id="+b+"]");if(e.length){d.toggleItem(e);d.updateFocus(e)}})};h.prototype.close=function(){var a=this;a._popup.close();a._reset()};h.prototype.display=function(){var c=this;return a.when(f.get_string("competencypicker","tool_lp"),c._render()).then(function(a,b){c._popup=new e(a,b[0],c._afterRender.bind(c))}).catch(b.exception)};h.prototype._fetchCompetencies=function(a,d){var e=this;return c.call([{methodname:"core_competency_search_competencies",args:{searchtext:d,competencyframeworkid:a}}])[0].done(function(a){function b(a,c){for(var d=0;d");f._frameworks=[];f._reset();f._pageContextId=b;f._pageContextIncludes=d||"children";f._multiSelect="undefined"==typeof e||!0===e;if(c){f._frameworkId=c;f._singleFramework=!0}};i.prototype._competencies=null;i.prototype._disallowedCompetencyIDs=null;i.prototype._eventNode=null;i.prototype._frameworks=null;i.prototype._frameworkId=null;i.prototype._pageContextId=null;i.prototype._pageContextIncludes=null;i.prototype._popup=null;i.prototype._searchText="";i.prototype._selectedCompetencies=null;i.prototype._singleFramework=!1;i.prototype._multiSelect=!0;i.prototype._onlyVisible=!0;i.prototype._afterRender=function(){var c=this,d=new g(c._find("[data-enhance=linktree]"),c._multiSelect);c._find("[data-enhance=linktree]").show();d.on("selectionchanged",function(b,d){var e=d.selected;b.preventDefault();var f=[];a.each(e,function(b,d){var e=a(d).data("id"),g=!0;if("undefined"==typeof e){g=!1}else{a.each(c._disallowedCompetencyIDs,function(a,b){if(b==e){g=!1}})}if(g){f.push(e)}});c._selectedCompetencies=f;if(!c._selectedCompetencies.length){c._find("[data-region=\"competencylinktree\"] [data-action=\"add\"]").attr("disabled","disabled")}else{c._find("[data-region=\"competencylinktree\"] [data-action=\"add\"]").removeAttr("disabled")}});if(!c._singleFramework){c._find("[data-action=\"chooseframework\"]").change(function(d){c._frameworkId=a(d.target).val();c._loadCompetencies().then(c._refresh.bind(c)).catch(b.exception)})}c._find("[data-region=\"filtercompetencies\"] button").click(function(b){b.preventDefault();a(b.target).attr("disabled","disabled");c._searchText=c._find("[data-region=\"filtercompetencies\"] input").val()||"";return c._refresh().always(function(){a(b.target).removeAttr("disabled")})});c._find("[data-region=\"competencylinktree\"] [data-action=\"cancel\"]").click(function(a){a.preventDefault();c.close()});c._find("[data-region=\"competencylinktree\"] [data-action=\"add\"]").click(function(a){a.preventDefault();var b=new h;if(!c._selectedCompetencies.length){return}if(c._multiSelect){c._trigger("save",{competencyIds:c._selectedCompetencies})}else{c._trigger("save",{competencyId:c._selectedCompetencies[0]})}c.close();b.resolve()});var e=c._selectedCompetencies.slice(0);a.each(e,function(a,b){var e=c._find("[data-id="+b+"]");if(e.length){d.toggleItem(e);d.updateFocus(e)}})};i.prototype.close=function(){var a=this;a._popup.close();a._reset()};i.prototype.display=function(){var c=this;return a.when(f.get_string("competencypicker","tool_lp"),c._render()).then(function(a,b){c._popup=new e(a,b[0],c._afterRender.bind(c))}).catch(b.exception)};i.prototype._fetchCompetencies=function(a,d){var e=this;return c.call([{methodname:"core_competency_search_competencies",args:{searchtext:d,competencyframeworkid:a}}])[0].done(function(a){function b(a,c){for(var d=0;d.\n\n/**\n * Competency picker.\n *\n * To handle 'save' events use: picker.on('save')\n * This will receive a object with either a single 'competencyId', or an array in 'competencyIds'\n * depending on the value of multiSelect.\n *\n * @package tool_lp\n * @copyright 2015 Frédéric Massart - FMCorz.net\n * @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later\n */\n\ndefine(['jquery',\n 'core/notification',\n 'core/ajax',\n 'core/templates',\n 'tool_lp/dialogue',\n 'core/str',\n 'tool_lp/tree'],\n function($, Notification, Ajax, Templates, Dialogue, Str, Tree) {\n\n /**\n * Competency picker class.\n * @param {Number} pageContextId The page context ID.\n * @param {Number|false} singleFramework The ID of the framework when limited to one.\n * @param {String} pageContextIncludes One of 'children', 'parents', 'self'.\n * @param {Boolean} multiSelect Support multi-select in the tree.\n */\n var Picker = function(pageContextId, singleFramework, pageContextIncludes, multiSelect) {\n var self = this;\n self._eventNode = $('
');\n self._frameworks = [];\n self._reset();\n\n self._pageContextId = pageContextId;\n self._pageContextIncludes = pageContextIncludes || 'children';\n self._multiSelect = (typeof multiSelect === 'undefined' || multiSelect === true);\n if (singleFramework) {\n self._frameworkId = singleFramework;\n self._singleFramework = true;\n }\n };\n\n /** @type {Array} The competencies fetched. */\n Picker.prototype._competencies = null;\n /** @type {Array} The competencies that cannot be picked. */\n Picker.prototype._disallowedCompetencyIDs = null;\n /** @type {Node} The node we attach the events to. */\n Picker.prototype._eventNode = null;\n /** @type {Array} The list of frameworks fetched. */\n Picker.prototype._frameworks = null;\n /** @type {Number} The current framework ID. */\n Picker.prototype._frameworkId = null;\n /** @type {Number} The page context ID. */\n Picker.prototype._pageContextId = null;\n /** @type {Number} Relevant contexts inclusion. */\n Picker.prototype._pageContextIncludes = null;\n /** @type {Dialogue} The reference to the dialogue. */\n Picker.prototype._popup = null;\n /** @type {String} The string we filter the competencies with. */\n Picker.prototype._searchText = '';\n /** @type {Object} The competency that was selected. */\n Picker.prototype._selectedCompetencies = null;\n /** @type {Boolean} Whether we can browse frameworks or not. */\n Picker.prototype._singleFramework = false;\n /** @type {Boolean} Do we allow multi select? */\n Picker.prototype._multiSelect = true;\n /** @type {Boolean} Do we allow to display hidden framework? */\n Picker.prototype._onlyVisible = true;\n\n /**\n * Hook to executed after the view is rendered.\n *\n * @method _afterRender\n */\n Picker.prototype._afterRender = function() {\n var self = this;\n\n // Initialise the tree.\n var tree = new Tree(self._find('[data-enhance=linktree]'), self._multiSelect);\n\n // To prevent jiggling we only show the tree after it is enhanced.\n self._find('[data-enhance=linktree]').show();\n\n tree.on('selectionchanged', function(evt, params) {\n var selected = params.selected;\n evt.preventDefault();\n var validIds = [];\n $.each(selected, function(index, item) {\n var compId = $(item).data('id'),\n valid = true;\n\n if (typeof compId === 'undefined') {\n // Do not allow picking nodes with no id.\n valid = false;\n } else {\n $.each(self._disallowedCompetencyIDs, function(i, id) {\n if (id == compId) {\n valid = false;\n }\n });\n }\n if (valid) {\n validIds.push(compId);\n }\n });\n\n self._selectedCompetencies = validIds;\n\n // TODO Implement disabling of nodes in the tree module somehow.\n if (!self._selectedCompetencies.length) {\n self._find('[data-region=\"competencylinktree\"] [data-action=\"add\"]').attr('disabled', 'disabled');\n } else {\n self._find('[data-region=\"competencylinktree\"] [data-action=\"add\"]').removeAttr('disabled');\n }\n });\n\n // Add listener for framework change.\n if (!self._singleFramework) {\n self._find('[data-action=\"chooseframework\"]').change(function(e) {\n self._frameworkId = $(e.target).val();\n self._loadCompetencies().then(self._refresh.bind(self)).catch(Notification.exception);\n });\n }\n\n // Add listener for search.\n self._find('[data-region=\"filtercompetencies\"] button').click(function(e) {\n e.preventDefault();\n $(e.target).attr('disabled', 'disabled');\n self._searchText = self._find('[data-region=\"filtercompetencies\"] input').val() || '';\n return self._refresh().always(function() {\n $(e.target).removeAttr('disabled');\n });\n });\n\n // Add listener for cancel.\n self._find('[data-region=\"competencylinktree\"] [data-action=\"cancel\"]').click(function(e) {\n e.preventDefault();\n self.close();\n });\n\n // Add listener for add.\n self._find('[data-region=\"competencylinktree\"] [data-action=\"add\"]').click(function(e) {\n e.preventDefault();\n if (!self._selectedCompetencies.length) {\n return;\n }\n\n if (self._multiSelect) {\n self._trigger('save', {competencyIds: self._selectedCompetencies});\n } else {\n // We checked above that the array has at least one value.\n self._trigger('save', {competencyId: self._selectedCompetencies[0]});\n }\n\n self.close();\n });\n\n // The list of selected competencies will be modified while looping (because of the listeners above).\n var currentItems = self._selectedCompetencies.slice(0);\n\n $.each(currentItems, function(index, id) {\n var node = self._find('[data-id=' + id + ']');\n if (node.length) {\n tree.toggleItem(node);\n tree.updateFocus(node);\n }\n });\n\n };\n\n /**\n * Close the dialogue.\n *\n * @method close\n */\n Picker.prototype.close = function() {\n var self = this;\n self._popup.close();\n self._reset();\n };\n\n /**\n * Opens the picker.\n *\n * @method display\n * @return {Promise}\n */\n Picker.prototype.display = function() {\n var self = this;\n return $.when(Str.get_string('competencypicker', 'tool_lp'), self._render())\n .then(function(title, render) {\n self._popup = new Dialogue(\n title,\n render[0],\n self._afterRender.bind(self)\n );\n return;\n }).catch(Notification.exception);\n };\n\n /**\n * Fetch the competencies.\n *\n * @param {Number} frameworkId The frameworkId.\n * @param {String} searchText Limit the competencies to those matching the text.\n * @method _fetchCompetencies\n * @return {Promise}\n */\n Picker.prototype._fetchCompetencies = function(frameworkId, searchText) {\n var self = this;\n\n return Ajax.call([\n {methodname: 'core_competency_search_competencies', args: {\n searchtext: searchText,\n competencyframeworkid: frameworkId\n }}\n ])[0].done(function(competencies) {\n /**\n * @param {Object} parent\n * @param {Array} competencies\n */\n function addCompetencyChildren(parent, competencies) {\n for (var i = 0; i < competencies.length; i++) {\n if (competencies[i].parentid == parent.id) {\n parent.haschildren = true;\n competencies[i].children = [];\n competencies[i].haschildren = false;\n parent.children[parent.children.length] = competencies[i];\n addCompetencyChildren(competencies[i], competencies);\n }\n }\n }\n\n // Expand the list of competencies into a tree.\n var i, comp;\n var tree = [];\n for (i = 0; i < competencies.length; i++) {\n comp = competencies[i];\n if (comp.parentid == \"0\") { // Loose check for now, because WS returns a string.\n comp.children = [];\n comp.haschildren = 0;\n tree[tree.length] = comp;\n addCompetencyChildren(comp, competencies);\n }\n }\n\n self._competencies = tree;\n\n }).fail(Notification.exception);\n };\n\n /**\n * Find a node in the dialogue.\n *\n * @param {String} selector\n * @return {JQuery}\n * @method _find\n */\n Picker.prototype._find = function(selector) {\n return $(this._popup.getContent()).find(selector);\n };\n\n /**\n * Convenience method to get a framework object.\n *\n * @param {Number} fid The framework ID.\n * @return {Object}\n * @method _getFramework\n */\n Picker.prototype._getFramework = function(fid) {\n var frm;\n $.each(this._frameworks, function(i, f) {\n if (f.id == fid) {\n frm = f;\n return;\n }\n });\n return frm;\n };\n\n /**\n * Load the competencies.\n *\n * @method _loadCompetencies\n * @return {Promise}\n */\n Picker.prototype._loadCompetencies = function() {\n return this._fetchCompetencies(this._frameworkId, this._searchText);\n };\n\n /**\n * Load the frameworks.\n *\n * @method _loadFrameworks\n * @return {Promise}\n */\n Picker.prototype._loadFrameworks = function() {\n var promise,\n self = this;\n\n // Quit early because we already have the data.\n if (self._frameworks.length > 0) {\n return $.when();\n }\n\n if (self._singleFramework) {\n promise = Ajax.call([\n {methodname: 'core_competency_read_competency_framework', args: {\n id: this._frameworkId\n }}\n ])[0].then(function(framework) {\n return [framework];\n });\n } else {\n promise = Ajax.call([\n {methodname: 'core_competency_list_competency_frameworks', args: {\n sort: 'shortname',\n context: {contextid: self._pageContextId},\n includes: self._pageContextIncludes,\n onlyvisible: self._onlyVisible\n }}\n ])[0];\n }\n\n return promise.done(function(frameworks) {\n self._frameworks = frameworks;\n }).fail(Notification.exception);\n };\n\n /**\n * Register an event listener.\n *\n * @param {String} type The event type.\n * @param {Function} handler The event listener.\n * @method on\n */\n Picker.prototype.on = function(type, handler) {\n this._eventNode.on(type, handler);\n };\n\n /**\n * Hook to executed before render.\n *\n * @method _preRender\n * @return {Promise}\n */\n Picker.prototype._preRender = function() {\n var self = this;\n return self._loadFrameworks().then(function() {\n if (!self._frameworkId && self._frameworks.length > 0) {\n self._frameworkId = self._frameworks[0].id;\n }\n\n // We could not set a framework ID, that probably means there are no frameworks accessible.\n if (!self._frameworkId) {\n self._frameworks = [];\n return $.when();\n }\n\n return self._loadCompetencies();\n });\n };\n\n /**\n * Refresh the view.\n *\n * @method _refresh\n * @return {Promise}\n */\n Picker.prototype._refresh = function() {\n var self = this;\n return self._render().then(function(html) {\n self._find('[data-region=\"competencylinktree\"]').replaceWith(html);\n self._afterRender();\n return;\n });\n };\n\n /**\n * Render the dialogue.\n *\n * @method _render\n * @return {Promise}\n */\n Picker.prototype._render = function() {\n var self = this;\n return self._preRender().then(function() {\n\n if (!self._singleFramework) {\n $.each(self._frameworks, function(i, framework) {\n if (framework.id == self._frameworkId) {\n framework.selected = true;\n } else {\n framework.selected = false;\n }\n });\n }\n\n var context = {\n competencies: self._competencies,\n framework: self._getFramework(self._frameworkId),\n frameworks: self._frameworks,\n search: self._searchText,\n singleFramework: self._singleFramework,\n };\n\n return Templates.render('tool_lp/competency_picker', context);\n });\n };\n\n /**\n * Reset the dialogue properties.\n *\n * This does not reset everything, just enough to reset the UI.\n *\n * @method _reset\n */\n Picker.prototype._reset = function() {\n this._competencies = [];\n this._disallowedCompetencyIDs = [];\n this._popup = null;\n this._searchText = '';\n this._selectedCompetencies = [];\n };\n\n /**\n * Set what competencies cannot be picked.\n *\n * This needs to be set after reset/close.\n *\n * @param {Number[]} ids The IDs.\n * @method _setDisallowedCompetencyIDs\n */\n Picker.prototype.setDisallowedCompetencyIDs = function(ids) {\n this._disallowedCompetencyIDs = ids;\n };\n\n /**\n * Trigger an event.\n *\n * @param {String} type The type of event.\n * @param {Object} data The data to pass to the listeners.\n * @method _reset\n */\n Picker.prototype._trigger = function(type, data) {\n this._eventNode.trigger(type, [data]);\n };\n\n return /** @alias module:tool_lp/competencypicker */ Picker;\n\n});\n"],"file":"competencypicker.min.js"} \ No newline at end of file +{"version":3,"sources":["../src/competencypicker.js"],"names":["define","$","Notification","Ajax","Templates","Dialogue","Str","Tree","Pending","Picker","pageContextId","singleFramework","pageContextIncludes","multiSelect","self","_eventNode","_frameworks","_reset","_pageContextId","_pageContextIncludes","_multiSelect","_frameworkId","_singleFramework","prototype","_competencies","_disallowedCompetencyIDs","_popup","_searchText","_selectedCompetencies","_onlyVisible","_afterRender","tree","_find","show","on","evt","params","selected","preventDefault","validIds","each","index","item","compId","data","valid","i","id","push","length","attr","removeAttr","change","e","target","val","_loadCompetencies","then","_refresh","bind","catch","exception","click","always","close","pendingPromise","_trigger","competencyIds","competencyId","resolve","currentItems","slice","node","toggleItem","updateFocus","display","when","get_string","_render","title","render","_fetchCompetencies","frameworkId","searchText","call","methodname","args","searchtext","competencyframeworkid","done","competencies","addCompetencyChildren","parent","parentid","haschildren","children","comp","fail","selector","getContent","find","_getFramework","fid","frm","f","_loadFrameworks","promise","framework","sort","context","contextid","includes","onlyvisible","frameworks","type","handler","_preRender","html","replaceWith","search","setDisallowedCompetencyIDs","ids","trigger"],"mappings":"AA2BAA,OAAM,4BAAC,CAAC,QAAD,CACC,mBADD,CAEC,WAFD,CAG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AO1B,CAAI,CAACE,WAAZ,CAAyB,SAAS8B,CAAT,CAAY6D,CAAZ,CAAuB,CAC5C,GAAIA,CAAS,CAAC5D,EAAV,EAAgBjC,CAAI,CAACO,YAAzB,CAAuC,CACnCsF,CAAS,CAACtE,QAAV,GACH,CAFD,IAEO,CACHsE,CAAS,CAACtE,QAAV,GACH,CACJ,CAND,CAOH,CAED,GAAIwE,CAAAA,CAAO,CAAG,CACVnB,YAAY,CAAE5E,CAAI,CAACU,aADT,CAEVmF,SAAS,CAAE7F,CAAI,CAACuF,aAAL,CAAmBvF,CAAI,CAACO,YAAxB,CAFD,CAGV4F,UAAU,CAAEnG,CAAI,CAACE,WAHP,CAIVuG,MAAM,CAAEzG,CAAI,CAACa,WAJH,CAKVhB,eAAe,CAAEG,CAAI,CAACQ,gBALZ,CAAd,CAQA,MAAOlB,CAAAA,CAAS,CAAC4E,MAAV,CAAiB,2BAAjB,CAA8C6B,CAA9C,CACV,CArBM,CAsBV,CAxBD,CAiCApG,CAAM,CAACc,SAAP,CAAiBN,MAAjB,CAA0B,UAAW,CACjC,KAAKO,aAAL,CAAqB,EAArB,CACA,KAAKC,wBAAL,CAAgC,EAAhC,CACA,KAAKC,MAAL,CAAc,IAAd,CACA,KAAKC,WAAL,CAAmB,EAAnB,CACA,KAAKC,qBAAL,CAA6B,EAChC,CAND,CAgBAnB,CAAM,CAACc,SAAP,CAAiBiG,0BAAjB,CAA8C,SAASC,CAAT,CAAc,CACxD,KAAKhG,wBAAL,CAAgCgG,CACnC,CAFD,CAWAhH,CAAM,CAACc,SAAP,CAAiB2C,QAAjB,CAA4B,SAASgD,CAAT,CAAetE,CAAf,CAAqB,CAC7C,KAAK7B,UAAL,CAAgB2G,OAAhB,CAAwBR,CAAxB,CAA8B,CAACtE,CAAD,CAA9B,CACH,CAFD,CAIA,MAAqDnC,CAAAA,CAExD,CA7bK,CAAN","sourcesContent":["// This file is part of Moodle - http://moodle.org/\n//\n// Moodle is free software: you can redistribute it and/or modify\n// it under the terms of the GNU General Public License as published by\n// the Free Software Foundation, either version 3 of the License, or\n// (at your option) any later version.\n//\n// Moodle is distributed in the hope that it will be useful,\n// but WITHOUT ANY WARRANTY; without even the implied warranty of\n// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the\n// GNU General Public License for more details.\n//\n// You should have received a copy of the GNU General Public License\n// along with Moodle. If not, see .\n\n/**\n * Competency picker.\n *\n * To handle 'save' events use: picker.on('save')\n * This will receive a object with either a single 'competencyId', or an array in 'competencyIds'\n * depending on the value of multiSelect.\n *\n * @package tool_lp\n * @copyright 2015 Frédéric Massart - FMCorz.net\n * @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later\n */\n\ndefine(['jquery',\n 'core/notification',\n 'core/ajax',\n 'core/templates',\n 'tool_lp/dialogue',\n 'core/str',\n 'tool_lp/tree',\n 'core/pending'\n ],\n function($, Notification, Ajax, Templates, Dialogue, Str, Tree, Pending) {\n\n /**\n * Competency picker class.\n * @param {Number} pageContextId The page context ID.\n * @param {Number|false} singleFramework The ID of the framework when limited to one.\n * @param {String} pageContextIncludes One of 'children', 'parents', 'self'.\n * @param {Boolean} multiSelect Support multi-select in the tree.\n */\n var Picker = function(pageContextId, singleFramework, pageContextIncludes, multiSelect) {\n var self = this;\n self._eventNode = $('
');\n self._frameworks = [];\n self._reset();\n\n self._pageContextId = pageContextId;\n self._pageContextIncludes = pageContextIncludes || 'children';\n self._multiSelect = (typeof multiSelect === 'undefined' || multiSelect === true);\n if (singleFramework) {\n self._frameworkId = singleFramework;\n self._singleFramework = true;\n }\n };\n\n /** @type {Array} The competencies fetched. */\n Picker.prototype._competencies = null;\n /** @type {Array} The competencies that cannot be picked. */\n Picker.prototype._disallowedCompetencyIDs = null;\n /** @type {Node} The node we attach the events to. */\n Picker.prototype._eventNode = null;\n /** @type {Array} The list of frameworks fetched. */\n Picker.prototype._frameworks = null;\n /** @type {Number} The current framework ID. */\n Picker.prototype._frameworkId = null;\n /** @type {Number} The page context ID. */\n Picker.prototype._pageContextId = null;\n /** @type {Number} Relevant contexts inclusion. */\n Picker.prototype._pageContextIncludes = null;\n /** @type {Dialogue} The reference to the dialogue. */\n Picker.prototype._popup = null;\n /** @type {String} The string we filter the competencies with. */\n Picker.prototype._searchText = '';\n /** @type {Object} The competency that was selected. */\n Picker.prototype._selectedCompetencies = null;\n /** @type {Boolean} Whether we can browse frameworks or not. */\n Picker.prototype._singleFramework = false;\n /** @type {Boolean} Do we allow multi select? */\n Picker.prototype._multiSelect = true;\n /** @type {Boolean} Do we allow to display hidden framework? */\n Picker.prototype._onlyVisible = true;\n\n /**\n * Hook to executed after the view is rendered.\n *\n * @method _afterRender\n */\n Picker.prototype._afterRender = function() {\n var self = this;\n\n // Initialise the tree.\n var tree = new Tree(self._find('[data-enhance=linktree]'), self._multiSelect);\n\n // To prevent jiggling we only show the tree after it is enhanced.\n self._find('[data-enhance=linktree]').show();\n\n tree.on('selectionchanged', function(evt, params) {\n var selected = params.selected;\n evt.preventDefault();\n var validIds = [];\n $.each(selected, function(index, item) {\n var compId = $(item).data('id'),\n valid = true;\n\n if (typeof compId === 'undefined') {\n // Do not allow picking nodes with no id.\n valid = false;\n } else {\n $.each(self._disallowedCompetencyIDs, function(i, id) {\n if (id == compId) {\n valid = false;\n }\n });\n }\n if (valid) {\n validIds.push(compId);\n }\n });\n\n self._selectedCompetencies = validIds;\n\n // TODO Implement disabling of nodes in the tree module somehow.\n if (!self._selectedCompetencies.length) {\n self._find('[data-region=\"competencylinktree\"] [data-action=\"add\"]').attr('disabled', 'disabled');\n } else {\n self._find('[data-region=\"competencylinktree\"] [data-action=\"add\"]').removeAttr('disabled');\n }\n });\n\n // Add listener for framework change.\n if (!self._singleFramework) {\n self._find('[data-action=\"chooseframework\"]').change(function(e) {\n self._frameworkId = $(e.target).val();\n self._loadCompetencies().then(self._refresh.bind(self)).catch(Notification.exception);\n });\n }\n\n // Add listener for search.\n self._find('[data-region=\"filtercompetencies\"] button').click(function(e) {\n e.preventDefault();\n $(e.target).attr('disabled', 'disabled');\n self._searchText = self._find('[data-region=\"filtercompetencies\"] input').val() || '';\n return self._refresh().always(function() {\n $(e.target).removeAttr('disabled');\n });\n });\n\n // Add listener for cancel.\n self._find('[data-region=\"competencylinktree\"] [data-action=\"cancel\"]').click(function(e) {\n e.preventDefault();\n self.close();\n });\n\n // Add listener for add.\n self._find('[data-region=\"competencylinktree\"] [data-action=\"add\"]').click(function(e) {\n e.preventDefault();\n var pendingPromise = new Pending();\n if (!self._selectedCompetencies.length) {\n return;\n }\n\n if (self._multiSelect) {\n self._trigger('save', {competencyIds: self._selectedCompetencies});\n } else {\n // We checked above that the array has at least one value.\n self._trigger('save', {competencyId: self._selectedCompetencies[0]});\n }\n\n // The dialogue here is a YUI dialogue and doesn't support Promises at all.\n // However, it is typically synchronous so this shoudl suffice.\n self.close();\n pendingPromise.resolve();\n });\n\n // The list of selected competencies will be modified while looping (because of the listeners above).\n var currentItems = self._selectedCompetencies.slice(0);\n\n $.each(currentItems, function(index, id) {\n var node = self._find('[data-id=' + id + ']');\n if (node.length) {\n tree.toggleItem(node);\n tree.updateFocus(node);\n }\n });\n\n };\n\n /**\n * Close the dialogue.\n *\n * @method close\n */\n Picker.prototype.close = function() {\n var self = this;\n self._popup.close();\n self._reset();\n };\n\n /**\n * Opens the picker.\n *\n * @method display\n * @return {Promise}\n */\n Picker.prototype.display = function() {\n var self = this;\n return $.when(Str.get_string('competencypicker', 'tool_lp'), self._render())\n .then(function(title, render) {\n self._popup = new Dialogue(\n title,\n render[0],\n self._afterRender.bind(self)\n );\n return;\n }).catch(Notification.exception);\n };\n\n /**\n * Fetch the competencies.\n *\n * @param {Number} frameworkId The frameworkId.\n * @param {String} searchText Limit the competencies to those matching the text.\n * @method _fetchCompetencies\n * @return {Promise}\n */\n Picker.prototype._fetchCompetencies = function(frameworkId, searchText) {\n var self = this;\n\n return Ajax.call([\n {methodname: 'core_competency_search_competencies', args: {\n searchtext: searchText,\n competencyframeworkid: frameworkId\n }}\n ])[0].done(function(competencies) {\n /**\n * @param {Object} parent\n * @param {Array} competencies\n */\n function addCompetencyChildren(parent, competencies) {\n for (var i = 0; i < competencies.length; i++) {\n if (competencies[i].parentid == parent.id) {\n parent.haschildren = true;\n competencies[i].children = [];\n competencies[i].haschildren = false;\n parent.children[parent.children.length] = competencies[i];\n addCompetencyChildren(competencies[i], competencies);\n }\n }\n }\n\n // Expand the list of competencies into a tree.\n var i, comp;\n var tree = [];\n for (i = 0; i < competencies.length; i++) {\n comp = competencies[i];\n if (comp.parentid == \"0\") { // Loose check for now, because WS returns a string.\n comp.children = [];\n comp.haschildren = 0;\n tree[tree.length] = comp;\n addCompetencyChildren(comp, competencies);\n }\n }\n\n self._competencies = tree;\n\n }).fail(Notification.exception);\n };\n\n /**\n * Find a node in the dialogue.\n *\n * @param {String} selector\n * @return {JQuery}\n * @method _find\n */\n Picker.prototype._find = function(selector) {\n return $(this._popup.getContent()).find(selector);\n };\n\n /**\n * Convenience method to get a framework object.\n *\n * @param {Number} fid The framework ID.\n * @return {Object}\n * @method _getFramework\n */\n Picker.prototype._getFramework = function(fid) {\n var frm;\n $.each(this._frameworks, function(i, f) {\n if (f.id == fid) {\n frm = f;\n return;\n }\n });\n return frm;\n };\n\n /**\n * Load the competencies.\n *\n * @method _loadCompetencies\n * @return {Promise}\n */\n Picker.prototype._loadCompetencies = function() {\n return this._fetchCompetencies(this._frameworkId, this._searchText);\n };\n\n /**\n * Load the frameworks.\n *\n * @method _loadFrameworks\n * @return {Promise}\n */\n Picker.prototype._loadFrameworks = function() {\n var promise,\n self = this;\n\n // Quit early because we already have the data.\n if (self._frameworks.length > 0) {\n return $.when();\n }\n\n if (self._singleFramework) {\n promise = Ajax.call([\n {methodname: 'core_competency_read_competency_framework', args: {\n id: this._frameworkId\n }}\n ])[0].then(function(framework) {\n return [framework];\n });\n } else {\n promise = Ajax.call([\n {methodname: 'core_competency_list_competency_frameworks', args: {\n sort: 'shortname',\n context: {contextid: self._pageContextId},\n includes: self._pageContextIncludes,\n onlyvisible: self._onlyVisible\n }}\n ])[0];\n }\n\n return promise.done(function(frameworks) {\n self._frameworks = frameworks;\n }).fail(Notification.exception);\n };\n\n /**\n * Register an event listener.\n *\n * @param {String} type The event type.\n * @param {Function} handler The event listener.\n * @method on\n */\n Picker.prototype.on = function(type, handler) {\n this._eventNode.on(type, handler);\n };\n\n /**\n * Hook to executed before render.\n *\n * @method _preRender\n * @return {Promise}\n */\n Picker.prototype._preRender = function() {\n var self = this;\n return self._loadFrameworks().then(function() {\n if (!self._frameworkId && self._frameworks.length > 0) {\n self._frameworkId = self._frameworks[0].id;\n }\n\n // We could not set a framework ID, that probably means there are no frameworks accessible.\n if (!self._frameworkId) {\n self._frameworks = [];\n return $.when();\n }\n\n return self._loadCompetencies();\n });\n };\n\n /**\n * Refresh the view.\n *\n * @method _refresh\n * @return {Promise}\n */\n Picker.prototype._refresh = function() {\n var self = this;\n return self._render().then(function(html) {\n self._find('[data-region=\"competencylinktree\"]').replaceWith(html);\n self._afterRender();\n return;\n });\n };\n\n /**\n * Render the dialogue.\n *\n * @method _render\n * @return {Promise}\n */\n Picker.prototype._render = function() {\n var self = this;\n return self._preRender().then(function() {\n\n if (!self._singleFramework) {\n $.each(self._frameworks, function(i, framework) {\n if (framework.id == self._frameworkId) {\n framework.selected = true;\n } else {\n framework.selected = false;\n }\n });\n }\n\n var context = {\n competencies: self._competencies,\n framework: self._getFramework(self._frameworkId),\n frameworks: self._frameworks,\n search: self._searchText,\n singleFramework: self._singleFramework,\n };\n\n return Templates.render('tool_lp/competency_picker', context);\n });\n };\n\n /**\n * Reset the dialogue properties.\n *\n * This does not reset everything, just enough to reset the UI.\n *\n * @method _reset\n */\n Picker.prototype._reset = function() {\n this._competencies = [];\n this._disallowedCompetencyIDs = [];\n this._popup = null;\n this._searchText = '';\n this._selectedCompetencies = [];\n };\n\n /**\n * Set what competencies cannot be picked.\n *\n * This needs to be set after reset/close.\n *\n * @param {Number[]} ids The IDs.\n * @method _setDisallowedCompetencyIDs\n */\n Picker.prototype.setDisallowedCompetencyIDs = function(ids) {\n this._disallowedCompetencyIDs = ids;\n };\n\n /**\n * Trigger an event.\n *\n * @param {String} type The type of event.\n * @param {Object} data The data to pass to the listeners.\n * @method _reset\n */\n Picker.prototype._trigger = function(type, data) {\n this._eventNode.trigger(type, [data]);\n };\n\n return /** @alias module:tool_lp/competencypicker */ Picker;\n\n});\n"],"file":"competencypicker.min.js"} \ No newline at end of file diff --git a/admin/tool/lp/amd/build/course_competency_settings.min.js b/admin/tool/lp/amd/build/course_competency_settings.min.js index dce39b1f87a..496c31ddee0 100644 --- a/admin/tool/lp/amd/build/course_competency_settings.min.js +++ b/admin/tool/lp/amd/build/course_competency_settings.min.js @@ -1,2 +1,2 @@ -define ("tool_lp/course_competency_settings",["jquery","core/notification","tool_lp/dialogue","core/str","core/ajax","core/templates"],function(a,b,c,d,f,g){var h=function(b){a(b).on("click",this.configureSettings.bind(this))};h.prototype._dialogue=null;h.prototype.configureSettings=function(f){var e=a(f.target).closest("a").data("courseid"),h=a(f.target).closest("a").data("pushratingstouserplans");f.preventDefault();g.render("tool_lp/course_competency_settings",{courseid:e,settings:{pushratingstouserplans:h}}).done(function(a){d.get_string("configurecoursecompetencysettings","tool_lp").done(function(b){this._dialogue=new c(b,a,this.addListeners.bind(this))}.bind(this)).fail(b.exception)}.bind(this)).fail(b.exception)};h.prototype.addListeners=function(){var a=this._find("[data-action=\"save\"]");a.on("click",this.saveSettings.bind(this));var b=this._find("[data-action=\"cancel\"]");b.on("click",this.cancelChanges.bind(this))};h.prototype.cancelChanges=function(a){a.preventDefault();this._dialogue.close()};h.prototype._find=function(b){return a("[data-region=\"coursecompetencysettings\"]").find(b)};h.prototype.saveSettings=function(a){a.preventDefault();var c=this._find("input[name=\"pushratingstouserplans\"]:checked").val(),d=this._find("input[name=\"courseid\"]").val();f.call([{methodname:"core_competency_update_course_competency_settings",args:{courseid:d,settings:{pushratingstouserplans:c}}}])[0].done(function(){this.refreshCourseCompetenciesPage()}.bind(this)).fail(b.exception)};h.prototype.refreshCourseCompetenciesPage=function(){var c=this._find("input[name=\"courseid\"]").val();f.call([{methodname:"tool_lp_data_for_course_competencies_page",args:{courseid:c,moduleid:0}}])[0].done(function(c){g.render("tool_lp/course_competencies_page",c).done(function(b,c){a("[data-region=\"coursecompetenciespage\"]").replaceWith(b);g.runTemplateJS(c);this._dialogue.close()}.bind(this)).fail(b.exception)}.bind(this)).fail(b.exception)};return h}); +define ("tool_lp/course_competency_settings",["jquery","core/notification","tool_lp/dialogue","core/str","core/ajax","core/templates","core/pending"],function(a,b,c,d,f,g,h){var i=function(b){a(b).on("click",this.configureSettings.bind(this))};i.prototype._dialogue=null;i.prototype.configureSettings=function(f){var e=new h,i=a(f.target).closest("a").data("courseid"),j=a(f.target).closest("a").data("pushratingstouserplans");f.preventDefault();a.when(d.get_string("configurecoursecompetencysettings","tool_lp"),g.render("tool_lp/course_competency_settings",{courseid:i,settings:{pushratingstouserplans:j}})).then(function(a,b){this._dialogue=new c(a,b[0],this.addListeners.bind(this));return this._dialogue}.bind(this)).then(e.resolve).catch(b.exception)};i.prototype.addListeners=function(){var a=this._find("[data-action=\"save\"]");a.on("click",this.saveSettings.bind(this));var b=this._find("[data-action=\"cancel\"]");b.on("click",this.cancelChanges.bind(this))};i.prototype.cancelChanges=function(a){a.preventDefault();this._dialogue.close()};i.prototype._find=function(b){return a("[data-region=\"coursecompetencysettings\"]").find(b)};i.prototype.saveSettings=function(a){var c=new h;a.preventDefault();var d=this._find("input[name=\"pushratingstouserplans\"]:checked").val(),e=this._find("input[name=\"courseid\"]").val();f.call([{methodname:"core_competency_update_course_competency_settings",args:{courseid:e,settings:{pushratingstouserplans:d}}}])[0].then(function(){return this.refreshCourseCompetenciesPage()}.bind(this)).then(c.resolve).catch(b.exception)};i.prototype.refreshCourseCompetenciesPage=function(){var c=this._find("input[name=\"courseid\"]").val(),d=new h;f.call([{methodname:"tool_lp_data_for_course_competencies_page",args:{courseid:c,moduleid:0}}])[0].then(function(a){return g.render("tool_lp/course_competencies_page",a)}).then(function(b,c){g.replaceNode(a("[data-region=\"coursecompetenciespage\"]"),b,c);this._dialogue.close()}.bind(this)).then(d.resolve).catch(b.exception)};return i}); //# sourceMappingURL=course_competency_settings.min.js.map diff --git a/admin/tool/lp/amd/build/course_competency_settings.min.js.map b/admin/tool/lp/amd/build/course_competency_settings.min.js.map index 329c5579ebc..9ab4d543df0 100644 --- a/admin/tool/lp/amd/build/course_competency_settings.min.js.map +++ b/admin/tool/lp/amd/build/course_competency_settings.min.js.map @@ -1 +1 @@ -{"version":3,"sources":["../src/course_competency_settings.js"],"names":["define","$","notification","Dialogue","str","ajax","templates","settingsMod","selector","on","configureSettings","bind","prototype","_dialogue","e","courseid","target","closest","data","currentValue","preventDefault","render","settings","pushratingstouserplans","done","html","get_string","title","addListeners","fail","exception","save","_find","saveSettings","cancel","cancelChanges","close","find","newValue","val","courseId","call","methodname","args","refreshCourseCompetenciesPage","moduleid","context","js","replaceWith","runTemplateJS"],"mappings":"AAuBAA,OAAM,sCAAC,CAAC,QAAD,CACC,mBADD,CAEC,kBAFD,CAGC,UAHD,CAIC,WAJD,CAKC,gBALD,CAAD,CAMC,SAASC,CAAT,CAAYC,CAAZ,CAA0BC,CAA1B,CAAoCC,CAApC,CAAyCC,CAAzC,CAA+CC,CAA/C,CAA0D,CAO7D,GAAIC,CAAAA,CAAW,CAAG,SAASC,CAAT,CAAmB,CACjCP,CAAC,CAACO,CAAD,CAAD,CAAYC,EAAZ,CAAe,OAAf,CAAwB,KAAKC,iBAAL,CAAuBC,IAAvB,CAA4B,IAA5B,CAAxB,CACH,CAFD,CAKAJ,CAAW,CAACK,SAAZ,CAAsBC,SAAtB,CAAkC,IAAlC,CAQAN,CAAW,CAACK,SAAZ,CAAsBF,iBAAtB,CAA0C,SAASI,CAAT,CAAY,IAC9CC,CAAAA,CAAQ,CAAGd,CAAC,CAACa,CAAC,CAACE,MAAH,CAAD,CA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ACzBxC,CAAS,CAACe,MAAV,CAAiB,kCAAjB,CAAqDyB,CAArD,EAA8DtB,IAA9D,CAAmE,SAASC,CAAT,CAAesB,CAAf,CAAmB,CAClF9C,CAAC,CAAC,0CAAD,CAAD,CAA4C+C,WAA5C,CAAwDvB,CAAxD,EACAnB,CAAS,CAAC2C,aAAV,CAAwBF,CAAxB,EACA,KAAKlC,SAAL,CAAeuB,KAAf,EACH,CAJkE,CAIjEzB,IAJiE,CAI5D,IAJ4D,CAAnE,EAIckB,IAJd,CAImB3B,CAAY,CAAC4B,SAJhC,CAKH,CANU,CAMTnB,IANS,CAMJ,IANI,CAHX,EASckB,IATd,CASmB3B,CAAY,CAAC4B,SAThC,CAWH,CAdD,CAgBA,MAAsEvB,CAAAA,CACzE,CA7HK,CAAN","sourcesContent":["// This file is part of Moodle - http://moodle.org/\n//\n// Moodle is free software: you can redistribute it and/or modify\n// it under the terms of the GNU General Public License as published by\n// the Free Software Foundation, either version 3 of the License, or\n// (at your option) any later version.\n//\n// Moodle is distributed in the hope that it will be useful,\n// but WITHOUT ANY WARRANTY; without even the implied warranty of\n// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the\n// GNU General Public License for more details.\n//\n// You should have received a copy of the GNU General Public License\n// along with Moodle. If not, see .\n\n/**\n * Change the course competency settings in a popup.\n *\n * @module tool_lp/configurecoursecompetencysettings\n * @package tool_lp\n * @copyright 2015 Damyon Wiese \n * @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later\n */\ndefine(['jquery',\n 'core/notification',\n 'tool_lp/dialogue',\n 'core/str',\n 'core/ajax',\n 'core/templates'],\n function($, notification, Dialogue, str, ajax, templates) {\n\n /**\n * Constructor\n *\n * @param {String} selector - selector for the links to open the dialogue.\n */\n var settingsMod = function(selector) {\n $(selector).on('click', this.configureSettings.bind(this));\n };\n\n /** @type {Dialogue} Reference to the dialogue that we opened. */\n settingsMod.prototype._dialogue = null;\n\n /**\n * Open the configure settings dialogue.\n *\n * @param {Event} e\n * @method configureSettings\n */\n settingsMod.prototype.configureSettings = function(e) {\n var courseid = $(e.target).closest('a').data('courseid');\n var currentValue = $(e.target).closest('a').data('pushratingstouserplans');\n var context = {\n courseid: courseid,\n settings: {pushratingstouserplans: currentValue}\n };\n e.preventDefault();\n\n templates.render('tool_lp/course_competency_settings', context).done(function(html) {\n str.get_string('configurecoursecompetencysettings', 'tool_lp').done(function(title) {\n this._dialogue = new Dialogue(\n title,\n html,\n this.addListeners.bind(this)\n );\n }.bind(this)).fail(notification.exception);\n }.bind(this)).fail(notification.exception);\n\n };\n\n /**\n * Add the save listener to the form.\n *\n * @method addSaveListener\n */\n settingsMod.prototype.addListeners = function() {\n var save = this._find('[data-action=\"save\"]');\n save.on('click', this.saveSettings.bind(this));\n var cancel = this._find('[data-action=\"cancel\"]');\n cancel.on('click', this.cancelChanges.bind(this));\n };\n\n /**\n * Cancel the changes.\n *\n * @param {Event} e\n * @method cancelChanges\n */\n settingsMod.prototype.cancelChanges = function(e) {\n e.preventDefault();\n this._dialogue.close();\n };\n\n /**\n * Cancel the changes.\n *\n * @param {String} selector\n * @return {JQuery}\n */\n settingsMod.prototype._find = function(selector) {\n return $('[data-region=\"coursecompetencysettings\"]').find(selector);\n };\n\n /**\n * Save the settings.\n *\n * @param {Event} e\n * @method saveSettings\n */\n settingsMod.prototype.saveSettings = function(e) {\n e.preventDefault();\n\n var newValue = this._find('input[name=\"pushratingstouserplans\"]:checked').val();\n var courseId = this._find('input[name=\"courseid\"]').val();\n var settings = {pushratingstouserplans: newValue};\n\n ajax.call([\n {methodname: 'core_competency_update_course_competency_settings',\n args: {courseid: courseId, settings: settings}}\n ])[0].done(function() {\n this.refreshCourseCompetenciesPage();\n }.bind(this)).fail(notification.exception);\n\n };\n\n /**\n * Refresh the course competencies page.\n *\n * @param {Event} e\n * @method saveSettings\n */\n settingsMod.prototype.refreshCourseCompetenciesPage = function() {\n var courseId = this._find('input[name=\"courseid\"]').val();\n\n ajax.call([\n {methodname: 'tool_lp_data_for_course_competencies_page',\n args: {courseid: courseId, moduleid: 0}}\n ])[0].done(function(context) {\n templates.render('tool_lp/course_competencies_page', context).done(function(html, js) {\n $('[data-region=\"coursecompetenciespage\"]').replaceWith(html);\n templates.runTemplateJS(js);\n this._dialogue.close();\n }.bind(this)).fail(notification.exception);\n }.bind(this)).fail(notification.exception);\n\n };\n\n return /** @alias module:tool_lp/configurecoursecompetencysettings */ settingsMod;\n});\n"],"file":"course_competency_settings.min.js"} \ No newline at end of file +{"version":3,"sources":["../src/course_competency_settings.js"],"names":["define","$","notification","Dialogue","str","ajax","templates","Pending","settingsMod","selector","on","configureSettings","bind","prototype","_dialogue","e","pendingPromise","courseid","target","closest","data","currentValue","preventDefault","when","get_string","render","settings","pushratingstouserplans","then","title","templateResult","addListeners","resolve","catch","exception","save","_find","saveSettings","cancel","cancelChanges","close","find","newValue","val","courseId","call","methodname","args","refreshCourseCompetenciesPage","moduleid","context","html","js","replaceNode"],"mappings":"AAuBAA,OAAM,sCAAC,CAAC,QAAD,CACC,mBADD,CAEC,kBAFD,CAGC,UAHD,CAIC,WAJD,CAKC,gBALD,CAMC,cAND,CAAD,CAQC,SAASC,CAAT,CAAYC,CAAZ,CAA0BC,CAA1B,CAAoCC,CAApC,CAAyCC,CAAzC,CAA+CC,CAA/C,CAA0DC,CAA1D,CAAmE,CAOtE,GAAIC,CAAAA,CAAW,CAAG,SAASC,CAAT,CAAmB,CACjCR,CAAC,CAACQ,CAAD,CAAD,CAAYC,EAAZ,CAAe,OAAf,CAAwB,KAAKC,iBAAL,CAAuBC,IAAvB,CAA4B,IAA5B,CAAxB,CACH,CAFD,CAKAJ,CAAW,CAACK,SAAZ,CAAsBC,SAAtB,CAAkC,IAAlC,CAQAN,CAAW,CAACK,SAAZ,CAAsBF,iBAAtB,CAA0C,SAASI,CAAT,CAAY,IAC9CC,CAAAA,CAAc,CAAG,GAAIT,CAAAA,CADyB,CAE9CU,CAAQ,CAAGhB,CAAC,CAACc,CAAC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AE,2CAAb,CACEC,IAAI,CAAE,CAAC9B,QAAQ,CAAE2B,CAAX,CAAqBK,QAAQ,CAAE,CAA/B,CADR,CADM,CAAV,EAGG,CAHH,EAICrB,IAJD,CAIM,SAASsB,CAAT,CAAkB,CACpB,MAAO5C,CAAAA,CAAS,CAACmB,MAAV,CAAiB,kCAAjB,CAAqDyB,CAArD,CACV,CAND,EAOCtB,IAPD,CAOM,SAASuB,CAAT,CAAeC,CAAf,CAAmB,CACrB9C,CAAS,CAAC+C,WAAV,CAAsBpD,CAAC,CAAC,0CAAD,CAAvB,CAAmEkD,CAAnE,CAAyEC,CAAzE,EACA,KAAKtC,SAAL,CAAe0B,KAAf,EAGH,CALK,CAKJ5B,IALI,CAKC,IALD,CAPN,EAaCgB,IAbD,CAaMZ,CAAc,CAACgB,OAbrB,EAcCC,KAdD,CAcO/B,CAAY,CAACgC,SAdpB,CAeH,CAnBD,CAqBA,MAAsE1B,CAAAA,CACzE,CA9IK,CAAN","sourcesContent":["// This file is part of Moodle - http://moodle.org/\n//\n// Moodle is free software: you can redistribute it and/or modify\n// it under the terms of the GNU General Public License as published by\n// the Free Software Foundation, either version 3 of the License, or\n// (at your option) any later version.\n//\n// Moodle is distributed in the hope that it will be useful,\n// but WITHOUT ANY WARRANTY; without even the implied warranty of\n// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the\n// GNU General Public License for more details.\n//\n// You should have received a copy of the GNU General Public License\n// along with Moodle. If not, see .\n\n/**\n * Change the course competency settings in a popup.\n *\n * @module tool_lp/configurecoursecompetencysettings\n * @package tool_lp\n * @copyright 2015 Damyon Wiese \n * @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later\n */\ndefine(['jquery',\n 'core/notification',\n 'tool_lp/dialogue',\n 'core/str',\n 'core/ajax',\n 'core/templates',\n 'core/pending'\n ],\n function($, notification, Dialogue, str, ajax, templates, Pending) {\n\n /**\n * Constructor\n *\n * @param {String} selector - selector for the links to open the dialogue.\n */\n var settingsMod = function(selector) {\n $(selector).on('click', this.configureSettings.bind(this));\n };\n\n /** @type {Dialogue} Reference to the dialogue that we opened. */\n settingsMod.prototype._dialogue = null;\n\n /**\n * Open the configure settings dialogue.\n *\n * @param {Event} e\n * @method configureSettings\n */\n settingsMod.prototype.configureSettings = function(e) {\n var pendingPromise = new Pending();\n var courseid = $(e.target).closest('a').data('courseid');\n var currentValue = $(e.target).closest('a').data('pushratingstouserplans');\n var context = {\n courseid: courseid,\n settings: {pushratingstouserplans: currentValue}\n };\n e.preventDefault();\n\n $.when(\n str.get_string('configurecoursecompetencysettings', 'tool_lp'),\n templates.render('tool_lp/course_competency_settings', context),\n )\n .then(function(title, templateResult) {\n this._dialogue = new Dialogue(\n title,\n templateResult[0],\n this.addListeners.bind(this)\n );\n\n return this._dialogue;\n }.bind(this))\n .then(pendingPromise.resolve)\n .catch(notification.exception);\n };\n\n /**\n * Add the save listener to the form.\n *\n * @method addSaveListener\n */\n settingsMod.prototype.addListeners = function() {\n var save = this._find('[data-action=\"save\"]');\n save.on('click', this.saveSettings.bind(this));\n var cancel = this._find('[data-action=\"cancel\"]');\n cancel.on('click', this.cancelChanges.bind(this));\n };\n\n /**\n * Cancel the changes.\n *\n * @param {Event} e\n * @method cancelChanges\n */\n settingsMod.prototype.cancelChanges = function(e) {\n e.preventDefault();\n this._dialogue.close();\n };\n\n /**\n * Cancel the changes.\n *\n * @param {String} selector\n * @return {JQuery}\n */\n settingsMod.prototype._find = function(selector) {\n return $('[data-region=\"coursecompetencysettings\"]').find(selector);\n };\n\n /**\n * Save the settings.\n *\n * @param {Event} e\n * @method saveSettings\n */\n settingsMod.prototype.saveSettings = function(e) {\n var pendingPromise = new Pending();\n e.preventDefault();\n\n var newValue = this._find('input[name=\"pushratingstouserplans\"]:checked').val();\n var courseId = this._find('input[name=\"courseid\"]').val();\n var settings = {pushratingstouserplans: newValue};\n\n ajax.call([\n {methodname: 'core_competency_update_course_competency_settings',\n args: {courseid: courseId, settings: settings}}\n ])[0]\n .then(function() {\n return this.refreshCourseCompetenciesPage();\n }.bind(this))\n .then(pendingPromise.resolve)\n .catch(notification.exception);\n\n };\n\n /**\n * Refresh the course competencies page.\n *\n * @param {Event} e\n * @method saveSettings\n */\n settingsMod.prototype.refreshCourseCompetenciesPage = function() {\n var courseId = this._find('input[name=\"courseid\"]').val();\n var pendingPromise = new Pending();\n\n ajax.call([\n {methodname: 'tool_lp_data_for_course_competencies_page',\n args: {courseid: courseId, moduleid: 0}}\n ])[0]\n .then(function(context) {\n return templates.render('tool_lp/course_competencies_page', context);\n })\n .then(function(html, js) {\n templates.replaceNode($('[data-region=\"coursecompetenciespage\"]'), html, js);\n this._dialogue.close();\n\n return;\n }.bind(this))\n .then(pendingPromise.resolve)\n .catch(notification.exception);\n };\n\n return /** @alias module:tool_lp/configurecoursecompetencysettings */ settingsMod;\n});\n"],"file":"course_competency_settings.min.js"} \ No newline at end of file diff --git a/admin/tool/lp/amd/build/grade_dialogue.min.js b/admin/tool/lp/amd/build/grade_dialogue.min.js index 9c0ecbdcf4a..806eeebbe3d 100644 --- a/admin/tool/lp/amd/build/grade_dialogue.min.js +++ b/admin/tool/lp/amd/build/grade_dialogue.min.js @@ -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 this._render().then(function(a){return f.get_string("rate","tool_lp").then(function(b){this._popup=new d(b,a,this._afterRender.bind(this))}.bind(this))}.bind(this)).fail(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(){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}); //# sourceMappingURL=grade_dialogue.min.js.map diff --git a/admin/tool/lp/amd/build/grade_dialogue.min.js.map b/admin/tool/lp/amd/build/grade_dialogue.min.js.map index 6f0202f40fc..6af7b518787 100644 --- a/admin/tool/lp/amd/build/grade_dialogue.min.js.map +++ b/admin/tool/lp/amd/build/grade_dialogue.min.js.map @@ -1 +1 @@ -{"version":3,"sources":["../src/grade_dialogue.js"],"names":["define","$","Notification","Templates","Dialogue","EventBase","Str","Grade","ratingOptions","prototype","constructor","apply","_ratingOptions","Object","create","_popup","_afterRender","btnRate","_find","lstRating","txtComment","click","e","preventDefault","_trigger","close","bind","change","node","val","prop","display","_render","then","html","get_string","title","fail","exception","selector","getContent","find","context","cangrade","_canGrade","ratings","render"],"mappings":"AAuBAA,OAAM,0BAAC,CAAC,QAAD,CACC,mBADD,CAEC,gBAFD,CAGC,kBAHD,CAIC,oBAJD,CAKC,UALD,CAAD,CAME,SAASC,CAAT,CAAYC,CAAZ,CAA0BC,CAA1B,CAAqCC,CAArC,CAA+CC,CAA/C,CAA0DC,CAA1D,CAA+D,CAMnE,GAAIC,CAAAA,CAAK,CAAG,SAASC,CAAT,CAAwB,CAChCH,CAAS,CAACI,SAAV,CAAoBC,WAApB,CAAgCC,KAAhC,CAAsC,IAAtC,CAA4C,EAA5C,EACA,KAAKC,cAAL,CAAsBJ,CACzB,CAHD,CAIAD,CAAK,CAACE,SAAN,CAAkBI,MAAM,CAACC,MAAP,CAAcT,CAAS,CAACI,SAAxB,CAAlB,CAGAF,CAAK,CAACE,SAAN,CAAgBM,MAAhB,CAAyB,IAAzB,CAEAR,CAAK,CAACE,SAAN,CAAgBG,cAAhB,CAAiC,IAAjC,CAQAL,CAAK,CAACE,SAAN,CAAgBO,YAAhB,CAA+B,UAAW,CACtC,GAAIC,CAAAA,CAAO,CAAG,KAAKC,KAAL,CAAW,wBAAX,CAAd,CACIC,CAAS,CAAG,KAAKD,KAAL,CAAW,mBAAX,CADhB,CAEIE,CAAU,CAAG,KAAKF,KAAL,CAAW,oBAAX,CAFjB,CAIA,KAAKA,KAAL,CAAW,0BAAX,EAAqCG,KAArC,CAA2C,SAASC,CAAT,CAAY,CACnDA,CAAC,CAACC,cAAF,GACA,KAAKC,QAAL,CAAc,WAAd,EACA,KAAKC,KAAL,EACH,CAJ0C,CAIzCC,IAJyC,CAIpC,IAJoC,CAA3C,EAMAP,CAAS,CAACQ,MAAV,CAA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B,CAAK,CAACE,SAAN,CAAgBS,KAAhB,CAAwB,SAASqB,CAAT,CAAmB,CACvC,MAAOtC,CAAAA,CAAC,CAAC,KAAKc,MAAL,CAAYyB,UAAZ,EAAD,CAAD,CAA4BC,IAA5B,CAAiCF,CAAjC,CACV,CAFD,CAWAhC,CAAK,CAACE,SAAN,CAAgBuB,OAAhB,CAA0B,UAAW,CACjC,GAAIU,CAAAA,CAAO,CAAG,CACVC,QAAQ,CAAE,KAAKC,SADL,CAEVC,OAAO,CAAE,KAAKjC,cAFJ,CAAd,CAIA,MAAOT,CAAAA,CAAS,CAAC2C,MAAV,CAAiB,2BAAjB,CAA8CJ,CAA9C,CACV,CAND,CAQA,MAAmDnC,CAAAA,CAEtD,CAzHK,CAAN","sourcesContent":["// This file is part of Moodle - http://moodle.org/\n//\n// Moodle is free software: you can redistribute it and/or modify\n// it under the terms of the GNU General Public License as published by\n// the Free Software Foundation, either version 3 of the License, or\n// (at your option) any later version.\n//\n// Moodle is distributed in the hope that it will be useful,\n// but WITHOUT ANY WARRANTY; without even the implied warranty of\n// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the\n// GNU General Public License for more details.\n//\n// You should have received a copy of the GNU General Public License\n// along with Moodle. If not, see .\n\n/**\n * Grade dialogue.\n *\n * @package tool_lp\n * @copyright 2016 Frédéric Massart - FMCorz.net\n * @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later\n */\n\ndefine(['jquery',\n 'core/notification',\n 'core/templates',\n 'tool_lp/dialogue',\n 'tool_lp/event_base',\n 'core/str'],\n function($, Notification, Templates, Dialogue, EventBase, Str) {\n\n /**\n * Grade dialogue class.\n * @param {Array} ratingOptions\n */\n var Grade = function(ratingOptions) {\n EventBase.prototype.constructor.apply(this, []);\n this._ratingOptions = ratingOptions;\n };\n Grade.prototype = Object.create(EventBase.prototype);\n\n /** @type {Dialogue} The dialogue. */\n Grade.prototype._popup = null;\n /** @type {Array} Array of objects containing, 'value', 'name' and optionally 'selected'. */\n Grade.prototype._ratingOptions = null;\n\n /**\n * After render hook.\n *\n * @method _afterRender\n * @protected\n */\n Grade.prototype._afterRender = function() {\n var btnRate = this._find('[data-action=\"rate\"]'),\n lstRating = this._find('[name=\"rating\"]'),\n txtComment = this._find('[name=\"comment\"]');\n\n this._find('[data-action=\"cancel\"]').click(function(e) {\n e.preventDefault();\n this._trigger('cancelled');\n this.close();\n }.bind(this));\n\n lstRating.change(function() {\n var node = $(this);\n if (!node.val()) {\n btnRate.prop('disabled', true);\n } else {\n btnRate.prop('disabled', false);\n }\n }).change();\n\n btnRate.click(function(e) {\n e.preventDefault();\n var val = lstRating.val();\n if (!val) {\n return;\n }\n this._trigger('rated', {\n 'rating': val,\n 'note': txtComment.val()\n });\n this.close();\n }.bind(this));\n };\n\n /**\n * Close the dialogue.\n *\n * @method close\n */\n Grade.prototype.close = function() {\n this._popup.close();\n this._popup = null;\n };\n\n /**\n * Opens the picker.\n *\n * @param {Number} competencyId The competency ID of the competency to work on.\n * @method display\n * @return {Promise}\n */\n Grade.prototype.display = function() {\n return this._render().then(function(html) {\n return Str.get_string('rate', 'tool_lp').then(function(title) {\n this._popup = new Dialogue(\n title,\n html,\n this._afterRender.bind(this)\n );\n }.bind(this));\n }.bind(this)).fail(Notification.exception);\n };\n\n /**\n * Find a node in the dialogue.\n *\n * @param {String} selector\n * @method _find\n * @returns {node} The node\n * @protected\n */\n Grade.prototype._find = function(selector) {\n return $(this._popup.getContent()).find(selector);\n };\n\n /**\n * Render the dialogue.\n *\n * @method _render\n * @protected\n * @return {Promise}\n */\n Grade.prototype._render = function() {\n var context = {\n cangrade: this._canGrade,\n ratings: this._ratingOptions\n };\n return Templates.render('tool_lp/competency_grader', context);\n };\n\n return /** @alias module:tool_lp/grade_dialogue */ Grade;\n\n});\n"],"file":"grade_dialogue.min.js"} \ No newline at end of file +{"version":3,"sources":["../src/grade_dialogue.js"],"names":["define","$","Notification","Templates","Dialogue","EventBase","Str","Grade","ratingOptions","prototype","constructor","apply","_ratingOptions","Object","create","_popup","_afterRender","btnRate","_find","lstRating","txtComment","click","e","preventDefault","_trigger","close","bind","change","node","val","prop","display","when","get_string","_render","then","title","templateResult","catch","exception","selector","getContent","find","context","cangrade","_canGrade","ratings","render"],"mappings":"AAuBAA,OAAM,0BAAC,CAAC,QAAD,CACC,mBADD,CAEC,gBAFD,CAGC,kBAHD,CAIC,oBAJD,CAKC,UALD,CAAD,CAME,SAASC,CAAT,CAAYC,CAAZ,CAA0BC,CAA1B,CAAqCC,CAArC,CAA+CC,CAA/C,CAA0DC,CAA1D,CAA+D,CAMnE,GAAIC,CAAAA,CAAK,CAAG,SAASC,CAAT,CAAwB,CAChCH,CAAS,CAACI,SAAV,CAAoBC,WAApB,CAAgCC,KAAhC,CAAsC,IAAtC,CAA4C,EAA5C,EACA,KAAKC,cAAL,CAAsBJ,CACzB,CAHD,CAIAD,CAAK,CAACE,SAAN,CAAkBI,MAAM,CAACC,MAAP,CAAcT,CAAS,CAACI,SAAxB,CAAlB,CAGAF,CAAK,CAACE,SAAN,CAAgBM,MAAhB,CAAyB,IAAzB,CAEAR,CAAK,CAACE,SAAN,CAAgBG,cAAhB,CAAiC,IAAjC,CAQAL,CAAK,CAACE,SAAN,CAAgBO,YAAhB,CAA+B,UAAW,CACtC,GAAIC,CAAAA,CAAO,CAAG,KAAKC,KAAL,CAAW,wBAAX,CAAd,CACIC,CAAS,CAAG,KAAKD,KAAL,CAAW,mBAAX,CADhB,CAEIE,CAAU,CAAG,KAAKF,KAAL,CAAW,oBAAX,CAFjB,CAIA,KAAKA,KAAL,CAAW,0BAAX,EAAqCG,KAArC,CAA2C,SAASC,CAAT,CAAY,CACnDA,CAAC,CAACC,cAAF,GACA,KAAKC,QAAL,CAAc,WAAd,EACA,KAAKC,KAAL,EACH,CAJ0C,CAIzCC,IAJyC,CAIpC,IAJoC,CAA3C,EAMAP,CAAS,CAACQ,MAAV,CAAiB,UAAW,CACxB,GAAIC,CAAAA,CAAI,CAAG3B,C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CAAmB,CACvC,MAAOvC,CAAAA,CAAC,CAAC,KAAKc,MAAL,CAAY0B,UAAZ,EAAD,CAAD,CAA4BC,IAA5B,CAAiCF,CAAjC,CACV,CAFD,CAWAjC,CAAK,CAACE,SAAN,CAAgByB,OAAhB,CAA0B,UAAW,CACjC,GAAIS,CAAAA,CAAO,CAAG,CACVC,QAAQ,CAAE,KAAKC,SADL,CAEVC,OAAO,CAAE,KAAKlC,cAFJ,CAAd,CAIA,MAAOT,CAAAA,CAAS,CAAC4C,MAAV,CAAiB,2BAAjB,CAA8CJ,CAA9C,CACV,CAND,CAQA,MAAmDpC,CAAAA,CAEtD,CA9HK,CAAN","sourcesContent":["// This file is part of Moodle - http://moodle.org/\n//\n// Moodle is free software: you can redistribute it and/or modify\n// it under the terms of the GNU General Public License as published by\n// the Free Software Foundation, either version 3 of the License, or\n// (at your option) any later version.\n//\n// Moodle is distributed in the hope that it will be useful,\n// but WITHOUT ANY WARRANTY; without even the implied warranty of\n// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the\n// GNU General Public License for more details.\n//\n// You should have received a copy of the GNU General Public License\n// along with Moodle. If not, see .\n\n/**\n * Grade dialogue.\n *\n * @package tool_lp\n * @copyright 2016 Frédéric Massart - FMCorz.net\n * @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later\n */\n\ndefine(['jquery',\n 'core/notification',\n 'core/templates',\n 'tool_lp/dialogue',\n 'tool_lp/event_base',\n 'core/str'],\n function($, Notification, Templates, Dialogue, EventBase, Str) {\n\n /**\n * Grade dialogue class.\n * @param {Array} ratingOptions\n */\n var Grade = function(ratingOptions) {\n EventBase.prototype.constructor.apply(this, []);\n this._ratingOptions = ratingOptions;\n };\n Grade.prototype = Object.create(EventBase.prototype);\n\n /** @type {Dialogue} The dialogue. */\n Grade.prototype._popup = null;\n /** @type {Array} Array of objects containing, 'value', 'name' and optionally 'selected'. */\n Grade.prototype._ratingOptions = null;\n\n /**\n * After render hook.\n *\n * @method _afterRender\n * @protected\n */\n Grade.prototype._afterRender = function() {\n var btnRate = this._find('[data-action=\"rate\"]'),\n lstRating = this._find('[name=\"rating\"]'),\n txtComment = this._find('[name=\"comment\"]');\n\n this._find('[data-action=\"cancel\"]').click(function(e) {\n e.preventDefault();\n this._trigger('cancelled');\n this.close();\n }.bind(this));\n\n lstRating.change(function() {\n var node = $(this);\n if (!node.val()) {\n btnRate.prop('disabled', true);\n } else {\n btnRate.prop('disabled', false);\n }\n }).change();\n\n btnRate.click(function(e) {\n e.preventDefault();\n var val = lstRating.val();\n if (!val) {\n return;\n }\n this._trigger('rated', {\n 'rating': val,\n 'note': txtComment.val()\n });\n this.close();\n }.bind(this));\n };\n\n /**\n * Close the dialogue.\n *\n * @method close\n */\n Grade.prototype.close = function() {\n this._popup.close();\n this._popup = null;\n };\n\n /**\n * Opens the picker.\n *\n * @param {Number} competencyId The competency ID of the competency to work on.\n * @method display\n * @return {Promise}\n */\n Grade.prototype.display = function() {\n return $.when(\n Str.get_string('rate', 'tool_lp'),\n this._render()\n )\n .then(function(title, templateResult) {\n this._popup = new Dialogue(\n title,\n templateResult[0],\n this._afterRender.bind(this)\n );\n\n return this._popup;\n }.bind(this))\n .catch(Notification.exception);\n };\n\n /**\n * Find a node in the dialogue.\n *\n * @param {String} selector\n * @method _find\n * @returns {node} The node\n * @protected\n */\n Grade.prototype._find = function(selector) {\n return $(this._popup.getContent()).find(selector);\n };\n\n /**\n * Render the dialogue.\n *\n * @method _render\n * @protected\n * @return {Promise}\n */\n Grade.prototype._render = function() {\n var context = {\n cangrade: this._canGrade,\n ratings: this._ratingOptions\n };\n return Templates.render('tool_lp/competency_grader', context);\n };\n\n return /** @alias module:tool_lp/grade_dialogue */ Grade;\n\n});\n"],"file":"grade_dialogue.min.js"} \ No newline at end of file diff --git a/admin/tool/lp/amd/build/grade_user_competency_inline.min.js b/admin/tool/lp/amd/build/grade_user_competency_inline.min.js index 4d52c200527..ade689970c2 100644 --- a/admin/tool/lp/amd/build/grade_user_competency_inline.min.js +++ b/admin/tool/lp/amd/build/grade_user_competency_inline.min.js @@ -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.done(function(f){a.push({value:"",name:d._chooseStr});for(var g=0,h;g.\n\n/**\n * Module to enable inline editing of a comptency grade.\n *\n * @package tool_lp\n * @copyright 2015 Damyon Wiese\n * @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later\n */\n\ndefine(['jquery',\n 'core/notification',\n 'core/ajax',\n 'core/log',\n 'tool_lp/grade_dialogue',\n 'tool_lp/event_base',\n 'tool_lp/scalevalues',\n ], function($, notification, ajax, log, GradeDialogue, EventBase, ScaleValues) {\n\n /**\n * InlineEditor\n *\n * @param {String} selector The selector to trigger the grading.\n * @param {Number} scaleId The id of the scale for this competency.\n * @param {Number} competencyId The id of the competency.\n * @param {Number} userId The id of the user.\n * @param {Number} planId The id of the plan.\n * @param {Number} courseId The id of the course.\n * @param {String} chooseStr Language string for choose a rating.\n */\n var InlineEditor = function(selector, scaleId, competencyId, userId, planId, courseId, chooseStr) {\n EventBase.prototype.constructor.apply(this, []);\n\n var trigger = $(selector);\n if (!trigger.length) {\n throw new Error('Could not find the trigger');\n }\n\n this._scaleId = scaleId;\n this._competencyId = competencyId;\n this._userId = userId;\n this._planId = planId;\n this._courseId = courseId;\n this._chooseStr = chooseStr;\n this._setUp();\n\n trigger.click(function(e) {\n e.preventDefault();\n this._dialogue.display();\n }.bind(this));\n\n if (this._planId) {\n this._methodName = 'core_competency_grade_competency_in_plan';\n this._args = {\n competencyid: this._competencyId,\n planid: this._planId\n };\n } else if (this._courseId) {\n this._methodName = 'core_competency_grade_competency_in_course';\n this._args = {\n competencyid: this._competencyId,\n courseid: this._courseId,\n userid: this._userId\n };\n } else {\n this._methodName = 'core_competency_grade_competency';\n this._args = {\n userid: this._userId,\n competencyid: this._competencyId\n };\n }\n };\n InlineEditor.prototype = Object.create(EventBase.prototype);\n\n /**\n * Setup.\n *\n * @method _setUp\n */\n InlineEditor.prototype._setUp = function() {\n var options = [],\n self = this;\n\n var promise = ScaleValues.get_values(self._scaleId);\n promise.done(function(scalevalues) {\n options.push({\n value: '',\n name: self._chooseStr\n });\n\n for (var i = 0; i < scalevalues.length; i++) {\n var optionConfig = scalevalues[i];\n options.push({\n value: optionConfig.id,\n name: optionConfig.name\n });\n }\n\n self._dialogue = new GradeDialogue(options);\n self._dialogue.on('rated', function(e, data) {\n var args = self._args;\n args.grade = data.rating;\n args.note = data.note;\n ajax.call([{\n methodname: self._methodName,\n args: args,\n done: function(evidence) {\n self._trigger('competencyupdated', {args: args, evidence: evidence});\n },\n fail: notification.exception\n }]);\n });\n }).fail(notification.exception);\n };\n\n /** @type {Number} The scale id for this competency. */\n InlineEditor.prototype._scaleId = null;\n /** @type {Number} The id of the competency. */\n InlineEditor.prototype._competencyId = null;\n /** @type {Number} The id of the user. */\n InlineEditor.prototype._userId = null;\n /** @type {Number} The id of the plan. */\n InlineEditor.prototype._planId = null;\n /** @type {Number} The id of the course. */\n InlineEditor.prototype._courseId = null;\n /** @type {String} The text for Choose rating. */\n InlineEditor.prototype._chooseStr = null;\n /** @type {GradeDialogue} The grading dialogue. */\n InlineEditor.prototype._dialogue = null;\n\n return /** @alias module:tool_lp/grade_user_competency_inline */ InlineEditor;\n\n});\n"],"file":"grade_user_competency_inline.min.js"} \ No newline at end of file +{"version":3,"sources":["../src/grade_user_competency_inline.js"],"names":["define","$","notification","ajax","log","GradeDialogue","EventBase","ScaleValues","InlineEditor","selector","scaleId","competencyId","userId","planId","courseId","chooseStr","prototype","constructor","apply","trigger","length","Error","_scaleId","_competencyId","_userId","_planId","_courseId","_chooseStr","_setUp","click","e","preventDefault","_dialogue","display","bind","_methodName","_args","competencyid","planid","courseid","userid","Object","create","options","self","promise","get_values","then","scalevalues","push","value","name","i","optionConfig","id","dialogue","on","data","args","grade","rating","note","call","methodname","done","evidence","_trigger","fail","exception"],"mappings":"AAuBAA,OAAM,wCAAC,CAAC,QAAD,CACC,mBADD,CAEC,WAFD,CAGC,UAHD,CAIC,wBAJD,CAKC,oBALD,CAMC,qBAND,CAAD,CAOC,SAASC,CAAT,CAAYC,CAAZ,CAA0BC,CAA1B,CAAgCC,CAAhC,CAAqCC,CAArC,CAAoDC,CAApD,CAA+DC,CAA/D,CAA4E,CAa/E,GAAIC,CAAAA,CAAY,CAAG,SAASC,CAAT,CAAmBC,CAAnB,CAA4BC,CAA5B,CAA0CC,CAA1C,CAAkDC,CAAlD,CAA0DC,CAA1D,CAAoEC,CAApE,CAA+E,CAC9FT,CAAS,CAACU,SAAV,CAAoBC,WAApB,CAAgCC,KAAhC,CAAsC,IAAtC,CAA4C,EAA5C,EAEA,GAAIC,CAAAA,CAAO,CAAGlB,CAAC,CAACQ,CAAD,CAAf,CACA,GAAI,CAACU,CAAO,CAACC,MAAb,CAAqB,CACjB,KAAM,IAAIC,CAAAA,KAAJ,CAAU,4BAAV,CACT,CAED,KAAKC,QAAL,CAAgBZ,CAAhB,CACA,KAAKa,aAAL,CAAqBZ,CAArB,CACA,KAAKa,OAAL,CAAeZ,CAAf,CACA,KAAKa,OAAL,CAAeZ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,CAAkC,IAAlC,CAEAd,CAAY,CAACQ,SAAb,CAAuBO,aAAvB,CAAuC,IAAvC,CAEAf,CAAY,CAACQ,SAAb,CAAuBQ,OAAvB,CAAiC,IAAjC,CAEAhB,CAAY,CAACQ,SAAb,CAAuBS,OAAvB,CAAiC,IAAjC,CAEAjB,CAAY,CAACQ,SAAb,CAAuBU,SAAvB,CAAmC,IAAnC,CAEAlB,CAAY,CAACQ,SAAb,CAAuBW,UAAvB,CAAoC,IAApC,CAEAnB,CAAY,CAACQ,SAAb,CAAuBgB,SAAvB,CAAmC,IAAnC,CAEA,MAAiExB,CAAAA,CAEpE,CAvIK,CAAN","sourcesContent":["// This file is part of Moodle - http://moodle.org/\n//\n// Moodle is free software: you can redistribute it and/or modify\n// it under the terms of the GNU General Public License as published by\n// the Free Software Foundation, either version 3 of the License, or\n// (at your option) any later version.\n//\n// Moodle is distributed in the hope that it will be useful,\n// but WITHOUT ANY WARRANTY; without even the implied warranty of\n// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the\n// GNU General Public License for more details.\n//\n// You should have received a copy of the GNU General Public License\n// along with Moodle. If not, see .\n\n/**\n * Module to enable inline editing of a comptency grade.\n *\n * @package tool_lp\n * @copyright 2015 Damyon Wiese\n * @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later\n */\n\ndefine(['jquery',\n 'core/notification',\n 'core/ajax',\n 'core/log',\n 'tool_lp/grade_dialogue',\n 'tool_lp/event_base',\n 'tool_lp/scalevalues',\n ], function($, notification, ajax, log, GradeDialogue, EventBase, ScaleValues) {\n\n /**\n * InlineEditor\n *\n * @param {String} selector The selector to trigger the grading.\n * @param {Number} scaleId The id of the scale for this competency.\n * @param {Number} competencyId The id of the competency.\n * @param {Number} userId The id of the user.\n * @param {Number} planId The id of the plan.\n * @param {Number} courseId The id of the course.\n * @param {String} chooseStr Language string for choose a rating.\n */\n var InlineEditor = function(selector, scaleId, competencyId, userId, planId, courseId, chooseStr) {\n EventBase.prototype.constructor.apply(this, []);\n\n var trigger = $(selector);\n if (!trigger.length) {\n throw new Error('Could not find the trigger');\n }\n\n this._scaleId = scaleId;\n this._competencyId = competencyId;\n this._userId = userId;\n this._planId = planId;\n this._courseId = courseId;\n this._chooseStr = chooseStr;\n this._setUp();\n\n trigger.click(function(e) {\n e.preventDefault();\n this._dialogue.display();\n }.bind(this));\n\n if (this._planId) {\n this._methodName = 'core_competency_grade_competency_in_plan';\n this._args = {\n competencyid: this._competencyId,\n planid: this._planId\n };\n } else if (this._courseId) {\n this._methodName = 'core_competency_grade_competency_in_course';\n this._args = {\n competencyid: this._competencyId,\n courseid: this._courseId,\n userid: this._userId\n };\n } else {\n this._methodName = 'core_competency_grade_competency';\n this._args = {\n userid: this._userId,\n competencyid: this._competencyId\n };\n }\n };\n InlineEditor.prototype = Object.create(EventBase.prototype);\n\n /**\n * Setup.\n *\n * @method _setUp\n */\n InlineEditor.prototype._setUp = function() {\n var options = [],\n self = this;\n\n var promise = ScaleValues.get_values(self._scaleId);\n promise.then(function(scalevalues) {\n options.push({\n value: '',\n name: self._chooseStr\n });\n\n for (var i = 0; i < scalevalues.length; i++) {\n var optionConfig = scalevalues[i];\n options.push({\n value: optionConfig.id,\n name: optionConfig.name\n });\n }\n\n return options;\n })\n .then(function(options) {\n return new GradeDialogue(options);\n })\n .then(function(dialogue) {\n dialogue.on('rated', function(e, data) {\n var args = self._args;\n args.grade = data.rating;\n args.note = data.note;\n ajax.call([{\n methodname: self._methodName,\n args: args,\n done: function(evidence) {\n self._trigger('competencyupdated', {args: args, evidence: evidence});\n },\n fail: notification.exception\n }]);\n });\n\n return dialogue;\n })\n .then(function(dialogue) {\n self._dialogue = dialogue;\n\n return;\n })\n .fail(notification.exception);\n };\n\n /** @type {Number} The scale id for this competency. */\n InlineEditor.prototype._scaleId = null;\n /** @type {Number} The id of the competency. */\n InlineEditor.prototype._competencyId = null;\n /** @type {Number} The id of the user. */\n InlineEditor.prototype._userId = null;\n /** @type {Number} The id of the plan. */\n InlineEditor.prototype._planId = null;\n /** @type {Number} The id of the course. */\n InlineEditor.prototype._courseId = null;\n /** @type {String} The text for Choose rating. */\n InlineEditor.prototype._chooseStr = null;\n /** @type {GradeDialogue} The grading dialogue. */\n InlineEditor.prototype._dialogue = null;\n\n return /** @alias module:tool_lp/grade_user_competency_inline */ InlineEditor;\n\n});\n"],"file":"grade_user_competency_inline.min.js"} \ No newline at end of file diff --git a/admin/tool/lp/amd/src/competencies.js b/admin/tool/lp/amd/src/competencies.js index e3a517677ab..82052a4b406 100644 --- a/admin/tool/lp/amd/src/competencies.js +++ b/admin/tool/lp/amd/src/competencies.js @@ -27,8 +27,9 @@ define(['jquery', 'core/templates', 'core/str', 'tool_lp/competencypicker', - 'tool_lp/dragdrop-reorder'], - function($, notification, ajax, templates, str, Picker, dragdrop) { + 'tool_lp/dragdrop-reorder', + 'core/pending'], + function($, notification, ajax, templates, str, Picker, dragdrop, Pending) { /** * Constructor @@ -117,6 +118,7 @@ define(['jquery', * Pick a competency * * @method pickCompetency + * @return {Promise} */ competencies.prototype.pickCompetency = function() { var self = this; @@ -132,6 +134,7 @@ define(['jquery', self.pickerInstance = new Picker(self.pageContextId, false, pageContextIncludes); self.pickerInstance.on('save', function(e, data) { var compIds = data.competencyIds; + var pendingPromise = new Pending(); if (self.itemtype === "course") { requests = []; @@ -181,17 +184,20 @@ define(['jquery', pagerender = 'tool_lp/plan_page'; pageregion = 'plan-page'; } - ajax.call(requests)[requests.length - 1].then(function(context) { + ajax.call(requests)[requests.length - 1] + .then(function(context) { return templates.render(pagerender, context); - }).then(function(html, js) { - $('[data-region="' + pageregion + '"]').replaceWith(html); - templates.runTemplateJS(js); + }) + .then(function(html, js) { + templates.replaceNode($('[data-region="' + pageregion + '"]'), html, js); return; - }).catch(notification.exception); + }) + .then(pendingPromise.resolve) + .catch(notification.exception); }); } - self.pickerInstance.display(); + return self.pickerInstance.display(); }; /** @@ -302,6 +308,7 @@ define(['jquery', if (localthis.itemtype == 'course') { // Course completion rule handling. $('[data-region="coursecompetenciespage"]').on('change', 'select[data-field="ruleoutcome"]', function(e) { + var pendingPromise = new Pending(); var requests = []; var pagerender = 'tool_lp/course_competencies_page'; var pageregion = 'coursecompetenciespage'; @@ -314,18 +321,24 @@ define(['jquery', args: {courseid: localthis.itemid, moduleid: 0}} ]); - requests[1].done(function(context) { - templates.render(pagerender, context).done(function(html, js) { - $('[data-region="' + pageregion + '"]').replaceWith(html); - templates.runTemplateJS(js); - }).fail(notification.exception); - }).fail(notification.exception); + requests[1].then(function(context) { + return templates.render(pagerender, context); + }) + .then(function(html, js) { + return templates.replaceNode($('[data-region="' + pageregion + '"]'), html, js); + }) + .then(pendingPromise.resolve) + .catch(notification.exception); }); } $('[data-region="actions"] button').click(function(e) { + var pendingPromise = new Pending(); e.preventDefault(); - localthis.pickCompetency(); + + localthis.pickCompetency() + .then(pendingPromise.resolve) + .catch(); }); $('[data-action="delete-competency-link"]').click(function(e) { e.preventDefault(); diff --git a/admin/tool/lp/amd/src/competencyactions.js b/admin/tool/lp/amd/src/competencyactions.js index 60c04daa6d5..78a7cd38114 100644 --- a/admin/tool/lp/amd/src/competencyactions.js +++ b/admin/tool/lp/amd/src/competencyactions.js @@ -33,8 +33,12 @@ define(['jquery', 'tool_lp/menubar', 'tool_lp/competencypicker', 'tool_lp/competency_outcomes', - 'tool_lp/competencyruleconfig'], - function($, url, templates, notification, str, ajax, dragdrop, Ariatree, Dialogue, menubar, Picker, Outcomes, RuleConfig) { + 'tool_lp/competencyruleconfig', + 'core/pending', + ], + function( + $, url, templates, notification, str, ajax, dragdrop, Ariatree, Dialogue, menubar, Picker, Outcomes, RuleConfig, Pending + ) { // Private variables and functions. /** @var {Object} treeModel - This is an object representing the nodes in the tree. */ @@ -412,6 +416,7 @@ define(['jquery', if (!pickerInstance) { pickerInstance = new Picker(pageContextId, relatedTarget.competencyframeworkid); pickerInstance.on('save', function(e, data) { + var pendingPromise = new Pending(); var compIds = data.competencyIds; var calls = []; @@ -436,7 +441,9 @@ define(['jquery', templates.runTemplateJS(js); updatedRelatedCompetencies(); return; - }).catch(notification.exception); + }) + .then(pendingPromise.resolve) + .catch(notification.exception); }); } diff --git a/admin/tool/lp/amd/src/competencypicker.js b/admin/tool/lp/amd/src/competencypicker.js index 23dce8a71ab..c3cb0b161f9 100644 --- a/admin/tool/lp/amd/src/competencypicker.js +++ b/admin/tool/lp/amd/src/competencypicker.js @@ -31,8 +31,10 @@ define(['jquery', 'core/templates', 'tool_lp/dialogue', 'core/str', - 'tool_lp/tree'], - function($, Notification, Ajax, Templates, Dialogue, Str, Tree) { + 'tool_lp/tree', + 'core/pending' + ], + function($, Notification, Ajax, Templates, Dialogue, Str, Tree, Pending) { /** * Competency picker class. @@ -157,6 +159,7 @@ define(['jquery', // Add listener for add. self._find('[data-region="competencylinktree"] [data-action="add"]').click(function(e) { e.preventDefault(); + var pendingPromise = new Pending(); if (!self._selectedCompetencies.length) { return; } @@ -168,7 +171,10 @@ define(['jquery', self._trigger('save', {competencyId: self._selectedCompetencies[0]}); } + // The dialogue here is a YUI dialogue and doesn't support Promises at all. + // However, it is typically synchronous so this shoudl suffice. self.close(); + pendingPromise.resolve(); }); // The list of selected competencies will be modified while looping (because of the listeners above). diff --git a/admin/tool/lp/amd/src/course_competency_settings.js b/admin/tool/lp/amd/src/course_competency_settings.js index ff21ade4399..fd497d2cf37 100644 --- a/admin/tool/lp/amd/src/course_competency_settings.js +++ b/admin/tool/lp/amd/src/course_competency_settings.js @@ -26,8 +26,10 @@ define(['jquery', 'tool_lp/dialogue', 'core/str', 'core/ajax', - 'core/templates'], - function($, notification, Dialogue, str, ajax, templates) { + 'core/templates', + 'core/pending' + ], + function($, notification, Dialogue, str, ajax, templates, Pending) { /** * Constructor @@ -48,6 +50,7 @@ define(['jquery', * @method configureSettings */ settingsMod.prototype.configureSettings = function(e) { + var pendingPromise = new Pending(); var courseid = $(e.target).closest('a').data('courseid'); var currentValue = $(e.target).closest('a').data('pushratingstouserplans'); var context = { @@ -56,16 +59,21 @@ define(['jquery', }; e.preventDefault(); - templates.render('tool_lp/course_competency_settings', context).done(function(html) { - str.get_string('configurecoursecompetencysettings', 'tool_lp').done(function(title) { - this._dialogue = new Dialogue( - title, - html, - this.addListeners.bind(this) - ); - }.bind(this)).fail(notification.exception); - }.bind(this)).fail(notification.exception); + $.when( + str.get_string('configurecoursecompetencysettings', 'tool_lp'), + templates.render('tool_lp/course_competency_settings', context), + ) + .then(function(title, templateResult) { + this._dialogue = new Dialogue( + title, + templateResult[0], + this.addListeners.bind(this) + ); + return this._dialogue; + }.bind(this)) + .then(pendingPromise.resolve) + .catch(notification.exception); }; /** @@ -108,6 +116,7 @@ define(['jquery', * @method saveSettings */ settingsMod.prototype.saveSettings = function(e) { + var pendingPromise = new Pending(); e.preventDefault(); var newValue = this._find('input[name="pushratingstouserplans"]:checked').val(); @@ -117,9 +126,12 @@ define(['jquery', ajax.call([ {methodname: 'core_competency_update_course_competency_settings', args: {courseid: courseId, settings: settings}} - ])[0].done(function() { - this.refreshCourseCompetenciesPage(); - }.bind(this)).fail(notification.exception); + ])[0] + .then(function() { + return this.refreshCourseCompetenciesPage(); + }.bind(this)) + .then(pendingPromise.resolve) + .catch(notification.exception); }; @@ -131,18 +143,23 @@ define(['jquery', */ settingsMod.prototype.refreshCourseCompetenciesPage = function() { var courseId = this._find('input[name="courseid"]').val(); + var pendingPromise = new Pending(); ajax.call([ {methodname: 'tool_lp_data_for_course_competencies_page', args: {courseid: courseId, moduleid: 0}} - ])[0].done(function(context) { - templates.render('tool_lp/course_competencies_page', context).done(function(html, js) { - $('[data-region="coursecompetenciespage"]').replaceWith(html); - templates.runTemplateJS(js); - this._dialogue.close(); - }.bind(this)).fail(notification.exception); - }.bind(this)).fail(notification.exception); + ])[0] + .then(function(context) { + return templates.render('tool_lp/course_competencies_page', context); + }) + .then(function(html, js) { + templates.replaceNode($('[data-region="coursecompetenciespage"]'), html, js); + this._dialogue.close(); + return; + }.bind(this)) + .then(pendingPromise.resolve) + .catch(notification.exception); }; return /** @alias module:tool_lp/configurecoursecompetencysettings */ settingsMod; diff --git a/admin/tool/lp/amd/src/grade_dialogue.js b/admin/tool/lp/amd/src/grade_dialogue.js index 576b511f3d7..80ef97c5c77 100644 --- a/admin/tool/lp/amd/src/grade_dialogue.js +++ b/admin/tool/lp/amd/src/grade_dialogue.js @@ -102,15 +102,20 @@ define(['jquery', * @return {Promise} */ Grade.prototype.display = function() { - return this._render().then(function(html) { - return Str.get_string('rate', 'tool_lp').then(function(title) { - this._popup = new Dialogue( - title, - html, - this._afterRender.bind(this) - ); - }.bind(this)); - }.bind(this)).fail(Notification.exception); + return $.when( + Str.get_string('rate', 'tool_lp'), + this._render() + ) + .then(function(title, templateResult) { + this._popup = new Dialogue( + title, + templateResult[0], + this._afterRender.bind(this) + ); + + return this._popup; + }.bind(this)) + .catch(Notification.exception); }; /** diff --git a/admin/tool/lp/amd/src/grade_user_competency_inline.js b/admin/tool/lp/amd/src/grade_user_competency_inline.js index 7a030b6be4b..81e4f3577c0 100644 --- a/admin/tool/lp/amd/src/grade_user_competency_inline.js +++ b/admin/tool/lp/amd/src/grade_user_competency_inline.js @@ -95,7 +95,7 @@ define(['jquery', self = this; var promise = ScaleValues.get_values(self._scaleId); - promise.done(function(scalevalues) { + promise.then(function(scalevalues) { options.push({ value: '', name: self._chooseStr @@ -109,8 +109,13 @@ define(['jquery', }); } - self._dialogue = new GradeDialogue(options); - self._dialogue.on('rated', function(e, data) { + return options; + }) + .then(function(options) { + return new GradeDialogue(options); + }) + .then(function(dialogue) { + dialogue.on('rated', function(e, data) { var args = self._args; args.grade = data.rating; args.note = data.note; @@ -123,7 +128,15 @@ define(['jquery', fail: notification.exception }]); }); - }).fail(notification.exception); + + return dialogue; + }) + .then(function(dialogue) { + self._dialogue = dialogue; + + return; + }) + .fail(notification.exception); }; /** @type {Number} The scale id for this competency. */