Proyectos de Subversion Moodle

Rev

Autoría | Ultima modificación | Ver Log |

{"version":3,"file":"user_competency_info.min.js","sources":["../src/user_competency_info.js"],"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 * Module to refresh a user competency summary in a page.\n *\n * @module     tool_lp/user_competency_info\n * @copyright  2015 Damyon Wiese\n * @license    http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later\n */\n\ndefine(['jquery', 'core/notification', 'core/ajax', 'core/templates'], function($, notification, ajax, templates) {\n\n    /**\n     * Info\n     *\n     * @param {JQuery} rootElement Selector to replace when the information needs updating.\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 {Boolean} displayuser If we should display the user info.\n     */\n    var Info = function(rootElement, competencyId, userId, planId, courseId, displayuser) {\n        this._rootElement = rootElement;\n        this._competencyId = competencyId;\n        this._userId = userId;\n        this._planId = planId;\n        this._courseId = courseId;\n        this._valid = true;\n        this._displayuser = (typeof displayuser !== 'undefined') ? displayuser : false;\n\n        if (this._planId) {\n            this._methodName = 'tool_lp_data_for_user_competency_summary_in_plan';\n            this._args = {competencyid: this._competencyId, planid: this._planId};\n            this._templateName = 'tool_lp/user_competency_summary_in_plan';\n        } else if (this._courseId) {\n            this._methodName = 'tool_lp_data_for_user_competency_summary_in_course';\n            this._args = {userid: this._userId, competencyid: this._competencyId, courseid: this._courseId};\n            this._templateName = 'tool_lp/user_competency_summary_in_course';\n        } else {\n            this._methodName = 'tool_lp_data_for_user_competency_summary';\n            this._args = {userid: this._userId, competencyid: this._competencyId};\n            this._templateName = 'tool_lp/user_competency_summary';\n        }\n    };\n\n    /**\n     * Reload the info for this user competency.\n     *\n     * @method reload\n     */\n    Info.prototype.reload = function() {\n        var self = this,\n            promises = [];\n\n        if (!this._valid) {\n            return;\n        }\n\n        promises = ajax.call([{\n            methodname: this._methodName,\n            args: this._args\n        }]);\n\n        promises[0].done(function(context) {\n            // Check if we should also the user info.\n            if (self._displayuser) {\n                context.displayuser = true;\n            }\n            templates.render(self._templateName, context).done(function(html, js) {\n                templates.replaceNode(self._rootElement, html, js);\n            }).fail(notification.exception);\n        }).fail(notification.exception);\n    };\n\n    /** @property {JQuery} The root element to replace in the DOM. */\n    Info.prototype._rootElement = null;\n    /** @property {Number} The id of the course. */\n    Info.prototype._courseId = null;\n    /** @property {Boolean} Is this module valid? */\n    Info.prototype._valid = null;\n    /** @property {Number} The id of the plan. */\n    Info.prototype._planId = null;\n    /** @property {Number} The id of the competency. */\n    Info.prototype._competencyId = null;\n    /** @property {Number} The id of the user. */\n    Info.prototype._userId = null;\n    /** @property {String} The method name to load the data. */\n    Info.prototype._methodName = null;\n    /** @property {Object} The arguments to load the data. */\n    Info.prototype._args = null;\n    /** @property {String} The template to reload the fragment. */\n    Info.prototype._templateName = null;\n    /** @property {Boolean} If we should display the user info? */\n    Info.prototype._displayuser = false;\n\n    return /** @alias module:tool_lp/user_competency_info */ Info;\n\n});\n"],"names":["define","$","notification","ajax","templates","Info","rootElement","competencyId","userId","planId","courseId","displayuser","_rootElement","_competencyId","_userId","_planId","_courseId","_valid","_displayuser","this","_methodName","_args","competencyid","planid","_templateName","userid","courseid","prototype","reload","self","call","methodname","args","done","context","render","html","js","replaceNode","fail","exception"],"mappings":";;;;;;;AAuBAA,sCAAO,CAAC,SAAU,oBAAqB,YAAa,mBAAmB,SAASC,EAAGC,aAAcC,KAAMC,eAY/FC,KAAO,SAASC,YAAaC,aAAc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