1 |
efrain |
1 |
{"version":3,"file":"grading_popup.min.js","sources":["../src/grading_popup.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 enable inline editing of a comptency grade.\n *\n * @module report_competency/grading_popup\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/str', 'core/ajax', 'core/log', 'core/templates', 'tool_lp/dialogue'],\n function($, notification, str, ajax, log, templates, Dialogue) {\n\n /**\n * GradingPopup\n *\n * @class report_competency/grading_popup\n * @param {String} regionSelector The regionSelector\n * @param {String} userCompetencySelector The userCompetencySelector\n */\n var GradingPopup = function(regionSelector, userCompetencySelector) {\n this._regionSelector = regionSelector;\n this._userCompetencySelector = userCompetencySelector;\n\n $(this._regionSelector).on('click', this._userCompetencySelector, this._handleClick.bind(this));\n };\n\n /**\n * Get the data from the clicked cell and open the popup.\n *\n * @method _handleClick\n * @param {Event} e The event\n */\n GradingPopup.prototype._handleClick = function(e) {\n var cell = $(e.target).closest(this._userCompetencySelector);\n var competencyId = $(cell).data('competencyid');\n var courseId = $(cell).data('courseid');\n var userId = $(cell).data('userid');\n\n log.debug('Clicked on cell: competencyId=' + competencyId + ', courseId=' + courseId + ', userId=' + userId);\n\n var requests = ajax.call([{\n methodname: 'tool_lp_data_for_user_competency_summary_in_course',\n args: {userid: userId, competencyid: competencyId, courseid: courseId},\n }, {\n methodname: 'core_competency_user_competency_viewed_in_course',\n args: {userid: userId, competencyid: competencyId, courseid: courseId},\n }]);\n\n $.when(requests[0], requests[1])\n .then(this._contextLoaded.bind(this))\n .catch(notification.exception);\n };\n\n /**\n * We loaded the context, now render the template.\n *\n * @method _contextLoaded\n * @param {Object} context\n * @returns {Promise}\n */\n GradingPopup.prototype._contextLoaded = function(context) {\n // We have to display user info in popup.\n context.displayuser = true;\n\n M.util.js_pending('report_competency/grading_popup:_contextLoaded');\n\n return $.when(\n str.get_string('usercompetencysummary', 'report_competency'),\n templates.render('tool_lp/user_competency_summary_in_course', context)\n )\n .then(function(title, templateData) {\n return new Dialogue(\n title,\n templateData[0],\n function() {\n templates.runTemplateJS(templateData[1]);\n M.util.js_complete('report_competency/grading_popup:_contextLoaded');\n },\n this._refresh.bind(this),\n true\n );\n }.bind(this));\n };\n\n /**\n * Refresh the page.\n *\n * @method _refresh\n * @returns {Promise}\n */\n GradingPopup.prototype._refresh = function() {\n var region = $(this._regionSelector);\n var courseId = region.data('courseid');\n var moduleId = region.data('moduleid');\n var userId = region.data('userid');\n\n // The module id is expected to be an integer, so don't pass empty string.\n if (moduleId === '') {\n moduleId = 0;\n }\n\n return ajax.call([{\n methodname: 'report_competency_data_for_report',\n args: {courseid: courseId, userid: userId, moduleid: moduleId},\n done: this._pageContextLoaded.bind(this),\n fail: notification.exception\n }]);\n };\n\n /**\n * We loaded the context, now render the template.\n *\n * @method _pageContextLoaded\n * @param {Object} context\n */\n GradingPopup.prototype._pageContextLoaded = function(context) {\n templates.render('report_competency/report', context)\n .then(function(html, js) {\n templates.replaceNode(this._regionSelector, html, js);\n\n return;\n }.bind(this))\n .catch(notification.exception);\n };\n\n /** @property {String} The selector for the region with the user competencies */\n GradingPopup.prototype._regionSelector = null;\n /** @property {String} The selector for the region with a single user competencies */\n GradingPopup.prototype._userCompetencySelector = null;\n\n return GradingPopup;\n});\n"],"names":["define","$","notification","str","ajax","log","templates","Dialogue","GradingPopup","regionSelector","userCompetencySelector","_regionSelector","_userCompetencySelector","this","on","_handleClick","bind","prototype","e","cell","target","closest","competencyId","data","courseId","userId","debug","requests","call","methodname","args","userid","competencyid","courseid","when","then","_contextLoaded","catch","exception","context","displayuser","M","util","js_pending","get_string","render","title","templateData","runTemplateJS","js_complete","_refresh","region","moduleId","moduleid","done","_pageContextLoaded","fail","html","js","replaceNode"],"mappings":";;;;;;;AAuBAA,yCAAO,CAAC,SAAU,oBAAqB,WAAY,YAAa,WAAY,iBAAkB,qBACvF,SAASC,EAAGC,aAAcC,IAAKC,KAAMC,IAAKC,UAAWC,cASpDC,aAAe,SAASC,eAAgBC,6BACnCC,gBAAkBF,oBAClBG,wBAA0BF,uBAE/BT,EAAEY,KAAKF,iBAAiBG,GAAG,QAASD,KAAKD,wBAAyBC,KAAKE,aAAaC,KAAKH,eAS7FL,aAAaS,UAAUF,aAAe,SAASG,OACvCC,KAAOlB,EAAEiB,EAAEE,QAAQC,QAAQR,KAAKD,yBAChCU,aAAerB,EAAEkB,MAAMI,KAAK,gBAC5BC,SAAWvB,EAAEkB,MAAMI,KAAK,YACxBE,OAASxB,EAAEkB,MAAMI,KAAK,UAE1BlB,IAAIqB,MAAM,iCAAmCJ,aAAe,cAAgBE,SAAW,YAAcC,YAEjGE,SAAWvB,KAAKwB,KAAK,CAAC,CACtBC,WAAY,qDACZC,KAAM,CAACC,OAAQN,OAAQO,aAAcV,aAAcW,SAAUT,WAC9D,CACCK,WAAY,mDACZC,KAAM,CAACC,OAAQN,OAAQO,aAAcV,aAAcW,SAAUT,aAGjEvB,EAAEiC,KAAKP,SAAS,GAAIA,SAAS,IAC5BQ,KAAKtB,KAAKuB,eAAepB,KAAKH,OAC9BwB,MAAMnC,aAAaoC,YAUxB9B,aAAaS,UAAUmB,eAAiB,SAASG,gBAE7CA,QAAQC,aAAc,EAEtBC,EAAEC,KAAKC,WAAW,kDAEX1C,EAAEiC,KACL/B,IAAIyC,WAAW,wBAAyB,qBACxCtC,UAAUuC,OAAO,4CAA6CN,UAEjEJ,KAAK,SAASW,MAAOC,qBACX,I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