Skip to content

Commit

Permalink
MDL-51036 tool_lp: Addressing comments left during peer review
Browse files Browse the repository at this point in the history
  • Loading branch information
Frederic Massart committed Apr 18, 2016
1 parent 572721a commit 182f609
Show file tree
Hide file tree
Showing 12 changed files with 59 additions and 23 deletions.
File renamed without changes.
2 changes: 1 addition & 1 deletion admin/tool/lp/amd/build/user_competency_workflow.min.js

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Expand Up @@ -14,9 +14,9 @@
// along with Moodle. If not, see <http://www.gnu.org/licenses/>.

/**
* Base javascript module.
* Event base javascript module.
*
* @module tool_lp/base
* @module tool_lp/event_base
* @package tool_lp
* @copyright 2015 Frédéric Massart - FMCorz.net
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
Expand Down Expand Up @@ -55,5 +55,5 @@ define(['jquery'], function($) {
this._eventNode.trigger(type, [data]);
};

return /** @alias module:tool_lp/base */ Base;
return /** @alias module:tool_lp/event_base */ Base;
});
8 changes: 4 additions & 4 deletions admin/tool/lp/amd/src/user_competency_workflow.js
Expand Up @@ -27,18 +27,18 @@ define(['jquery',
'core/notification',
'core/str',
'tool_lp/menubar',
'tool_lp/base'],
function($, Templates, Ajax, Notification, Str, Menubar, Base) {
'tool_lp/event_base'],
function($, Templates, Ajax, Notification, Str, Menubar, EventBase) {

/**
* UserCompetencyWorkflow class.
*
* @param {String} selector The node containing the buttons to switch mode.
*/
var UserCompetencyWorkflow = function() {
Base.prototype.constructor.apply(this, []);
EventBase.prototype.constructor.apply(this, []);
};
UserCompetencyWorkflow.prototype = Object.create(Base.prototype);
UserCompetencyWorkflow.prototype = Object.create(EventBase.prototype);

/** @type {String} The selector to find the user competency data. */
UserCompetencyWorkflow.prototype._nodeSelector = '[data-node="user-competency"]';
Expand Down
1 change: 1 addition & 0 deletions admin/tool/lp/classes/course_competency.php
Expand Up @@ -24,6 +24,7 @@
namespace tool_lp;
defined('MOODLE_INTERNAL') || die();

use coding_exception;
use stdClass;
use lang_string;

Expand Down
8 changes: 4 additions & 4 deletions admin/tool/lp/classes/external.php
Expand Up @@ -2714,7 +2714,7 @@ public static function user_competency_cancel_review_request($userid, $competenc
* @return \external_function_parameters
*/
public static function user_competency_cancel_review_request_returns() {
new external_value(PARAM_BOOL, 'The success');
return new external_value(PARAM_BOOL, 'The success');
}

/**
Expand Down Expand Up @@ -2754,7 +2754,7 @@ public static function user_competency_request_review($userid, $competencyid) {
* @return \external_function_parameters
*/
public static function user_competency_request_review_returns() {
new external_value(PARAM_BOOL, 'The success');
return new external_value(PARAM_BOOL, 'The success');
}

/**
Expand Down Expand Up @@ -2793,7 +2793,7 @@ public static function user_competency_start_review($userid, $competencyid) {
* @return \external_function_parameters
*/
public static function user_competency_start_review_returns() {
new external_value(PARAM_BOOL, 'The success');
return new external_value(PARAM_BOOL, 'The success');
}

/**
Expand Down Expand Up @@ -2832,7 +2832,7 @@ public static function user_competency_stop_review($userid, $competencyid) {
* @return \external_function_parameters
*/
public static function user_competency_stop_review_returns() {
new external_value(PARAM_BOOL, 'The success');
return new external_value(PARAM_BOOL, 'The success');
}

/**
Expand Down
1 change: 1 addition & 0 deletions admin/tool/lp/classes/external/comment_area_exporter.php
Expand Up @@ -26,6 +26,7 @@
namespace tool_lp\external;
require_once($CFG->dirroot . '/comment/lib.php');

// TODO MDL-52243 Move this to core.
defined('MOODLE_INTERNAL') || die();

use comment;
Expand Down
9 changes: 8 additions & 1 deletion admin/tool/lp/lang/en/tool_lp.php
Expand Up @@ -153,6 +153,12 @@
$string['lp:planviewowndraft'] = 'View own draft learning plans';
$string['lp:templatemanage'] = 'Manage templates';
$string['lp:templateread'] = 'View template';
$string['lp:usercompetencycomment'] = 'Comment on a user competency';
$string['lp:usercompetencycommentown'] = 'Comment on own user competency';
$string['lp:usercompetencyrequestreview'] = 'Request the review of a user competency';
$string['lp:usercompetencyrequestreviewown'] = 'Request the review of own user competency';
$string['lp:usercompetencyreview'] = 'Review a user competency';
$string['lp:usercompetencyview'] = 'View a user competency';
$string['lp:userevidencemanage'] = 'Manage evidence of prior learning';
$string['lp:userevidencemanageown'] = 'Manage own evidence of prior learning';
$string['lp:userevidenceread'] = 'View evidence of prior learning of a user';
Expand Down Expand Up @@ -203,6 +209,7 @@
$string['rate'] = 'Rate';
$string['rating'] = 'Rating';
$string['relatedcompetencies'] = 'Related competencies';
$string['reviewstatus'] = 'Review status';
$string['requestreview'] = 'Request review';
$string['reopenplan'] = 'Reopen this learning plan';
$string['reopenplanconfirm'] = 'Reopen the plan \'{$a}\'? The status of the users competencies that was recorded at the time the plan was previously completed will be deleted, and the plan will become active again.';
Expand All @@ -219,7 +226,7 @@
$string['startreview'] = 'Start review';
$string['state'] = 'State';
$string['status'] = 'Status';
$string['stopreview'] = 'Stop review';
$string['stopreview'] = 'Finish review';
$string['stopsyncingcohort'] = 'Stop syncing cohort';
$string['suggest'] = 'Suggest';
$string['syncplanscohorts'] = 'Sync plans from template cohorts';
Expand Down
15 changes: 11 additions & 4 deletions admin/tool/lp/lib.php
Expand Up @@ -222,6 +222,7 @@ function tool_lp_comment_add($comment, $params) {
}

// Urls.
// TODO MDL-52749 Replace the link to the plan with the user competency page.
if (empty($plan)) {
$urlname = get_string('userplans', 'tool_lp');
$url = new moodle_url('/admin/tool/lp/plans.php', array('userid' => $uc->get_userid()));
Expand Down Expand Up @@ -258,8 +259,8 @@ function tool_lp_comment_add($comment, $params) {
$message = new \core\message\message();
$message->component = 'tool_lp';
$message->name = 'user_competency_comment';
$message->notification = 0;
$message->userfrom = $comment->userid;
$message->notification = 1;
$message->userfrom = core_user::get_noreply_user();
$message->subject = get_string('usercommentedonacompetencysubject', 'tool_lp', $fullname);
$message->fullmessage = $fullmessage;
$message->fullmessageformat = $format;
Expand Down Expand Up @@ -299,8 +300,14 @@ function tool_lp_comment_permissions($params) {
* Validates comments.
*
* @param stdClass $params The parameters.
* @return array
* @return bool
*/
function tool_lp_comment_validate($params) {
return true;
if ($params->commentarea == 'user_competency') {
if (!\tool_lp\user_competency::record_exists($params->itemid)) {
return false;
}
return true;
}
return false;
}
28 changes: 24 additions & 4 deletions admin/tool/lp/templates/user_competency_summary_in_course.mustache
Expand Up @@ -40,13 +40,25 @@
This template does not have an example context because it includes ajax functionality.
}}
{{#usercompetencysummary}}
<div data-region="user-competency-full-info" >
<div data-region="user-competency-full-info" data-node="user-competency" data-competencyid="{{usercompetency.competencyid}}" data-userid="{{usercompetency.userid}}" data-region-id="{{uniqid}}">
<div data-region="competency-summary">
{{#competency}}
{{> tool_lp/competency_summary }}
{{/competency}}
<dl>
{{#usercompetency}}
<dt>{{#str}}reviewstatus, tool_lp{{/str}}</dt>
<dd data-region="user-competency-status">{{statusname}}

{{#isstatusinreview}}
- {{reviewer.fullname}}
{{/isstatusinreview}}

{{#isrequestreviewallowed}}<button data-action="request-review">{{#str}}requestreview, tool_lp{{/str}}</button>{{/isrequestreviewallowed}}
{{#iscancelreviewrequestallowed}}<button data-action="cancel-review-request">{{#str}}cancelreviewrequest, tool_lp{{/str}}</button>{{/iscancelreviewrequestallowed}}
{{#isstartreviewallowed}}<button data-action="start-review">{{#str}}startreview, tool_lp{{/str}}</button>{{/isstartreviewallowed}}
{{#isstopreviewallowed}}<button data-action="stop-review">{{#str}}stopreview, tool_lp{{/str}}</button>{{/isstopreviewallowed}}
</dd>
<dt>{{#str}}proficient, tool_lp{{/str}}</dt>
<dd>
<span class="label{{^proficiency}} label-important{{/proficiency}} pull-left">
Expand All @@ -71,20 +83,25 @@
</form>
<br><br>
</p>
{{/cangradeorsuggest}}
</dd>
{{#js}}
require(['jquery', 'tool_lp/grade_user_competency_inline', 'tool_lp/user_competency_info'], function($, mod, info) {
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 inlineGrader = new mod('grade-competency-form-{{uniqid}}', scaleConfig, '{{competency.competency.id}}', '{{user.id}}', '', '{{course.id}}', '{{#str}}chooserating, tool_lp{{/str}}');
var competencyElement = $(document.getElementById('grade-competency-form-{{uniqid}}')).closest('[data-region=user-competency-full-info]');
var competencyElement = $('[data-region-id="{{uniqid}}"]');
var infoReloader = new info(competencyElement, '{{competency.competency.id}}', '{{user.id}}', '', '{{course.id}}');
var ucw = new UserCompWorkflow();
ucw.registerEvents('[data-region="user-competency-status"]');
ucw.on('status-changed', infoReloader.reload.bind(infoReloader));
ucw.on('error-occured', infoReloader.reload.bind(infoReloader));
inlineGrader.on('competencyupdated', infoReloader.reload.bind(infoReloader));
});

{{/js}}
{{/cangradeorsuggest}}
{{/usercompetency}}
{{#usercompetencyplan}}
<dd>{{gradename}} - {{#str}}plancompleted, tool_lp{{/str}}</dd>
Expand All @@ -101,6 +118,9 @@
</dd>
{{/usercompetencyplan}}
</dl>
{{#commentarea}}
{{>tool_lp/comment_area}}
{{/commentarea}}
<dl data-region="evidence-listing">
<dt>{{#str}}evidence, tool_lp{{/str}}</dt>
<dd>
Expand Down
Expand Up @@ -47,7 +47,7 @@
{{/competency}}
<dl>
{{#usercompetency}}
<dt>{{#str}}status, tool_lp{{/str}}</dt>
<dt>{{#str}}reviewstatus, tool_lp{{/str}}</dt>
<dd data-region="user-competency-status">{{statusname}}

{{#isstatusinreview}}
Expand Down
2 changes: 1 addition & 1 deletion admin/tool/lp/version.php
Expand Up @@ -25,6 +25,6 @@
defined('MOODLE_INTERNAL') || die();


$plugin->version = 2015111036; // The current plugin version (Date: YYYYMMDDXX).
$plugin->version = 2015111037; // 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).

0 comments on commit 182f609

Please sign in to comment.