mirror of
https://github.com/moodle/moodle.git
synced 2025-01-19 06:18:28 +01:00
MDL-51040 cbe: Allow competency rating in course or plan
Modify the inline competency rating module to handle rating competencies in a course or in a plan.
This commit is contained in:
parent
06475034f2
commit
3fb067a203
@ -1 +1 @@
|
||||
define(["jquery","core/notification","core/ajax"],function(a,b,c){var d=function(a,b,c,d,e){this._formId=a,this._scaleConfig=b,this._competencyId=c,this._userId=d,this._planId=e,this._buildSelect(),this._addListeners()};return d.prototype._buildSelect=function(){var b=1;for(b=1;b<this._scaleConfig.length;b++){var c=this._scaleConfig[b],d=a("<option></option>");d.text(c.name),d.attr("value",c.id),c.scaledefault&&d.attr("selected","selected"),a(document.getElementById(this._formId)).find("select").append(d)}},d.prototype._handleGrade=function(d){var e=this,f=a(document.getElementById(this._formId)).find("select").val();if(d.preventDefault(),this._planId>0){var g={competencyid:this._competencyId,planid:this._planId,grade:f,override:!0};c.call([{methodname:"tool_lp_grade_competency_in_plan",args:g,done:function(a){e._trigger("competencyupdated",{args:g,evidence:a})},fail:b.exception}])}},d.prototype._handleSuggest=function(d){var e=this,f=a(document.getElementById(this._formId)).find("select").val();if(d.preventDefault(),this._planId>0){var g={competencyid:this._competencyId,planid:this._planId,grade:f,override:!1};c.call([{methodname:"tool_lp_grade_competency_in_plan",args:g,done:function(a){e._trigger("competencyupdated",{args:g,evidence:a})},fail:b.exception}])}},d.prototype._addListeners=function(){var b=this,c=a(document.getElementById(this._formId)),d=c.find('[data-action="grade"]');d.on("click",function(a){b._handleGrade.call(b,a)});var e=c.find('[data-action="suggest"]');e.on("click",function(a){b._handleSuggest.call(b,a)})},d.prototype._trigger=function(c,d){return"competencyupdated"!=c&&b.exception("Invalid event name:"+c),a(document.getElementById(this._formId)).trigger(c,d),this},d.prototype.on=function(c,d){return"competencyupdated"!=c&&b.exception("Invalid event name:"+c),a(document.getElementById(this._formId)).on(c,d),this},d.prototype._formId=null,d.prototype._scaleConfig=null,d.prototype._competencyId=null,d.prototype._userId=null,d.prototype._planId=null,d});
|
||||
define(["jquery","core/notification","core/ajax","core/log"],function(a,b,c,d){var e=function(a,b,c,e,f,g,h){this._formId=a,this._scaleConfig=b,this._competencyId=c,this._userId=e,this._planId=f,this._courseId=g,this._valid=!0,this._chooseStr=h,this._buildSelect(),this._addListeners(),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}):(d.error("Plan id or course id is required."),this._valid=!1)};return e.prototype._buildSelect=function(){var b=1,c=a("<option></option>");for(c.text(this._chooseStr),c.attr("value",""),a(document.getElementById(this._formId)).find("select").append(c),b=1;b<this._scaleConfig.length;b++){var d=this._scaleConfig[b],e=a("<option></option>");e.text(d.name),e.attr("value",d.id),a(document.getElementById(this._formId)).find("select").append(e)}},e.prototype._handleGrade=function(d){var e=this,f=a(document.getElementById(this._formId)).find("select").val();if(d.preventDefault(),this._valid&&f){var g=this._args;g.grade=f,g.override=!0,c.call([{methodname:this._methodName,args:g,done:function(a){e._trigger("competencyupdated",{args:g,evidence:a})},fail:b.exception}])}},e.prototype._handleSuggest=function(d){var e=this,f=a(document.getElementById(this._formId)).find("select").val();if(d.preventDefault(),this._valid&&f){var g=this._args;g.grade=f,g.override=!1,c.call([{methodname:this._methodName,args:g,done:function(a){e._trigger("competencyupdated",{args:g,evidence:a})},fail:b.exception}])}},e.prototype._addListeners=function(){var b=this,c=a(document.getElementById(this._formId)),d=c.find('[data-action="grade"]');d.on("click",function(a){b._handleGrade.call(b,a)});var e=c.find('[data-action="suggest"]');e.on("click",function(a){b._handleSuggest.call(b,a)})},e.prototype._trigger=function(c,d){return"competencyupdated"!=c&&b.exception("Invalid event name:"+c),a(document.getElementById(this._formId)).trigger(c,d),this},e.prototype.on=function(c,d){return"competencyupdated"!=c&&b.exception("Invalid event name:"+c),a(document.getElementById(this._formId)).on(c,d),this},e.prototype._formId=null,e.prototype._scaleConfig=null,e.prototype._competencyId=null,e.prototype._userId=null,e.prototype._planId=null,e.prototype._courseId=null,e.prototype._valid=null,e});
|
@ -1 +1 @@
|
||||
define(["jquery","core/notification","core/ajax","core/templates"],function(a,b,c,d){var e=function(a,c,d,e){this._rootElement=a,this._competencyId=c,this._userId=d,this._planId=e,this._planId?(this._methodName="tool_lp_data_for_user_competency_summary_in_plan",this._args={userid:this._userId,competencyid:this._competencyId,planid:this._planId},this._templateName="tool_lp/user_competency_summary_in_plan"):b.exception("Plan id is required.")};return e.prototype.reload=function(){var a=this,e=[];e=c.call([{methodname:this._methodName,args:this._args}]),e[0].done(function(c){d.render(a._templateName,c).done(function(b,c){d.replaceNode(a._rootElement,b,c)}).fail(b.exception)}).fail(b.exception)},e.prototype._rootElement=null,e.prototype._planId=null,e.prototype._competencyId=null,e.prototype._userId=null,e.prototype._methodName=null,e.prototype._args=null,e.prototype._templateName=null,e});
|
||||
define(["jquery","core/notification","core/ajax","core/templates","core/log"],function(a,b,c,d,e){var f=function(a,b,c,d,f){this._rootElement=a,this._competencyId=b,this._userId=c,this._planId=d,this._courseId=f,this._valid=!0,this._planId?(this._methodName="tool_lp_data_for_user_competency_summary_in_plan",this._args={userid:this._userId,competencyid:this._competencyId,planid:this._planId},this._templateName="tool_lp/user_competency_summary_in_plan"):this._courseId?(this._methodName="tool_lp_data_for_user_competency_summary_in_course",this._args={userid:this._userId,competencyid:this._competencyId,courseid:this._courseId},this._templateName="tool_lp/user_competency_summary_in_course"):(e.error("Plan id or course id is required."),this._valid=!1)};return f.prototype.reload=function(){var a=this,e=[];this._valid&&(e=c.call([{methodname:this._methodName,args:this._args}]),e[0].done(function(c){d.render(a._templateName,c).done(function(b,c){d.replaceNode(a._rootElement,b,c)}).fail(b.exception)}).fail(b.exception))},f.prototype._rootElement=null,f.prototype._courseId=null,f.prototype._valid=null,f.prototype._planId=null,f.prototype._competencyId=null,f.prototype._userId=null,f.prototype._methodName=null,f.prototype._args=null,f.prototype._templateName=null,f});
|
@ -21,7 +21,7 @@
|
||||
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
|
||||
*/
|
||||
|
||||
define(['jquery', 'core/notification', 'core/ajax'], function($, notification, ajax) {
|
||||
define(['jquery', 'core/notification', 'core/ajax', 'core/log'], function($, notification, ajax, log) {
|
||||
|
||||
/**
|
||||
* InlineEditor
|
||||
@ -31,15 +31,38 @@ define(['jquery', 'core/notification', 'core/ajax'], function($, notification, a
|
||||
* @param {Number} The id of the competency.
|
||||
* @param {Number} The id of the user.
|
||||
* @param {Number} The id of the plan.
|
||||
* @param {Number} The id of the course.
|
||||
* @param {String} Language string for choose a rating.
|
||||
*/
|
||||
var InlineEditor = function(formId, scaleConfig, competencyId, userId, planId) {
|
||||
var InlineEditor = function(formId, scaleConfig, competencyId, userId, planId, courseId, chooseStr) {
|
||||
this._formId = formId;
|
||||
this._scaleConfig = scaleConfig;
|
||||
this._competencyId = competencyId;
|
||||
this._userId = userId;
|
||||
this._planId = planId;
|
||||
this._courseId = courseId;
|
||||
this._valid = true;
|
||||
this._chooseStr = chooseStr;
|
||||
this._buildSelect();
|
||||
this._addListeners();
|
||||
|
||||
if (this._planId) {
|
||||
this._methodName = 'tool_lp_grade_competency_in_plan';
|
||||
this._args = {
|
||||
competencyid: this._competencyId,
|
||||
planid: this._planId
|
||||
};
|
||||
} else if (this._courseId) {
|
||||
this._methodName = 'tool_lp_grade_competency_in_course';
|
||||
this._args = {
|
||||
competencyid: this._competencyId,
|
||||
courseid: this._courseId,
|
||||
userid: this._userId
|
||||
};
|
||||
} else {
|
||||
log.error('Plan id or course id is required.');
|
||||
this._valid = false;
|
||||
}
|
||||
};
|
||||
|
||||
/**
|
||||
@ -50,15 +73,16 @@ define(['jquery', 'core/notification', 'core/ajax'], function($, notification, a
|
||||
InlineEditor.prototype._buildSelect = function() {
|
||||
var i = 1;
|
||||
|
||||
var blankOption = $('<option></option>');
|
||||
blankOption.text(this._chooseStr);
|
||||
blankOption.attr('value', '');
|
||||
$(document.getElementById(this._formId)).find('select').append(blankOption);
|
||||
// The first item is the scaleid - we don't care about that.
|
||||
for (i = 1; i < this._scaleConfig.length; i++) {
|
||||
var optionConfig = this._scaleConfig[i];
|
||||
var optionEle = $('<option></option>');
|
||||
optionEle.text(optionConfig.name);
|
||||
optionEle.attr('value', optionConfig.id);
|
||||
if (optionConfig.scaledefault) {
|
||||
optionEle.attr('selected', 'selected');
|
||||
}
|
||||
|
||||
$(document.getElementById(this._formId)).find('select').append(optionEle);
|
||||
}
|
||||
@ -74,15 +98,13 @@ define(['jquery', 'core/notification', 'core/ajax'], function($, notification, a
|
||||
var currentthis = this;
|
||||
var grade = $(document.getElementById(this._formId)).find('select').val();
|
||||
event.preventDefault();
|
||||
if (this._planId > 0) {
|
||||
var args = {
|
||||
competencyid: this._competencyId,
|
||||
planid: this._planId,
|
||||
grade: grade,
|
||||
override: true
|
||||
};
|
||||
if (this._valid && grade) {
|
||||
var args = this._args;
|
||||
args.grade = grade;
|
||||
args.override = true;
|
||||
|
||||
ajax.call([{
|
||||
methodname: 'tool_lp_grade_competency_in_plan',
|
||||
methodname: this._methodName,
|
||||
args: args,
|
||||
done: function(evidence) {
|
||||
currentthis._trigger('competencyupdated', { args: args, evidence: evidence});
|
||||
@ -102,15 +124,12 @@ define(['jquery', 'core/notification', 'core/ajax'], function($, notification, a
|
||||
var currentthis = this;
|
||||
var grade = $(document.getElementById(this._formId)).find('select').val();
|
||||
event.preventDefault();
|
||||
if (this._planId > 0) {
|
||||
var args = {
|
||||
competencyid: this._competencyId,
|
||||
planid: this._planId,
|
||||
grade: grade,
|
||||
override: false
|
||||
};
|
||||
if (this._valid && grade) {
|
||||
var args = this._args;
|
||||
args.grade = grade;
|
||||
args.override = false;
|
||||
ajax.call([{
|
||||
methodname: 'tool_lp_grade_competency_in_plan',
|
||||
methodname: this._methodName,
|
||||
args: args,
|
||||
done: function(evidence) {
|
||||
currentthis._trigger('competencyupdated', { args: args, evidence: evidence});
|
||||
@ -181,6 +200,10 @@ define(['jquery', 'core/notification', 'core/ajax'], function($, notification, a
|
||||
InlineEditor.prototype._userId = null;
|
||||
/** @type {Number} The id of the plan. */
|
||||
InlineEditor.prototype._planId = null;
|
||||
/** @type {Number} The id of the course. */
|
||||
InlineEditor.prototype._courseId = null;
|
||||
/** @type {Boolean} Is this module valid. */
|
||||
InlineEditor.prototype._valid = null;
|
||||
|
||||
return /** @alias module:tool_lp/grade_user_competency_inline */ InlineEditor;
|
||||
|
||||
|
@ -21,7 +21,7 @@
|
||||
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
|
||||
*/
|
||||
|
||||
define(['jquery', 'core/notification', 'core/ajax', 'core/templates'], function($, notification, ajax, templates) {
|
||||
define(['jquery', 'core/notification', 'core/ajax', 'core/templates', 'core/log'], function($, notification, ajax, templates, log) {
|
||||
|
||||
/**
|
||||
* Info
|
||||
@ -30,20 +30,28 @@ define(['jquery', 'core/notification', 'core/ajax', 'core/templates'], function(
|
||||
* @param {Number} The id of the competency.
|
||||
* @param {Number} The id of the user.
|
||||
* @param {Number} The id of the plan.
|
||||
* @param {Number} The id of the course.
|
||||
*/
|
||||
var Info = function(rootElement, competencyId, userId, planId) {
|
||||
var Info = function(rootElement, competencyId, userId, planId, courseId) {
|
||||
this._rootElement = rootElement;
|
||||
this._competencyId = competencyId;
|
||||
this._userId = userId;
|
||||
this._planId = planId;
|
||||
this._courseId = courseId;
|
||||
this._valid = true;
|
||||
|
||||
if (this._planId) {
|
||||
this._methodName = 'tool_lp_data_for_user_competency_summary_in_plan';
|
||||
this._args = { userid: this._userId, competencyid: this._competencyId, planid: this._planId };
|
||||
this._templateName = 'tool_lp/user_competency_summary_in_plan';
|
||||
} else if (this._courseId) {
|
||||
this._methodName = 'tool_lp_data_for_user_competency_summary_in_course';
|
||||
this._args = { userid: this._userId, competencyid: this._competencyId, courseid: this._courseId };
|
||||
this._templateName = 'tool_lp/user_competency_summary_in_course';
|
||||
} else {
|
||||
// TODO - add optional courseid support.
|
||||
notification.exception('Plan id is required.');
|
||||
log.error('Plan id or course id is required.');
|
||||
this._valid = false;
|
||||
}
|
||||
};
|
||||
|
||||
@ -56,6 +64,10 @@ define(['jquery', 'core/notification', 'core/ajax', 'core/templates'], function(
|
||||
var self = this,
|
||||
promises = [];
|
||||
|
||||
if (!this._valid) {
|
||||
return;
|
||||
}
|
||||
|
||||
promises = ajax.call([{
|
||||
methodname: this._methodName,
|
||||
args: this._args
|
||||
@ -70,6 +82,10 @@ define(['jquery', 'core/notification', 'core/ajax', 'core/templates'], function(
|
||||
|
||||
/** @type {JQuery} The root element to replace in the DOM. */
|
||||
Info.prototype._rootElement = null;
|
||||
/** @type {Number} The id of the course. */
|
||||
Info.prototype._courseId = null;
|
||||
/** @type {Boolean} Is this module valid? */
|
||||
Info.prototype._valid = null;
|
||||
/** @type {Number} The id of the plan. */
|
||||
Info.prototype._planId = null;
|
||||
/** @type {Number} The id of the competency. */
|
||||
|
Loading…
x
Reference in New Issue
Block a user