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/competency_rule_points.min.js.map

{"version":3,"sources":["../src/competency_rule_points.js"],"names":["define","$","Str","Templates","RuleBase","Rule","apply","arguments","prototype","Object","create","_container","_templateLoaded","getConfig","JSON","stringify","base","points","_getRequiredPoints","competencies","_getCompetenciesConfig","find","each","node","id","data","parseInt","val","required","prop","push","getType","injectTemplate","container","self","children","_tree","getChildren","_competency","context","config","ruletype","parse","ruleconfig","e","requiredpoints","competency","index","child","shortname","comp","render","then","html","change","_triggerChange","isValid","max","valid"],"mappings":"AAuBAA,OAAM,kCAAC,CAAC,QAAD,CACC,UADD,CAEC,gBAFD,CAGC,yBAHD,CAAD,CAKE,SAASC,CAAT,CAAYC,CAAZ,CAAiBC,CAAjB,CAA4BC,CAA5B,CAAsC,CAK1C,GAAIC,CAAAA,CAAI,CAAG,UAAW,CAClBD,CAAQ,CAACE,KAAT,CAAe,IAAf,CAAqBC,SAArB,CACH,CAFD,CAGAF,CAAI,CAACG,SAAL,CAAiBC,MAAM,CAACC,MAAP,CAAcN,CAAQ,CAACI,SAAvB,CAAjB,CAGAH,CAAI,CAACG,SAAL,CAAeG,UAAf,CAA4B,IAA5B,CAEAN,CAAI,CAACG,SAAL,CAAeI,eAAf,IAQAP,CAAI,CAACG,SAAL,CAAeK,SAAf,CAA2B,UAAW,CAClC,MAAOC,CAAAA,IAAI,CAACC,SAAL,CAAe,CAClBC,IAAI,CAAE,CACFC,MAAM,CAAE,KAAKC,kBAAL,EADN,CADY,CAIlBC,YAAY,CAAE,KAAKC,sBAAL,EAJI,CAAf,CAMV,CAPD,CAgBAf,CAAI,CAACG,SAAL,CAAeY,sBAAf,CAAwC,UAAW,CAC/C,GAAID,CAAAA,CAAY,CAAG,EAAnB,CAEA,KAAKR,UAAL,CAAgBU,IAAhB,CAAqB,mBAArB,EAA0CC,IAA1C,CAA+C,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,CAACqB,cAAL,EACH,CAFD,EAKArB,CAAI,CAACtB,eAAL,IACAsB,CAAI,CAACqB,cAAL,EAEH,CAXM,CAYV,CA1DD,CAkEAlD,CAAI,CAACG,SAAL,CAAegD,OAAf,CAAyB,UAAW,CAChC,GAAI,CAAC,KAAK5C,eAAV,CAA2B,CACvB,QACH,CAED,GAAIgB,CAAAA,CAAQ,CAAG,KAAKV,kBAAL,EAAf,CACIuC,CAAG,CAAG,CADV,CAEIC,CAAK,GAFT,CAIAzD,CAAC,CAACqB,IAAF,CAAO,KAAKF,sBAAL,EAAP,CAAsC,SAAS2B,CAAT,CAAgBD,CAAhB,CAA4B,CAC9D,GAAwB,CAApB,CAAAA,CAAU,CAAC7B,MAAf,CAA2B,CACvByC,CAAK,GACR,CACDD,CAAG,EAAIX,CAAU,CAAC7B,MACrB,CALD,EAOAyC,CAAK,CAAGA,CAAK,EAAID,CAAG,EAAI7B,CAAxB,CACA,MAAO8B,CAAAA,CACV,CAlBD,CAoBA,MAAwDrD,CAAAA,CAE3D,CAjLK,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 <http://www.gnu.org/licenses/>.\n\n/**\n * Competency rule points module.\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/str',\n        'core/templates',\n        'tool_lp/competency_rule',\n        ],\n        function($, Str, Templates, RuleBase) {\n\n    /**\n     * Competency rule points class.\n     */\n    var Rule = function() {\n        RuleBase.apply(this, arguments);\n    };\n    Rule.prototype = Object.create(RuleBase.prototype);\n\n    /** @type {Node} Reference to the container in which the template was included. */\n    Rule.prototype._container = null;\n    /** @type {Boolean} Whether or not the template was included. */\n    Rule.prototype._templateLoaded = false;\n\n    /**\n     * The config established by this rule.\n     *\n     * @return {String}\n     * @method getConfig\n     */\n    Rule.prototype.getConfig = function() {\n        return JSON.stringify({\n            base: {\n                points: this._getRequiredPoints(),\n            },\n            competencies: this._getCompetenciesConfig()\n        });\n    };\n\n    /**\n     * Gathers the input provided by the user for competencies.\n     *\n     * @return {Array} Containing id, points and required.\n     * @method _getCompetenciesConfig\n     * @protected\n     */\n    Rule.prototype._getCompetenciesConfig = function() {\n        var competencies = [];\n\n        this._container.find('[data-competency]').each(function() {\n            var node = $(this),\n                id = node.data('competency'),\n                points = parseInt(node.find('[name=\"points\"]').val(), 10),\n                required = node.find('[name=\"required\"]').prop('checked');\n\n            competencies.push({\n                id: id,\n                points: points,\n                required: required ? 1 : 0\n            });\n        });\n\n        return competencies;\n    };\n\n    /**\n     * Fetches the required points set by the user.\n     *\n     * @return {Number}\n     * @method _getRequiredPoints\n     * @protected\n     */\n    Rule.prototype._getRequiredPoints = function() {\n        return parseInt(this._container.find('[name=\"requiredpoints\"]').val() || 1, 10);\n    };\n\n    /**\n     * Return the type of the module.\n     *\n     * @return {String}\n     * @method getType\n     */\n    Rule.prototype.getType = function() {\n        return 'core_competency\\\\competency_rule_points';\n    };\n\n    /**\n     * Callback to inject the template.\n     *\n     * @param  {Node} container Node to inject in.\n     * @return {Promise} Resolved when done.\n     * @method injectTemplate\n     */\n    Rule.prototype.injectTemplate = function(container) {\n        var self = this,\n            children = this._tree.getChildren(this._competency.id),\n            context,\n            config = {\n                base: {points: 2},\n                competencies: []\n            };\n\n        this._templateLoaded = false;\n\n        // Only pre-load the configuration when the competency is using this rule.\n        if (self._competency.ruletype == self.getType()) {\n            try {\n                config = JSON.parse(self._competency.ruleconfig);\n            } catch (e) {\n                // eslint-disable-line no-empty\n            }\n        }\n\n        context = {\n            requiredpoints: (config && config.base) ? config.base.points : 2,\n            competency: self._competency,\n            children: []\n        };\n\n        $.each(children, function(index, child) {\n            var competency = {\n                id: child.id,\n                shortname: child.shortname,\n                required: false,\n                points: 0\n            };\n\n            if (config) {\n                $.each(config.competencies, function(index, comp) {\n                    if (comp.id == competency.id) {\n                        competency.required = comp.required ? true : false;\n                        competency.points = comp.points;\n                    }\n                });\n            }\n\n            context.children.push(competency);\n        });\n\n        return Templates.render('tool_lp/competency_rule_points', context).then(function(html) {\n            self._container = container;\n            container.html(html);\n            container.find('input').change(function() {\n                self._triggerChange();\n            });\n\n            // We're done, let's trigger a change.\n            self._templateLoaded = true;\n            self._triggerChange();\n            return;\n        });\n    };\n\n    /**\n     * Whether or not the current config is valid.\n     *\n     * @return {Boolean}\n     * @method isValid\n     */\n    Rule.prototype.isValid = function() {\n        if (!this._templateLoaded) {\n            return false;\n        }\n\n        var required = this._getRequiredPoints(),\n            max = 0,\n            valid = true;\n\n        $.each(this._getCompetenciesConfig(), function(index, competency) {\n            if (competency.points < 0) {\n                valid = false;\n            }\n            max += competency.points;\n        });\n\n        valid = valid && max >= required;\n        return valid;\n    };\n\n    return /** @alias module:tool_lp/competency_rule_all */ Rule;\n\n});\n"],"file":"competency_rule_points.min.js"}