MDL-53186 tool_lp: Removing push for review when adding competencies

This commit is contained in:
Frederic Massart
2016-04-18 10:58:58 +08:00
parent 71cb304ad8
commit 1f58618863
7 changed files with 7 additions and 54 deletions
+1 -1
View File
@@ -1 +1 @@
define(["jquery","core/notification","core/ajax","core/templates","core/str","tool_lp/tree","tool_lp/competencypicker"],function(a,b,c,d,e,f,g){var h=function(a,b,c){g.prototype.constructor.apply(this,[1,!1,"self",c]),this._userId=a,this._plans=[],b&&(this._planId=b,this._singlePlan=!0)};return h.prototype=Object.create(g.prototype),h.prototype._plans=null,h.prototype._planId=null,h.prototype._singlePlan=!1,h.prototype._userId=null,h.prototype._requestReview=!1,h.prototype._afterRender=function(){var b=this;g.prototype._afterRender.apply(b,arguments),b._singlePlan||b._find('[data-action="chooseplan"]').change(function(c){b._planId=a(c.target).val(),b._loadCompetencies().then(b._refresh.bind(b))}.bind(b)),b._find('[data-action="request-review"]').change(function(c){b._requestReview=a(c.target).is(":checked"),b._refresh.bind(b)}.bind(b))},h.prototype._fetchCompetencies=function(a,d){var e=this;return c.call([{methodname:"tool_lp_list_plan_competencies",args:{id:a}}])[0].done(function(a){var b,c,f=[];for(b=0;b<a.length;b++)c=a[b].competency,c.shortname.toLowerCase().indexOf(d.toLowerCase())<0||(c.children=[],c.haschildren=0,f.push(c));e._competencies=f}).fail(b.exception)},h.prototype._getPlan=function(b){var c;return a.each(this._plans,function(a,d){return d.id==b?(c=d,!1):void 0}),c},h.prototype._loadCompetencies=function(){return this._fetchCompetencies(this._planId,this._searchText)},h.prototype._loadPlans=function(){var d,e=this;return e._plans.length>0?a.when():(d=e._singlePlan?c.call([{methodname:"tool_lp_read_plan",args:{id:this._planId}}])[0].then(function(a){return[a]}):c.call([{methodname:"tool_lp_list_user_plans",args:{userid:e._userId}}])[0],d.done(function(a){e._plans=a}).fail(b.exception))},h.prototype._preRender=function(){var b=this;return b._loadPlans().then(function(){return!b._planId&&b._plans.length>0&&(b._planId=b._plans[0].id),b._planId?b._loadCompetencies():(b._plans=[],a.when())}.bind(b))},h.prototype._render=function(){var b=this;return b._preRender().then(function(){b._singlePlan||a.each(b._plans,function(a,c){c.id==b._planId?c.selected=!0:c.selected=!1});var c={competencies:b._competencies,plan:b._getPlan(b._planId),plans:b._plans,search:b._searchText,singlePlan:b._singlePlan};return d.render("tool_lp/competency_picker_user_plans",c)}.bind(b))},h.prototype._trigger=function(a,b){var c=this;return"save"===a&&(b.requestReview=c._requestReview),g.prototype._trigger.apply(c,arguments)},h});
define(["jquery","core/notification","core/ajax","core/templates","core/str","tool_lp/tree","tool_lp/competencypicker"],function(a,b,c,d,e,f,g){var h=function(a,b,c){g.prototype.constructor.apply(this,[1,!1,"self",c]),this._userId=a,this._plans=[],b&&(this._planId=b,this._singlePlan=!0)};return h.prototype=Object.create(g.prototype),h.prototype._plans=null,h.prototype._planId=null,h.prototype._singlePlan=!1,h.prototype._userId=null,h.prototype._afterRender=function(){var b=this;g.prototype._afterRender.apply(b,arguments),b._singlePlan||b._find('[data-action="chooseplan"]').change(function(c){b._planId=a(c.target).val(),b._loadCompetencies().then(b._refresh.bind(b))}.bind(b))},h.prototype._fetchCompetencies=function(a,d){var e=this;return c.call([{methodname:"tool_lp_list_plan_competencies",args:{id:a}}])[0].done(function(a){var b,c,f=[];for(b=0;b<a.length;b++)c=a[b].competency,c.shortname.toLowerCase().indexOf(d.toLowerCase())<0||(c.children=[],c.haschildren=0,f.push(c));e._competencies=f}).fail(b.exception)},h.prototype._getPlan=function(b){var c;return a.each(this._plans,function(a,d){return d.id==b?(c=d,!1):void 0}),c},h.prototype._loadCompetencies=function(){return this._fetchCompetencies(this._planId,this._searchText)},h.prototype._loadPlans=function(){var d,e=this;return e._plans.length>0?a.when():(d=e._singlePlan?c.call([{methodname:"tool_lp_read_plan",args:{id:this._planId}}])[0].then(function(a){return[a]}):c.call([{methodname:"tool_lp_list_user_plans",args:{userid:e._userId}}])[0],d.done(function(a){e._plans=a}).fail(b.exception))},h.prototype._preRender=function(){var b=this;return b._loadPlans().then(function(){return!b._planId&&b._plans.length>0&&(b._planId=b._plans[0].id),b._planId?b._loadCompetencies():(b._plans=[],a.when())}.bind(b))},h.prototype._render=function(){var b=this;return b._preRender().then(function(){b._singlePlan||a.each(b._plans,function(a,c){c.id==b._planId?c.selected=!0:c.selected=!1});var c={competencies:b._competencies,plan:b._getPlan(b._planId),plans:b._plans,search:b._searchText,singlePlan:b._singlePlan};return d.render("tool_lp/competency_picker_user_plans",c)}.bind(b))},h});
File diff suppressed because one or more lines are too long
@@ -63,8 +63,6 @@ define(['jquery',
Picker.prototype._singlePlan = false;
/** @type {Number} The user the plans belongs to. */
Picker.prototype._userId = null;
/** @type {Boolean} Whether user want to send competencies to review. */
Picker.prototype._requestReview = false;
/**
* Hook to executed after the view is rendered.
@@ -82,13 +80,6 @@ define(['jquery',
self._loadCompetencies().then(self._refresh.bind(self));
}.bind(self));
}
// Add listener for checkbox change.
self._find('[data-action="request-review"]').change(function(e) {
self._requestReview = $(e.target).is(":checked");
self._refresh.bind(self);
}.bind(self));
};
/**
@@ -244,22 +235,6 @@ define(['jquery',
}.bind(self));
};
/**
* Trigger an event.
*
* @param {String} type The type of event.
* @param {Object} The data to pass to the listeners.
* @method _reset
*/
Picker.prototype._trigger = function(type, args) {
var self = this;
if (type === 'save') {
args.requestReview = self._requestReview;
}
return PickerBase.prototype._trigger.apply(self, arguments);
};
return /** @alias module:tool_lp/competencypicker_user_plans */ Picker;
});
+1 -11
View File
@@ -198,7 +198,7 @@ define(['jquery',
* @param {Number} competencyIds The competency IDs.
* @param {Boolean} requestReview Send competencies to review.
*/
UserEvidenceActions.prototype._doCreateUserEvidenceCompetency = function(evidenceData, competencyIds, requestReview) {
UserEvidenceActions.prototype._doCreateUserEvidenceCompetency = function(evidenceData, competencyIds) {
var self = this,
calls = [];
@@ -210,16 +210,6 @@ define(['jquery',
competencyid: competencyId,
}
});
if (requestReview) {
calls.push({
methodname: 'tool_lp_user_competency_request_review',
args: {
userid: evidenceData.userid,
competencyid: competencyId,
checkstatus: false
}
});
}
});
self._callAndRefresh(calls, evidenceData);
+2 -7
View File
@@ -3346,10 +3346,9 @@ class api {
*
* @param int $userid The user ID.
* @param int $competencyid The competency ID.
* @param bool $onlyidle Return exception if status is not idle.
* @return bool
*/
public static function user_competency_request_review($userid, $competencyid, $onlyidle = true) {
public static function user_competency_request_review($userid, $competencyid) {
static::require_enabled();
$uc = user_competency::get_record(array('userid' => $userid, 'competencyid' => $competencyid));
if (!$uc) {
@@ -3360,11 +3359,7 @@ class api {
if (!$uc->can_read()) {
throw new required_capability_exception($uc->get_context(), 'tool/lp:usercompetencyread', 'nopermissions', '');
} else if ($uc->get_status() != user_competency::STATUS_IDLE) {
if ($onlyidle) {
throw new coding_exception('The competency can not be sent for review at this stage.');
} else {
return true;
}
throw new coding_exception('The competency can not be sent for review at this stage.');
} else if (!$uc->can_request_review()) {
throw new required_capability_exception($uc->get_context(), 'tool/lp:usercompetencyrequestreview', 'nopermissions', '');
}
+2 -5
View File
@@ -2970,7 +2970,6 @@ class external extends external_api {
return new external_function_parameters(array(
'userid' => new external_value(PARAM_INT, 'The user ID'),
'competencyid' => new external_value(PARAM_INT, 'The competency ID'),
'checkstatus' => new external_value(PARAM_BOOL, 'Check status request', VALUE_DEFAULT, true)
));
}
@@ -2979,20 +2978,18 @@ class external extends external_api {
*
* @param int $userid The user ID.
* @param int $competencyid The competency ID.
* @param boolean $checkstatus True to return exception when status is already in review.
* @return boolean
*/
public static function user_competency_request_review($userid, $competencyid, $checkstatus) {
public static function user_competency_request_review($userid, $competencyid) {
$params = self::validate_parameters(self::user_competency_request_review_parameters(), array(
'userid' => $userid,
'competencyid' => $competencyid,
'checkstatus' => $checkstatus,
));
$context = context_user::instance($params['userid']);
self::validate_context($context);
return api::user_competency_request_review($userid, $competencyid, $checkstatus);
return api::user_competency_request_review($userid, $competencyid);
}
/**
@@ -27,10 +27,6 @@
</ul>
<div data-region="link-buttons">
<div>
<input id="send-for-review-checkbox" type="checkbox" value="true" data-action="request-review">
<label for="send-for-review-checkbox">{{#str}}sendcompetenciestoreview, tool_lp{{/str}}</label>
</div>
<input type="button" data-action="add" value="{{#str}}add{{/str}}"/>
<input type="button" data-action="cancel" value="{{#str}}cancel{{/str}}"/>
</div>