Current Path : C:/xampp/htdocs/moodle/admin/tool/lp/amd/build/ |
Current File : C:/xampp/htdocs/moodle/admin/tool/lp/amd/build/competency_rule_points.min.js |
define ("tool_lp/competency_rule_points",["jquery","core/str","core/templates","tool_lp/competency_rule"],function(a,b,c,d){var e=function(){d.apply(this,arguments)};e.prototype=Object.create(d.prototype);e.prototype._container=null;e.prototype._templateLoaded=!1;e.prototype.getConfig=function(){return JSON.stringify({base:{points:this._getRequiredPoints()},competencies:this._getCompetenciesConfig()})};e.prototype._getCompetenciesConfig=function(){var b=[];this._container.find("[data-competency]").each(function(){var c=a(this),d=c.data("competency"),e=parseInt(c.find("[name=\"points\"]").val(),10),f=c.find("[name=\"required\"]").prop("checked");b.push({id:d,points:e,required:f?1:0})});return b};e.prototype._getRequiredPoints=function(){return parseInt(this._container.find("[name=\"requiredpoints\"]").val()||1,10)};e.prototype.getType=function(){return"core_competency\\competency_rule_points"};e.prototype.injectTemplate=function(b){var d=this,e=this._tree.getChildren(this._competency.id),f,g={base:{points:2},competencies:[]};this._templateLoaded=!1;if(d._competency.ruletype==d.getType()){try{g=JSON.parse(d._competency.ruleconfig)}catch(a){}}f={requiredpoints:g&&g.base?g.base.points:2,competency:d._competency,children:[]};a.each(e,function(b,c){var d={id:c.id,shortname:c.shortname,required:!1,points:0};if(g){a.each(g.competencies,function(a,b){if(b.id==d.id){d.required=b.required?!0:!1;d.points=b.points}})}f.children.push(d)});return c.render("tool_lp/competency_rule_points",f).then(function(a){d._container=b;b.html(a);b.find("input").change(function(){d._triggerChange()});d._templateLoaded=!0;d._triggerChange()})};e.prototype.isValid=function(){if(!this._templateLoaded){return!1}var b=this._getRequiredPoints(),c=0,d=!0;a.each(this._getCompetenciesConfig(),function(a,b){if(0>b.points){d=!1}c+=b.points});d=d&&c>=b;return d};return e}); //# sourceMappingURL=competency_rule_points.min.js.map