Your IP : 192.168.165.1


Current Path : C:/xampp/htdocs/moodle/admin/tool/lp/amd/build/
Upload File :
Current File : C:/xampp/htdocs/moodle/admin/tool/lp/amd/build/competencies.min.js

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