mirror of
https://github.com/moodle/moodle.git
synced 2025-01-19 06:18:28 +01:00
MDL-51648 cbe: Refactor the user_competency_summary exporter
Split it into a core exporter, and an extended one that adds information about the plan. Also * Remove userid from grade_competency_in_plan function (redundant) * Improve the signature of list_evidence so it can handle completed plans (later) * Rename read_user_competency_summary to data_for_user_competency_summary_in_plan * Handle completed plans (list user_competency_plan as well as user_competency) * Remove user_can_see_details_cap handling - if you can see the users plan you can see the user * Pass final scaleconfiguration in the competency_summary_exporter * Add docs comments to new templates
This commit is contained in:
parent
3c659fc202
commit
0845a3a09a
@ -1 +1 @@
|
||||
define(["jquery","core/notification","core/ajax","core/log"],function(a,b,c,d){var e=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 e.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)}},e.prototype._handleGrade=function(d){var e=this,f=a(document.getElementById(this._formId)).find("select").val();if(d.preventDefault(),this._planId>0){var g={userid:this._userId,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}])}},e.prototype._handleSuggest=function(d){var e=this,f=a(document.getElementById(this._formId)).find("select").val();if(d.preventDefault(),this._planId>0){var g={userid:this._userId,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}])}},e.prototype._addListeners=function(){var b=this,c=a(document.getElementById(this._formId)),e=c.find('[data-action="grade"]');e.on("click",function(a){b._handleGrade.call(b,a)});var f=c.find('[data-action="suggest"]');f.on("click",function(a){b._handleSuggest.call(b,a)}),this.on("competencyupdated",function(a,b){d.debug("Competency updated"),d.debug(b)})},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});
|
||||
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});
|
@ -1 +1 @@
|
||||
define(["jquery","core/notification","core/ajax","core/templates"],function(a,b,c,d){var e=function(a,b,c,d){this._rootElement=a,this._competencyId=b,this._userId=c,this._planId=d};return e.prototype.reload=function(){var a=this,e=[];e=c.call([{methodname:"tool_lp_read_user_competency_summary",args:{userid:this._userId,competencyid:this._competencyId,planid:this._planId}}]),e[0].done(function(c){d.render("tool_lp/user_competency_info",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});
|
||||
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});
|
@ -21,7 +21,7 @@
|
||||
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
|
||||
*/
|
||||
|
||||
define(['jquery', 'core/notification', 'core/ajax', 'core/log'], function($, notification, ajax, log) {
|
||||
define(['jquery', 'core/notification', 'core/ajax'], function($, notification, ajax) {
|
||||
|
||||
/**
|
||||
* InlineEditor
|
||||
@ -76,7 +76,6 @@ define(['jquery', 'core/notification', 'core/ajax', 'core/log'], function($, not
|
||||
event.preventDefault();
|
||||
if (this._planId > 0) {
|
||||
var args = {
|
||||
userid: this._userId,
|
||||
competencyid: this._competencyId,
|
||||
planid: this._planId,
|
||||
grade: grade,
|
||||
@ -105,7 +104,6 @@ define(['jquery', 'core/notification', 'core/ajax', 'core/log'], function($, not
|
||||
event.preventDefault();
|
||||
if (this._planId > 0) {
|
||||
var args = {
|
||||
userid: this._userId,
|
||||
competencyid: this._competencyId,
|
||||
planid: this._planId,
|
||||
grade: grade,
|
||||
@ -138,11 +136,6 @@ define(['jquery', 'core/notification', 'core/ajax', 'core/log'], function($, not
|
||||
suggestbutton.on('click', function(event) {
|
||||
currentthis._handleSuggest.call(currentthis, event);
|
||||
});
|
||||
|
||||
this.on('competencyupdated', function(event, args) {
|
||||
log.debug('Competency updated');
|
||||
log.debug(args);
|
||||
});
|
||||
};
|
||||
|
||||
/**
|
||||
|
@ -36,6 +36,15 @@ define(['jquery', 'core/notification', 'core/ajax', 'core/templates'], function(
|
||||
this._competencyId = competencyId;
|
||||
this._userId = userId;
|
||||
this._planId = planId;
|
||||
|
||||
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 {
|
||||
// TODO - add optional courseid support.
|
||||
notification.exception('Plan id is required.');
|
||||
}
|
||||
};
|
||||
|
||||
/**
|
||||
@ -48,12 +57,12 @@ define(['jquery', 'core/notification', 'core/ajax', 'core/templates'], function(
|
||||
promises = [];
|
||||
|
||||
promises = ajax.call([{
|
||||
methodname: 'tool_lp_read_user_competency_summary',
|
||||
args: { userid: this._userId, competencyid: this._competencyId, planid: this._planId }
|
||||
methodname: this._methodName,
|
||||
args: this._args
|
||||
}]);
|
||||
|
||||
promises[0].done(function(context) {
|
||||
templates.render('tool_lp/user_competency_info', context).done(function(html, js) {
|
||||
templates.render(self._templateName, context).done(function(html, js) {
|
||||
templates.replaceNode(self._rootElement, html, js);
|
||||
}).fail(notification.exception);
|
||||
}).fail(notification.exception);
|
||||
@ -67,7 +76,13 @@ define(['jquery', 'core/notification', 'core/ajax', 'core/templates'], function(
|
||||
Info.prototype._competencyId = null;
|
||||
/** @type {Number} The id of the user. */
|
||||
Info.prototype._userId = null;
|
||||
/** @type {String} The method name to load the data. */
|
||||
Info.prototype._methodName = null;
|
||||
/** @type {Object} The arguments to load the data. */
|
||||
Info.prototype._args = null;
|
||||
/** @type {String} The template to reload the fragment. */
|
||||
Info.prototype._templateName = null;
|
||||
|
||||
return /** @alias module:tool_lp/grade_user_competency_inline */ Info;
|
||||
return /** @alias module:tool_lp/user_competency_info */ Info;
|
||||
|
||||
});
|
||||
|
@ -2390,32 +2390,27 @@ class api {
|
||||
/**
|
||||
* List all the evidence for a user competency
|
||||
*
|
||||
* @param int $usercompetencyid The user competency id - if 0, then userid and competencyid are used.
|
||||
* @param int $userid The user id - only used if usercompetencyid is 0.
|
||||
* @param int $competencyid The competency id - only used it usercompetencyid is 0.
|
||||
* @param int $planid The plan id - not used yet - but can be used to only list archived evidence if a plan is completed.
|
||||
* @return array of \tool_lp\evidence
|
||||
*/
|
||||
public static function list_evidence($usercompetencyid = 0,
|
||||
$userid = 0,
|
||||
public static function list_evidence($userid = 0,
|
||||
$competencyid = 0,
|
||||
$planid = 0,
|
||||
$sort = 'timecreated',
|
||||
$order = 'DESC',
|
||||
$skip = 0,
|
||||
$limit = 0) {
|
||||
|
||||
if ($usercompetencyid > 0) {
|
||||
$usercompetency = new user_competency($usercompetencyid);
|
||||
$context = context_user::instance($userid);
|
||||
require_capability('tool/lp:planview', $context);
|
||||
|
||||
$context = context_user::instance($usercompetency->get_userid());
|
||||
require_capability('tool/lp:planview', $context);
|
||||
} else {
|
||||
$context = context_user::instance($userid);
|
||||
require_capability('tool/lp:planview', $context);
|
||||
// TODO - handle archived plans.
|
||||
|
||||
$usercompetency = user_competency::get_record(array('userid' => $userid, 'competencyid' => $competencyid));
|
||||
if (!$usercompetency) {
|
||||
return array();
|
||||
}
|
||||
$usercompetency = user_competency::get_record(array('userid' => $userid, 'competencyid' => $competencyid));
|
||||
if (!$usercompetency) {
|
||||
return array();
|
||||
}
|
||||
|
||||
return evidence::get_records(array('usercompetencyid' => $usercompetency->get_id()), $sort, $order, $skip, $limit);
|
||||
@ -2718,33 +2713,23 @@ class api {
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns a user competency data.
|
||||
*
|
||||
* @param int $userid
|
||||
* @param array of int $competencyids
|
||||
* @return array of \tool_lp\user_competency
|
||||
*/
|
||||
public static function read_user_competencies($userid, $competencyids) {
|
||||
$context = context_user::instance($userid);
|
||||
require_capability('tool/lp:planview', $context);
|
||||
|
||||
return user_competency::get_multiple($userid, $competencyids);
|
||||
}
|
||||
|
||||
/**
|
||||
* Manually grade a user competency from the plans page.
|
||||
*
|
||||
* @param int $userid
|
||||
* @param mixed $planorid
|
||||
* @param int $competencyid
|
||||
* @param int $planid
|
||||
* @param int $grade
|
||||
* @param boolean $override
|
||||
* @return array of \tool_lp\user_competency
|
||||
*/
|
||||
public static function grade_competency_in_plan($userid, $competencyid, $planid, $grade, $override) {
|
||||
public static function grade_competency_in_plan($planorid, $competencyid, $grade, $override) {
|
||||
global $USER;
|
||||
$context = context_user::instance($userid);
|
||||
|
||||
$plan = $planorid;
|
||||
if (!is_object($planorid)) {
|
||||
$plan = new plan($planorid);
|
||||
}
|
||||
$context = $plan->get_context();
|
||||
if ($override) {
|
||||
require_capability('tool/lp:competencygrade', $context);
|
||||
} else {
|
||||
@ -2753,10 +2738,6 @@ class api {
|
||||
|
||||
// Verify the data.
|
||||
|
||||
$plan = new plan($planid);
|
||||
if ($plan->get_userid() != $userid) {
|
||||
throw new coding_exception('The plan does not belong to this user: ' . $planid . ', ' . $userid);
|
||||
}
|
||||
|
||||
$userplancompetencies = self::list_plan_competencies($plan);
|
||||
$competency = null;
|
||||
@ -2777,7 +2758,7 @@ class api {
|
||||
$desckey = 'evidence_manualsuggestinplan';
|
||||
}
|
||||
|
||||
return self::add_evidence($userid,
|
||||
return self::add_evidence($plan->get_userid(),
|
||||
$competency,
|
||||
$context->id,
|
||||
$action,
|
||||
|
@ -48,6 +48,7 @@ use tool_lp\external\user_summary_exporter;
|
||||
use tool_lp\external\user_competency_exporter;
|
||||
use tool_lp\external\user_competency_plan_exporter;
|
||||
use tool_lp\external\user_competency_summary_exporter;
|
||||
use tool_lp\external\user_competency_summary_in_plan_exporter;
|
||||
use tool_lp\external\user_evidence_exporter;
|
||||
use tool_lp\external\user_evidence_competency_exporter;
|
||||
use tool_lp\external\competency_exporter;
|
||||
@ -4122,9 +4123,9 @@ class external extends external_api {
|
||||
* @return \external_function_parameters
|
||||
*/
|
||||
public static function grade_competency_in_plan_parameters() {
|
||||
$userid = new external_value(
|
||||
$planid = new external_value(
|
||||
PARAM_INT,
|
||||
'User id',
|
||||
'Plan id',
|
||||
VALUE_REQUIRED
|
||||
);
|
||||
$competencyid = new external_value(
|
||||
@ -4132,11 +4133,6 @@ class external extends external_api {
|
||||
'Competency id',
|
||||
VALUE_REQUIRED
|
||||
);
|
||||
$planid = new external_value(
|
||||
PARAM_INT,
|
||||
'Plan id',
|
||||
VALUE_REQUIRED
|
||||
);
|
||||
$grade = new external_value(
|
||||
PARAM_INT,
|
||||
'New grade',
|
||||
@ -4149,9 +4145,8 @@ class external extends external_api {
|
||||
);
|
||||
|
||||
$params = array(
|
||||
'userid' => $userid,
|
||||
'competencyid' => $competencyid,
|
||||
'planid' => $planid,
|
||||
'competencyid' => $competencyid,
|
||||
'grade' => $grade,
|
||||
'override' => $override
|
||||
);
|
||||
@ -4161,29 +4156,34 @@ class external extends external_api {
|
||||
/**
|
||||
* Grade a competency in a plan.
|
||||
*
|
||||
* @param int $userid The user id
|
||||
* @param int $competencyid The competency id
|
||||
* @param int $planid The plan id
|
||||
* @param int $competencyid The competency id
|
||||
* @param int $grade The new grade value
|
||||
* @param bool $override Override the grade or only suggest it
|
||||
* @return bool
|
||||
*/
|
||||
public static function grade_competency_in_plan($userid, $competencyid, $planid, $grade, $override) {
|
||||
public static function grade_competency_in_plan($planid, $competencyid, $grade, $override) {
|
||||
global $USER, $PAGE;
|
||||
|
||||
$params = self::validate_parameters(self::grade_competency_in_plan_parameters(),
|
||||
array(
|
||||
'userid' => $userid,
|
||||
'competencyid' => $competencyid,
|
||||
'planid' => $planid,
|
||||
'competencyid' => $competencyid,
|
||||
'grade' => $grade,
|
||||
'override' => $override
|
||||
));
|
||||
|
||||
self::validate_context(context_user::instance($params['userid']));
|
||||
$plan = new plan($params['planid']);
|
||||
$context = $plan->get_context();
|
||||
self::validate_context($context);
|
||||
$output = $PAGE->get_renderer('tool_lp');
|
||||
|
||||
$evidence = api::grade_competency_in_plan($params['userid'], $params['competencyid'], $params['planid'], $params['grade'], $params['override']);
|
||||
$evidence = api::grade_competency_in_plan(
|
||||
$plan->get_id(),
|
||||
$params['competencyid'],
|
||||
$params['grade'],
|
||||
$params['override']
|
||||
);
|
||||
$competency = api::read_competency($params['competencyid']);
|
||||
$scale = $competency->get_scale();
|
||||
$exporter = new evidence_exporter($evidence, array('actionuser' => $USER, 'scale' => $scale));
|
||||
@ -4200,11 +4200,11 @@ class external extends external_api {
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns description of read_user_competency_summary() parameters.
|
||||
* Returns description of data_for_user_competency_summary_in_plan() parameters.
|
||||
*
|
||||
* @return \external_function_parameters
|
||||
*/
|
||||
public static function read_user_competency_summary_parameters() {
|
||||
public static function data_for_user_competency_summary_in_plan_parameters() {
|
||||
$userid = new external_value(
|
||||
PARAM_INT,
|
||||
'Data base record id for the user',
|
||||
@ -4218,8 +4218,7 @@ class external extends external_api {
|
||||
$planid = new external_value(
|
||||
PARAM_INT,
|
||||
'Data base record id for the plan',
|
||||
VALUE_DEFAULT,
|
||||
0
|
||||
VALUE_REQUIRED
|
||||
);
|
||||
|
||||
$params = array(
|
||||
@ -4238,11 +4237,9 @@ class external extends external_api {
|
||||
* @param int $planid The plan id
|
||||
* @return \stdClass
|
||||
*/
|
||||
public static function read_user_competency_summary($userid, $competencyid, $planid) {
|
||||
public static function data_for_user_competency_summary_in_plan($userid, $competencyid, $planid) {
|
||||
global $PAGE, $DB, $CFG;
|
||||
require_once($CFG->dirroot . '/user/lib.php');
|
||||
|
||||
$params = self::validate_parameters(self::read_user_competency_summary_parameters(),
|
||||
$params = self::validate_parameters(self::data_for_user_competency_summary_in_plan_parameters(),
|
||||
array(
|
||||
'userid' => $userid,
|
||||
'competencyid' => $competencyid,
|
||||
@ -4251,52 +4248,53 @@ class external extends external_api {
|
||||
$context = context_user::instance($params['userid']);
|
||||
self::validate_context($context);
|
||||
$output = $PAGE->get_renderer('tool_lp');
|
||||
require_capability('tool/lp:planview', $context);
|
||||
|
||||
$list = api::read_user_competencies($params['userid'], array($params['competencyid']));
|
||||
if ($list) {
|
||||
$usercompetency = array_pop($list);
|
||||
} else {
|
||||
$record = (object)array('userid' => $params['userid'], 'competencyid' => $params['competencyid']);
|
||||
$usercompetency = new user_competency(0, $record);
|
||||
$plan = api::read_plan($params['planid']);
|
||||
if ($plan->get_userid() != $params['userid']) {
|
||||
throw new invalid_parameter_exception('Invalid params. The plan does not belong to the user.');
|
||||
}
|
||||
|
||||
$records = api::list_plan_competencies($planid);
|
||||
|
||||
$competency = $usercompetency = $usercompetencyplan = null;
|
||||
foreach ($records as $record) {
|
||||
if ($record->competency->get_id() == $params['competencyid']) {
|
||||
$competency = $record->competency;
|
||||
$usercompetency = $record->usercompetency;
|
||||
$usercompetencyplan = $record->usercompetencyplan;
|
||||
break;
|
||||
}
|
||||
}
|
||||
if (empty($competency)) {
|
||||
throw new invalid_parameter_exception('Invalid params. The competency does not belong to the plan.');
|
||||
}
|
||||
|
||||
$competency = $usercompetency->get_competency();
|
||||
$relatedcompetencies = api::list_related_competencies($competency->get_id());
|
||||
$userid = $usercompetency->get_userid();
|
||||
$user = (object) array('id' => $userid);
|
||||
if (can_view_user_details_cap($user)) {
|
||||
$user = $DB->get_record('user', array('id' => $userid));
|
||||
} else {
|
||||
$user = null;
|
||||
}
|
||||
$plan = null;
|
||||
if ($params['planid']) {
|
||||
$plan = \tool_lp\api::read_plan($planid);
|
||||
}
|
||||
$evidence = api::list_evidence(0, $params['userid'], $params['competencyid']);
|
||||
$userid = $params['userid'];
|
||||
$user = $DB->get_record('user', array('id' => $userid));
|
||||
$evidence = api::list_evidence($params['userid'], $params['competencyid'], $plan->get_id());
|
||||
|
||||
$params = array(
|
||||
'competency' => $competency,
|
||||
'usercompetency' => $usercompetency,
|
||||
'usercompetencyplan' => $usercompetencyplan,
|
||||
'evidence' => $evidence,
|
||||
'user' => $user,
|
||||
'plan' => $plan,
|
||||
'relatedcompetencies' => $relatedcompetencies
|
||||
);
|
||||
$exporter = new user_competency_summary_exporter(null, $params);
|
||||
$exporter = new user_competency_summary_in_plan_exporter(null, $params);
|
||||
$data = $exporter->export($output);
|
||||
|
||||
return $data;
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns description of read_user_competency_summary() result value.
|
||||
* Returns description of data_for_user_competency_summary_in_plan() result value.
|
||||
*
|
||||
* @return \external_description
|
||||
*/
|
||||
public static function read_user_competency_summary_returns() {
|
||||
return user_competency_summary_exporter::get_read_structure();
|
||||
public static function data_for_user_competency_summary_in_plan_returns() {
|
||||
return user_competency_summary_in_plan_exporter::get_read_structure();
|
||||
}
|
||||
|
||||
}
|
||||
|
@ -66,6 +66,9 @@ class competency_summary_exporter extends exporter {
|
||||
),
|
||||
'hasrelatedcompetencies' => array(
|
||||
'type' => PARAM_BOOL
|
||||
),
|
||||
'scaleconfiguration' => array(
|
||||
'type' => PARAM_RAW
|
||||
)
|
||||
);
|
||||
}
|
||||
@ -100,6 +103,11 @@ 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();
|
||||
if ($competency->get_scaleid()) {
|
||||
$scaleconfiguration = $competency->get_scaleconfiguration();
|
||||
}
|
||||
$result->scaleconfiguration = $scaleconfiguration;
|
||||
|
||||
return (array) $result;
|
||||
}
|
||||
|
@ -34,7 +34,7 @@ use renderer_base;
|
||||
class evidence_exporter extends persistent_exporter {
|
||||
|
||||
protected static function define_related() {
|
||||
return array('actionuser' => '\\stdClass?',
|
||||
return array('actionuser' => '\\stdClass',
|
||||
'scale' => 'grade_scale');
|
||||
}
|
||||
|
||||
@ -44,11 +44,9 @@ class evidence_exporter extends persistent_exporter {
|
||||
|
||||
protected function get_other_values(renderer_base $output) {
|
||||
$other = array();
|
||||
if ($this->related['actionuser']) {
|
||||
$exporter = new user_summary_exporter($this->related['actionuser']);
|
||||
$actionuser = $exporter->export($output);
|
||||
$other['actionuser'] = $actionuser;
|
||||
}
|
||||
$exporter = new user_summary_exporter($this->related['actionuser']);
|
||||
$actionuser = $exporter->export($output);
|
||||
$other['actionuser'] = $actionuser;
|
||||
$other['description'] = $this->persistent->get_description();
|
||||
|
||||
$other['userdate'] = userdate($this->persistent->get_timecreated());
|
||||
|
@ -39,9 +39,9 @@ class user_competency_summary_exporter extends exporter {
|
||||
// We cache the context so it does not need to be retrieved from the framework every time.
|
||||
return array('competency' => '\\tool_lp\\competency',
|
||||
'relatedcompetencies' => '\\tool_lp\\competency[]',
|
||||
'user' => '\\stdClass?',
|
||||
'plan' => '\\tool_lp\\plan?',
|
||||
'usercompetency' => '\\tool_lp\\user_competency',
|
||||
'user' => '\\stdClass',
|
||||
'usercompetency' => '\\tool_lp\\user_competency?',
|
||||
'usercompetencyplan' => '\\tool_lp\\user_competency_plan?',
|
||||
'evidence' => '\\tool_lp\\evidence[]');
|
||||
}
|
||||
|
||||
@ -64,14 +64,14 @@ class user_competency_summary_exporter extends exporter {
|
||||
),
|
||||
'user' => array(
|
||||
'type' => user_summary_exporter::read_properties_definition(),
|
||||
'optional' => true
|
||||
),
|
||||
'plan' => array(
|
||||
'type' => plan_exporter::read_properties_definition(),
|
||||
'optional' => true
|
||||
),
|
||||
'usercompetency' => array(
|
||||
'type' => user_competency_exporter::read_properties_definition()
|
||||
'type' => user_competency_exporter::read_properties_definition(),
|
||||
'optional' => true
|
||||
),
|
||||
'usercompetencyplan' => array(
|
||||
'type' => user_competency_exporter::read_properties_definition(),
|
||||
'optional' => true
|
||||
),
|
||||
'evidence' => array(
|
||||
'type' => evidence_exporter::read_properties_definition(),
|
||||
@ -94,7 +94,8 @@ class user_competency_summary_exporter extends exporter {
|
||||
'relatedcompetencies' => $this->related['relatedcompetencies']
|
||||
));
|
||||
$result->competency = $exporter->export($output);
|
||||
$context = context_user::instance($this->related['usercompetency']->get_userid());
|
||||
|
||||
$context = context_user::instance($this->related['user']->id);
|
||||
$result->cangrade = has_capability('tool/lp:competencygrade', $context);
|
||||
$result->cansuggest = has_capability('tool/lp:competencysuggestgrade', $context);
|
||||
$result->cangradeorsuggest = $result->cangrade || $result->cansuggest;
|
||||
@ -102,12 +103,14 @@ class user_competency_summary_exporter extends exporter {
|
||||
$exporter = new user_summary_exporter($this->related['user']);
|
||||
$result->user = $exporter->export($output);
|
||||
}
|
||||
$exporter = new user_competency_exporter($this->related['usercompetency'], array('scale' => $competency->get_scale()));
|
||||
$result->usercompetency = $exporter->export($output);
|
||||
|
||||
if ($this->related['plan']) {
|
||||
$exporter = new plan_exporter($this->related['plan'], array('template' => $this->related['plan']->get_template()));
|
||||
$result->plan = $exporter->export($output);
|
||||
$related = array('scale' => $competency->get_scale());
|
||||
if ($this->related['usercompetency']) {
|
||||
$exporter = new user_competency_exporter($this->related['usercompetency'], $related);
|
||||
$result->usercompetency = $exporter->export($output);
|
||||
}
|
||||
if ($this->related['usercompetencyplan']) {
|
||||
$exporter = new user_competency_plan_exporter($this->related['usercompetencyplan'], $related);
|
||||
$result->usercompetency = $exporter->export($output);
|
||||
}
|
||||
|
||||
$allevidence = array();
|
||||
@ -128,20 +131,12 @@ class user_competency_summary_exporter extends exporter {
|
||||
}
|
||||
|
||||
foreach ($users as $user) {
|
||||
if (can_view_user_details_cap($user)) {
|
||||
$usercache[$user->id] = $user;
|
||||
} else {
|
||||
unset($usercache[$user->id]);
|
||||
}
|
||||
$usercache[$user->id] = $user;
|
||||
}
|
||||
|
||||
foreach ($this->related['evidence'] as $evidence) {
|
||||
$related = array('scale' => $scale);
|
||||
if (!empty($usercache[$evidence->get_actionuserid()])) {
|
||||
$related['actionuser'] = $usercache[$evidence->get_actionuserid()];
|
||||
} else {
|
||||
$related['actionuser'] = null;
|
||||
}
|
||||
$related['actionuser'] = $usercache[$evidence->get_actionuserid()];
|
||||
$exporter = new evidence_exporter($evidence, $related);
|
||||
$allevidence[] = $exporter->export($output);
|
||||
}
|
||||
|
74
admin/tool/lp/classes/external/user_competency_summary_in_plan_exporter.php
vendored
Normal file
74
admin/tool/lp/classes/external/user_competency_summary_in_plan_exporter.php
vendored
Normal file
@ -0,0 +1,74 @@
|
||||
<?php
|
||||
// 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/>.
|
||||
|
||||
/**
|
||||
* Class for exporting user competency data with all the evidence in a plan
|
||||
*
|
||||
* @package tool_lp
|
||||
* @copyright 2015 Damyon Wiese
|
||||
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
|
||||
*/
|
||||
namespace tool_lp\external;
|
||||
|
||||
use context_user;
|
||||
use renderer_base;
|
||||
use stdClass;
|
||||
|
||||
/**
|
||||
* Class for exporting user competency data with additional related data in a plan.
|
||||
*
|
||||
* @copyright 2015 Damyon Wiese
|
||||
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
|
||||
*/
|
||||
class user_competency_summary_in_plan_exporter extends exporter {
|
||||
|
||||
protected static function define_related() {
|
||||
// We cache the context so it does not need to be retrieved from the framework every time.
|
||||
return array('competency' => '\\tool_lp\\competency',
|
||||
'relatedcompetencies' => '\\tool_lp\\competency[]',
|
||||
'user' => '\\stdClass',
|
||||
'plan' => '\\tool_lp\\plan',
|
||||
'usercompetency' => '\\tool_lp\\user_competency?',
|
||||
'usercompetencyplan' => '\\tool_lp\\user_competency_plan?',
|
||||
'evidence' => '\\tool_lp\\evidence[]');
|
||||
}
|
||||
|
||||
protected static function define_other_properties() {
|
||||
return array(
|
||||
'usercompetencysummary' => array(
|
||||
'type' => user_competency_summary_exporter::read_properties_definition()
|
||||
),
|
||||
'plan' => array(
|
||||
'type' => plan_exporter::read_properties_definition(),
|
||||
)
|
||||
);
|
||||
}
|
||||
|
||||
protected function get_other_values(renderer_base $output) {
|
||||
// Arrays are copy on assign.
|
||||
$related = $this->related;
|
||||
// Remove plan from related as it is not wanted by the user_competency_summary_exporter.
|
||||
unset($related['plan']);
|
||||
$exporter = new user_competency_summary_exporter(null, $related);
|
||||
$result = new stdClass();
|
||||
$result->usercompetencysummary = $exporter->export($output);
|
||||
|
||||
$exporter = new plan_exporter($this->related['plan'], array('template' => $this->related['plan']->get_template()));
|
||||
$result->plan = $exporter->export($output);
|
||||
|
||||
return (array) $result;
|
||||
}
|
||||
}
|
@ -137,9 +137,9 @@ class renderer extends plugin_renderer_base {
|
||||
* @param renderable $page
|
||||
* @return string
|
||||
*/
|
||||
public function render_user_competency_plan_page(user_competency_plan_page $page) {
|
||||
public function render_user_competency_summary_in_plan_page(user_competency_summary_in_plan_page $page) {
|
||||
$data = $page->export_for_template($this);
|
||||
return parent::render_from_template('tool_lp/user_competency_info', $data);
|
||||
return parent::render_from_template('tool_lp/user_competency_summary_in_plan', $data);
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -38,7 +38,7 @@ use tool_lp\external\plan_exporter;
|
||||
* @copyright 2015 Damyon Wiese
|
||||
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
|
||||
*/
|
||||
class user_competency_plan_page implements renderable, templatable {
|
||||
class user_competency_summary_in_plan_page implements renderable, templatable {
|
||||
|
||||
/** @var userid */
|
||||
protected $userid;
|
||||
@ -69,6 +69,6 @@ class user_competency_plan_page implements renderable, templatable {
|
||||
* @return stdClass
|
||||
*/
|
||||
public function export_for_template(\renderer_base $output) {
|
||||
return \tool_lp\external::read_user_competency_summary($this->userid, $this->competencyid, $this->planid);
|
||||
return \tool_lp\external::data_for_user_competency_summary_in_plan($this->userid, $this->competencyid, $this->planid);
|
||||
}
|
||||
}
|
@ -672,9 +672,9 @@ $functions = array(
|
||||
'capabilities' => 'tool/lp:competencygrade',
|
||||
'ajax' => true,
|
||||
),
|
||||
'tool_lp_read_user_competency_summary' => array(
|
||||
'tool_lp_data_for_user_competency_summary_in_plan' => array(
|
||||
'classname' => 'tool_lp\external',
|
||||
'methodname' => 'read_user_competency_summary',
|
||||
'methodname' => 'data_for_user_competency_summary_in_plan',
|
||||
'classpath' => '',
|
||||
'description' => 'Load a summary of a user competency.',
|
||||
'type' => 'read',
|
||||
|
@ -81,10 +81,12 @@ $string['duplicateditemname'] = '{$a} (copy)';
|
||||
$string['editcompetency'] = 'Edit competency';
|
||||
$string['editcompetencyframework'] = 'Edit competency framework';
|
||||
$string['editplan'] = 'Edit learning plan';
|
||||
$string['editrating'] = 'Edit rating';
|
||||
$string['edittemplate'] = 'Edit learning plan template';
|
||||
$string['editthisplan'] = 'Edit this learning plan';
|
||||
$string['editthisuserevidence'] = 'Edit this evidence';
|
||||
$string['edituserevidence'] = 'Edit evidence';
|
||||
$string['evidence'] = 'Evidence';
|
||||
$string['evidence_competencyrule'] = 'The rule of the competency was met.';
|
||||
$string['evidence_coursecompleted'] = 'The course \'{$a}\' was completed.';
|
||||
$string['evidence_evidenceofpriorlearninglinked'] = 'The evidence of prior learning \'{$a}\' was linked.';
|
||||
@ -157,6 +159,7 @@ $string['nocompetenciesintemplate'] = 'No competencies have been linked to this
|
||||
$string['nocompetencyframeworks'] = 'No competency frameworks have been created yet.';
|
||||
$string['nocompetencyselected'] = 'No competency selected';
|
||||
$string['nofiles'] = 'No files';
|
||||
$string['noevidence'] = 'No evidence';
|
||||
$string['nolinkedcourses'] = 'No courses are linked to this competency';
|
||||
$string['noplanswerecreated'] = 'No plans were created.';
|
||||
$string['norelatedcompetencies'] = 'No other competencies have been related to this competency.';
|
||||
@ -167,6 +170,7 @@ $string['nouserplans'] = 'No learning plans have been created yet.';
|
||||
$string['oneplanwascreated'] = 'A plan was created';
|
||||
$string['outcome'] = 'Outcome';
|
||||
$string['parentcompetency'] = 'Parent competency';
|
||||
$string['plancompleted'] = 'Plan completed';
|
||||
$string['plancreated'] = 'Learning plan created';
|
||||
$string['plandescription'] = 'Description';
|
||||
$string['planname'] = 'Name';
|
||||
@ -181,6 +185,7 @@ $string['points'] = 'Points';
|
||||
$string['pointsgivenfor'] = 'Points given for \'{$a}\'';
|
||||
$string['pointsrequiredaremet'] = 'Points required are met';
|
||||
$string['proficient'] = 'Proficient';
|
||||
$string['rate'] = 'Rate';
|
||||
$string['rating'] = 'Rating';
|
||||
$string['relatedcompetencies'] = 'Related competencies';
|
||||
$string['reopenplan'] = 'Reopen this learning plan';
|
||||
@ -198,6 +203,7 @@ $string['shortname'] = 'Name';
|
||||
$string['state'] = 'State';
|
||||
$string['status'] = 'Status';
|
||||
$string['stopsyncingcohort'] = 'Stop syncing cohort';
|
||||
$string['suggest'] = 'Suggest';
|
||||
$string['syncplanscohorts'] = 'Sync plans from template cohorts';
|
||||
$string['taxonomies'] = 'Taxonomies';
|
||||
$string['taxonomy_add_behaviour'] = 'Add behaviour';
|
||||
@ -279,7 +285,3 @@ $string['userplans'] = 'User plans';
|
||||
$string['visible'] = 'Visible';
|
||||
$string['visible_help'] = 'A competency framework can be hidden from teachers. This could be useful if a framework is still in the process of being developed.';
|
||||
$string['when'] = 'When';
|
||||
$string['noevidence'] = 'No evidence';
|
||||
$string['evidence'] = 'Evidence';
|
||||
$string['grade'] = 'Grade';
|
||||
$string['suggest'] = 'Suggest';
|
||||
|
@ -1,15 +1,59 @@
|
||||
{{!
|
||||
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/>.
|
||||
}}
|
||||
{{!
|
||||
@template tool_lp/evidence_summary
|
||||
|
||||
Moodle template for the the summary of a single piece of evidence.
|
||||
|
||||
Classes required for JS:
|
||||
* none
|
||||
|
||||
Data attributes required for JS:
|
||||
* none
|
||||
|
||||
Context variables required for this template:
|
||||
* actionuser User record from a user_summary_exporter
|
||||
* userdate User formatted date this evidence was created
|
||||
* grade Raw grade value if set
|
||||
* gradename Scale grade item
|
||||
* description Description of the evidence
|
||||
* url Optional url for the evidence
|
||||
|
||||
Example context (json):
|
||||
{ "actionuser": { "id": 1, "fullname": "Legend", "profileimageurlsmall": "https://secure.gravatar.com/avatar/78f83716ad197a25e175fbb747cff1ff?s=35&d=mm" },
|
||||
"userdate": "Tuesday...",
|
||||
"grade": 2,
|
||||
"gradename": "Met",
|
||||
"description": "The user competency was manually suggested in the plan Personal plan A",
|
||||
"url": "http://moodle.org/"
|
||||
}
|
||||
}}
|
||||
<div class="well well-small evidence">
|
||||
{{#actionuser}}
|
||||
<div>
|
||||
{{> tool_lp/form-user-selector-suggestion }}
|
||||
</div>
|
||||
<div>
|
||||
{{> tool_lp/form-user-selector-suggestion }}
|
||||
</div>
|
||||
{{/actionuser}}
|
||||
<strong><time datetime="{{userdate}}">{{userdate}}</time></strong>
|
||||
{{#grade}}
|
||||
<p><span class="label">{{gradename}}</span></p>
|
||||
<p><span class="label">{{gradename}}</span></p>
|
||||
{{/grade}}
|
||||
<p>{{description}}</p>
|
||||
{{#url}}
|
||||
<p><a href="{{url}}" target="_blank" rel="noreferrer">{{url}}</a></p>
|
||||
<p><a href="{{url}}" target="_blank" rel="noreferrer">{{url}}</a></p>
|
||||
{{/url}}
|
||||
</div>
|
||||
|
@ -1,31 +0,0 @@
|
||||
<form class="form-inline pull-left" id="grade-competency-form-{{uniqid}}">
|
||||
{{#cangrade}}
|
||||
<div class="btn-group">
|
||||
<button class="btn btn-primary" data-action="grade">{{#str}}grade, tool_lp{{/str}}</button>
|
||||
{{/cangrade}}
|
||||
{{#cansuggest}}
|
||||
<button class="btn btn-inverse" data-action="suggest">{{#str}}suggest, tool_lp{{/str}}</button>
|
||||
{{/cansuggest}}
|
||||
</div>
|
||||
|
||||
<select>
|
||||
</select>
|
||||
</form>
|
||||
{{#js}}
|
||||
require(['jquery', 'tool_lp/grade_user_competency_inline', 'tool_lp/user_competency_info'], function($, mod, info) {
|
||||
var competencyScaleConfig = '{{{competency.competency.scaleconfiguration}}}';
|
||||
var frameworkScaleConfig = '{{{competency.framework.scaleconfiguration}}}';
|
||||
var scaleConfig = frameworkScaleConfig;
|
||||
{{#competency.competency.scaleid}}
|
||||
scaleConfig = competencyScaleConfig;
|
||||
{{/competency.competency.scaleid}}
|
||||
scaleConfig = JSON.parse(scaleConfig);
|
||||
|
||||
var inlineGrader = new mod('grade-competency-form-{{uniqid}}', scaleConfig, '{{competency.competency.id}}', '{{user.id}}', '{{plan.id}}');
|
||||
var competencyElement = $(document.getElementById('grade-competency-form-{{uniqid}}')).closest('[data-region=user-competency-full-info]');
|
||||
var infoReloader = new info(competencyElement, '{{competency.competency.id}}', '{{user.id}}', '{{plan.id}}');
|
||||
|
||||
inlineGrader.on('competencyupdated', infoReloader.reload.bind(infoReloader));
|
||||
});
|
||||
|
||||
{{/js}}
|
@ -1 +1,29 @@
|
||||
{{!
|
||||
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/>.
|
||||
}}
|
||||
{{!
|
||||
Manage learning plan templates template.
|
||||
|
||||
Classes required for JS:
|
||||
* None
|
||||
|
||||
Data attibutes required for JS:
|
||||
* None
|
||||
|
||||
Context variables required for this template:
|
||||
* None
|
||||
}}
|
||||
{{#pix}}y/loading, core, {{#str}}loading, tool_lp{{/str}}{{/pix}}
|
||||
|
@ -79,7 +79,7 @@
|
||||
{{#plan.canbeedited}}
|
||||
<span class="drag-handlecontainer pull-left"></span>
|
||||
{{/plan.canbeedited}}
|
||||
<a href="{{pluginbaseurl}}/usercompetencyplan.php?competencyid={{competency.id}}&userid={{plan.userid}}&planid={{plan.id}}">{{competency.shortname}}</a>
|
||||
<a href="{{pluginbaseurl}}/user_competency_in_plan.php?competencyid={{competency.id}}&userid={{plan.userid}}&planid={{plan.id}}">{{competency.shortname}}</a>
|
||||
<em>{{competency.idnumber}}</em>
|
||||
</td>
|
||||
{{#plan.iscompleted}}
|
||||
|
@ -2,8 +2,8 @@
|
||||
<p>
|
||||
<strong>{{#str}}relatedcompetencies, tool_lp{{/str}}:</strong>
|
||||
</p>
|
||||
{{#relatedcompetencies}}
|
||||
<ul>
|
||||
<ul>
|
||||
{{#relatedcompetencies}}
|
||||
<li>
|
||||
{{#showdeleterelatedaction}}
|
||||
<div class="pull-right">
|
||||
@ -16,8 +16,8 @@
|
||||
</a>
|
||||
</p>
|
||||
</li>
|
||||
</ul>
|
||||
{{/relatedcompetencies}}
|
||||
{{/relatedcompetencies}}
|
||||
</ul>
|
||||
{{^relatedcompetencies}}
|
||||
{{#str}}norelatedcompetencies, tool_lp{{/str}}
|
||||
{{/relatedcompetencies}}
|
||||
|
@ -1,31 +0,0 @@
|
||||
<div data-region="user-competency-full-info" >
|
||||
<div data-region="competency-summary">
|
||||
{{#competency}}
|
||||
{{> tool_lp/competency_summary }}
|
||||
{{/competency}}
|
||||
<dl>
|
||||
<dt>{{#str}}grade, tool_lp{{/str}}</dt>
|
||||
<dd>{{usercompetency.gradename}}</dd>
|
||||
{{#cangradeorsuggest}}
|
||||
<dt>{{#str}}editgrade, grades{{/str}}</dt>
|
||||
<dd>{{> tool_lp/grade_user_competency_form }}</dd>
|
||||
{{/cangradeorsuggest}}
|
||||
<dt>{{#str}}proficient, tool_lp{{/str}}</dt>
|
||||
<dd>
|
||||
<span class="label{{^usercompetency.proficiency}} label-important{{/usercompetency.proficiency}} pull-left">
|
||||
{{usercompetency.proficiencyname}}
|
||||
</span>
|
||||
</dd>
|
||||
</dl>
|
||||
<dl data-region="evidence-listing">
|
||||
<dt>{{#str}}evidence, tool_lp{{/str}}</dt>
|
||||
<dd>
|
||||
{{#evidence}}
|
||||
{{> tool_lp/evidence_summary }}
|
||||
{{/evidence}}
|
||||
{{^evidence}}
|
||||
<p>{{#str}}noevidence, tool_lp{{/str}}</p>
|
||||
{{/evidence}}
|
||||
</dd>
|
||||
</dl>
|
||||
</div>
|
123
admin/tool/lp/templates/user_competency_summary_in_plan.mustache
Normal file
123
admin/tool/lp/templates/user_competency_summary_in_plan.mustache
Normal file
@ -0,0 +1,123 @@
|
||||
{{!
|
||||
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/>.
|
||||
}}
|
||||
{{!
|
||||
@template tool_lp/user_competency_summary_in_plan
|
||||
|
||||
Moodle template for the the summary of a user competency
|
||||
|
||||
Classes required for JS:
|
||||
* none
|
||||
|
||||
Data attributes required for JS:
|
||||
* none
|
||||
|
||||
Context variables required for this template:
|
||||
* usercompetencysummary - object containing:
|
||||
* showrelatedcompetencies - boolean
|
||||
* cangrade - boolean
|
||||
* cansuggest - boolean
|
||||
* cangradeorsuggest - boolean
|
||||
* competency - competency summary record
|
||||
* user - user record
|
||||
* usercompetency - user competency record
|
||||
* evidence - array of evidence
|
||||
* plan - plan summary record
|
||||
|
||||
This template does not have an example context because it includes ajax functionality.
|
||||
}}
|
||||
{{#usercompetencysummary}}
|
||||
<div data-region="user-competency-full-info" >
|
||||
<div data-region="competency-summary">
|
||||
{{#competency}}
|
||||
{{> tool_lp/competency_summary }}
|
||||
{{/competency}}
|
||||
<dl>
|
||||
<dt>{{#str}}rating, tool_lp{{/str}}</dt>
|
||||
{{#usercompetency}}
|
||||
<dd>{{gradename}}</dd>
|
||||
{{#cangradeorsuggest}}
|
||||
<dt>{{#str}}editrating, tool_lp{{/str}}</dt>
|
||||
<dd>
|
||||
<form class="form-inline pull-left" id="grade-competency-form-{{uniqid}}">
|
||||
<select></select>
|
||||
<div class="btn-group">
|
||||
{{#cangrade}}
|
||||
<button class="btn btn-primary" data-action="grade">{{#str}}rate, tool_lp{{/str}}</button>
|
||||
{{/cangrade}}
|
||||
{{#cansuggest}}
|
||||
<button class="btn btn-inverse" data-action="suggest">{{#str}}suggest, tool_lp{{/str}}</button>
|
||||
{{/cansuggest}}
|
||||
</div>
|
||||
|
||||
</form>
|
||||
</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('grade-competency-form-{{uniqid}}', scaleConfig, '{{competency.competency.id}}', '{{user.id}}', '{{plan.id}}');
|
||||
var competencyElement = $(document.getElementById('grade-competency-form-{{uniqid}}')).closest('[data-region=user-competency-full-info]');
|
||||
var infoReloader = new info(competencyElement, '{{competency.competency.id}}', '{{user.id}}', '{{plan.id}}');
|
||||
|
||||
inlineGrader.on('competencyupdated', infoReloader.reload.bind(infoReloader));
|
||||
});
|
||||
|
||||
{{/js}}
|
||||
{{/cangradeorsuggest}}
|
||||
<dt>{{#str}}proficient, tool_lp{{/str}}</dt>
|
||||
<dd>
|
||||
<span class="label{{^proficiency}} label-important{{/proficiency}} pull-left">
|
||||
{{proficiencyname}}
|
||||
</span>
|
||||
</dd>
|
||||
{{/usercompetency}}
|
||||
{{#usercompetencyplan}}
|
||||
<dd>{{gradename}} - {{#str}}plancompleted, tool_lp{{/str}}</dd>
|
||||
{{#cangradeorsuggest}}
|
||||
Hi
|
||||
{{$gradeform}}
|
||||
<!-- Grading a user competency is specific to the context you are in. -->
|
||||
{{/gradeform}}
|
||||
{{/cangradeorsuggest}}
|
||||
<dt>{{#str}}proficient, tool_lp{{/str}}</dt>
|
||||
<dd>
|
||||
<span class="label{{^proficiency}} label-important{{/proficiency}} pull-left">
|
||||
{{proficiencyname}}
|
||||
</span>
|
||||
</dd>
|
||||
{{/usercompetencyplan}}
|
||||
</dl>
|
||||
<dl data-region="evidence-listing">
|
||||
<dt>{{#str}}evidence, tool_lp{{/str}}</dt>
|
||||
<dd>
|
||||
{{#evidence}}
|
||||
{{> tool_lp/evidence_summary }}
|
||||
{{/evidence}}
|
||||
{{^evidence}}
|
||||
<p>{{#str}}noevidence, tool_lp{{/str}}</p>
|
||||
{{/evidence}}
|
||||
</dd>
|
||||
</dl>
|
||||
</div>
|
||||
{{/usercompetencysummary}}
|
||||
|
||||
{{#js}}
|
||||
require(['tool_lp/competencydialogue'], function(Compdialogue) {
|
||||
var competencydialogue = new Compdialogue({includerelated : true});
|
||||
competencydialogue.watch('[data-region="competency-summary"]');
|
||||
});
|
||||
{{/js}}
|
@ -2638,25 +2638,25 @@ class tool_lp_external_testcase extends externallib_advanced_testcase {
|
||||
|
||||
$uc = $lpg->create_user_competency(array('userid' => $this->user->id, 'competencyid' => $c1->get_id()));
|
||||
|
||||
$evidence = external::grade_competency_in_plan($this->user->id, $c1->get_id(), $plan->get_id(), 1, false);
|
||||
$evidence = external::grade_competency_in_plan($plan->get_id(), $c1->get_id(), 1, false);
|
||||
|
||||
$this->assertEquals('The competency grade was manually suggested in the plan \'Evil\'.', $evidence->description);
|
||||
$this->assertEquals('A', $evidence->gradename);
|
||||
$evidence = external::grade_competency_in_plan($this->user->id, $c1->get_id(), $plan->get_id(), 1, true);
|
||||
$evidence = external::grade_competency_in_plan($plan->get_id(), $c1->get_id(), 1, true);
|
||||
|
||||
$this->assertEquals('The competency grade was manually set in the plan \'Evil\'.', $evidence->description);
|
||||
$this->assertEquals('A', $evidence->gradename);
|
||||
|
||||
$this->setUser($this->user);
|
||||
$evidence = external::grade_competency_in_plan($this->user->id, $c1->get_id(), $plan->get_id(), 1, false);
|
||||
$evidence = external::grade_competency_in_plan($plan->get_id(), $c1->get_id(), 1, false);
|
||||
$this->assertEquals('The competency grade was manually suggested in the plan \'Evil\'.', $evidence->description);
|
||||
$this->assertEquals('A', $evidence->gradename);
|
||||
|
||||
$this->setExpectedException('required_capability_exception');
|
||||
$evidence = external::grade_competency_in_plan($this->user->id, $c1->get_id(), $plan->get_id(), 1, true);
|
||||
$evidence = external::grade_competency_in_plan($plan->get_id(), $c1->get_id(), 1, true);
|
||||
}
|
||||
|
||||
public function test_read_user_competency_summary() {
|
||||
public function test_data_for_user_competency_summary_in_plan() {
|
||||
global $CFG;
|
||||
|
||||
$this->setUser($this->creator);
|
||||
@ -2675,16 +2675,16 @@ class tool_lp_external_testcase extends externallib_advanced_testcase {
|
||||
|
||||
$uc = $lpg->create_user_competency(array('userid' => $this->user->id, 'competencyid' => $c1->get_id()));
|
||||
|
||||
$evidence = external::grade_competency_in_plan($this->user->id, $c1->get_id(), $plan->get_id(), 1, false);
|
||||
$evidence = external::grade_competency_in_plan($this->user->id, $c1->get_id(), $plan->get_id(), 2, true);
|
||||
$evidence = external::grade_competency_in_plan($plan->get_id(), $c1->get_id(), 1, false);
|
||||
$evidence = external::grade_competency_in_plan($plan->get_id(), $c1->get_id(), 1, true);
|
||||
|
||||
$summary = external::read_user_competency_summary($this->user->id, $c1->get_id(), $plan->get_id());
|
||||
$this->assertTrue($summary->cangrade);
|
||||
$this->assertTrue($summary->cansuggest);
|
||||
$summary = external::data_for_user_competency_summary_in_plan($this->user->id, $c1->get_id(), $plan->get_id());
|
||||
$this->assertTrue($summary->usercompetencysummary->cangrade);
|
||||
$this->assertTrue($summary->usercompetencysummary->cansuggest);
|
||||
$this->assertEquals('Evil', $summary->plan->name);
|
||||
$this->assertEquals('B', $summary->usercompetency->gradename);
|
||||
$this->assertEquals('B', $summary->evidence[0]->gradename);
|
||||
$this->assertEquals('A', $summary->evidence[1]->gradename);
|
||||
$this->assertEquals('B', $summary->usercompetencysummary->usercompetency->gradename);
|
||||
$this->assertEquals('B', $summary->usercompetencysummary->evidence[0]->gradename);
|
||||
$this->assertEquals('A', $summary->usercompetencysummary->evidence[1]->gradename);
|
||||
}
|
||||
|
||||
}
|
||||
|
@ -39,21 +39,17 @@ $plan = \tool_lp\api::read_plan($planid);
|
||||
$url = new moodle_url('/admin/tool/lp/usercompetencyplan.php', $params);
|
||||
$competency = new \tool_lp\competency($competencyid);
|
||||
$framework = $competency->get_framework();
|
||||
$subtitle = get_string('taxonomy_' . $framework->get_taxonomy($competency->get_level()), 'tool_lp');
|
||||
$subtitle = $competency->get_shortname();
|
||||
|
||||
list($title, $subtitle) = \tool_lp\page_helper::setup_for_plan($userid, $url, $plan,
|
||||
$subtitle);
|
||||
|
||||
$output = $PAGE->get_renderer('tool_lp');
|
||||
echo $output->header();
|
||||
if ($userid != $USER->id) {
|
||||
echo $output->context_header($userid);
|
||||
} else {
|
||||
echo $output->heading($title);
|
||||
echo $output->heading($subtitle, 3);
|
||||
}
|
||||
echo $output->heading($title);
|
||||
echo $output->heading($subtitle, 3);
|
||||
|
||||
$page = new \tool_lp\output\user_competency_plan_page($userid, $competencyid, $planid);
|
||||
$page = new \tool_lp\output\user_competency_summary_in_plan_page($userid, $competencyid, $planid);
|
||||
echo $output->render($page);
|
||||
|
||||
echo $output->footer();
|
@ -25,6 +25,6 @@
|
||||
defined('MOODLE_INTERNAL') || die();
|
||||
|
||||
|
||||
$plugin->version = 2015111031; // The current plugin version (Date: YYYYMMDDXX).
|
||||
$plugin->version = 2015111032; // The current plugin version (Date: YYYYMMDDXX).
|
||||
$plugin->requires = 2014110400; // Requires this Moodle version.
|
||||
$plugin->component = 'tool_lp'; // Full name of the plugin (used for diagnostics).
|
||||
|
Loading…
x
Reference in New Issue
Block a user