Proyectos de Subversion Moodle

Rev

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

{"version":3,"file":"grade_user_competency_inline.min.js","sources":["../src/grade_user_competency_inline.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     tool_lp/grade_user_competency_inline\n * @copyright  2015 Damyon Wiese\n * @license    http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later\n */\n\ndefine(['jquery',\n        'core/notification',\n        'core/ajax',\n        'core/log',\n        'tool_lp/grade_dialogue',\n        'tool_lp/event_base',\n        'tool_lp/scalevalues',\n    ], function($, notification, ajax, log, GradeDialogue, EventBase, ScaleValues) {\n\n    /**\n     * InlineEditor\n     *\n     * @class tool_lp/grade_user_competency_inline\n     * @param {String} selector The selector to trigger the grading.\n     * @param {Number} scaleId The id of the scale for this competency.\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 {String} chooseStr Language string for choose a rating.\n     */\n    var InlineEditor = function(selector, scaleId, competencyId, userId, planId, courseId, chooseStr) {\n        EventBase.prototype.constructor.apply(this, []);\n\n        var trigger = $(selector);\n        if (!trigger.length) {\n            throw new Error('Could not find the trigger');\n        }\n\n        this._scaleId = scaleId;\n        this._competencyId = competencyId;\n        this._userId = userId;\n        this._planId = planId;\n        this._courseId = courseId;\n        this._chooseStr = chooseStr;\n        this._setUp();\n\n        trigger.click(function(e) {\n            e.preventDefault();\n            this._dialogue.display();\n        }.bind(this));\n\n        if (this._planId) {\n            this._methodName = 'core_competency_grade_competency_in_plan';\n            this._args = {\n                competencyid: this._competencyId,\n                planid: this._planId\n            };\n        } else if (this._courseId) {\n            this._methodName = 'core_competency_grade_competency_in_course';\n            this._args = {\n                competencyid: this._competencyId,\n                courseid: this._courseId,\n                userid: this._userId\n            };\n        } else {\n            this._methodName = 'core_competency_grade_competency';\n            this._args = {\n                userid: this._userId,\n                competencyid: this._competencyId\n            };\n        }\n    };\n    InlineEditor.prototype = Object.create(EventBase.prototype);\n\n    /**\n     * Setup.\n     *\n     * @method _setUp\n     */\n    InlineEditor.prototype._setUp = function() {\n        var options = [],\n            self = this;\n\n        M.util.js_pending('tool_lp/grade_user_competency_inline:_setUp');\n        var promise = ScaleValues.get_values(self._scaleId);\n        promise.then(function(scalevalues) {\n            options.push({\n                value: '',\n                name: self._chooseStr\n            });\n\n            for (var i = 0; i < scalevalues.length; i++) {\n                var optionConfig = scalevalues[i];\n                options.push({\n                    value: optionConfig.id,\n                    name: optionConfig.name\n                });\n            }\n\n            return options;\n        })\n        .then(function(options) {\n            return new GradeDialogue(options);\n        })\n        .then(function(dialogue) {\n            dialogue.on('rated', function(e, data) {\n                var args = self._args;\n                args.grade = data.rating;\n                args.note = data.note;\n                ajax.call([{\n                    methodname: self._methodName,\n                    args: args,\n                    done: function(evidence) {\n                        self._trigger('competencyupdated', {args: args, evidence: evidence});\n                    },\n                    fail: notification.exception\n                }]);\n            });\n\n            return dialogue;\n        })\n        .then(function(dialogue) {\n            self._dialogue = dialogue;\n\n            M.util.js_complete('tool_lp/grade_user_competency_inline:_setUp');\n            return;\n        })\n        .fail(notification.exception);\n    };\n\n    /** @property {Number} The scale id for this competency. */\n    InlineEditor.prototype._scaleId = null;\n    /** @property {Number} The id of the competency. */\n    InlineEditor.prototype._competencyId = null;\n    /** @property {Number} The id of the user. */\n    InlineEditor.prototype._userId = null;\n    /** @property {Number} The id of the plan. */\n    InlineEditor.prototype._planId = null;\n    /** @property {Number} The id of the course. */\n    InlineEditor.prototype._courseId = null;\n    /** @property {String} The text for Choose rating. */\n    InlineEditor.prototype._chooseStr = null;\n    /** @property {GradeDialogue} The grading dialogue. */\n    InlineEditor.prototype._dialogue = null;\n\n    return InlineEditor;\n});\n"],"names":["define","$","notification","ajax","log","GradeDialogue","EventBase","ScaleValues","InlineEditor","selector","scaleId","competencyId","userId","planId","courseId","chooseStr","prototype","constructor","apply","this","trigger","length","Error","_scaleId","_competencyId","_userId","_planId","_courseId","_chooseStr","_setUp","click","e","preventDefault","_dialogue","display","bind","_methodName","_args","competencyid","planid","courseid","userid","Object","create","options","self","M","util","js_pending","get_values","then","scalevalues","push","value","name","i","optionConfig","id","dialogue","on","data","args","grade","rating","note","call","methodname","done","evidence","_trigger","fail","exception","js_complete"],"mappings":";;;;;;;AAuBAA,8CAAO,CAAC,SACA,oBACA,YACA,WACA,yBACA,qBACA,wBACD,SAASC,EAAGC,aAAcC,KAAMC,IAAKC,cAAeC,UAAWC,iBAc9DC,aAAe,SAASC,SAAUC,QAASC,aAAcC,OAAQC,OAAQC,SAAUC,WACnFT,UAAUU,UAAUC,YAAYC,MAAMC,KAAM,QAExCC,QAAUnB,EAAEQ,cACXW,QAAQC,aACH,IAAIC,MAAM,mCAGfC,SAAWb,aACXc,cAAgBb,kBAChBc,QAAUb,YACVc,QAAUb,YACVc,UAAYb,cACZc,WAAab,eACbc,SAELT,QAAQU,MAAM,SAASC,GACnBA,EAAEC,sBACGC,UAAUC,WACjBC,KAAKhB,OAEHA,KAAKO,cACAU,YAAc,gDACdC,MAAQ,CACTC,aAAcnB,KAAKK,cACnBe,OAAQpB,KAAKO,UAEVP,KAAKQ,gBACPS,YAAc,kDACdC,MAAQ,CACTC,aAAcnB,KAAKK,cACnBgB,SAAUrB,KAAKQ,UACfc,OAAQtB,KAAKM,gBAGZW,YAAc,wCACdC,MAAQ,CACTI,OAAQtB,KAAKM,QACba,aAAcnB,KAAKK,wBAI/BhB,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