MDL-53700 competency: Migrate capabilities to core

This commit is contained in:
Frederic Massart 2016-04-04 14:49:50 +08:00
parent 1f7699533c
commit b90e2205b4
42 changed files with 791 additions and 821 deletions

File diff suppressed because it is too large Load diff

View file

@ -488,7 +488,7 @@ class competency_framework extends persistent {
* @return bool
*/
public static function can_manage_context($context) {
return has_capability('tool/lp:competencymanage', $context);
return has_capability('moodle/competency:competencymanage', $context);
}
/**
@ -507,7 +507,7 @@ class competency_framework extends persistent {
* @return bool
*/
public static function can_read_context($context) {
return has_capability('tool/lp:competencyview', $context) || self::can_manage_context($context);
return has_capability('moodle/competency:competencyview', $context) || self::can_manage_context($context);
}
}

View file

@ -88,7 +88,7 @@ class course_competency_settings extends persistent {
public static function can_read($courseid) {
$context = context_course::instance($courseid);
$capabilities = array('tool/lp:coursecompetencyview');
$capabilities = array('moodle/competency:coursecompetencyview');
return has_any_capability($capabilities, $context);
}
@ -102,7 +102,7 @@ class course_competency_settings extends persistent {
public static function can_manage_course($courseid) {
$context = context_course::instance($courseid);
$capabilities = array('tool/lp:coursecompetencyconfigure');
$capabilities = array('moodle/competency:coursecompetencyconfigure');
return has_any_capability($capabilities, $context);
}

View file

@ -54,7 +54,7 @@ class competency_framework_exporter extends persistent_exporter {
$filters = array('competencyframeworkid' => $this->persistent->get_id());
$context = $this->persistent->get_context();
return array(
'canmanage' => has_capability('tool/lp:competencymanage', $context),
'canmanage' => has_capability('moodle/competency:competencymanage', $context),
'competenciescount' => api::count_competencies($filters),
'contextname' => $context->get_context_name(),
'contextnamenoprefix' => $context->get_context_name(false)

View file

@ -96,8 +96,8 @@ class course_competency_statistics_exporter extends exporter {
'proficientcompetencypercentageformatted' => $proficientcompetencypercentageformatted,
'leastproficient' => $competencies,
'leastproficientcount' => count($competencies),
'canbegradedincourse' => has_capability('tool/lp:coursecompetencygradable', $this->related['context']),
'canmanagecoursecompetencies' => has_capability('tool/lp:coursecompetencymanage', $this->related['context'])
'canbegradedincourse' => has_capability('moodle/competency:coursecompetencygradable', $this->related['context']),
'canmanagecoursecompetencies' => has_capability('moodle/competency:coursecompetencymanage', $this->related['context'])
);
}
}

View file

@ -106,7 +106,7 @@ class framework_autocomplete extends MoodleQuickForm_autocomplete {
list($insql, $inparams) = $DB->get_in_or_equal($ids, SQL_PARAMS_NAMED, 'param');
$frameworks = competency_framework::get_records_select("id $insql", $inparams, 'shortname');
foreach ($frameworks as $framework) {
if (!has_any_capability(array('tool/lp:competencyview', 'tool/lp:competencymanage'), $framework->get_context())) {
if (!has_any_capability(array('moodle/competency:competencyview', 'moodle/competency:competencymanage'), $framework->get_context())) {
continue;
} else if ($this->onlyvisible && !$framework->get_visible()) {
continue;

View file

@ -75,7 +75,7 @@ class plan extends persistent {
// There is only one status to select from.
$mform->addElement('static', 'staticstatus', get_string('status', 'tool_lp'), current($status));
} else {
throw new required_capability_exception($context, 'tool/lp:planmanage', 'nopermissions', '');
throw new required_capability_exception($context, 'moodle/competency:planmanage', 'nopermissions', '');
}
// Disable short forms.

View file

@ -44,7 +44,7 @@ class template_plans extends moodleform {
$options = array(
'ajax' => 'tool_lp/form-user-selector',
'multiple' => true,
'data-capability' => 'tool/lp:planmanage'
'data-capability' => 'moodle/competency:planmanage'
);
$mform->addElement('autocomplete', 'users', get_string('selectuserstocreateplansfor', 'tool_lp'), array(), $options);
$mform->addElement('submit', 'submit', get_string('createplans', 'tool_lp'));

View file

@ -78,8 +78,8 @@ class course_competencies_page implements renderable, templatable {
$this->context = context_course::instance($courseid);
$this->courseid = $courseid;
$this->coursecompetencylist = api::list_course_competencies($courseid);
$this->canmanagecoursecompetencies = has_capability('tool/lp:coursecompetencymanage', $this->context);
$this->canconfigurecoursecompetencies = has_capability('tool/lp:coursecompetencyconfigure', $this->context);
$this->canmanagecoursecompetencies = has_capability('moodle/competency:coursecompetencymanage', $this->context);
$this->canconfigurecoursecompetencies = has_capability('moodle/competency:coursecompetencyconfigure', $this->context);
$this->coursecompetencysettings = api::read_course_competency_settings($courseid);
$this->coursecompetencystatistics = new course_competency_statistics($courseid);
@ -88,7 +88,7 @@ class course_competencies_page implements renderable, templatable {
$this->canmanagecompetencyframeworks = false;
$contexts = array_reverse($this->context->get_parent_contexts(true));
foreach ($contexts as $context) {
$canmanage = has_capability('tool/lp:competencymanage', $context);
$canmanage = has_capability('moodle/competency:competencymanage', $context);
if ($canmanage) {
$this->manageurl = new moodle_url('/admin/tool/lp/competencyframeworks.php',
array('pagecontextid' => $context->id));
@ -113,7 +113,7 @@ class course_competencies_page implements renderable, templatable {
$data->competencies = array();
$contextcache = array();
$gradable = is_enrolled($this->context, $USER, 'tool/lp:coursecompetencygradable');
$gradable = is_enrolled($this->context, $USER, 'moodle/competency:coursecompetencygradable');
if ($gradable) {
$usercompetencycourses = api::list_user_competencies_in_course($this->courseid, $USER->id);
$data->gradableuserid = $USER->id;

View file

@ -79,7 +79,7 @@ class manage_competencies_page implements renderable, templatable {
);
$this->navigation[] = $addpage;
$this->canmanage = has_capability('tool/lp:competencymanage', $framework->get_context());
$this->canmanage = has_capability('moodle/competency:competencymanage', $framework->get_context());
}
/**

View file

@ -61,7 +61,7 @@ class template_cohorts_table extends table_sql {
// This object should not be used without the right permissions.
if (!$template->can_read()) {
throw new \required_capability_exception($template->get_context(), 'tool/lp:templateview', 'nopermissions', '');
throw new \required_capability_exception($template->get_context(), 'moodle/competency:templateview', 'nopermissions', '');
}
// Set protected properties.

View file

@ -78,8 +78,8 @@ class template_competencies_page implements renderable, templatable {
$this->template = $template;
$this->templatestatistics = new template_statistics($template->get_id());
$this->competencies = api::list_competencies_in_template($template);
$this->canmanagecompetencyframeworks = has_capability('tool/lp:competencymanage', $this->pagecontext);
$this->canmanagetemplatecompetencies = has_capability('tool/lp:templatemanage', $this->pagecontext);
$this->canmanagecompetencyframeworks = has_capability('moodle/competency:competencymanage', $this->pagecontext);
$this->canmanagetemplatecompetencies = has_capability('moodle/competency:templatemanage', $this->pagecontext);
$this->manageurl = new moodle_url('/admin/tool/lp/competencyframeworks.php',
array('pagecontextid' => $this->pagecontext->id));
}

View file

@ -61,7 +61,7 @@ class template_plans_table extends table_sql {
// This object should not be used without the right permissions.
if (!$template->can_read()) {
throw new \required_capability_exception($template->get_context(), 'tool/lp:templateview', 'nopermissions', '');
throw new \required_capability_exception($template->get_context(), 'moodle/competency:templateview', 'nopermissions', '');
}
// Set protected properties.

View file

@ -85,7 +85,7 @@ class user_competency_course_navigation implements renderable, templatable {
$data->baseurl = $this->baseurl;
$data->groupselector = '';
if (has_capability('tool/lp:coursecompetencymanage', $context)) {
if (has_capability('moodle/competency:coursecompetencymanage', $context)) {
$course = $DB->get_record('course', array('id' => $this->courseid));
$currentgroup = groups_get_course_group($course, true);
if ($currentgroup !== false) {
@ -97,7 +97,7 @@ class user_competency_course_navigation implements renderable, templatable {
$showonlyactiveenrol = get_user_preferences('grade_report_showonlyactiveenrol', $defaultgradeshowactiveenrol);
$showonlyactiveenrol = $showonlyactiveenrol || !has_capability('moodle/course:viewsuspendedusers', $context);
$users = get_enrolled_users($context, 'tool/lp:coursecompetencygradable', $currentgroup,
$users = get_enrolled_users($context, 'moodle/competency:coursecompetencygradable', $currentgroup,
'u.*', null, 0, 0, $showonlyactiveenrol);
$data->users = array();

View file

@ -364,9 +364,9 @@ class plan extends persistent {
public static function can_comment_user($planuserid) {
global $USER;
$capabilities = array('tool/lp:plancomment');
$capabilities = array('moodle/competency:plancomment');
if ($USER->id == $planuserid) {
$capabilities[] = 'tool/lp:plancommentown';
$capabilities[] = 'moodle/competency:plancommentown';
}
return has_any_capability($capabilities, context_user::instance($planuserid));
@ -382,9 +382,9 @@ class plan extends persistent {
global $USER;
$context = context_user::instance($planuserid);
$capabilities = array('tool/lp:planmanage');
$capabilities = array('moodle/competency:planmanage');
if ($context->instanceid == $USER->id) {
$capabilities[] = 'tool/lp:planmanageown';
$capabilities[] = 'moodle/competency:planmanageown';
}
return has_any_capability($capabilities, $context);
@ -400,9 +400,9 @@ class plan extends persistent {
global $USER;
$context = context_user::instance($planuserid);
$capabilities = array('tool/lp:planmanagedraft');
$capabilities = array('moodle/competency:planmanagedraft');
if ($context->instanceid == $USER->id) {
$capabilities[] = 'tool/lp:planmanageowndraft';
$capabilities[] = 'moodle/competency:planmanageowndraft';
}
return has_any_capability($capabilities, $context);
@ -429,9 +429,9 @@ class plan extends persistent {
global $USER;
$context = context_user::instance($planuserid);
$capabilities = array('tool/lp:planview');
$capabilities = array('moodle/competency:planview');
if ($context->instanceid == $USER->id) {
$capabilities[] = 'tool/lp:planviewown';
$capabilities[] = 'moodle/competency:planviewown';
}
return has_any_capability($capabilities, $context)
@ -448,9 +448,9 @@ class plan extends persistent {
global $USER;
$context = context_user::instance($planuserid);
$capabilities = array('tool/lp:planviewdraft');
$capabilities = array('moodle/competency:planviewdraft');
if ($context->instanceid == $USER->id) {
$capabilities[] = 'tool/lp:planviewowndraft';
$capabilities[] = 'moodle/competency:planviewowndraft';
}
return has_any_capability($capabilities, $context)
@ -466,9 +466,9 @@ class plan extends persistent {
public static function can_request_review_user($planuserid) {
global $USER;
$capabilities = array('tool/lp:planrequestreview');
$capabilities = array('moodle/competency:planrequestreview');
if ($USER->id == $planuserid) {
$capabilities[] = 'tool/lp:planrequestreviewown';
$capabilities[] = 'moodle/competency:planrequestreviewown';
}
return has_any_capability($capabilities, context_user::instance($planuserid));
@ -483,7 +483,7 @@ class plan extends persistent {
* @return bool
*/
public static function can_review_user($planuserid) {
return has_capability('tool/lp:planreview', context_user::instance($planuserid))
return has_capability('moodle/competency:planreview', context_user::instance($planuserid))
|| self::can_manage_user($planuserid);
}

View file

@ -114,7 +114,7 @@ class template extends persistent {
* @return bool
*/
public static function can_manage_context($context) {
return has_capability('tool/lp:templatemanage', $context);
return has_capability('moodle/competency:templatemanage', $context);
}
/**
@ -133,7 +133,7 @@ class template extends persistent {
* @return bool
*/
public static function can_read_context($context) {
return has_capability('tool/lp:templateview', $context) || self::can_manage_context($context);
return has_capability('moodle/competency:templateview', $context) || self::can_manage_context($context);
}
/**

View file

@ -335,9 +335,9 @@ class user_competency extends persistent {
public static function can_comment_user($userid) {
global $USER;
$capabilities = array('tool/lp:usercompetencycomment');
$capabilities = array('moodle/competency:usercompetencycomment');
if ($USER->id == $userid) {
$capabilities[] = 'tool/lp:usercompetencycommentown';
$capabilities[] = 'moodle/competency:usercompetencycommentown';
}
if (has_any_capability($capabilities, context_user::instance($userid))) {
@ -354,7 +354,7 @@ class user_competency extends persistent {
* @return bool
*/
public static function can_grade_user($userid) {
$ratecap = 'tool/lp:competencygrade';
$ratecap = 'moodle/competency:competencygrade';
return has_capability($ratecap, context_user::instance($userid));
}
@ -366,7 +366,7 @@ class user_competency extends persistent {
* @return bool
*/
public static function can_grade_user_in_course($userid, $courseid) {
$ratecap = 'tool/lp:competencygrade';
$ratecap = 'moodle/competency:competencygrade';
return has_capability($ratecap, context_course::instance($courseid))
|| static::can_grade_user($userid);
}
@ -390,7 +390,7 @@ class user_competency extends persistent {
* @return bool
*/
public static function can_read_user_in_course($userid, $courseid) {
$capability = 'tool/lp:usercompetencyview';
$capability = 'moodle/competency:usercompetencyview';
return has_capability($capability, context_course::instance($courseid))
|| static::can_read_user($userid);
}
@ -402,7 +402,7 @@ class user_competency extends persistent {
* @return bool
*/
public static function can_read_user($userid) {
$capability = 'tool/lp:usercompetencyview';
$capability = 'moodle/competency:usercompetencyview';
return has_capability($capability, context_user::instance($userid))
|| plan::can_read_user($userid);
}
@ -420,9 +420,9 @@ class user_competency extends persistent {
public static function can_request_review_user($userid) {
global $USER;
$capabilities = array('tool/lp:usercompetencyrequestreview');
$capabilities = array('moodle/competency:usercompetencyrequestreview');
if ($USER->id == $userid) {
$capabilities[] = 'tool/lp:usercompetencyrequestreviewown';
$capabilities[] = 'moodle/competency:usercompetencyrequestreviewown';
}
if (has_any_capability($capabilities, context_user::instance($userid))) {
@ -439,7 +439,7 @@ class user_competency extends persistent {
* @return bool
*/
public static function can_review_user($userid) {
$capability = 'tool/lp:usercompetencyreview';
$capability = 'moodle/competency:usercompetencyreview';
return has_capability($capability, context_user::instance($userid));
}

View file

@ -170,9 +170,9 @@ class user_evidence extends persistent {
global $USER;
$context = context_user::instance($evidenceuserid);
$capabilities = array('tool/lp:userevidencemanage');
$capabilities = array('moodle/competency:userevidencemanage');
if ($context->instanceid == $USER->id) {
$capabilities[] = 'tool/lp:userevidencemanageown';
$capabilities[] = 'moodle/competency:userevidencemanageown';
}
return has_any_capability($capabilities, $context);
@ -187,7 +187,7 @@ class user_evidence extends persistent {
public static function can_read_user($evidenceuserid) {
$context = context_user::instance($evidenceuserid);
$capabilities = array('tool/lp:userevidenceview');
$capabilities = array('moodle/competency:userevidenceview');
return has_any_capability($capabilities, $context) || self::can_manage_user($evidenceuserid);
}

View file

@ -37,7 +37,7 @@ $framework = \tool_lp\api::read_framework($id);
$context = $framework->get_context();
if (!\tool_lp\competency_framework::can_read_context($context)) {
throw new required_capability_exception($context, 'tool/lp:competencyview', 'nopermissions', '');
throw new required_capability_exception($context, 'moodle/competency:competencyview', 'nopermissions', '');
}
$title = get_string('competencies', 'tool_lp');

View file

@ -35,7 +35,7 @@ require_login();
\tool_lp\api::require_enabled();
if (!\tool_lp\competency_framework::can_read_context($context)) {
throw new required_capability_exception($context, 'tool/lp:competencyview', 'nopermissions', '');
throw new required_capability_exception($context, 'moodle/competency:competencyview', 'nopermissions', '');
}
$title = get_string('competencies', 'tool_lp');

View file

@ -1,263 +0,0 @@
<?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/>.
/**
* Capabilities.
*
* This files lists capabilities related to tool_lp.
*
* @package tool_lp
* @copyright 2015 Damyon Wiese
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
*/
defined('MOODLE_INTERNAL') || die();
$capabilities = array(
// Competencies.
'tool/lp:competencymanage' => array(
'captype' => 'write',
'contextlevel' => CONTEXT_COURSECAT,
'archetypes' => array(
'manager' => CAP_ALLOW
)
),
'tool/lp:competencyview' => array(
'captype' => 'read',
'contextlevel' => CONTEXT_COURSECAT,
'archetypes' => array(
'user' => CAP_ALLOW
),
'clonepermissionsfrom' => 'moodle/block:view'
),
'tool/lp:competencygrade' => array(
'captype' => 'write',
'contextlevel' => CONTEXT_COURSE, // And CONTEXT_USER.
'archetypes' => array(
'editingteacher' => CAP_ALLOW,
'teacher' => CAP_ALLOW,
'manager' => CAP_ALLOW
),
),
// Course competencies.
'tool/lp:coursecompetencymanage' => array(
'captype' => 'write',
'contextlevel' => CONTEXT_COURSE,
'archetypes' => array(
'editingteacher' => CAP_ALLOW,
'manager' => CAP_ALLOW
),
'clonepermissionsfrom' => 'moodle/site:backup'
),
'tool/lp:coursecompetencyconfigure' => array(
'captype' => 'write',
'contextlevel' => CONTEXT_MODULE,
'archetypes' => array(
'manager' => CAP_ALLOW
),
'clonepermissionsfrom' => 'moodle/site:backup'
),
'tool/lp:coursecompetencygradable' => array(
'captype' => 'read',
'contextlevel' => CONTEXT_COURSE,
'archetypes' => array(
'student' => CAP_ALLOW
),
'clonepermissionsfrom' => 'moodle/course:isincompletionreports'
),
'tool/lp:coursecompetencyview' => array(
'captype' => 'read',
'contextlevel' => CONTEXT_COURSE,
'archetypes' => array(
'user' => CAP_ALLOW
),
'clonepermissionsfrom' => 'moodle/block:view'
),
// User plans.
'tool/lp:planmanage' => array(
'captype' => 'write',
'contextlevel' => CONTEXT_USER,
'archetypes' => array(
),
'clonepermissionsfrom' => 'moodle/site:config'
),
'tool/lp:planmanagedraft' => array(
'captype' => 'write',
'contextlevel' => CONTEXT_USER,
'archetypes' => array(
),
'clonepermissionsfrom' => 'moodle/site:config'
),
'tool/lp:planmanageown' => array(
'captype' => 'write',
'contextlevel' => CONTEXT_USER,
'archetypes' => array(
),
'clonepermissionsfrom' => 'moodle/site:config'
),
'tool/lp:planmanageowndraft' => array(
'captype' => 'write',
'contextlevel' => CONTEXT_USER,
'archetypes' => array(
),
'clonepermissionsfrom' => 'moodle/site:config'
),
'tool/lp:planview' => array(
'captype' => 'read',
'contextlevel' => CONTEXT_USER,
'archetypes' => array(
),
'clonepermissionsfrom' => 'moodle/site:config'
),
'tool/lp:planviewdraft' => array(
'captype' => 'read',
'contextlevel' => CONTEXT_USER,
'archetypes' => array(
),
'clonepermissionsfrom' => 'moodle/site:config'
),
'tool/lp:planviewown' => array(
'captype' => 'read',
'contextlevel' => CONTEXT_USER,
'archetypes' => array(
'user' => CAP_ALLOW
),
'clonepermissionsfrom' => 'moodle/block:view'
),
'tool/lp:planviewowndraft' => array(
'captype' => 'read',
'contextlevel' => CONTEXT_USER,
'archetypes' => array(
),
'clonepermissionsfrom' => 'moodle/site:config'
),
'tool/lp:planrequestreview' => array(
'captype' => 'write',
'contextlevel' => CONTEXT_USER,
'archetypes' => array(
)
),
'tool/lp:planrequestreviewown' => array(
'captype' => 'write',
'contextlevel' => CONTEXT_USER,
'archetypes' => array(
'user' => CAP_ALLOW
)
),
'tool/lp:planreview' => array(
'captype' => 'write',
'contextlevel' => CONTEXT_USER,
'archetypes' => array(
),
'clonepermissionsfrom' => 'moodle/site:config'
),
'tool/lp:plancomment' => array(
'captype' => 'write',
'contextlevel' => CONTEXT_USER,
'archetypes' => array(
),
'clonepermissionsfrom' => 'moodle/site:config'
),
'tool/lp:plancommentown' => array(
'captype' => 'write',
'contextlevel' => CONTEXT_USER,
'archetypes' => array(
'user' => CAP_ALLOW
),
),
// User competencies.
'tool/lp:usercompetencyview' => array(
'captype' => 'read',
'contextlevel' => CONTEXT_USER, // And CONTEXT_COURSE.
'archetypes' => array(
'editingteacher' => CAP_ALLOW,
'teacher' => CAP_ALLOW
)
),
'tool/lp:usercompetencyrequestreview' => array(
'captype' => 'write',
'contextlevel' => CONTEXT_USER,
'archetypes' => array(
)
),
'tool/lp:usercompetencyrequestreviewown' => array(
'captype' => 'write',
'contextlevel' => CONTEXT_USER,
'archetypes' => array(
'user' => CAP_ALLOW
)
),
'tool/lp:usercompetencyreview' => array(
'captype' => 'write',
'contextlevel' => CONTEXT_USER,
'archetypes' => array(
),
'clonepermissionsfrom' => 'moodle/site:config'
),
'tool/lp:usercompetencycomment' => array(
'captype' => 'write',
'contextlevel' => CONTEXT_USER,
'archetypes' => array(
),
'clonepermissionsfrom' => 'moodle/site:config'
),
'tool/lp:usercompetencycommentown' => array(
'captype' => 'write',
'contextlevel' => CONTEXT_USER,
'archetypes' => array(
'user' => CAP_ALLOW
),
),
// Template.
'tool/lp:templatemanage' => array(
'captype' => 'write',
'contextlevel' => CONTEXT_COURSECAT,
'archetypes' => array(
),
'clonepermissionsfrom' => 'moodle/site:config'
),
'tool/lp:templateview' => array(
'captype' => 'read',
'contextlevel' => CONTEXT_COURSECAT,
'archetypes' => array(
),
'clonepermissionsfrom' => 'moodle/site:config'
),
// User evidence.
'tool/lp:userevidencemanage' => array(
'captype' => 'write',
'contextlevel' => CONTEXT_USER,
'archetypes' => array(
),
'clonepermissionsfrom' => 'moodle/site:config'
),
'tool/lp:userevidencemanageown' => array(
'captype' => 'write',
'contextlevel' => CONTEXT_USER,
'archetypes' => array(
'user' => CAP_ALLOW
),
'clonepermissionsfrom' => 'moodle/block:view'
),
'tool/lp:userevidenceview' => array(
'captype' => 'read',
'contextlevel' => CONTEXT_USER,
'archetypes' => array(
),
'clonepermissionsfrom' => 'moodle/site:config'
),
);

View file

@ -36,7 +36,7 @@ $functions = array(
'classpath' => '',
'description' => 'Creates new competency frameworks.',
'type' => 'write',
'capabilities' => 'tool/lp:competencymanage',
'capabilities' => 'moodle/competency:competencymanage',
'ajax' => true,
),
'tool_lp_read_competency_framework' => array(
@ -45,7 +45,7 @@ $functions = array(
'classpath' => '',
'description' => 'Load a summary of a competency framework.',
'type' => 'read',
'capabilities' => 'tool/lp:competencyview',
'capabilities' => 'moodle/competency:competencyview',
'ajax' => true,
),
'tool_lp_duplicate_competency_framework' => array(
@ -54,7 +54,7 @@ $functions = array(
'classpath' => '',
'description' => 'Duplicate a competency framework.',
'type' => 'write',
'capabilities' => 'tool/lp:competencymanage',
'capabilities' => 'moodle/competency:competencymanage',
'ajax' => true,
),
'tool_lp_delete_competency_framework' => array(
@ -63,7 +63,7 @@ $functions = array(
'classpath' => '',
'description' => 'Delete a competency framework.',
'type' => 'write',
'capabilities' => 'tool/lp:competencymanage',
'capabilities' => 'moodle/competency:competencymanage',
'ajax' => true,
),
'tool_lp_update_competency_framework' => array(
@ -72,7 +72,7 @@ $functions = array(
'classpath' => '',
'description' => 'Update a competency framework.',
'type' => 'write',
'capabilities' => 'tool/lp:competencymanage',
'capabilities' => 'moodle/competency:competencymanage',
'ajax' => true,
),
'tool_lp_list_competency_frameworks' => array(
@ -81,7 +81,7 @@ $functions = array(
'classpath' => '',
'description' => 'Load a list of a competency frameworks.',
'type' => 'read',
'capabilities' => 'tool/lp:competencyview',
'capabilities' => 'moodle/competency:competencyview',
'ajax' => true,
),
'tool_lp_count_competency_frameworks' => array(
@ -90,7 +90,7 @@ $functions = array(
'classpath' => '',
'description' => 'Count a list of a competency frameworks.',
'type' => 'read',
'capabilities' => 'tool/lp:competencyview',
'capabilities' => 'moodle/competency:competencyview',
'ajax' => true,
),
'tool_lp_competency_framework_viewed' => array(
@ -99,7 +99,7 @@ $functions = array(
'classpath' => '',
'description' => 'Log event competency framework viewed',
'type' => 'read',
'capabilities' => 'tool/lp:competencyview',
'capabilities' => 'moodle/competency:competencyview',
'ajax' => true,
),
'tool_lp_data_for_competency_frameworks_manage_page' => array(
@ -108,7 +108,7 @@ $functions = array(
'classpath' => '',
'description' => 'Load the data for the competency frameworks manage page template',
'type' => 'read',
'capabilities' => 'tool/lp:competencyview',
'capabilities' => 'moodle/competency:competencyview',
'ajax' => true,
),
'tool_lp_create_competency' => array(
@ -117,7 +117,7 @@ $functions = array(
'classpath' => '',
'description' => 'Creates new competencies.',
'type' => 'write',
'capabilities' => 'tool/lp:competencymanage',
'capabilities' => 'moodle/competency:competencymanage',
'ajax' => true,
),
'tool_lp_read_competency' => array(
@ -126,7 +126,7 @@ $functions = array(
'classpath' => '',
'description' => 'Load a summary of a competency.',
'type' => 'read',
'capabilities' => 'tool/lp:competencyview',
'capabilities' => 'moodle/competency:competencyview',
'ajax' => true,
),
'tool_lp_competency_viewed' => array(
@ -135,7 +135,7 @@ $functions = array(
'classpath' => '',
'description' => 'Log event competency viewed',
'type' => 'read',
'capabilities' => 'tool/lp:competencyview',
'capabilities' => 'moodle/competency:competencyview',
'ajax' => true,
),
'tool_lp_delete_competency' => array(
@ -144,7 +144,7 @@ $functions = array(
'classpath' => '',
'description' => 'Delete a competency.',
'type' => 'write',
'capabilities' => 'tool/lp:competencymanage',
'capabilities' => 'moodle/competency:competencymanage',
'ajax' => true,
),
'tool_lp_update_competency' => array(
@ -153,7 +153,7 @@ $functions = array(
'classpath' => '',
'description' => 'Update a competency.',
'type' => 'write',
'capabilities' => 'tool/lp:competencymanage',
'capabilities' => 'moodle/competency:competencymanage',
'ajax' => true,
),
'tool_lp_data_for_competency_summary' => array(
@ -162,7 +162,7 @@ $functions = array(
'classpath' => '',
'description' => 'Load competency data for summary template.',
'type' => 'read',
'capabilities' => 'tool/lp:competencyview',
'capabilities' => 'moodle/competency:competencyview',
'ajax' => true,
),
'tool_lp_list_competencies' => array(
@ -171,7 +171,7 @@ $functions = array(
'classpath' => '',
'description' => 'Load a list of a competencies.',
'type' => 'read',
'capabilities' => 'tool/lp:competencyview',
'capabilities' => 'moodle/competency:competencyview',
'ajax' => true,
),
'tool_lp_list_competencies_in_template' => array(
@ -180,7 +180,7 @@ $functions = array(
'classpath' => '',
'description' => 'Load a list of a competencies for a given template.',
'type' => 'read',
'capabilities' => 'tool/lp:competencyview',
'capabilities' => 'moodle/competency:competencyview',
'ajax' => true,
),
'tool_lp_count_competencies' => array(
@ -189,7 +189,7 @@ $functions = array(
'classpath' => '',
'description' => 'Count a list of a competencies.',
'type' => 'read',
'capabilities' => 'tool/lp:competencyview',
'capabilities' => 'moodle/competency:competencyview',
'ajax' => true,
),
'tool_lp_count_competencies_in_template' => array(
@ -198,7 +198,7 @@ $functions = array(
'classpath' => '',
'description' => 'Count a list of a competencies for a given template.',
'type' => 'read',
'capabilities' => 'tool/lp:competencyview',
'capabilities' => 'moodle/competency:competencyview',
'ajax' => true,
),
'tool_lp_search_competencies' => array(
@ -207,7 +207,7 @@ $functions = array(
'classpath' => '',
'description' => 'Search a list of a competencies.',
'type' => 'read',
'capabilities' => 'tool/lp:competencyview',
'capabilities' => 'moodle/competency:competencyview',
'ajax' => true,
),
'tool_lp_data_for_competencies_manage_page' => array(
@ -216,7 +216,7 @@ $functions = array(
'classpath' => '',
'description' => 'Load the data for the competencies manage page template',
'type' => 'read',
'capabilities' => 'tool/lp:competencyview',
'capabilities' => 'moodle/competency:competencyview',
'ajax' => true,
),
'tool_lp_set_parent_competency' => array(
@ -225,7 +225,7 @@ $functions = array(
'classpath' => '',
'description' => 'Set a new parent for a competency.',
'type' => 'write',
'capabilities' => 'tool/lp:competencymanage',
'capabilities' => 'moodle/competency:competencymanage',
'ajax' => true,
),
'tool_lp_move_up_competency' => array(
@ -234,7 +234,7 @@ $functions = array(
'classpath' => '',
'description' => 'Re-order a competency.',
'type' => 'write',
'capabilities' => 'tool/lp:competencymanage',
'capabilities' => 'moodle/competency:competencymanage',
'ajax' => true,
),
'tool_lp_move_down_competency' => array(
@ -243,7 +243,7 @@ $functions = array(
'classpath' => '',
'description' => 'Re-order a competency.',
'type' => 'write',
'capabilities' => 'tool/lp:competencymanage',
'capabilities' => 'moodle/competency:competencymanage',
'ajax' => true,
),
'tool_lp_list_course_competencies' => array(
@ -252,7 +252,7 @@ $functions = array(
'classpath' => '',
'description' => 'List the competencies in a course',
'type' => 'read',
'capabilities' => 'tool/lp:coursecompetencyview',
'capabilities' => 'moodle/competency:coursecompetencyview',
'ajax' => true,
),
'tool_lp_list_courses_using_competency' => array(
@ -261,7 +261,7 @@ $functions = array(
'classpath' => '',
'description' => 'List the courses using a competency',
'type' => 'read',
'capabilities' => 'tool/lp:coursecompetencyview',
'capabilities' => 'moodle/competency:coursecompetencyview',
'ajax' => true,
),
'tool_lp_count_competencies_in_course' => array(
@ -270,7 +270,7 @@ $functions = array(
'classpath' => '',
'description' => 'List the competencies in a course',
'type' => 'read',
'capabilities' => 'tool/lp:coursecompetencyview',
'capabilities' => 'moodle/competency:coursecompetencyview',
'ajax' => true,
),
'tool_lp_count_courses_using_competency' => array(
@ -279,7 +279,7 @@ $functions = array(
'classpath' => '',
'description' => 'List the courses using a competency',
'type' => 'read',
'capabilities' => 'tool/lp:coursecompetencyview',
'capabilities' => 'moodle/competency:coursecompetencyview',
'ajax' => true,
),
'tool_lp_add_competency_to_course' => array(
@ -288,7 +288,7 @@ $functions = array(
'classpath' => '',
'description' => 'Add the competency to a course',
'type' => 'write',
'capabilities' => 'tool/lp:coursecompetencymanage',
'capabilities' => 'moodle/competency:coursecompetencymanage',
'ajax' => true,
),
'tool_lp_add_competency_to_template' => array(
@ -297,7 +297,7 @@ $functions = array(
'classpath' => '',
'description' => 'Add the competency to a template',
'type' => 'write',
'capabilities' => 'tool/lp:templatemanage',
'capabilities' => 'moodle/competency:templatemanage',
'ajax' => true,
),
'tool_lp_remove_competency_from_course' => array(
@ -306,7 +306,7 @@ $functions = array(
'classpath' => '',
'description' => 'Remove a competency from a course',
'type' => 'write',
'capabilities' => 'tool/lp:coursecompetencymanage',
'capabilities' => 'moodle/competency:coursecompetencymanage',
'ajax' => true,
),
'tool_lp_set_course_competency_ruleoutcome' => array(
@ -315,7 +315,7 @@ $functions = array(
'classpath' => '',
'description' => 'Modify the ruleoutcome value for course competency',
'type' => 'write',
'capabilities' => 'tool/lp:coursecompetencymanage',
'capabilities' => 'moodle/competency:coursecompetencymanage',
'ajax' => true,
),
'tool_lp_remove_competency_from_template' => array(
@ -324,7 +324,7 @@ $functions = array(
'classpath' => '',
'description' => 'Remove a competency from a template',
'type' => 'write',
'capabilities' => 'tool/lp:templatemanage',
'capabilities' => 'moodle/competency:templatemanage',
'ajax' => true,
),
'tool_lp_data_for_course_competencies_page' => array(
@ -333,7 +333,7 @@ $functions = array(
'classpath' => '',
'description' => 'Load the data for the course competencies page template.',
'type' => 'read',
'capabilities' => 'tool/lp:coursecompetencyview',
'capabilities' => 'moodle/competency:coursecompetencyview',
'ajax' => true,
),
'tool_lp_data_for_template_competencies_page' => array(
@ -342,7 +342,7 @@ $functions = array(
'classpath' => '',
'description' => 'Load the data for the template competencies page template.',
'type' => 'read',
'capabilities' => 'tool/lp:templateview',
'capabilities' => 'moodle/competency:templateview',
'ajax' => true,
),
'tool_lp_reorder_course_competency' => array(
@ -351,7 +351,7 @@ $functions = array(
'classpath' => '',
'description' => 'Move a course competency to a new relative sort order.',
'type' => 'write',
'capabilities' => 'tool/lp:coursecompetencymanage',
'capabilities' => 'moodle/competency:coursecompetencymanage',
'ajax' => true,
),
'tool_lp_reorder_template_competency' => array(
@ -360,7 +360,7 @@ $functions = array(
'classpath' => '',
'description' => 'Move a template competency to a new relative sort order.',
'type' => 'write',
'capabilities' => 'tool/lp:templatemanage',
'capabilities' => 'moodle/competency:templatemanage',
'ajax' => true,
),
'tool_lp_create_template' => array(
@ -369,7 +369,7 @@ $functions = array(
'classpath' => '',
'description' => 'Creates new learning plan templates.',
'type' => 'write',
'capabilities' => 'tool/lp:templatemanage',
'capabilities' => 'moodle/competency:templatemanage',
'ajax' => true,
),
'tool_lp_duplicate_template' => array(
@ -378,7 +378,7 @@ $functions = array(
'classpath' => '',
'description' => 'Duplicate learning plan template.',
'type' => 'write',
'capabilities' => 'tool/lp:templatemanage',
'capabilities' => 'moodle/competency:templatemanage',
'ajax' => true,
),
'tool_lp_read_template' => array(
@ -387,7 +387,7 @@ $functions = array(
'classpath' => '',
'description' => 'Load a summary of a learning plan template.',
'type' => 'read',
'capabilities' => 'tool/lp:templateview',
'capabilities' => 'moodle/competency:templateview',
'ajax' => true,
),
'tool_lp_delete_template' => array(
@ -396,7 +396,7 @@ $functions = array(
'classpath' => '',
'description' => 'Delete a learning plan template.',
'type' => 'write',
'capabilities' => 'tool/lp:templatemanage',
'capabilities' => 'moodle/competency:templatemanage',
'ajax' => true,
),
'tool_lp_update_template' => array(
@ -405,7 +405,7 @@ $functions = array(
'classpath' => '',
'description' => 'Update a learning plan template.',
'type' => 'write',
'capabilities' => 'tool/lp:templatemanage',
'capabilities' => 'moodle/competency:templatemanage',
'ajax' => true,
),
'tool_lp_list_templates' => array(
@ -414,7 +414,7 @@ $functions = array(
'classpath' => '',
'description' => 'Load a list of a learning plan templates.',
'type' => 'read',
'capabilities' => 'tool/lp:templateview',
'capabilities' => 'moodle/competency:templateview',
'ajax' => true,
),
'tool_lp_list_templates_using_competency' => array(
@ -423,7 +423,7 @@ $functions = array(
'classpath' => '',
'description' => 'Load a list of a learning plan templates for a given competency.',
'type' => 'read',
'capabilities' => 'tool/lp:templateview',
'capabilities' => 'moodle/competency:templateview',
'ajax' => true,
),
'tool_lp_count_templates' => array(
@ -432,7 +432,7 @@ $functions = array(
'classpath' => '',
'description' => 'Count a list of a learning plan templates.',
'type' => 'read',
'capabilities' => 'tool/lp:templateview',
'capabilities' => 'moodle/competency:templateview',
'ajax' => true,
),
'tool_lp_count_templates_using_competency' => array(
@ -441,7 +441,7 @@ $functions = array(
'classpath' => '',
'description' => 'Count a list of a learning plan templates for a given competency.',
'type' => 'read',
'capabilities' => 'tool/lp:templateview',
'capabilities' => 'moodle/competency:templateview',
'ajax' => true,
),
'tool_lp_data_for_templates_manage_page' => array(
@ -450,7 +450,7 @@ $functions = array(
'classpath' => '',
'description' => 'Load the data for the learning plan templates manage page template',
'type' => 'read',
'capabilities' => 'tool/lp:templateview',
'capabilities' => 'moodle/competency:templateview',
'ajax' => true,
),
'tool_lp_create_plan' => array(
@ -459,7 +459,7 @@ $functions = array(
'classpath' => '',
'description' => 'Creates a learning plan.',
'type' => 'write',
'capabilities' => 'tool/lp:planmanage',
'capabilities' => 'moodle/competency:planmanage',
'ajax' => true,
),
'tool_lp_update_plan' => array(
@ -468,7 +468,7 @@ $functions = array(
'classpath' => '',
'description' => 'Updates a learning plan.',
'type' => 'write',
'capabilities' => 'tool/lp:planmanage',
'capabilities' => 'moodle/competency:planmanage',
'ajax' => true,
),
'tool_lp_complete_plan' => array(
@ -477,7 +477,7 @@ $functions = array(
'classpath' => '',
'description' => 'Complete learning plan.',
'type' => 'write',
'capabilities' => 'tool/lp:planmanage',
'capabilities' => 'moodle/competency:planmanage',
'ajax' => true,
),
'tool_lp_reopen_plan' => array(
@ -486,7 +486,7 @@ $functions = array(
'classpath' => '',
'description' => 'Reopen learning plan.',
'type' => 'write',
'capabilities' => 'tool/lp:planmanage',
'capabilities' => 'moodle/competency:planmanage',
'ajax' => true,
),
'tool_lp_read_plan' => array(
@ -495,7 +495,7 @@ $functions = array(
'classpath' => '',
'description' => 'Load a learning plan.',
'type' => 'read',
'capabilities' => 'tool/lp:planviewown',
'capabilities' => 'moodle/competency:planviewown',
'ajax' => true,
),
'tool_lp_delete_plan' => array(
@ -504,7 +504,7 @@ $functions = array(
'classpath' => '',
'description' => 'Delete a learning plan.',
'type' => 'write',
'capabilities' => 'tool/lp:planmanage',
'capabilities' => 'moodle/competency:planmanage',
'ajax' => true,
),
'tool_lp_list_user_plans' => array(
@ -513,7 +513,7 @@ $functions = array(
'classpath' => '',
'description' => 'List a user\'s learning plans.',
'type' => 'read',
'capabilities' => 'tool/lp:planviewown',
'capabilities' => 'moodle/competency:planviewown',
'ajax' => true,
),
'tool_lp_data_for_plans_page' => array(
@ -522,7 +522,7 @@ $functions = array(
'classpath' => '',
'description' => 'Load the data for the plans page template',
'type' => 'read',
'capabilities' => 'tool/lp:planviewown',
'capabilities' => 'moodle/competency:planviewown',
'ajax' => true,
),
'tool_lp_data_for_plan_page' => array(
@ -531,7 +531,7 @@ $functions = array(
'classpath' => '',
'description' => 'Load the data for the plan page template.',
'type' => 'read',
'capabilities' => 'tool/lp:planview',
'capabilities' => 'moodle/competency:planview',
'ajax' => true,
),
'tool_lp_list_plan_competencies' => array(
@ -540,7 +540,7 @@ $functions = array(
'classpath' => '',
'description' => 'List the competencies in a plan',
'type' => 'read',
'capabilities' => 'tool/lp:planviewown',
'capabilities' => 'moodle/competency:planviewown',
'ajax' => true,
),
'tool_lp_add_competency_to_plan' => array(
@ -549,7 +549,7 @@ $functions = array(
'classpath' => '',
'description' => 'Add the competency to a learning plan',
'type' => 'write',
'capabilities' => 'tool/lp:planmanage',
'capabilities' => 'moodle/competency:planmanage',
'ajax' => true,
),
'tool_lp_remove_competency_from_plan' => array(
@ -558,7 +558,7 @@ $functions = array(
'classpath' => '',
'description' => 'Remove the competency from a learning plan',
'type' => 'write',
'capabilities' => 'tool/lp:planmanage',
'capabilities' => 'moodle/competency:planmanage',
'ajax' => true,
),
'tool_lp_reorder_plan_competency' => array(
@ -567,7 +567,7 @@ $functions = array(
'classpath' => '',
'description' => 'Move a plan competency to a new relative sort order.',
'type' => 'write',
'capabilities' => 'tool/lp:planmanage',
'capabilities' => 'moodle/competency:planmanage',
'ajax' => true,
),
'tool_lp_plan_request_review' => array(
@ -576,7 +576,7 @@ $functions = array(
'classpath' => '',
'description' => 'Request for a plan to be reviewed.',
'type' => 'write',
'capabilities' => 'tool/lp:planmanagedraft',
'capabilities' => 'moodle/competency:planmanagedraft',
'ajax' => true,
),
'tool_lp_plan_start_review' => array(
@ -585,7 +585,7 @@ $functions = array(
'classpath' => '',
'description' => 'Start the review of a plan.',
'type' => 'write',
'capabilities' => 'tool/lp:planmanage',
'capabilities' => 'moodle/competency:planmanage',
'ajax' => true,
),
'tool_lp_plan_stop_review' => array(
@ -594,7 +594,7 @@ $functions = array(
'classpath' => '',
'description' => 'Stop the review of a plan.',
'type' => 'write',
'capabilities' => 'tool/lp:planmanage',
'capabilities' => 'moodle/competency:planmanage',
'ajax' => true,
),
'tool_lp_plan_cancel_review_request' => array(
@ -603,7 +603,7 @@ $functions = array(
'classpath' => '',
'description' => 'Cancel the review of a plan.',
'type' => 'write',
'capabilities' => 'tool/lp:planmanagedraft',
'capabilities' => 'moodle/competency:planmanagedraft',
'ajax' => true,
),
'tool_lp_approve_plan' => array(
@ -612,7 +612,7 @@ $functions = array(
'classpath' => '',
'description' => 'Approve a plan.',
'type' => 'write',
'capabilities' => 'tool/lp:planmanage',
'capabilities' => 'moodle/competency:planmanage',
'ajax' => true,
),
'tool_lp_unapprove_plan' => array(
@ -621,7 +621,7 @@ $functions = array(
'classpath' => '',
'description' => 'Unapprove a plan.',
'type' => 'write',
'capabilities' => 'tool/lp:planmanage',
'capabilities' => 'moodle/competency:planmanage',
'ajax' => true,
),
'tool_lp_template_has_related_data' => array(
@ -630,7 +630,7 @@ $functions = array(
'classpath' => '',
'description' => 'Check if a template has related data',
'type' => 'read',
'capabilities' => 'tool/lp:templateview',
'capabilities' => 'moodle/competency:templateview',
'ajax' => true,
),
'tool_lp_get_scale_values' => array(
@ -639,7 +639,7 @@ $functions = array(
'classpath' => '',
'description' => 'Fetch the values for a specific scale',
'type' => 'read',
'capabilities' => 'tool/lp:competencymanage',
'capabilities' => 'moodle/competency:competencymanage',
'ajax' => true,
),
'tool_lp_add_related_competency' => array(
@ -648,7 +648,7 @@ $functions = array(
'classpath' => '',
'description' => 'Adds a related competency',
'type' => 'write',
'capabilities' => 'tool/lp:competencymanage',
'capabilities' => 'moodle/competency:competencymanage',
'ajax' => true,
),
'tool_lp_remove_related_competency' => array(
@ -657,7 +657,7 @@ $functions = array(
'classpath' => '',
'description' => 'Remove a related competency',
'type' => 'write',
'capabilities' => 'tool/lp:competencymanage',
'capabilities' => 'moodle/competency:competencymanage',
'ajax' => true,
),
'tool_lp_data_for_related_competencies_section' => array(
@ -666,7 +666,7 @@ $functions = array(
'classpath' => '',
'description' => 'Load the data for the related competencies template.',
'type' => 'read',
'capabilities' => 'tool/lp:competencyview',
'capabilities' => 'moodle/competency:competencyview',
'ajax' => true,
),
'tool_lp_search_users' => array(
@ -695,7 +695,7 @@ $functions = array(
'classpath' => '',
'description' => 'Read an evidence of prior learning.',
'type' => 'read',
'capabilities' => 'tool/lp:userevidenceview',
'capabilities' => 'moodle/competency:userevidenceview',
'ajax' => true,
),
'tool_lp_delete_user_evidence' => array(
@ -704,7 +704,7 @@ $functions = array(
'classpath' => '',
'description' => 'Delete an evidence of prior learning.',
'type' => 'write',
'capabilities' => 'tool/lp:userevidencemanageown',
'capabilities' => 'moodle/competency:userevidencemanageown',
'ajax' => true,
),
'tool_lp_data_for_user_evidence_list_page' => array(
@ -713,7 +713,7 @@ $functions = array(
'classpath' => '',
'description' => 'Load the data for the user evidence list page template',
'type' => 'read',
'capabilities' => 'tool/lp:userevidenceview',
'capabilities' => 'moodle/competency:userevidenceview',
'ajax' => true,
),
'tool_lp_data_for_user_evidence_page' => array(
@ -722,7 +722,7 @@ $functions = array(
'classpath' => '',
'description' => 'Load the data for the user evidence page template',
'type' => 'read',
'capabilities' => 'tool/lp:userevidenceview',
'capabilities' => 'moodle/competency:userevidenceview',
'ajax' => true,
),
'tool_lp_create_user_evidence_competency' => array(
@ -731,7 +731,7 @@ $functions = array(
'classpath' => '',
'description' => 'Create an evidence of prior learning relationship with a competency.',
'type' => 'read',
'capabilities' => 'tool/lp:userevidencemanageown, tool/lp:competencyview',
'capabilities' => 'moodle/competency:userevidencemanageown, moodle/competency:competencyview',
'ajax' => true,
),
'tool_lp_delete_user_evidence_competency' => array(
@ -740,7 +740,7 @@ $functions = array(
'classpath' => '',
'description' => 'Delete an evidence of prior learning relationship with a competency.',
'type' => 'write',
'capabilities' => 'tool/lp:userevidencemanageown',
'capabilities' => 'moodle/competency:userevidencemanageown',
'ajax' => true,
),
@ -751,7 +751,7 @@ $functions = array(
'classpath' => '',
'description' => 'Cancel a review request.',
'type' => 'write',
'capabilities' => 'tool/lp:userevidencemanageown',
'capabilities' => 'moodle/competency:userevidencemanageown',
'ajax' => true,
),
'tool_lp_user_competency_request_review' => array(
@ -760,7 +760,7 @@ $functions = array(
'classpath' => '',
'description' => 'Request a review.',
'type' => 'write',
'capabilities' => 'tool/lp:userevidencemanageown',
'capabilities' => 'moodle/competency:userevidencemanageown',
'ajax' => true,
),
'tool_lp_user_competency_start_review' => array(
@ -769,7 +769,7 @@ $functions = array(
'classpath' => '',
'description' => 'Start a review.',
'type' => 'write',
'capabilities' => 'tool/lp:competencygrade',
'capabilities' => 'moodle/competency:competencygrade',
'ajax' => true,
),
'tool_lp_user_competency_stop_review' => array(
@ -778,7 +778,7 @@ $functions = array(
'classpath' => '',
'description' => 'Stop a review.',
'type' => 'write',
'capabilities' => 'tool/lp:competencygrade',
'capabilities' => 'moodle/competency:competencygrade',
'ajax' => true,
),
@ -788,7 +788,7 @@ $functions = array(
'classpath' => '',
'description' => 'Load a summary of a user competency.',
'type' => 'read',
'capabilities' => 'tool/lp:planview',
'capabilities' => 'moodle/competency:planview',
'ajax' => true,
),
'tool_lp_user_competency_viewed' => array(
@ -797,7 +797,7 @@ $functions = array(
'classpath' => '',
'description' => 'Log the user competency viewed event.',
'type' => 'read',
'capabilities' => 'tool/lp:usercompetencyview',
'capabilities' => 'moodle/competency:usercompetencyview',
'ajax' => true,
),
'tool_lp_user_competency_viewed_in_plan' => array(
@ -806,7 +806,7 @@ $functions = array(
'classpath' => '',
'description' => 'Log the user competency viewed in plan event.',
'type' => 'read',
'capabilities' => 'tool/lp:usercompetencyview',
'capabilities' => 'moodle/competency:usercompetencyview',
'ajax' => true,
),
'tool_lp_user_competency_viewed_in_course' => array(
@ -815,7 +815,7 @@ $functions = array(
'classpath' => '',
'description' => 'Log the user competency viewed in course event',
'type' => 'read',
'capabilities' => 'tool/lp:usercompetencyview',
'capabilities' => 'moodle/competency:usercompetencyview',
'ajax' => true,
),
'tool_lp_user_competency_plan_viewed' => array(
@ -824,7 +824,7 @@ $functions = array(
'classpath' => '',
'description' => 'Log the user competency plan viewed event.',
'type' => 'read',
'capabilities' => 'tool/lp:usercompetencyview',
'capabilities' => 'moodle/competency:usercompetencyview',
'ajax' => true,
),
'tool_lp_grade_competency' => array(
@ -833,7 +833,7 @@ $functions = array(
'classpath' => '',
'description' => 'Grade a competency.',
'type' => 'write',
'capabilities' => 'tool/lp:competencygrade',
'capabilities' => 'moodle/competency:competencygrade',
'ajax' => true,
),
'tool_lp_grade_competency_in_plan' => array(
@ -842,7 +842,7 @@ $functions = array(
'classpath' => '',
'description' => 'Grade a competency from the user plan page.',
'type' => 'write',
'capabilities' => 'tool/lp:competencygrade',
'capabilities' => 'moodle/competency:competencygrade',
'ajax' => true,
),
'tool_lp_data_for_user_competency_summary_in_plan' => array(
@ -851,7 +851,7 @@ $functions = array(
'classpath' => '',
'description' => 'Load a summary of a user competency.',
'type' => 'read',
'capabilities' => 'tool/lp:planview',
'capabilities' => 'moodle/competency:planview',
'ajax' => true,
),
'tool_lp_grade_competency_in_course' => array(
@ -860,7 +860,7 @@ $functions = array(
'classpath' => '',
'description' => 'Grade a competency from the course page.',
'type' => 'write',
'capabilities' => 'tool/lp:competencygrade',
'capabilities' => 'moodle/competency:competencygrade',
'ajax' => true,
),
'tool_lp_data_for_user_competency_summary_in_course' => array(
@ -869,7 +869,7 @@ $functions = array(
'classpath' => '',
'description' => 'Load a summary of a user competency.',
'type' => 'read',
'capabilities' => 'tool/lp:coursecompetencyview',
'capabilities' => 'moodle/competency:coursecompetencyview',
'ajax' => true,
),
'tool_lp_unlink_plan_from_template' => array(
@ -878,7 +878,7 @@ $functions = array(
'classpath' => '',
'description' => 'Unlink a plan form it template.',
'type' => 'write',
'capabilities' => 'tool/lp:planmanage',
'capabilities' => 'moodle/competency:planmanage',
'ajax' => true,
),
'tool_lp_view_template' => array(
@ -887,7 +887,7 @@ $functions = array(
'classpath' => '',
'description' => 'Log event template viewed',
'type' => 'read',
'capabilities' => 'tool/lp:templateview',
'capabilities' => 'moodle/competency:templateview',
'ajax' => true,
),
'tool_lp_request_review_of_user_evidence_linked_competencies' => array(
@ -896,7 +896,7 @@ $functions = array(
'classpath' => '',
'description' => 'Send user evidence competencies in review',
'type' => 'write',
'capabilities' => 'tool/lp:userevidencemanageown',
'capabilities' => 'moodle/competency:userevidencemanageown',
'ajax' => true,
),
'tool_lp_update_course_competency_settings' => array(
@ -905,7 +905,7 @@ $functions = array(
'classpath' => '',
'description' => 'Update the course competency settings',
'type' => 'write',
'capabilities' => 'tool/lp:coursecompetencyconfigure',
'capabilities' => 'moodle/competency:coursecompetencyconfigure',
'ajax' => true,
),
);

View file

@ -41,7 +41,7 @@ if (!empty($id)) {
// We check that we have the permission to edit this framework, in its own context.
require_login();
\tool_lp\api::require_enabled();
require_capability('tool/lp:competencymanage', $context);
require_capability('moodle/competency:competencymanage', $context);
// Set up the framework page.
list($pagetitle, $pagesubtitle, $url, $frameworksurl) = tool_lp\page_helper::setup_for_framework($id,

View file

@ -62,13 +62,13 @@ $cancreate = \tool_lp\plan::can_manage_user_draft($userid) || \tool_lp\plan::can
// If editing plan, check if user has permissions to edit it.
if ($plan != null) {
if (!$plan->can_manage()) {
throw new required_capability_exception($PAGE->context, 'tool/lp:planmanage', 'nopermissions', '');
throw new required_capability_exception($PAGE->context, 'moodle/competency:planmanage', 'nopermissions', '');
}
if (!$plan->can_be_edited()) {
throw new coding_exception('Completed plan can not be edited');
}
} else if (!$cancreate) {
throw new required_capability_exception($PAGE->context, 'tool/lp:planmanage', 'nopermissions', '');
throw new required_capability_exception($PAGE->context, 'moodle/competency:planmanage', 'nopermissions', '');
}
$form = new \tool_lp\form\plan($url->out(false), $customdata);

View file

@ -41,7 +41,7 @@ if (!empty($id)) {
// We check that we have the permission to edit this framework, in its own context.
require_login(0, false);
\tool_lp\api::require_enabled();
require_capability('tool/lp:templatemanage', $context);
require_capability('moodle/competency:templatemanage', $context);
// We keep the original context in the URLs, so that we remain in the same context.
$url = new moodle_url("/admin/tool/lp/edittemplate.php", [

View file

@ -201,37 +201,6 @@ $string['listplanscaption'] = 'List of learning plans';
$string['listtemplatescaption'] = 'List of learning plan templates';
$string['loading'] = 'Loading...';
$string['locatecompetency'] = 'Locate competency';
$string['lp:competencymanage'] = 'Manage competency frameworks';
$string['lp:competencygrade'] = 'Set competency grade';
$string['lp:competencyview'] = 'View competency frameworks';
$string['lp:coursecompetencygradable'] = 'Receive competency marks';
$string['lp:coursecompetencyconfigure'] = 'Configure course competency settings';
$string['lp:coursecompetencymanage'] = 'Manage course competencies';
$string['lp:coursecompetencyview'] = 'View course competencies';
$string['lp:plancomment'] = 'Comment on a learning plan';
$string['lp:plancommentown'] = 'Comment on own learning plan';
$string['lp:planmanage'] = 'Manage learning plans';
$string['lp:planmanagedraft'] = 'Manage draft learning plans';
$string['lp:planmanageown'] = 'Manage own learning plans';
$string['lp:planmanageowndraft'] = 'Manage own draft learning plans';
$string['lp:planrequestreview'] = 'Request the review of a learning plan';
$string['lp:planrequestreviewown'] = 'Request the review of own learning plan';
$string['lp:planreview'] = 'Review a learning plan';
$string['lp:planview'] = 'View all learning plans';
$string['lp:planviewdraft'] = 'View draft learning plans';
$string['lp:planviewown'] = 'View own learning plans';
$string['lp:planviewowndraft'] = 'View own draft learning plans';
$string['lp:templatemanage'] = 'Manage templates';
$string['lp:templateview'] = '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:userevidenceview'] = 'View evidence of prior learning of a user';
$string['managecompetenciesandframeworks'] = 'Manage competencies and frameworks';
$string['messageprovider:user_competency_comment'] = 'Comment posted on a competency.';
$string['messageprovider:plan_comment'] = 'Comment posted on a learning plan.';

View file

@ -31,7 +31,7 @@ $context = context::instance_by_id($pagecontextid);
require_login(0, false);
\tool_lp\api::require_enabled();
if (!\tool_lp\template::can_read_context($context)) {
throw new required_capability_exception($context, 'tool/lp:templateview', 'nopermissions', '');
throw new required_capability_exception($context, 'moodle/competency:templateview', 'nopermissions', '');
}
$url = new moodle_url('/admin/tool/lp/learningplans.php', array('pagecontextid' => $pagecontextid));

View file

@ -438,7 +438,7 @@ function tool_lp_coursemodule_standard_elements($formwrapper, $mform) {
if (!\tool_lp\api::is_enabled()) {
return;
} else if (!has_capability('tool/lp:coursecompetencymanage', $formwrapper->get_context())) {
} else if (!has_capability('moodle/competency:coursecompetencymanage', $formwrapper->get_context())) {
return;
}

View file

@ -37,7 +37,7 @@ if (\tool_lp\api::is_enabled()) {
'toollpcompetencies',
get_string('competencyframeworks', 'tool_lp'),
new moodle_url('/admin/tool/lp/competencyframeworks.php', array('pagecontextid' => context_system::instance()->id)),
array('tool/lp:competencymanage')
array('moodle/competency:competencymanage')
);
$ADMIN->add($parentname, $temp);
@ -46,7 +46,7 @@ if (\tool_lp\api::is_enabled()) {
'toollplearningplans',
get_string('templates', 'tool_lp'),
new moodle_url('/admin/tool/lp/learningplans.php', array('pagecontextid' => context_system::instance()->id)),
array('tool/lp:templatemanage')
array('moodle/competency:templatemanage')
);
$ADMIN->add($parentname, $temp);
}

View file

@ -37,7 +37,7 @@ $canmanagetemplate = $template->can_manage();
$duedatereached = $template->get_duedate() > 0 && $template->get_duedate() < time();
if (!$canreadtemplate) {
throw new required_capability_exception($context, 'tool/lp:templateview', 'nopermissions', '');
throw new required_capability_exception($context, 'moodle/competency:templateview', 'nopermissions', '');
}
// Set up the page.

View file

@ -35,7 +35,7 @@ $context = $template->get_context();
$canreadtemplate = $template->can_read();
$canmanagetemplate = $template->can_manage();
if (!$canreadtemplate) {
throw new required_capability_exception($context, 'tool/lp:templateview', 'nopermissions', '');
throw new required_capability_exception($context, 'moodle/competency:templateview', 'nopermissions', '');
}
// Set up the page.

View file

@ -35,7 +35,7 @@ $pagecontext = context::instance_by_id($pagecontextid);
$template = \tool_lp\api::read_template($templateid);
$context = $template->get_context();
if (!$template->can_read()) {
throw new required_capability_exception($context, 'tool/lp:templateview', 'nopermissions', '');
throw new required_capability_exception($context, 'moodle/competency:templateview', 'nopermissions', '');
}
// Trigger a template viewed event.

View file

@ -80,18 +80,18 @@ class tool_lp_api_testcase extends advanced_testcase {
$sysctx = context_system::instance();
$roleallow = create_role('Allow', 'allow', 'Allow read');
assign_capability('tool/lp:competencyview', CAP_ALLOW, $roleallow, $sysctx->id);
assign_capability('moodle/competency:competencyview', CAP_ALLOW, $roleallow, $sysctx->id);
role_assign($roleallow, $user->id, $sysctx->id);
$roleprevent = create_role('Prevent', 'prevent', 'Prevent read');
assign_capability('tool/lp:competencyview', CAP_PROHIBIT, $roleprevent, $sysctx->id);
assign_capability('moodle/competency:competencyview', CAP_PROHIBIT, $roleprevent, $sysctx->id);
role_assign($roleprevent, $user->id, $cat2ctx->id);
accesslib_clear_all_caches_for_unit_testing();
$this->setUser($user);
$this->assertFalse(has_capability('tool/lp:competencyview', $cat2ctx));
$this->assertFalse(has_capability('moodle/competency:competencyview', $cat2ctx));
$requiredcap = array('tool/lp:competencyview');
$requiredcap = array('moodle/competency:competencyview');
$expected = array();
$this->assertEquals($expected, api::get_related_contexts($cat2ctx, 'self', $requiredcap));
@ -141,18 +141,18 @@ class tool_lp_api_testcase extends advanced_testcase {
$sysctx = context_system::instance();
$roleallow = create_role('Allow', 'allow', 'Allow read');
assign_capability('tool/lp:templateview', CAP_ALLOW, $roleallow, $sysctx->id);
assign_capability('moodle/competency:templateview', CAP_ALLOW, $roleallow, $sysctx->id);
role_assign($roleallow, $user->id, $sysctx->id);
$roleprevent = create_role('Prevent', 'prevent', 'Prevent read');
assign_capability('tool/lp:templateview', CAP_PROHIBIT, $roleprevent, $sysctx->id);
assign_capability('moodle/competency:templateview', CAP_PROHIBIT, $roleprevent, $sysctx->id);
role_assign($roleprevent, $user->id, $cat2ctx->id);
accesslib_clear_all_caches_for_unit_testing();
$this->setUser($user);
$this->assertFalse(has_capability('tool/lp:templateview', $cat2ctx));
$this->assertFalse(has_capability('moodle/competency:templateview', $cat2ctx));
$requiredcap = array('tool/lp:templateview');
$requiredcap = array('moodle/competency:templateview');
$expected = array();
$this->assertEquals($expected, api::get_related_contexts($cat2ctx, 'self', $requiredcap));
@ -417,17 +417,17 @@ class tool_lp_api_testcase extends advanced_testcase {
'shortname' => 'manage'
));
assign_capability('tool/lp:planmanageowndraft', CAP_ALLOW, $manageowndraftrole, $syscontext->id);
assign_capability('tool/lp:planviewowndraft', CAP_ALLOW, $manageowndraftrole, $syscontext->id);
assign_capability('moodle/competency:planmanageowndraft', CAP_ALLOW, $manageowndraftrole, $syscontext->id);
assign_capability('moodle/competency:planviewowndraft', CAP_ALLOW, $manageowndraftrole, $syscontext->id);
assign_capability('tool/lp:planmanageown', CAP_ALLOW, $manageownrole, $syscontext->id);
assign_capability('tool/lp:planviewown', CAP_ALLOW, $manageownrole, $syscontext->id);
assign_capability('moodle/competency:planmanageown', CAP_ALLOW, $manageownrole, $syscontext->id);
assign_capability('moodle/competency:planviewown', CAP_ALLOW, $manageownrole, $syscontext->id);
assign_capability('tool/lp:planmanagedraft', CAP_ALLOW, $managedraftrole, $syscontext->id);
assign_capability('tool/lp:planviewdraft', CAP_ALLOW, $managedraftrole, $syscontext->id);
assign_capability('moodle/competency:planmanagedraft', CAP_ALLOW, $managedraftrole, $syscontext->id);
assign_capability('moodle/competency:planviewdraft', CAP_ALLOW, $managedraftrole, $syscontext->id);
assign_capability('tool/lp:planmanage', CAP_ALLOW, $managerole, $syscontext->id);
assign_capability('tool/lp:planview', CAP_ALLOW, $managerole, $syscontext->id);
assign_capability('moodle/competency:planmanage', CAP_ALLOW, $managerole, $syscontext->id);
assign_capability('moodle/competency:planview', CAP_ALLOW, $managerole, $syscontext->id);
$dg->role_assign($manageowndraftrole, $usermanageowndraft->id, $syscontext->id);
$dg->role_assign($manageownrole, $usermanageown->id, $syscontext->id);
@ -855,9 +855,9 @@ class tool_lp_api_testcase extends advanced_testcase {
$reviewerrole = $dg->create_role();
$otheruserrole = $dg->create_role();
assign_capability('tool/lp:planmanageowndraft', CAP_ALLOW, $userrole, $syscontext->id);
assign_capability('tool/lp:planmanage', CAP_ALLOW, $reviewerrole, $syscontext->id);
assign_capability('tool/lp:planviewdraft', CAP_ALLOW, $reviewerrole, $syscontext->id);
assign_capability('moodle/competency:planmanageowndraft', CAP_ALLOW, $userrole, $syscontext->id);
assign_capability('moodle/competency:planmanage', CAP_ALLOW, $reviewerrole, $syscontext->id);
assign_capability('moodle/competency:planviewdraft', CAP_ALLOW, $reviewerrole, $syscontext->id);
$dg->role_assign($userrole, $user->id, $syscontext->id);
$dg->role_assign($reviewerrole, $reviewer->id, $syscontext->id);
accesslib_clear_all_caches_for_unit_testing();
@ -1496,10 +1496,10 @@ class tool_lp_api_testcase extends advanced_testcase {
'name' => 'User manage own',
'shortname' => 'manageown'
));
assign_capability('tool/lp:planmanageowndraft', CAP_ALLOW, $manageownrole, $syscontext->id);
assign_capability('tool/lp:planviewowndraft', CAP_ALLOW, $manageownrole, $syscontext->id);
assign_capability('tool/lp:planmanageown', CAP_ALLOW, $manageownrole, $syscontext->id);
assign_capability('tool/lp:planviewown', CAP_ALLOW, $manageownrole, $syscontext->id);
assign_capability('moodle/competency:planmanageowndraft', CAP_ALLOW, $manageownrole, $syscontext->id);
assign_capability('moodle/competency:planviewowndraft', CAP_ALLOW, $manageownrole, $syscontext->id);
assign_capability('moodle/competency:planmanageown', CAP_ALLOW, $manageownrole, $syscontext->id);
assign_capability('moodle/competency:planviewown', CAP_ALLOW, $manageownrole, $syscontext->id);
$dg->role_assign($manageownrole, $user->id, $syscontext->id);
$this->setUser($user);
@ -1692,8 +1692,8 @@ class tool_lp_api_testcase extends advanced_testcase {
'name' => 'User manage own',
'shortname' => 'manageown'
));
assign_capability('tool/lp:planmanageowndraft', CAP_ALLOW, $managerole, $syscontext->id);
assign_capability('tool/lp:planmanageown', CAP_ALLOW, $managerole, $syscontext->id);
assign_capability('moodle/competency:planmanageowndraft', CAP_ALLOW, $managerole, $syscontext->id);
assign_capability('moodle/competency:planmanageown', CAP_ALLOW, $managerole, $syscontext->id);
$dg->role_assign($managerole, $user->id, $syscontext->id);
$this->setUser($user);
@ -1741,8 +1741,8 @@ class tool_lp_api_testcase extends advanced_testcase {
'name' => 'User view',
'shortname' => 'view'
));
assign_capability('tool/lp:planviewdraft', CAP_ALLOW, $viewrole, $syscontext->id);
assign_capability('tool/lp:planview', CAP_ALLOW, $viewrole, $syscontext->id);
assign_capability('moodle/competency:planviewdraft', CAP_ALLOW, $viewrole, $syscontext->id);
assign_capability('moodle/competency:planview', CAP_ALLOW, $viewrole, $syscontext->id);
$dg->role_assign($viewrole, $user->id, $syscontext->id);
$this->setUser($user);
@ -1844,7 +1844,7 @@ class tool_lp_api_testcase extends advanced_testcase {
$user = $dg->create_user();
$role = $dg->create_role();
assign_capability('tool/lp:templatemanage', CAP_ALLOW, $role, $syscontext->id, true);
assign_capability('moodle/competency:templatemanage', CAP_ALLOW, $role, $syscontext->id, true);
$dg->role_assign($role, $user->id, $syscontext->id);
$cohortrole = $dg->create_role();
@ -3819,22 +3819,22 @@ class tool_lp_api_testcase extends advanced_testcase {
$studentrole = array_shift($studentarch);
$gradablerole = $dg->create_role();
assign_capability('tool/lp:coursecompetencygradable', CAP_ALLOW, $gradablerole, $sysctx->id);
assign_capability('moodle/competency:coursecompetencygradable', CAP_ALLOW, $gradablerole, $sysctx->id);
$notgradablerole = $dg->create_role();
assign_capability('tool/lp:coursecompetencygradable', CAP_PROHIBIT, $notgradablerole, $sysctx->id);
assign_capability('moodle/competency:coursecompetencygradable', CAP_PROHIBIT, $notgradablerole, $sysctx->id);
$canviewucrole = $dg->create_role();
assign_capability('tool/lp:usercompetencyview', CAP_ALLOW, $canviewucrole, $sysctx->id);
assign_capability('moodle/competency:usercompetencyview', CAP_ALLOW, $canviewucrole, $sysctx->id);
$cannotviewcomp = $dg->create_role();
assign_capability('tool/lp:competencyview', CAP_PROHIBIT, $cannotviewcomp, $sysctx->id);
assign_capability('moodle/competency:competencyview', CAP_PROHIBIT, $cannotviewcomp, $sysctx->id);
$canmanagecomp = $dg->create_role();
assign_capability('tool/lp:competencymanage', CAP_ALLOW, $canmanagecomp, $sysctx->id);
assign_capability('moodle/competency:competencymanage', CAP_ALLOW, $canmanagecomp, $sysctx->id);
$cangraderole = $dg->create_role();
assign_capability('tool/lp:competencygrade', CAP_ALLOW, $cangraderole, $sysctx->id);
assign_capability('moodle/competency:competencygrade', CAP_ALLOW, $cangraderole, $sysctx->id);
// Enrol s1 and s2 as students in course 1.
$dg->enrol_user($student1->id, $c1->id, $studentrole->id);

View file

@ -40,19 +40,19 @@ Feature: Manage plan workflow
And I log in as "admin"
And I set the following system permissions of "User manage own draft plan role" role:
| capability | permission |
| tool/lp:planmanageowndraft | Allow |
| moodle/competency:planmanageowndraft | Allow |
And I set the following system permissions of "User manage own plan role" role:
| capability | permission |
| tool/lp:planmanageowndraft | Allow |
| tool/lp:planmanageown | Allow |
| moodle/competency:planmanageowndraft | Allow |
| moodle/competency:planmanageown | Allow |
And I set the following system permissions of "Manager all plans role" role:
| capability | permission |
| tool/lp:planmanage | Allow |
| tool/lp:planmanagedraft | Allow |
| tool/lp:planmanageowndraft | Allow |
| tool/lp:planview | Allow |
| tool/lp:planreview | Allow |
| tool/lp:planrequestreview | Allow |
| moodle/competency:planmanage | Allow |
| moodle/competency:planmanagedraft | Allow |
| moodle/competency:planmanageowndraft | Allow |
| moodle/competency:planview | Allow |
| moodle/competency:planreview | Allow |
| moodle/competency:planrequestreview | Allow |
| block/lp:myaddinstance | Allow |
And I log out

View file

@ -47,12 +47,12 @@ class tool_lp_course_competency_settings_testcase extends advanced_testcase {
$dg = $this->getDataGenerator();
$lpg = $dg->get_plugin_generator('tool_lp');
$role = create_role('Settings changer role', 'settingschanger', 'Someone who can change course competency settings');
assign_capability('tool/lp:coursecompetencyconfigure', CAP_ALLOW, $role, $syscontext->id);
assign_capability('tool/lp:competencygrade', CAP_ALLOW, $role, $syscontext->id);
assign_capability('tool/lp:coursecompetencyview', CAP_ALLOW, $role, $syscontext->id);
assign_capability('tool/lp:planview', CAP_ALLOW, $role, $syscontext->id);
assign_capability('moodle/competency:coursecompetencyconfigure', CAP_ALLOW, $role, $syscontext->id);
assign_capability('moodle/competency:competencygrade', CAP_ALLOW, $role, $syscontext->id);
assign_capability('moodle/competency:coursecompetencyview', CAP_ALLOW, $role, $syscontext->id);
assign_capability('moodle/competency:planview', CAP_ALLOW, $role, $syscontext->id);
$gradedrole = create_role('Graded role', 'graded', 'Someone who can be graded');
assign_capability('tool/lp:coursecompetencygradable', CAP_ALLOW, $gradedrole, $syscontext->id);
assign_capability('moodle/competency:coursecompetencygradable', CAP_ALLOW, $gradedrole, $syscontext->id);
$c1 = $dg->create_course();
$u1 = $dg->create_user();

View file

@ -105,39 +105,39 @@ class tool_lp_external_testcase extends externallib_advanced_testcase {
$authrole = array_pop($userroles);
// Reset all default authenticated users permissions.
unassign_capability('tool/lp:competencygrade', $authrole->id);
unassign_capability('tool/lp:competencymanage', $authrole->id);
unassign_capability('tool/lp:competencyview', $authrole->id);
unassign_capability('tool/lp:planmanage', $authrole->id);
unassign_capability('tool/lp:planmanagedraft', $authrole->id);
unassign_capability('tool/lp:planmanageown', $authrole->id);
unassign_capability('tool/lp:planview', $authrole->id);
unassign_capability('tool/lp:planviewdraft', $authrole->id);
unassign_capability('tool/lp:planviewown', $authrole->id);
unassign_capability('tool/lp:planviewowndraft', $authrole->id);
unassign_capability('tool/lp:templatemanage', $authrole->id);
unassign_capability('tool/lp:templateview', $authrole->id);
unassign_capability('moodle/competency:competencygrade', $authrole->id);
unassign_capability('moodle/competency:competencymanage', $authrole->id);
unassign_capability('moodle/competency:competencyview', $authrole->id);
unassign_capability('moodle/competency:planmanage', $authrole->id);
unassign_capability('moodle/competency:planmanagedraft', $authrole->id);
unassign_capability('moodle/competency:planmanageown', $authrole->id);
unassign_capability('moodle/competency:planview', $authrole->id);
unassign_capability('moodle/competency:planviewdraft', $authrole->id);
unassign_capability('moodle/competency:planviewown', $authrole->id);
unassign_capability('moodle/competency:planviewowndraft', $authrole->id);
unassign_capability('moodle/competency:templatemanage', $authrole->id);
unassign_capability('moodle/competency:templateview', $authrole->id);
unassign_capability('moodle/cohort:manage', $authrole->id);
unassign_capability('tool/lp:coursecompetencyconfigure', $authrole->id);
unassign_capability('moodle/competency:coursecompetencyconfigure', $authrole->id);
// Creating specific roles.
$this->creatorrole = create_role('Creator role', 'creatorrole', 'learning plan creator role description');
$this->userrole = create_role('User role', 'userrole', 'learning plan user role description');
assign_capability('tool/lp:competencymanage', CAP_ALLOW, $this->creatorrole, $syscontext->id);
assign_capability('tool/lp:competencycompetencyconfigure', CAP_ALLOW, $this->creatorrole, $syscontext->id);
assign_capability('tool/lp:competencyview', CAP_ALLOW, $this->userrole, $syscontext->id);
assign_capability('tool/lp:planmanage', CAP_ALLOW, $this->creatorrole, $syscontext->id);
assign_capability('tool/lp:planmanagedraft', CAP_ALLOW, $this->creatorrole, $syscontext->id);
assign_capability('tool/lp:planmanageown', CAP_ALLOW, $this->creatorrole, $syscontext->id);
assign_capability('tool/lp:planview', CAP_ALLOW, $this->creatorrole, $syscontext->id);
assign_capability('tool/lp:planviewdraft', CAP_ALLOW, $this->creatorrole, $syscontext->id);
assign_capability('tool/lp:templatemanage', CAP_ALLOW, $this->creatorrole, $syscontext->id);
assign_capability('tool/lp:competencygrade', CAP_ALLOW, $this->creatorrole, $syscontext->id);
assign_capability('moodle/competency:competencymanage', CAP_ALLOW, $this->creatorrole, $syscontext->id);
assign_capability('moodle/competency:competencycompetencyconfigure', CAP_ALLOW, $this->creatorrole, $syscontext->id);
assign_capability('moodle/competency:competencyview', CAP_ALLOW, $this->userrole, $syscontext->id);
assign_capability('moodle/competency:planmanage', CAP_ALLOW, $this->creatorrole, $syscontext->id);
assign_capability('moodle/competency:planmanagedraft', CAP_ALLOW, $this->creatorrole, $syscontext->id);
assign_capability('moodle/competency:planmanageown', CAP_ALLOW, $this->creatorrole, $syscontext->id);
assign_capability('moodle/competency:planview', CAP_ALLOW, $this->creatorrole, $syscontext->id);
assign_capability('moodle/competency:planviewdraft', CAP_ALLOW, $this->creatorrole, $syscontext->id);
assign_capability('moodle/competency:templatemanage', CAP_ALLOW, $this->creatorrole, $syscontext->id);
assign_capability('moodle/competency:competencygrade', CAP_ALLOW, $this->creatorrole, $syscontext->id);
assign_capability('moodle/cohort:manage', CAP_ALLOW, $this->creatorrole, $syscontext->id);
assign_capability('tool/lp:templateview', CAP_ALLOW, $this->userrole, $syscontext->id);
assign_capability('tool/lp:planviewown', CAP_ALLOW, $this->userrole, $syscontext->id);
assign_capability('tool/lp:planviewowndraft', CAP_ALLOW, $this->userrole, $syscontext->id);
assign_capability('moodle/competency:templateview', CAP_ALLOW, $this->userrole, $syscontext->id);
assign_capability('moodle/competency:planviewown', CAP_ALLOW, $this->userrole, $syscontext->id);
assign_capability('moodle/competency:planviewowndraft', CAP_ALLOW, $this->userrole, $syscontext->id);
role_assign($this->creatorrole, $creator->id, $syscontext->id);
role_assign($this->creatorrole, $catcreator->id, $catcontext->id);
@ -1170,7 +1170,7 @@ class tool_lp_external_testcase extends externallib_advanced_testcase {
$this->assertEquals('nopermissions', $e->errorcode);
}
assign_capability('tool/lp:planmanageowndraft', CAP_ALLOW, $this->userrole, $syscontext->id);
assign_capability('moodle/competency:planmanageowndraft', CAP_ALLOW, $this->userrole, $syscontext->id);
accesslib_clear_all_caches_for_unit_testing();
$this->setUser($this->user);
@ -1190,7 +1190,7 @@ class tool_lp_external_testcase extends externallib_advanced_testcase {
$this->assertTrue(true);
}
assign_capability('tool/lp:planmanageown', CAP_ALLOW, $this->userrole, $syscontext->id);
assign_capability('moodle/competency:planmanageown', CAP_ALLOW, $this->userrole, $syscontext->id);
accesslib_clear_all_caches_for_unit_testing();
$plan3 = $this->create_plan(4, $this->user->id, 0, plan::STATUS_ACTIVE, 0);
@ -1207,8 +1207,8 @@ class tool_lp_external_testcase extends externallib_advanced_testcase {
$this->assertEquals('nopermissions', $e->errorcode);
}
unassign_capability('tool/lp:planmanageown', $this->userrole, $syscontext->id);
unassign_capability('tool/lp:planmanageowndraft', $this->userrole, $syscontext->id);
unassign_capability('moodle/competency:planmanageown', $this->userrole, $syscontext->id);
unassign_capability('moodle/competency:planmanageowndraft', $this->userrole, $syscontext->id);
accesslib_clear_all_caches_for_unit_testing();
try {
@ -1230,8 +1230,8 @@ class tool_lp_external_testcase extends externallib_advanced_testcase {
$this->setUser($this->user);
assign_capability('tool/lp:planmanageowndraft', CAP_ALLOW, $this->userrole, $syscontext->id);
assign_capability('tool/lp:planmanageown', CAP_ALLOW, $this->userrole, $syscontext->id);
assign_capability('moodle/competency:planmanageowndraft', CAP_ALLOW, $this->userrole, $syscontext->id);
assign_capability('moodle/competency:planmanageown', CAP_ALLOW, $this->userrole, $syscontext->id);
accesslib_clear_all_caches_for_unit_testing();
$this->setUser($this->user);
@ -1252,8 +1252,8 @@ class tool_lp_external_testcase extends externallib_advanced_testcase {
$this->setUser($this->user);
assign_capability('tool/lp:planmanageowndraft', CAP_ALLOW, $this->userrole, $syscontext->id);
assign_capability('tool/lp:planmanageown', CAP_ALLOW, $this->userrole, $syscontext->id);
assign_capability('moodle/competency:planmanageowndraft', CAP_ALLOW, $this->userrole, $syscontext->id);
assign_capability('moodle/competency:planmanageown', CAP_ALLOW, $this->userrole, $syscontext->id);
accesslib_clear_all_caches_for_unit_testing();
$this->setUser($this->user);
@ -1319,9 +1319,9 @@ class tool_lp_external_testcase extends externallib_advanced_testcase {
$plan1->commentarea['canview'] = true;
// Prevent the user from seeing their own non-draft plans.
assign_capability('tool/lp:plancommentown', CAP_PROHIBIT, $this->userrole, $syscontext->id, true);
assign_capability('tool/lp:planviewown', CAP_PROHIBIT, $this->userrole, $syscontext->id, true);
assign_capability('tool/lp:planviewowndraft', CAP_ALLOW, $this->userrole, $syscontext->id, true);
assign_capability('moodle/competency:plancommentown', CAP_PROHIBIT, $this->userrole, $syscontext->id, true);
assign_capability('moodle/competency:planviewown', CAP_PROHIBIT, $this->userrole, $syscontext->id, true);
assign_capability('moodle/competency:planviewowndraft', CAP_ALLOW, $this->userrole, $syscontext->id, true);
accesslib_clear_all_caches_for_unit_testing();
$this->assertEquals((array)$plan1, external::read_plan($plan1->id));
@ -1340,9 +1340,9 @@ class tool_lp_external_testcase extends externallib_advanced_testcase {
}
// Allow user to see their plan.
assign_capability('tool/lp:plancommentown', CAP_ALLOW, $this->userrole, $syscontext->id, true);
assign_capability('tool/lp:planviewown', CAP_ALLOW, $this->userrole, $syscontext->id, true);
assign_capability('tool/lp:planmanageowndraft', CAP_PROHIBIT, $this->userrole, $syscontext->id, true);
assign_capability('moodle/competency:plancommentown', CAP_ALLOW, $this->userrole, $syscontext->id, true);
assign_capability('moodle/competency:planviewown', CAP_ALLOW, $this->userrole, $syscontext->id, true);
assign_capability('moodle/competency:planmanageowndraft', CAP_PROHIBIT, $this->userrole, $syscontext->id, true);
accesslib_clear_all_caches_for_unit_testing();
$plan1->commentarea['canpost'] = true;
@ -1360,9 +1360,9 @@ class tool_lp_external_testcase extends externallib_advanced_testcase {
$this->assertEquals((array)$plan3, external::read_plan($plan3->id));
// Allow use to manage their own draft plan.
assign_capability('tool/lp:planviewown', CAP_PROHIBIT, $this->userrole, $syscontext->id, true);
assign_capability('tool/lp:planmanageown', CAP_PROHIBIT, $this->userrole, $syscontext->id, true);
assign_capability('tool/lp:planmanageowndraft', CAP_ALLOW, $this->userrole, $syscontext->id, true);
assign_capability('moodle/competency:planviewown', CAP_PROHIBIT, $this->userrole, $syscontext->id, true);
assign_capability('moodle/competency:planmanageown', CAP_PROHIBIT, $this->userrole, $syscontext->id, true);
assign_capability('moodle/competency:planmanageowndraft', CAP_ALLOW, $this->userrole, $syscontext->id, true);
accesslib_clear_all_caches_for_unit_testing();
$plan1->canmanage = true;
@ -1384,9 +1384,9 @@ class tool_lp_external_testcase extends externallib_advanced_testcase {
}
// Allow use to manage their plan.
assign_capability('tool/lp:planviewown', CAP_PROHIBIT, $this->userrole, $syscontext->id, true);
assign_capability('tool/lp:planmanageowndraft', CAP_PROHIBIT, $this->userrole, $syscontext->id, true);
assign_capability('tool/lp:planmanageown', CAP_ALLOW, $this->userrole, $syscontext->id, true);
assign_capability('moodle/competency:planviewown', CAP_PROHIBIT, $this->userrole, $syscontext->id, true);
assign_capability('moodle/competency:planmanageowndraft', CAP_PROHIBIT, $this->userrole, $syscontext->id, true);
assign_capability('moodle/competency:planmanageown', CAP_ALLOW, $this->userrole, $syscontext->id, true);
accesslib_clear_all_caches_for_unit_testing();
$plan1->canmanage = false;
@ -1423,7 +1423,7 @@ class tool_lp_external_testcase extends externallib_advanced_testcase {
$this->assertTrue(external::delete_plan($plan1->id));
unassign_capability('tool/lp:planmanage', $this->creatorrole, $syscontext->id);
unassign_capability('moodle/competency:planmanage', $this->creatorrole, $syscontext->id);
accesslib_clear_all_caches_for_unit_testing();
try {
@ -1443,7 +1443,7 @@ class tool_lp_external_testcase extends externallib_advanced_testcase {
$this->assertEquals('nopermissions', $e->errorcode);
}
assign_capability('tool/lp:planmanageown', CAP_ALLOW, $this->userrole, $syscontext->id);
assign_capability('moodle/competency:planmanageown', CAP_ALLOW, $this->userrole, $syscontext->id);
accesslib_clear_all_caches_for_unit_testing();
$this->assertTrue(external::delete_plan($plan2->id));
@ -1585,7 +1585,7 @@ class tool_lp_external_testcase extends externallib_advanced_testcase {
$this->assertEquals(1, external::count_competencies_in_template($template->id));
// Unassign capability.
unassign_capability('tool/lp:templatemanage', $this->creatorrole, $syscontext->id);
unassign_capability('moodle/competency:templatemanage', $this->creatorrole, $syscontext->id);
accesslib_clear_all_caches_for_unit_testing();
// Check we can not add the competency now.
@ -1622,7 +1622,7 @@ class tool_lp_external_testcase extends externallib_advanced_testcase {
$this->assertEquals(0, external::count_competencies_in_template($template->id));
// Unassign capability.
unassign_capability('tool/lp:templatemanage', $this->creatorrole, $syscontext->id);
unassign_capability('moodle/competency:templatemanage', $this->creatorrole, $syscontext->id);
accesslib_clear_all_caches_for_unit_testing();
// Check we can not remove the competency now.
@ -1848,10 +1848,10 @@ class tool_lp_external_testcase extends externallib_advanced_testcase {
$cattemplate = $this->create_template(2, false);
// User without permissions to read in system.
assign_capability('tool/lp:templateview', CAP_PROHIBIT, $this->userrole, $syscontextid, true);
assign_capability('moodle/competency:templateview', CAP_PROHIBIT, $this->userrole, $syscontextid, true);
accesslib_clear_all_caches_for_unit_testing();
$this->setUser($this->user);
$this->assertFalse(has_capability('tool/lp:templateview', context_system::instance()));
$this->assertFalse(has_capability('moodle/competency:templateview', context_system::instance()));
try {
external::read_template($systemplate->id);
$this->fail('Invalid permissions');
@ -1866,11 +1866,11 @@ class tool_lp_external_testcase extends externallib_advanced_testcase {
}
// User with permissions to read in a category.
assign_capability('tool/lp:templateview', CAP_PREVENT, $this->userrole, $syscontextid, true);
assign_capability('tool/lp:templateview', CAP_ALLOW, $this->userrole, $catcontextid, true);
assign_capability('moodle/competency:templateview', CAP_PREVENT, $this->userrole, $syscontextid, true);
assign_capability('moodle/competency:templateview', CAP_ALLOW, $this->userrole, $catcontextid, true);
accesslib_clear_all_caches_for_unit_testing();
$this->assertFalse(has_capability('tool/lp:templateview', context_system::instance()));
$this->assertTrue(has_capability('tool/lp:templateview', context_coursecat::instance($this->category->id)));
$this->assertFalse(has_capability('moodle/competency:templateview', context_system::instance()));
$this->assertTrue(has_capability('moodle/competency:templateview', context_coursecat::instance($this->category->id)));
try {
external::read_template($systemplate->id);
$this->fail('Invalid permissions');
@ -1889,9 +1889,9 @@ class tool_lp_external_testcase extends externallib_advanced_testcase {
$this->assertEquals(userdate(0), $result['duedateformatted']);
// User with permissions to read in the system.
assign_capability('tool/lp:templateview', CAP_ALLOW, $this->userrole, $syscontextid, true);
assign_capability('moodle/competency:templateview', CAP_ALLOW, $this->userrole, $syscontextid, true);
accesslib_clear_all_caches_for_unit_testing();
$this->assertTrue(has_capability('tool/lp:templateview', context_system::instance()));
$this->assertTrue(has_capability('moodle/competency:templateview', context_system::instance()));
$result = external::read_template($systemplate->id);
$result = external_api::clean_returnvalue(external::read_template_returns(), $result);
$this->assertEquals($systemplate->id, $result['id']);
@ -2068,7 +2068,7 @@ class tool_lp_external_testcase extends externallib_advanced_testcase {
// User without permission.
$this->setUser($this->user);
assign_capability('tool/lp:templateview', CAP_PROHIBIT, $this->userrole, $syscontextid, true);
assign_capability('moodle/competency:templateview', CAP_PROHIBIT, $this->userrole, $syscontextid, true);
accesslib_clear_all_caches_for_unit_testing();
try {
external::list_templates('id', 'ASC', 0, 10, array('contextid' => $syscontextid), 'children', false);
@ -2078,8 +2078,8 @@ class tool_lp_external_testcase extends externallib_advanced_testcase {
}
// User with category permissions.
assign_capability('tool/lp:templateview', CAP_PREVENT, $this->userrole, $syscontextid, true);
assign_capability('tool/lp:templateview', CAP_ALLOW, $this->userrole, $catcontextid, true);
assign_capability('moodle/competency:templateview', CAP_PREVENT, $this->userrole, $syscontextid, true);
assign_capability('moodle/competency:templateview', CAP_ALLOW, $this->userrole, $catcontextid, true);
accesslib_clear_all_caches_for_unit_testing();
$result = external::list_templates('id', 'ASC', 0, 10, array('contextid' => $syscontextid), 'children', false);
$result = external_api::clean_returnvalue(external::list_templates_returns(), $result);
@ -2088,7 +2088,7 @@ class tool_lp_external_testcase extends externallib_advanced_testcase {
$this->assertEquals($cat2->id, $result[1]['id']);
// User with system permissions.
assign_capability('tool/lp:templateview', CAP_ALLOW, $this->userrole, $syscontextid, true);
assign_capability('moodle/competency:templateview', CAP_ALLOW, $this->userrole, $syscontextid, true);
accesslib_clear_all_caches_for_unit_testing();
$result = external::list_templates('id', 'DESC', 0, 3, array('contextid' => $catcontextid), 'parents', false);
$result = external_api::clean_returnvalue(external::list_templates_returns(), $result);
@ -2159,7 +2159,7 @@ class tool_lp_external_testcase extends externallib_advanced_testcase {
// User without permission.
$this->setUser($this->user);
assign_capability('tool/lp:templateview', CAP_PROHIBIT, $this->userrole, $syscontextid, true);
assign_capability('moodle/competency:templateview', CAP_PROHIBIT, $this->userrole, $syscontextid, true);
accesslib_clear_all_caches_for_unit_testing();
try {
external::count_templates(array('contextid' => $syscontextid), 'children');
@ -2169,15 +2169,15 @@ class tool_lp_external_testcase extends externallib_advanced_testcase {
}
// User with category permissions.
assign_capability('tool/lp:templateview', CAP_PREVENT, $this->userrole, $syscontextid, true);
assign_capability('tool/lp:templateview', CAP_ALLOW, $this->userrole, $catcontextid, true);
assign_capability('moodle/competency:templateview', CAP_PREVENT, $this->userrole, $syscontextid, true);
assign_capability('moodle/competency:templateview', CAP_ALLOW, $this->userrole, $catcontextid, true);
accesslib_clear_all_caches_for_unit_testing();
$result = external::count_templates(array('contextid' => $syscontextid), 'children');
$result = external_api::clean_returnvalue(external::count_templates_returns(), $result);
$this->assertEquals(3, $result);
// User with system permissions.
assign_capability('tool/lp:templateview', CAP_ALLOW, $this->userrole, $syscontextid, true);
assign_capability('moodle/competency:templateview', CAP_ALLOW, $this->userrole, $syscontextid, true);
accesslib_clear_all_caches_for_unit_testing();
$result = external::count_templates(array('contextid' => $catcontextid), 'parents');
$result = external_api::clean_returnvalue(external::count_templates_returns(), $result);
@ -2360,8 +2360,8 @@ class tool_lp_external_testcase extends externallib_advanced_testcase {
'shortname' => 'manage'
));
assign_capability('tool/lp:planmanage', CAP_ALLOW, $managerole, $syscontext->id);
assign_capability('tool/lp:planview', CAP_ALLOW, $managerole, $syscontext->id);
assign_capability('moodle/competency:planmanage', CAP_ALLOW, $managerole, $syscontext->id);
assign_capability('moodle/competency:planview', CAP_ALLOW, $managerole, $syscontext->id);
$dg->role_assign($managerole, $usermanage->id, $syscontext->id);
@ -2422,8 +2422,8 @@ class tool_lp_external_testcase extends externallib_advanced_testcase {
'shortname' => 'manage'
));
assign_capability('tool/lp:planmanage', CAP_ALLOW, $managerole, $syscontext->id);
assign_capability('tool/lp:planview', CAP_ALLOW, $managerole, $syscontext->id);
assign_capability('moodle/competency:planmanage', CAP_ALLOW, $managerole, $syscontext->id);
assign_capability('moodle/competency:planview', CAP_ALLOW, $managerole, $syscontext->id);
$dg->role_assign($managerole, $usermanage->id, $syscontext->id);
@ -2467,8 +2467,8 @@ class tool_lp_external_testcase extends externallib_advanced_testcase {
'shortname' => 'manage'
));
assign_capability('tool/lp:planmanage', CAP_ALLOW, $managerole, $syscontext->id);
assign_capability('tool/lp:planview', CAP_ALLOW, $managerole, $syscontext->id);
assign_capability('moodle/competency:planmanage', CAP_ALLOW, $managerole, $syscontext->id);
assign_capability('moodle/competency:planview', CAP_ALLOW, $managerole, $syscontext->id);
$dg->role_assign($managerole, $usermanage->id, $syscontext->id);
@ -2663,7 +2663,7 @@ class tool_lp_external_testcase extends externallib_advanced_testcase {
// First we search with no capability assigned.
$this->setUser($ux);
$result = external::search_users('yyylan', 'tool/lp:planmanage');
$result = external::search_users('yyylan', 'moodle/competency:planmanage');
$result = external_api::clean_returnvalue(external::search_users_returns(), $result);
$this->assertCount(0, $result['users']);
$this->assertEquals(0, $result['count']);
@ -2671,25 +2671,25 @@ class tool_lp_external_testcase extends externallib_advanced_testcase {
// Now we assign a different capability.
$usercontext = context_user::instance($u1->id);
$systemcontext = context_system::instance();
$customrole = $this->assignUserCapability('tool/lp:planview', $usercontext->id);
$customrole = $this->assignUserCapability('moodle/competency:planview', $usercontext->id);
$result = external::search_users('yyylan', 'tool/lp:planmanage');
$result = external::search_users('yyylan', 'moodle/competency:planmanage');
$result = external_api::clean_returnvalue(external::search_users_returns(), $result);
$this->assertCount(0, $result['users']);
$this->assertEquals(0, $result['count']);
// Now we assign a matching capability in the same role.
$usercontext = context_user::instance($u1->id);
$this->assignUserCapability('tool/lp:planmanage', $usercontext->id, $customrole);
$this->assignUserCapability('moodle/competency:planmanage', $usercontext->id, $customrole);
$result = external::search_users('yyylan', 'tool/lp:planmanage');
$result = external::search_users('yyylan', 'moodle/competency:planmanage');
$result = external_api::clean_returnvalue(external::search_users_returns(), $result);
$this->assertCount(1, $result['users']);
$this->assertEquals(1, $result['count']);
// Now assign another role with the same capability (test duplicates).
role_assign($this->creatorrole, $ux->id, $usercontext->id);
$result = external::search_users('yyylan', 'tool/lp:planmanage');
$result = external::search_users('yyylan', 'moodle/competency:planmanage');
$result = external_api::clean_returnvalue(external::search_users_returns(), $result);
$this->assertCount(1, $result['users']);
$this->assertEquals(1, $result['count']);
@ -2698,7 +2698,7 @@ class tool_lp_external_testcase extends externallib_advanced_testcase {
$ux2 = $dg->create_user();
role_assign($this->creatorrole, $ux2->id, $systemcontext->id);
$this->setUser($ux2);
$result = external::search_users('yyylan', 'tool/lp:planmanage');
$result = external::search_users('yyylan', 'moodle/competency:planmanage');
$result = external_api::clean_returnvalue(external::search_users_returns(), $result);
$this->assertCount(1, $result['users']);
$this->assertEquals(1, $result['count']);
@ -2707,7 +2707,7 @@ class tool_lp_external_testcase extends externallib_advanced_testcase {
$ux3 = $dg->create_user();
role_assign($this->creatorrole, $ux3->id, $usercontext->id);
$this->setUser($ux3);
$result = external::search_users('yyylan', 'tool/lp:planmanage');
$result = external::search_users('yyylan', 'moodle/competency:planmanage');
$result = external_api::clean_returnvalue(external::search_users_returns(), $result);
$this->assertCount(1, $result['users']);
$this->assertEquals(1, $result['count']);
@ -2716,15 +2716,15 @@ class tool_lp_external_testcase extends externallib_advanced_testcase {
$this->setUser($ux);
// Now add a prevent override (will change nothing because we still have an ALLOW).
assign_capability('tool/lp:planmanage', CAP_PREVENT, $customrole, $usercontext->id);
$result = external::search_users('yyylan', 'tool/lp:planmanage');
assign_capability('moodle/competency:planmanage', CAP_PREVENT, $customrole, $usercontext->id);
$result = external::search_users('yyylan', 'moodle/competency:planmanage');
$result = external_api::clean_returnvalue(external::search_users_returns(), $result);
$this->assertCount(1, $result['users']);
$this->assertEquals(1, $result['count']);
// Now change to a prohibit override (should prevent access).
assign_capability('tool/lp:planmanage', CAP_PROHIBIT, $customrole, $usercontext->id);
$result = external::search_users('yyylan', 'tool/lp:planmanage');
assign_capability('moodle/competency:planmanage', CAP_PROHIBIT, $customrole, $usercontext->id);
$result = external::search_users('yyylan', 'moodle/competency:planmanage');
$result = external_api::clean_returnvalue(external::search_users_returns(), $result);
$this->assertCount(1, $result['users']);
$this->assertEquals(1, $result['count']);
@ -2814,32 +2814,32 @@ class tool_lp_external_testcase extends externallib_advanced_testcase {
// We need to give the user the capability we are searching for on each of the test users.
$this->setAdminUser();
$usercontext = context_user::instance($u1->id);
$dummyrole = $this->assignUserCapability('tool/lp:planmanage', $usercontext->id);
$dummyrole = $this->assignUserCapability('moodle/competency:planmanage', $usercontext->id);
$usercontext = context_user::instance($u2->id);
$this->assignUserCapability('tool/lp:planmanage', $usercontext->id, $dummyrole);
$this->assignUserCapability('moodle/competency:planmanage', $usercontext->id, $dummyrole);
$usercontext = context_user::instance($u3->id);
$this->assignUserCapability('tool/lp:planmanage', $usercontext->id, $dummyrole);
$this->assignUserCapability('moodle/competency:planmanage', $usercontext->id, $dummyrole);
$this->setUser($ux);
$usercontext = context_user::instance($u1->id);
$this->assignUserCapability('tool/lp:planmanage', $usercontext->id, $dummyrole);
$this->assignUserCapability('moodle/competency:planmanage', $usercontext->id, $dummyrole);
$usercontext = context_user::instance($u2->id);
$this->assignUserCapability('tool/lp:planmanage', $usercontext->id, $dummyrole);
$this->assignUserCapability('moodle/competency:planmanage', $usercontext->id, $dummyrole);
$usercontext = context_user::instance($u3->id);
$this->assignUserCapability('tool/lp:planmanage', $usercontext->id, $dummyrole);
$this->assignUserCapability('moodle/competency:planmanage', $usercontext->id, $dummyrole);
$this->setAdminUser();
// No identity fields.
$CFG->showuseridentity = '';
$result = external::search_users('cats', 'tool/lp:planmanage');
$result = external::search_users('cats', 'moodle/competency:planmanage');
$result = external_api::clean_returnvalue(external::search_users_returns(), $result);
$this->assertCount(0, $result['users']);
$this->assertEquals(0, $result['count']);
// Filter by name.
$CFG->showuseridentity = '';
$result = external::search_users('dyyylan', 'tool/lp:planmanage');
$result = external::search_users('dyyylan', 'moodle/competency:planmanage');
$result = external_api::clean_returnvalue(external::search_users_returns(), $result);
$this->assertCount(2, $result['users']);
$this->assertEquals(2, $result['count']);
@ -2848,7 +2848,7 @@ class tool_lp_external_testcase extends externallib_advanced_testcase {
// Filter by institution and name.
$CFG->showuseridentity = 'institution';
$result = external::search_users('bob', 'tool/lp:planmanage');
$result = external::search_users('bob', 'moodle/competency:planmanage');
$result = external_api::clean_returnvalue(external::search_users_returns(), $result);
$this->assertCount(2, $result['users']);
$this->assertEquals(2, $result['count']);
@ -2857,7 +2857,7 @@ class tool_lp_external_testcase extends externallib_advanced_testcase {
// Filter by id number.
$CFG->showuseridentity = 'idnumber';
$result = external::search_users('cats', 'tool/lp:planmanage');
$result = external::search_users('cats', 'moodle/competency:planmanage');
$result = external_api::clean_returnvalue(external::search_users_returns(), $result);
$this->assertCount(1, $result['users']);
$this->assertEquals(1, $result['count']);
@ -2871,7 +2871,7 @@ class tool_lp_external_testcase extends externallib_advanced_testcase {
// Filter by email.
$CFG->showuseridentity = 'email';
$result = external::search_users('yyy', 'tool/lp:planmanage');
$result = external::search_users('yyy', 'moodle/competency:planmanage');
$result = external_api::clean_returnvalue(external::search_users_returns(), $result);
$this->assertCount(3, $result['users']);
$this->assertEquals(3, $result['count']);
@ -2884,7 +2884,7 @@ class tool_lp_external_testcase extends externallib_advanced_testcase {
// Filter by any.
$CFG->showuseridentity = 'idnumber,email,phone1,phone2,department,institution';
$result = external::search_users('yyy', 'tool/lp:planmanage');
$result = external::search_users('yyy', 'moodle/competency:planmanage');
$result = external_api::clean_returnvalue(external::search_users_returns(), $result);
$this->assertCount(3, $result['users']);
$this->assertEquals(3, $result['count']);
@ -2905,7 +2905,7 @@ class tool_lp_external_testcase extends externallib_advanced_testcase {
$this->assertCount(0, $result['users']);
$this->assertEquals(0, $result['count']);
$result = external::search_users('bob', 'tool/lp:planmanage');
$result = external::search_users('bob', 'moodle/competency:planmanage');
$result = external_api::clean_returnvalue(external::search_users_returns(), $result);
$this->assertCount(1, $result['users']);
$this->assertEquals(1, $result['count']);
@ -3066,9 +3066,9 @@ class tool_lp_external_testcase extends externallib_advanced_testcase {
$compmanager = $this->getDataGenerator()->create_user();
$compnoob = $this->getDataGenerator()->create_user();
assign_capability('tool/lp:coursecompetencyconfigure', CAP_ALLOW, $roleid, $context->id, true);
assign_capability('tool/lp:coursecompetencyview', CAP_ALLOW, $roleid, $context->id, true);
assign_capability('tool/lp:coursecompetencyview', CAP_ALLOW, $noobroleid, $context->id, true);
assign_capability('moodle/competency:coursecompetencyconfigure', CAP_ALLOW, $roleid, $context->id, true);
assign_capability('moodle/competency:coursecompetencyview', CAP_ALLOW, $roleid, $context->id, true);
assign_capability('moodle/competency:coursecompetencyview', CAP_ALLOW, $noobroleid, $context->id, true);
role_assign($roleid, $compmanager->id, $context->id);
role_assign($noobroleid, $compnoob->id, $context->id);

View file

@ -48,8 +48,8 @@ class tool_lp_lib_testcase extends advanced_testcase {
$u2 = $dg->create_user();
$u3 = $dg->create_user();
$reviewerroleid = $dg->create_role();
assign_capability('tool/lp:planview', CAP_ALLOW, $reviewerroleid, context_system::instance()->id, true);
assign_capability('tool/lp:usercompetencycomment', CAP_ALLOW, $reviewerroleid, context_system::instance()->id, true);
assign_capability('moodle/competency:planview', CAP_ALLOW, $reviewerroleid, context_system::instance()->id, true);
assign_capability('moodle/competency:usercompetencycomment', CAP_ALLOW, $reviewerroleid, context_system::instance()->id, true);
$dg->role_assign($reviewerroleid, $u2->id, context_user::instance($u1->id));
$dg->role_assign($reviewerroleid, $u3->id, context_user::instance($u1->id));
accesslib_clear_all_caches_for_unit_testing();
@ -196,11 +196,11 @@ class tool_lp_lib_testcase extends advanced_testcase {
$u3 = $dg->create_user();
$userroleid = $dg->create_role();
$reviewerroleid = $dg->create_role();
assign_capability('tool/lp:planviewowndraft', CAP_ALLOW, $userroleid, context_system::instance()->id, true);
assign_capability('tool/lp:planviewown', CAP_ALLOW, $userroleid, context_system::instance()->id, true);
assign_capability('tool/lp:planviewdraft', CAP_ALLOW, $reviewerroleid, context_system::instance()->id, true);
assign_capability('tool/lp:planmanage', CAP_ALLOW, $reviewerroleid, context_system::instance()->id, true);
assign_capability('tool/lp:plancomment', CAP_ALLOW, $reviewerroleid, context_system::instance()->id, true);
assign_capability('moodle/competency:planviewowndraft', CAP_ALLOW, $userroleid, context_system::instance()->id, true);
assign_capability('moodle/competency:planviewown', CAP_ALLOW, $userroleid, context_system::instance()->id, true);
assign_capability('moodle/competency:planviewdraft', CAP_ALLOW, $reviewerroleid, context_system::instance()->id, true);
assign_capability('moodle/competency:planmanage', CAP_ALLOW, $reviewerroleid, context_system::instance()->id, true);
assign_capability('moodle/competency:plancomment', CAP_ALLOW, $reviewerroleid, context_system::instance()->id, true);
$dg->role_assign($userroleid, $u1->id, context_user::instance($u1->id));
$dg->role_assign($reviewerroleid, $u2->id, context_user::instance($u1->id));
$dg->role_assign($reviewerroleid, $u3->id, context_system::instance());

View file

@ -51,8 +51,8 @@ class tool_lp_plan_testcase extends advanced_testcase {
$u2context = context_user::instance($u2->id);
$u3context = context_user::instance($u3->id);
assign_capability('tool/lp:planmanage', CAP_ALLOW, $manage, $syscontext->id);
assign_capability('tool/lp:planmanageown', CAP_ALLOW, $manageown, $u2context->id);
assign_capability('moodle/competency:planmanage', CAP_ALLOW, $manage, $syscontext->id);
assign_capability('moodle/competency:planmanageown', CAP_ALLOW, $manageown, $u2context->id);
role_assign($manage, $u1->id, $syscontext->id);
role_assign($manageown, $u2->id, $syscontext->id);
@ -96,10 +96,10 @@ class tool_lp_plan_testcase extends advanced_testcase {
$u4context = context_user::instance($u4->id);
$u5context = context_user::instance($u5->id);
assign_capability('tool/lp:planmanage', CAP_ALLOW, $manage, $syscontext->id);
assign_capability('tool/lp:planmanageown', CAP_ALLOW, $manageown, $syscontext->id);
assign_capability('tool/lp:planmanagedraft', CAP_ALLOW, $managedraft, $syscontext->id);
assign_capability('tool/lp:planmanageowndraft', CAP_ALLOW, $manageowndraft, $syscontext->id);
assign_capability('moodle/competency:planmanage', CAP_ALLOW, $manage, $syscontext->id);
assign_capability('moodle/competency:planmanageown', CAP_ALLOW, $manageown, $syscontext->id);
assign_capability('moodle/competency:planmanagedraft', CAP_ALLOW, $managedraft, $syscontext->id);
assign_capability('moodle/competency:planmanageowndraft', CAP_ALLOW, $manageowndraft, $syscontext->id);
role_assign($manage, $u1->id, $syscontext->id);
role_assign($manageown, $u2->id, $syscontext->id);
@ -159,8 +159,8 @@ class tool_lp_plan_testcase extends advanced_testcase {
$u2context = context_user::instance($u2->id);
$u3context = context_user::instance($u3->id);
assign_capability('tool/lp:planview', CAP_ALLOW, $read, $syscontext->id);
assign_capability('tool/lp:planviewown', CAP_ALLOW, $readown, $u2context->id);
assign_capability('moodle/competency:planview', CAP_ALLOW, $read, $syscontext->id);
assign_capability('moodle/competency:planviewown', CAP_ALLOW, $readown, $u2context->id);
role_assign($read, $u1->id, $syscontext->id);
role_assign($readown, $u2->id, $syscontext->id);
@ -204,11 +204,11 @@ class tool_lp_plan_testcase extends advanced_testcase {
$u4context = context_user::instance($u4->id);
$u5context = context_user::instance($u5->id);
assign_capability('tool/lp:planview', CAP_ALLOW, $read, $syscontext->id);
assign_capability('tool/lp:planviewown', CAP_ALLOW, $readown, $syscontext->id);
assign_capability('tool/lp:planviewdraft', CAP_ALLOW, $readdraft, $syscontext->id);
assign_capability('tool/lp:planviewowndraft', CAP_ALLOW, $readowndraft, $syscontext->id);
assign_capability('tool/lp:planviewown', CAP_PROHIBIT, $readowndraft, $syscontext->id);
assign_capability('moodle/competency:planview', CAP_ALLOW, $read, $syscontext->id);
assign_capability('moodle/competency:planviewown', CAP_ALLOW, $readown, $syscontext->id);
assign_capability('moodle/competency:planviewdraft', CAP_ALLOW, $readdraft, $syscontext->id);
assign_capability('moodle/competency:planviewowndraft', CAP_ALLOW, $readowndraft, $syscontext->id);
assign_capability('moodle/competency:planviewown', CAP_PROHIBIT, $readowndraft, $syscontext->id);
role_assign($read, $u1->id, $syscontext->id);
role_assign($readown, $u2->id, $syscontext->id);

View file

@ -38,14 +38,14 @@ $course = $DB->get_record('course', array('id' => $courseid));
$context = context_course::instance($courseid);
$currentgroup = groups_get_course_group($course, true);
if (empty($userid)) {
$gradable = get_enrolled_users($context, 'tool/lp:coursecompetencygradable', $currentgroup, 'u.id', null, 0, 1);
$gradable = get_enrolled_users($context, 'moodle/competency:coursecompetencygradable', $currentgroup, 'u.id', null, 0, 1);
if (empty($gradable)) {
$userid = 0;
} else {
$userid = array_pop($gradable)->id;
}
} else {
$gradable = get_enrolled_users($context, 'tool/lp:coursecompetencygradable', $currentgroup, 'u.id');
$gradable = get_enrolled_users($context, 'moodle/competency:coursecompetencygradable', $currentgroup, 'u.id');
if (count($gradable) == 0) {
$userid = 0;
} else if (!in_array($userid, array_keys($gradable))) {

View file

@ -68,12 +68,12 @@ $customdata = array(
// Check if user has permissions to manage user evidence.
if ($userevidence != null) {
if (!$userevidence->can_manage()) {
throw new required_capability_exception($context, 'tool/lp:userevidencemanage', 'nopermissions', '');
throw new required_capability_exception($context, 'moodle/competency:userevidencemanage', 'nopermissions', '');
}
$customdata['evidence'] = $userevidence;
} else if (!\tool_lp\user_evidence::can_manage_user($userid)) {
throw new required_capability_exception($context, 'tool/lp:userevidencemanage', 'nopermissions', '');
throw new required_capability_exception($context, 'moodle/competency:userevidencemanage', 'nopermissions', '');
}
$form = new \tool_lp\form\user_evidence($url->out(false), $customdata);