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.map

{"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,CAAT,CAAiBC,CAAjB,CAA2BC,CAA3B,CAAsC,CACrD,KAAKF,MAAL,CAAcA,CAAd,CACA,KAAKC,QAAL,CAAgBA,CAAhB,CACA,KAAKE,aAAL,CAAqBD,CAArB,CACA,KAAKE,cAAL,CAAsB,IAAtB,CAEAb,CAAC,CAAC,kCAAD,CAAD,CAAoCc,IAApC,CAAyC,UAAzC,KACA,KAAKC,cAAL,GACA,KAAKC,gBAAL,EACH,CATD,CAeAR,CAAY,CAACS,SAAb,CAAuBD,gBAAvB,CAA0C,UAAW,CAC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CD,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 <http://www.gnu.org/licenses/>.\n\n/**\n * Handle add/remove competency links.\n *\n * @module     tool_lp/competencies\n * @package    tool_lp\n * @copyright  2015 Damyon Wiese <damyon@moodle.com>\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"}