MDL-52754 tool_lp: Dropdown list of scales with single quotes in values
This commit is contained in:
committed by
Frederic Massart
parent
d54c4f8b73
commit
c7484fcc35
@@ -1 +1 @@
|
||||
define(["jquery","core/notification","core/ajax","core/log","tool_lp/grade_dialogue","tool_lp/event_base"],function(a,b,c,d,e,f){var g=function(b,c,d,e,g,h,i,j,k){f.prototype.constructor.apply(this,[]);var l=a(b);if(!l.length)throw new Error("Could not find the trigger");this._scaleConfig=c,this._competencyId=d,this._userId=e,this._planId=g,this._courseId=h,this._chooseStr=i,this._canGrade=j,this._canSuggest=k,this._setUp(),l.click(function(a){a.preventDefault(),this._dialogue.display()}.bind(this)),this._planId?(this._methodName="tool_lp_grade_competency_in_plan",this._args={competencyid:this._competencyId,planid:this._planId}):this._courseId?(this._methodName="tool_lp_grade_competency_in_course",this._args={competencyid:this._competencyId,courseid:this._courseId,userid:this._userId}):(this._methodName="tool_lp_grade_competency",this._args={userid:this._userId,competencyid:this._competencyId})};return g.prototype=Object.create(f.prototype),g.prototype._setUp=function(){var a=[],d=this;a.push({value:"",name:this._chooseStr});for(var f=1;f<this._scaleConfig.length;f++){var g=this._scaleConfig[f];a.push({value:g.id,name:g.name})}this._dialogue=new e(a,this._canGrade,this._canSuggest),this._dialogue.on("rated",function(a,e){var f=this._args;f.grade=e.rating,f.note=e.note,f.override=!0,c.call([{methodname:this._methodName,args:f,done:function(a){this._trigger("competencyupdated",{args:f,evidence:a})}.bind(d),fail:b.exception}])}.bind(this)),this._dialogue.on("suggested",function(a,e){var f=this._args;f.grade=e.rating,f.note=e.note,f.override=!1,c.call([{methodname:this._methodName,args:f,done:function(a){this._trigger("competencyupdated",{args:f,evidence:a})}.bind(d),fail:b.exception}])}.bind(this))},g.prototype._scaleConfig=null,g.prototype._competencyId=null,g.prototype._userId=null,g.prototype._planId=null,g.prototype._courseId=null,g.prototype._dialogue=null,g.prototype._canGrade=null,g.prototype._canSuggest=null,g});
|
||||
define(["jquery","core/notification","core/ajax","core/log","tool_lp/grade_dialogue","tool_lp/event_base","tool_lp/scalevalues"],function(a,b,c,d,e,f,g){var h=function(b,c,d,e,g,h,i,j,k){f.prototype.constructor.apply(this,[]);var l=a(b);if(!l.length)throw new Error("Could not find the trigger");this._scaleId=c,this._competencyId=d,this._userId=e,this._planId=g,this._courseId=h,this._chooseStr=i,this._canGrade=j,this._canSuggest=k,this._setUp(),l.click(function(a){a.preventDefault(),this._dialogue.display()}.bind(this)),this._planId?(this._methodName="tool_lp_grade_competency_in_plan",this._args={competencyid:this._competencyId,planid:this._planId}):this._courseId?(this._methodName="tool_lp_grade_competency_in_course",this._args={competencyid:this._competencyId,courseid:this._courseId,userid:this._userId}):(this._methodName="tool_lp_grade_competency",this._args={userid:this._userId,competencyid:this._competencyId})};return h.prototype=Object.create(f.prototype),h.prototype._setUp=function(){var a=[],d=this;window.alert("setup");var f=g.get_values(d._scaleId);f.done(function(f){a.push({value:"",name:d._chooseStr});for(var g=0;g<f.length;g++){var h=f[g];a.push({value:h.id,name:h.name})}d._dialogue=new e(a,d._canGrade,d._canSuggest),d._dialogue.on("rated",function(a,e){var f=d._args;f.grade=e.rating,f.note=e.note,f.override=!0,c.call([{methodname:d._methodName,args:f,done:function(a){d._trigger("competencyupdated",{args:f,evidence:a})}.bind(d),fail:b.exception}])}.bind(d)),d._dialogue.on("suggested",function(a,e){var f=d._args;f.grade=e.rating,f.note=e.note,f.override=!1,c.call([{methodname:d._methodName,args:f,done:function(a){d._trigger("competencyupdated",{args:f,evidence:a})}.bind(d),fail:b.exception}])}.bind(d))}).fail(b.exception)},h.prototype._scaleId=null,h.prototype._competencyId=null,h.prototype._userId=null,h.prototype._planId=null,h.prototype._courseId=null,h.prototype._chooseStr=null,h.prototype._dialogue=null,h.prototype._canGrade=null,h.prototype._canSuggest=null,h});
|
||||
+1
@@ -0,0 +1 @@
|
||||
define(["jquery","core/ajax"],function(a,b){var c=[];return{get_values:function(d){var e=a.Deferred();return c[d]?(window.alert("cached"),e.resolve(c[d])):(window.alert("not cached"),b.call([{methodname:"tool_lp_get_scale_values",args:{scaleid:d},done:function(a){c[d]=a,e.resolve(a)},fail:e.reject}])),e.promise()}}});
|
||||
@@ -27,13 +27,14 @@ define(['jquery',
|
||||
'core/log',
|
||||
'tool_lp/grade_dialogue',
|
||||
'tool_lp/event_base',
|
||||
], function($, notification, ajax, log, GradeDialogue, EventBase) {
|
||||
'tool_lp/scalevalues',
|
||||
], function($, notification, ajax, log, GradeDialogue, EventBase, ScaleValues) {
|
||||
|
||||
/**
|
||||
* InlineEditor
|
||||
*
|
||||
* @param {String} selector The selector to trigger the grading.
|
||||
* @param {Object} The scale config for this competency.
|
||||
* @param {Number} The id of the scale for this competency.
|
||||
* @param {Number} The id of the competency.
|
||||
* @param {Number} The id of the user.
|
||||
* @param {Number} The id of the plan.
|
||||
@@ -42,7 +43,7 @@ define(['jquery',
|
||||
* @param {Boolean} canGrade Whether the user can grade.
|
||||
* @param {Boolean} canSuggest Whether the user can suggest.
|
||||
*/
|
||||
var InlineEditor = function(selector, scaleConfig, competencyId, userId, planId, courseId, chooseStr, canGrade, canSuggest) {
|
||||
var InlineEditor = function(selector, scaleId, competencyId, userId, planId, courseId, chooseStr, canGrade, canSuggest) {
|
||||
EventBase.prototype.constructor.apply(this, []);
|
||||
|
||||
var trigger = $(selector);
|
||||
@@ -50,7 +51,7 @@ define(['jquery',
|
||||
throw new Error('Could not find the trigger');
|
||||
}
|
||||
|
||||
this._scaleConfig = scaleConfig;
|
||||
this._scaleId = scaleId;
|
||||
this._competencyId = competencyId;
|
||||
this._userId = userId;
|
||||
this._planId = planId;
|
||||
@@ -97,52 +98,55 @@ define(['jquery',
|
||||
var options = [],
|
||||
self = this;
|
||||
|
||||
options.push({
|
||||
value: '',
|
||||
name: this._chooseStr
|
||||
});
|
||||
|
||||
for (var i = 1; i < this._scaleConfig.length; i++) {
|
||||
var optionConfig = this._scaleConfig[i];
|
||||
var promise = ScaleValues.get_values(self._scaleId);
|
||||
promise.done(function(scalevalues) {
|
||||
options.push({
|
||||
value: optionConfig.id,
|
||||
name: optionConfig.name
|
||||
value: '',
|
||||
name: self._chooseStr
|
||||
});
|
||||
}
|
||||
|
||||
this._dialogue = new GradeDialogue(options, this._canGrade, this._canSuggest);
|
||||
this._dialogue.on('rated', function(e, data) {
|
||||
var args = this._args;
|
||||
args.grade = data.rating;
|
||||
args.note = data.note;
|
||||
args.override = true;
|
||||
ajax.call([{
|
||||
methodname: this._methodName,
|
||||
args: args,
|
||||
done: function(evidence) {
|
||||
this._trigger('competencyupdated', { args: args, evidence: evidence });
|
||||
}.bind(self),
|
||||
fail: notification.exception
|
||||
}]);
|
||||
}.bind(this));
|
||||
this._dialogue.on('suggested', function(e, data) {
|
||||
var args = this._args;
|
||||
args.grade = data.rating;
|
||||
args.note = data.note;
|
||||
args.override = false;
|
||||
ajax.call([{
|
||||
methodname: this._methodName,
|
||||
args: args,
|
||||
done: function(evidence) {
|
||||
this._trigger('competencyupdated', { args: args, evidence: evidence });
|
||||
}.bind(self),
|
||||
fail: notification.exception
|
||||
}]);
|
||||
}.bind(this));
|
||||
for (var i = 0; i < scalevalues.length; i++) {
|
||||
var optionConfig = scalevalues[i];
|
||||
options.push({
|
||||
value: optionConfig.id,
|
||||
name: optionConfig.name
|
||||
});
|
||||
}
|
||||
|
||||
self._dialogue = new GradeDialogue(options, self._canGrade, self._canSuggest);
|
||||
self._dialogue.on('rated', function(e, data) {
|
||||
var args = self._args;
|
||||
args.grade = data.rating;
|
||||
args.note = data.note;
|
||||
args.override = true;
|
||||
ajax.call([{
|
||||
methodname: self._methodName,
|
||||
args: args,
|
||||
done: function(evidence) {
|
||||
self._trigger('competencyupdated', { args: args, evidence: evidence });
|
||||
}.bind(self),
|
||||
fail: notification.exception
|
||||
}]);
|
||||
}.bind(self));
|
||||
self._dialogue.on('suggested', function(e, data) {
|
||||
var args = self._args;
|
||||
args.grade = data.rating;
|
||||
args.note = data.note;
|
||||
args.override = false;
|
||||
ajax.call([{
|
||||
methodname: self._methodName,
|
||||
args: args,
|
||||
done: function(evidence) {
|
||||
self._trigger('competencyupdated', { args: args, evidence: evidence });
|
||||
}.bind(self),
|
||||
fail: notification.exception
|
||||
}]);
|
||||
}.bind(self));
|
||||
}).fail(notification.exception);
|
||||
};
|
||||
|
||||
/** @type {Object} The scale config for this competency. */
|
||||
InlineEditor.prototype._scaleConfig = null;
|
||||
/** @type {Number} The scale id for this competency. */
|
||||
InlineEditor.prototype._scaleId = null;
|
||||
/** @type {Number} The id of the competency. */
|
||||
InlineEditor.prototype._competencyId = null;
|
||||
/** @type {Number} The id of the user. */
|
||||
@@ -151,6 +155,8 @@ define(['jquery',
|
||||
InlineEditor.prototype._planId = null;
|
||||
/** @type {Number} The id of the course. */
|
||||
InlineEditor.prototype._courseId = null;
|
||||
/** @type {String} The text for Choose rating. */
|
||||
InlineEditor.prototype._chooseStr = null;
|
||||
/** @type {GradeDialogue} The grading dialogue. */
|
||||
InlineEditor.prototype._dialogue = null;
|
||||
/** @type {Boolean} Can grade. */
|
||||
|
||||
@@ -0,0 +1,57 @@
|
||||
// This file is part of Moodle - http://moodle.org/
|
||||
//
|
||||
// Moodle is free software: you can redistribute it and/or modify
|
||||
// it under the terms of the GNU General Public License as published by
|
||||
// the Free Software Foundation, either version 3 of the License, or
|
||||
// (at your option) any later version.
|
||||
//
|
||||
// Moodle is distributed in the hope that it will be useful,
|
||||
// but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
// GNU General Public License for more details.
|
||||
//
|
||||
// You should have received a copy of the GNU General Public License
|
||||
// along with Moodle. If not, see <http://www.gnu.org/licenses/>.
|
||||
|
||||
/**
|
||||
* Module to get the scale values.
|
||||
*
|
||||
* @package tool_lp
|
||||
* @copyright 2016 Serge Gauthier
|
||||
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
|
||||
*/
|
||||
define(['jquery', 'core/ajax'], function($, ajax) {
|
||||
var localCache = [];
|
||||
|
||||
return /** @alias module:tool_lp/scalevalues */ {
|
||||
|
||||
/**
|
||||
* Return a promise object that will be resolved into a string eventually (maybe immediately).
|
||||
*
|
||||
* @method get_values
|
||||
* @param {Number} scaleid The scale id
|
||||
* @return [] {Promise}
|
||||
*/
|
||||
|
||||
get_values: function(scaleid) {
|
||||
|
||||
var deferred = $.Deferred();
|
||||
|
||||
if (!localCache[scaleid]) {
|
||||
ajax.call([{
|
||||
methodname: 'tool_lp_get_scale_values',
|
||||
args: {scaleid : scaleid},
|
||||
done: function(scaleinfo) {
|
||||
localCache[scaleid] = scaleinfo;
|
||||
deferred.resolve(scaleinfo);
|
||||
},
|
||||
fail: (deferred.reject)
|
||||
}]);
|
||||
} else {
|
||||
deferred.resolve(localCache[scaleid]);
|
||||
}
|
||||
|
||||
return deferred.promise();
|
||||
}
|
||||
};
|
||||
});
|
||||
@@ -68,6 +68,9 @@ class competency_summary_exporter extends exporter {
|
||||
'hasrelatedcompetencies' => array(
|
||||
'type' => PARAM_BOOL
|
||||
),
|
||||
'scaleid' => array(
|
||||
'type' => PARAM_INT
|
||||
),
|
||||
'scaleconfiguration' => array(
|
||||
'type' => PARAM_RAW
|
||||
),
|
||||
@@ -108,10 +111,13 @@ class competency_summary_exporter extends exporter {
|
||||
$exporter = new competency_framework_exporter($this->related['framework']);
|
||||
$result->framework = $exporter->export($output);
|
||||
$scaleconfiguration = $this->related['framework']->get_scaleconfiguration();
|
||||
$scaleid = $this->related['framework']->get_scaleid();
|
||||
if ($competency->get_scaleid()) {
|
||||
$scaleconfiguration = $competency->get_scaleconfiguration();
|
||||
$scaleid = $competency->get_scaleid();
|
||||
}
|
||||
$result->scaleconfiguration = $scaleconfiguration;
|
||||
$result->scaleid = $scaleid;
|
||||
|
||||
$level = $competency->get_level();
|
||||
$taxonomy = $this->related['framework']->get_taxonomy($level);
|
||||
|
||||
@@ -71,7 +71,6 @@
|
||||
</dd>
|
||||
{{#js}}
|
||||
require(['jquery', 'tool_lp/grade_user_competency_inline', 'tool_lp/user_competency_info', 'tool_lp/user_competency_workflow'], function($, mod, info, UserCompWorkflow) {
|
||||
var scaleConfig = JSON.parse('{{{competency.scaleconfiguration}}}');
|
||||
|
||||
var competencyElement = $('[data-region-id="{{uniqid}}"]');
|
||||
var infoReloader = new info(competencyElement, '{{competency.competency.id}}', '{{user.id}}');
|
||||
@@ -81,7 +80,7 @@
|
||||
ucw.on('status-changed', infoReloader.reload.bind(infoReloader));
|
||||
ucw.on('error-occured', infoReloader.reload.bind(infoReloader));
|
||||
|
||||
var inlineGrader = new mod('#rate_{{uniqid}}', scaleConfig, '{{competency.competency.id}}', '{{user.id}}', '{{plan.id}}', '', '{{#str}}chooserating, tool_lp{{/str}}', {{cangrade}}, {{cansuggest}});
|
||||
var inlineGrader = new mod('#rate_{{uniqid}}', '{{competency.scaleid}}', '{{competency.competency.id}}', '{{user.id}}', '{{plan.id}}', '', '{{#str}}chooserating, tool_lp{{/str}}', {{cangrade}}, {{cansuggest}});
|
||||
inlineGrader.on('competencyupdated', infoReloader.reload.bind(infoReloader));
|
||||
});
|
||||
{{/js}}
|
||||
|
||||
@@ -89,9 +89,8 @@
|
||||
</dd>
|
||||
{{#js}}
|
||||
require(['jquery', 'tool_lp/grade_user_competency_inline', 'tool_lp/user_competency_info'], function($, mod, info) {
|
||||
var scaleConfig = JSON.parse('{{{competency.scaleconfiguration}}}');
|
||||
|
||||
var inlineGrader = new mod('#rate_{{uniqid}}', scaleConfig, '{{competency.competency.id}}', '{{user.id}}', '', '{{course.id}}', '{{#str}}chooserating, tool_lp{{/str}}', {{cangrade}}, {{cansuggest}});
|
||||
var inlineGrader = new mod('#rate_{{uniqid}}', '{{competency.scaleid}}', '{{competency.competency.id}}', '{{user.id}}', '', '{{course.id}}', '{{#str}}chooserating, tool_lp{{/str}}', {{cangrade}}, {{cansuggest}});
|
||||
var competencyElement = $('[data-region-id="{{uniqid}}"]');
|
||||
|
||||
var displayuser = ('{{displayuser}}' == 'true') ? true : false;
|
||||
|
||||
@@ -73,7 +73,6 @@
|
||||
</dd>
|
||||
{{#js}}
|
||||
require(['jquery', 'tool_lp/grade_user_competency_inline', 'tool_lp/user_competency_info', 'tool_lp/user_competency_workflow'], function($, mod, info, UserCompWorkflow) {
|
||||
var scaleConfig = JSON.parse('{{{competency.scaleconfiguration}}}');
|
||||
|
||||
var competencyElement = $('[data-region-id="{{uniqid}}"]');
|
||||
var infoReloader = new info(competencyElement, '{{competency.competency.id}}', '{{user.id}}', '{{plan.id}}');
|
||||
@@ -84,7 +83,7 @@
|
||||
ucw.on('error-occured', infoReloader.reload.bind(infoReloader));
|
||||
|
||||
{{#cangradeorsuggest}}
|
||||
var inlineGrader = new mod('#rate_{{uniqid}}', scaleConfig, '{{competency.competency.id}}', '{{user.id}}', '{{plan.id}}', '', '{{#str}}chooserating, tool_lp{{/str}}', {{cangrade}}, {{cansuggest}});
|
||||
var inlineGrader = new mod('#rate_{{uniqid}}', '{{competency.scaleid}}', '{{competency.competency.id}}', '{{user.id}}', '{{plan.id}}', '', '{{#str}}chooserating, tool_lp{{/str}}', {{cangrade}}, {{cansuggest}});
|
||||
inlineGrader.on('competencyupdated', infoReloader.reload.bind(infoReloader));
|
||||
{{/cangradeorsuggest}}
|
||||
});
|
||||
|
||||
Reference in New Issue
Block a user