From b90e2205b4cb9537536553d036de098db0873ff6 Mon Sep 17 00:00:00 2001 From: Frederic Massart Date: Mon, 4 Apr 2016 14:49:50 +0800 Subject: [PATCH] MDL-53700 competency: Migrate capabilities to core --- admin/tool/lp/classes/api.php | 396 +++++++++--------- .../tool/lp/classes/competency_framework.php | 4 +- .../lp/classes/course_competency_settings.php | 4 +- .../competency_framework_exporter.php | 2 +- .../course_competency_statistics_exporter.php | 4 +- .../classes/form/framework_autocomplete.php | 2 +- admin/tool/lp/classes/form/plan.php | 2 +- admin/tool/lp/classes/form/template_plans.php | 2 +- .../output/course_competencies_page.php | 8 +- .../output/manage_competencies_page.php | 2 +- .../classes/output/template_cohorts_table.php | 2 +- .../output/template_competencies_page.php | 4 +- .../classes/output/template_plans_table.php | 2 +- .../user_competency_course_navigation.php | 4 +- admin/tool/lp/classes/plan.php | 26 +- admin/tool/lp/classes/template.php | 4 +- admin/tool/lp/classes/user_competency.php | 18 +- admin/tool/lp/classes/user_evidence.php | 6 +- admin/tool/lp/competencies.php | 2 +- admin/tool/lp/competencyframeworks.php | 2 +- admin/tool/lp/db/access.php | 263 ------------ admin/tool/lp/db/services.php | 190 ++++----- admin/tool/lp/editcompetencyframework.php | 2 +- admin/tool/lp/editplan.php | 4 +- admin/tool/lp/edittemplate.php | 2 +- admin/tool/lp/lang/en/tool_lp.php | 31 -- admin/tool/lp/learningplans.php | 2 +- admin/tool/lp/lib.php | 2 +- admin/tool/lp/settings.php | 4 +- admin/tool/lp/template_cohorts.php | 2 +- admin/tool/lp/template_plans.php | 2 +- admin/tool/lp/templatecompetencies.php | 2 +- admin/tool/lp/tests/api_test.php | 68 +-- .../tool/lp/tests/behat/plan_workflow.feature | 18 +- .../tests/course_competency_settings_test.php | 10 +- admin/tool/lp/tests/externallib_test.php | 200 ++++----- admin/tool/lp/tests/lib_test.php | 14 +- admin/tool/lp/tests/plan_test.php | 26 +- admin/tool/lp/user_competency_in_course.php | 4 +- admin/tool/lp/user_evidence_edit.php | 4 +- lang/en/role.php | 31 ++ lib/db/access.php | 235 ++++++++++- 42 files changed, 791 insertions(+), 821 deletions(-) delete mode 100644 admin/tool/lp/db/access.php diff --git a/admin/tool/lp/classes/api.php b/admin/tool/lp/classes/api.php index d761eb2868a79..a7e63358a5e45 100644 --- a/admin/tool/lp/classes/api.php +++ b/admin/tool/lp/classes/api.php @@ -147,7 +147,7 @@ protected static function validate_course($courseorid, $throwexception = true) { /** * Create a competency from a record containing all the data for the class. * - * Requires tool/lp:competencymanage capability at the system context. + * Requires moodle/competency:competencymanage capability at the system context. * * @param stdClass $record Record containing all the data for an instance of the class. * @return competency @@ -157,7 +157,7 @@ public static function create_competency(stdClass $record) { $competency = new competency(0, $record); // First we do a permissions check. - require_capability('tool/lp:competencymanage', $competency->get_context()); + require_capability('moodle/competency:competencymanage', $competency->get_context()); // Reset the sortorder, use reorder instead. $competency->set_sortorder(null); @@ -178,7 +178,7 @@ public static function create_competency(stdClass $record) { /** * Delete a competency by id. * - * Requires tool/lp:competencymanage capability at the system context. + * Requires moodle/competency:competencymanage capability at the system context. * * @param int $id The record to delete. This will delete alot of related data - you better be sure. * @return boolean @@ -189,7 +189,7 @@ public static function delete_competency($id) { $competency = new competency($id); // First we do a permissions check. - require_capability('tool/lp:competencymanage', $competency->get_context()); + require_capability('moodle/competency:competencymanage', $competency->get_context()); $events = array(); $competencyids = array(intval($competency->get_id())); @@ -240,7 +240,7 @@ public static function delete_competency($id) { /** * Reorder this competency. * - * Requires tool/lp:competencymanage capability at the system context. + * Requires moodle/competency:competencymanage capability at the system context. * * @param int $id The id of the competency to move. * @return boolean @@ -250,7 +250,7 @@ public static function move_down_competency($id) { $current = new competency($id); // First we do a permissions check. - require_capability('tool/lp:competencymanage', $current->get_context()); + require_capability('moodle/competency:competencymanage', $current->get_context()); $max = self::count_competencies(array('parentid' => $current->get_parentid(), 'competencyframeworkid' => $current->get_competencyframeworkid())); @@ -283,7 +283,7 @@ public static function move_down_competency($id) { /** * Reorder this competency. * - * Requires tool/lp:competencymanage capability at the system context. + * Requires moodle/competency:competencymanage capability at the system context. * * @param int $id The id of the competency to move. * @return boolean @@ -293,7 +293,7 @@ public static function move_up_competency($id) { $current = new competency($id); // First we do a permissions check. - require_capability('tool/lp:competencymanage', $current->get_context()); + require_capability('moodle/competency:competencymanage', $current->get_context()); $sortorder = $current->get_sortorder(); if ($sortorder == 0) { @@ -321,7 +321,7 @@ public static function move_up_competency($id) { /** * Move this competency so it sits in a new parent. * - * Requires tool/lp:competencymanage capability at the system context. + * Requires moodle/competency:competencymanage capability at the system context. * * @param int $id The id of the competency to move. * @param int $newparentid The new parent id for the competency. @@ -333,7 +333,7 @@ public static function set_parent_competency($id, $newparentid) { $current = new competency($id); // First we do a permissions check. - require_capability('tool/lp:competencymanage', $current->get_context()); + require_capability('moodle/competency:competencymanage', $current->get_context()); if ($id == $newparentid) { throw new coding_exception('Can not set a competency as a parent of itself.'); } if ($newparentid == $current->get_parentid()) { @@ -390,7 +390,7 @@ public static function set_parent_competency($id, $newparentid) { /** * Update the details for a competency. * - * Requires tool/lp:competencymanage capability at the system context. + * Requires moodle/competency:competencymanage capability at the system context. * * @param stdClass $record The new details for the competency. * Note - must contain an id that points to the competency to update. @@ -402,7 +402,7 @@ public static function update_competency($record) { $competency = new competency($record->id); // First we do a permissions check. - require_capability('tool/lp:competencymanage', $competency->get_context()); + require_capability('moodle/competency:competencymanage', $competency->get_context()); // Some things should not be changed in an update - they should use a more specific method. $record->sortorder = $competency->get_sortorder(); @@ -410,7 +410,7 @@ public static function update_competency($record) { $record->competencyframeworkid = $competency->get_competencyframeworkid(); $competency->from_record($record); - require_capability('tool/lp:competencymanage', $competency->get_context()); + require_capability('moodle/competency:competencymanage', $competency->get_context()); // OK - all set. $result = $competency->update(); @@ -424,7 +424,7 @@ public static function update_competency($record) { /** * Read a the details for a single competency and return a record. * - * Requires tool/lp:competencyview capability at the system context. + * Requires moodle/competency:competencyview capability at the system context. * * @param int $id The id of the competency to read. * @param bool $includerelated Include related tags or not. @@ -436,8 +436,8 @@ public static function read_competency($id, $includerelated = false) { // First we do a permissions check. $context = $competency->get_context(); - if (!has_any_capability(array('tool/lp:competencyview', 'tool/lp:competencymanage'), $context)) { - throw new required_capability_exception($context, 'tool/lp:competencyview', 'nopermissions', ''); + if (!has_any_capability(array('moodle/competency:competencyview', 'moodle/competency:competencymanage'), $context)) { + throw new required_capability_exception($context, 'moodle/competency:competencyview', 'nopermissions', ''); } // OK - all set. @@ -454,7 +454,7 @@ public static function read_competency($id, $includerelated = false) { /** * Perform a text search based and return all results and their parents. * - * Requires tool/lp:competencyview capability at the framework context. + * Requires moodle/competency:competencyview capability at the framework context. * * @param string $textsearch A string to search for. * @param int $competencyframeworkid The id of the framework to limit the search. @@ -466,8 +466,8 @@ public static function search_competencies($textsearch, $competencyframeworkid) // First we do a permissions check. $context = $framework->get_context(); - if (!has_any_capability(array('tool/lp:competencyview', 'tool/lp:competencymanage'), $context)) { - throw new required_capability_exception($context, 'tool/lp:competencyview', 'nopermissions', ''); + if (!has_any_capability(array('moodle/competency:competencyview', 'moodle/competency:competencymanage'), $context)) { + throw new required_capability_exception($context, 'moodle/competency:competencyview', 'nopermissions', ''); } // OK - all set. @@ -478,7 +478,7 @@ public static function search_competencies($textsearch, $competencyframeworkid) /** * Perform a search based on the provided filters and return a paginated list of records. * - * Requires tool/lp:competencyview capability at some context. + * Requires moodle/competency:competencyview capability at some context. * * @param array $filters A list of filters to apply to the list. * @param string $sort The column to sort on @@ -497,8 +497,8 @@ public static function list_competencies($filters, $sort = '', $order = 'ASC', $ } // First we do a permissions check. - if (!has_any_capability(array('tool/lp:competencyview', 'tool/lp:competencymanage'), $context)) { - throw new required_capability_exception($context, 'tool/lp:competencyview', 'nopermissions', ''); + if (!has_any_capability(array('moodle/competency:competencyview', 'moodle/competency:competencymanage'), $context)) { + throw new required_capability_exception($context, 'moodle/competency:competencyview', 'nopermissions', ''); } // OK - all set. @@ -508,7 +508,7 @@ public static function list_competencies($filters, $sort = '', $order = 'ASC', $ /** * Perform a search based on the provided filters and return a paginated list of records. * - * Requires tool/lp:competencyview capability at some context. + * Requires moodle/competency:competencyview capability at some context. * * @param array $filters A list of filters to apply to the list. * @return int @@ -523,8 +523,8 @@ public static function count_competencies($filters) { } // First we do a permissions check. - if (!has_any_capability(array('tool/lp:competencyview', 'tool/lp:competencymanage'), $context)) { - throw new required_capability_exception($context, 'tool/lp:competencyview', 'nopermissions', ''); + if (!has_any_capability(array('moodle/competency:competencyview', 'moodle/competency:competencymanage'), $context)) { + throw new required_capability_exception($context, 'moodle/competency:competencyview', 'nopermissions', ''); } // OK - all set. @@ -534,7 +534,7 @@ public static function count_competencies($filters) { /** * Create a competency framework from a record containing all the data for the class. * - * Requires tool/lp:competencymanage capability at the system context. + * Requires moodle/competency:competencymanage capability at the system context. * * @param stdClass $record Record containing all the data for an instance of the class. * @return competency_framework @@ -542,7 +542,7 @@ public static function count_competencies($filters) { public static function create_framework(stdClass $record) { static::require_enabled(); $framework = new competency_framework(0, $record); - require_capability('tool/lp:competencymanage', $framework->get_context()); + require_capability('moodle/competency:competencymanage', $framework->get_context()); // Account for different formats of taxonomies. if (isset($record->taxonomies)) { @@ -560,7 +560,7 @@ public static function create_framework(stdClass $record) { /** * Duplicate a competency framework by id. * - * Requires tool/lp:competencymanage capability at the system context. + * Requires moodle/competency:competencymanage capability at the system context. * * @param int $id The record to duplicate. All competencies associated and related will be duplicated. * @return competency_framework the framework duplicated @@ -570,7 +570,7 @@ public static function duplicate_framework($id) { static::require_enabled(); $framework = new competency_framework($id); - require_capability('tool/lp:competencymanage', $framework->get_context()); + require_capability('moodle/competency:competencymanage', $framework->get_context()); // Starting transaction. $transaction = $DB->start_delegated_transaction(); @@ -629,7 +629,7 @@ public static function duplicate_framework($id) { /** * Delete a competency framework by id. * - * Requires tool/lp:competencymanage capability at the system context. + * Requires moodle/competency:competencymanage capability at the system context. * * @param int $id The record to delete. This will delete alot of related data - you better be sure. * @return boolean @@ -638,7 +638,7 @@ public static function delete_framework($id) { global $DB; static::require_enabled(); $framework = new competency_framework($id); - require_capability('tool/lp:competencymanage', $framework->get_context()); + require_capability('moodle/competency:competencymanage', $framework->get_context()); $events = array(); $competenciesid = competency::get_ids_by_frameworkid($id); @@ -687,7 +687,7 @@ public static function delete_framework($id) { /** * Update the details for a competency framework. * - * Requires tool/lp:competencymanage capability at the system context. + * Requires moodle/competency:competencymanage capability at the system context. * * @param stdClass $record The new details for the framework. Note - must contain an id that points to the framework to update. * @return boolean @@ -697,7 +697,7 @@ public static function update_framework($record) { $framework = new competency_framework($record->id); // Check the permissions before update. - require_capability('tool/lp:competencymanage', $framework->get_context()); + require_capability('moodle/competency:competencymanage', $framework->get_context()); // Account for different formats of taxonomies. $framework->from_record($record); @@ -714,7 +714,7 @@ public static function update_framework($record) { /** * Read a the details for a single competency framework and return a record. * - * Requires tool/lp:competencyview capability at the system context. + * Requires moodle/competency:competencyview capability at the system context. * * @param int $id The id of the framework to read. * @return competency_framework @@ -722,8 +722,8 @@ public static function update_framework($record) { public static function read_framework($id) { static::require_enabled(); $framework = new competency_framework($id); - if (!has_any_capability(array('tool/lp:competencyview', 'tool/lp:competencymanage'), $framework->get_context())) { - throw new required_capability_exception($framework->get_context(), 'tool/lp:competencyview', 'nopermissions', ''); + if (!has_any_capability(array('moodle/competency:competencyview', 'moodle/competency:competencymanage'), $framework->get_context())) { + throw new required_capability_exception($framework->get_context(), 'moodle/competency:competencyview', 'nopermissions', ''); } return $framework; } @@ -740,8 +740,8 @@ public static function competency_framework_viewed($frameworkorid) { if (!is_object($framework)) { $framework = new competency_framework($framework); } - if (!has_any_capability(array('tool/lp:competencyview', 'tool/lp:competencymanage'), $framework->get_context())) { - throw new required_capability_exception($framework->get_context(), 'tool/lp:competencyview', 'nopermissions', ''); + if (!has_any_capability(array('moodle/competency:competencyview', 'moodle/competency:competencymanage'), $framework->get_context())) { + throw new required_capability_exception($framework->get_context(), 'moodle/competency:competencyview', 'nopermissions', ''); } \tool_lp\event\competency_framework_viewed::create_from_framework($framework)->trigger(); return true; @@ -760,8 +760,8 @@ public static function competency_viewed($competencyorid) { $competency = new competency($competency); } - if (!has_any_capability(array('tool/lp:competencyview', 'tool/lp:competencymanage'), $competency->get_context())) { - throw new required_capability_exception($competency->get_context(), 'tool/lp:competencyview', 'nopermissions', ''); + if (!has_any_capability(array('moodle/competency:competencyview', 'moodle/competency:competencymanage'), $competency->get_context())) { + throw new required_capability_exception($competency->get_context(), 'moodle/competency:competencyview', 'nopermissions', ''); } \tool_lp\event\competency_viewed::create_from_competency($competency)->trigger(); @@ -771,7 +771,7 @@ public static function competency_viewed($competencyorid) { /** * Perform a search based on the provided filters and return a paginated list of records. * - * Requires tool/lp:competencyview capability at the system context. + * Requires moodle/competency:competencyview capability at the system context. * * @param string $sort The column to sort on * @param string $order ('ASC' or 'DESC') @@ -794,10 +794,10 @@ public static function list_frameworks($sort, $order, $skip, $limit, $context, $ // Get all the relevant contexts. $contexts = self::get_related_contexts($context, $includes, - array('tool/lp:competencyview', 'tool/lp:competencymanage')); + array('moodle/competency:competencyview', 'moodle/competency:competencymanage')); if (empty($contexts)) { - throw new required_capability_exception($context, 'tool/lp:competencyview', 'nopermissions', ''); + throw new required_capability_exception($context, 'moodle/competency:competencyview', 'nopermissions', ''); } // OK - all set. @@ -823,7 +823,7 @@ public static function list_frameworks($sort, $order, $skip, $limit, $context, $ /** * Perform a search based on the provided filters and return a paginated list of records. * - * Requires tool/lp:competencyview capability at the system context. + * Requires moodle/competency:competencyview capability at the system context. * * @param context $context The parent context of the frameworks. * @param string $includes Defines what other contexts to fetch frameworks from. @@ -839,10 +839,10 @@ public static function count_frameworks($context, $includes) { // Get all the relevant contexts. $contexts = self::get_related_contexts($context, $includes, - array('tool/lp:competencyview', 'tool/lp:competencymanage')); + array('moodle/competency:competencyview', 'moodle/competency:competencymanage')); if (empty($contexts)) { - throw new required_capability_exception($context, 'tool/lp:competencyview', 'nopermissions', ''); + throw new required_capability_exception($context, 'moodle/competency:competencyview', 'nopermissions', ''); } // OK - all set. @@ -932,7 +932,7 @@ public static function count_courses_using_competency($competencyid) { } $context = context_course::instance($course->id); - $capabilities = array('tool/lp:coursecompetencyview', 'tool/lp:coursecompetencymanage'); + $capabilities = array('moodle/competency:coursecompetencyview', 'moodle/competency:coursecompetencymanage'); if (!has_any_capability($capabilities, $context)) { continue; } @@ -959,9 +959,9 @@ public static function list_course_modules_using_competency($competencyid, $cour $coursecontext = context_course::instance($courseid); // We will not check each module - course permissions should be enough. - $capabilities = array('tool/lp:coursecompetencyview', 'tool/lp:coursecompetencymanage'); + $capabilities = array('moodle/competency:coursecompetencyview', 'moodle/competency:coursecompetencymanage'); if (!has_any_capability($capabilities, $coursecontext)) { - throw new required_capability_exception($coursecontext, 'tool/lp:coursecompetencyview', 'nopermissions', ''); + throw new required_capability_exception($coursecontext, 'moodle/competency:coursecompetencyview', 'nopermissions', ''); } $cmlist = course_module_competency::list_course_modules($competencyid, $courseid); @@ -991,9 +991,9 @@ public static function list_course_module_competencies_in_course_module($cmorid) self::validate_course_module($cm); $context = context_module::instance($cm->id); - $capabilities = array('tool/lp:coursecompetencyview', 'tool/lp:coursecompetencymanage'); + $capabilities = array('moodle/competency:coursecompetencyview', 'moodle/competency:coursecompetencymanage'); if (!has_any_capability($capabilities, $context)) { - throw new required_capability_exception($context, 'tool/lp:coursecompetencyview', 'nopermissions', ''); + throw new required_capability_exception($context, 'moodle/competency:coursecompetencyview', 'nopermissions', ''); } $result = array(); @@ -1022,7 +1022,7 @@ public static function list_courses_using_competency($competencyid) { // Now check permissions on each course. foreach ($courses as $id => $course) { $context = context_course::instance($course->id); - $capabilities = array('tool/lp:coursecompetencyview', 'tool/lp:coursecompetencymanage'); + $capabilities = array('moodle/competency:coursecompetencyview', 'moodle/competency:coursecompetencymanage'); if (!has_any_capability($capabilities, $context)) { unset($courses[$id]); continue; @@ -1052,9 +1052,9 @@ public static function count_proficient_competencies_in_course_for_user($coursei // First we do a permissions check. $context = context_course::instance($courseid); - $capabilities = array('tool/lp:coursecompetencyview', 'tool/lp:coursecompetencymanage'); + $capabilities = array('moodle/competency:coursecompetencyview', 'moodle/competency:coursecompetencymanage'); if (!has_any_capability($capabilities, $context)) { - throw new required_capability_exception($context, 'tool/lp:coursecompetencyview', 'nopermissions', ''); + throw new required_capability_exception($context, 'moodle/competency:coursecompetencyview', 'nopermissions', ''); } // OK - all set. @@ -1075,9 +1075,9 @@ public static function count_competencies_in_course($courseid) { // First we do a permissions check. $context = context_course::instance($courseid); - $capabilities = array('tool/lp:coursecompetencyview', 'tool/lp:coursecompetencymanage'); + $capabilities = array('moodle/competency:coursecompetencyview', 'moodle/competency:coursecompetencymanage'); if (!has_any_capability($capabilities, $context)) { - throw new required_capability_exception($context, 'tool/lp:coursecompetencyview', 'nopermissions', ''); + throw new required_capability_exception($context, 'moodle/competency:coursecompetencyview', 'nopermissions', ''); } // OK - all set. @@ -1104,9 +1104,9 @@ public static function list_course_competencies($courseorid) { self::validate_course($course); $context = context_course::instance($course->id); - $capabilities = array('tool/lp:coursecompetencyview', 'tool/lp:coursecompetencymanage'); + $capabilities = array('moodle/competency:coursecompetencyview', 'moodle/competency:coursecompetencymanage'); if (!has_any_capability($capabilities, $context)) { - throw new required_capability_exception($context, 'tool/lp:coursecompetencyview', 'nopermissions', ''); + throw new required_capability_exception($context, 'moodle/competency:coursecompetencyview', 'nopermissions', ''); } $result = array(); @@ -1144,7 +1144,7 @@ public static function get_user_competency($userid, $competencyid) { } if (!$uc->can_read()) { - throw new required_capability_exception($uc->get_context(), 'tool/lp:usercompetencyview', 'nopermissions', ''); + throw new required_capability_exception($uc->get_context(), 'moodle/competency:usercompetencyview', 'nopermissions', ''); } return $uc; } @@ -1159,7 +1159,7 @@ public static function get_user_competency_by_id($usercompetencyid) { static::require_enabled(); $uc = new user_competency($usercompetencyid); if (!$uc->can_read()) { - throw new required_capability_exception($uc->get_context(), 'tool/lp:usercompetencyview', 'nopermissions', ''); + throw new required_capability_exception($uc->get_context(), 'moodle/competency:usercompetencyview', 'nopermissions', ''); } return $uc; } @@ -1184,9 +1184,9 @@ public static function list_course_module_competencies($cmorid) { self::validate_course_module($cm); $context = context_module::instance($cm->id); - $capabilities = array('tool/lp:coursecompetencyview', 'tool/lp:coursecompetencymanage'); + $capabilities = array('moodle/competency:coursecompetencyview', 'moodle/competency:coursecompetencymanage'); if (!has_any_capability($capabilities, $context)) { - throw new required_capability_exception($context, 'tool/lp:coursecompetencyview', 'nopermissions', ''); + throw new required_capability_exception($context, 'moodle/competency:coursecompetencyview', 'nopermissions', ''); } $result = array(); @@ -1219,11 +1219,11 @@ public static function get_user_competency_in_course($courseid, $userid, $compet // First we do a permissions check. $context = context_course::instance($courseid); - $capabilities = array('tool/lp:coursecompetencyview', 'tool/lp:coursecompetencymanage'); + $capabilities = array('moodle/competency:coursecompetencyview', 'moodle/competency:coursecompetencymanage'); if (!has_any_capability($capabilities, $context)) { - throw new required_capability_exception($context, 'tool/lp:coursecompetencyview', 'nopermissions', ''); + throw new required_capability_exception($context, 'moodle/competency:coursecompetencyview', 'nopermissions', ''); } else if (!user_competency::can_read_user_in_course($userid, $courseid)) { - throw new required_capability_exception($context, 'tool/lp:usercompetencyview', 'nopermissions', ''); + throw new required_capability_exception($context, 'moodle/competency:usercompetencyview', 'nopermissions', ''); } // This will throw an exception if the competency does not belong to the course. @@ -1255,11 +1255,11 @@ public static function list_user_competencies_in_course($courseid, $userid) { $context = context_course::instance($courseid); $onlyvisible = 1; - $capabilities = array('tool/lp:coursecompetencyview', 'tool/lp:coursecompetencymanage'); + $capabilities = array('moodle/competency:coursecompetencyview', 'moodle/competency:coursecompetencymanage'); if (!has_any_capability($capabilities, $context)) { - throw new required_capability_exception($context, 'tool/lp:coursecompetencyview', 'nopermissions', ''); + throw new required_capability_exception($context, 'moodle/competency:coursecompetencyview', 'nopermissions', ''); } else if (!user_competency::can_read_user_in_course($userid, $courseid)) { - throw new required_capability_exception($context, 'tool/lp:usercompetencyview', 'nopermissions', ''); + throw new required_capability_exception($context, 'moodle/competency:usercompetencyview', 'nopermissions', ''); } // OK - all set. @@ -1318,7 +1318,7 @@ public static function list_user_competencies_to_review($skip = 0, $limit = 50, $userid = $USER->id; } - $capability = 'tool/lp:usercompetencyreview'; + $capability = 'moodle/competency:usercompetencyreview'; $ucfields = user_competency::get_sql_fields('uc'); $compfields = competency::get_sql_fields('c'); $usercols = array('id') + get_user_fieldnames(); @@ -1397,7 +1397,7 @@ public static function add_competency_to_course_module($cmorid, $competencyid) { // First we do a permissions check. $context = context_module::instance($cm->id); - require_capability('tool/lp:coursecompetencymanage', $context); + require_capability('moodle/competency:coursecompetencymanage', $context); // Check that the competency belongs to the course. $exists = course_competency::get_records(array('courseid' => $cm->course, 'competencyid' => $competencyid)); @@ -1439,7 +1439,7 @@ public static function remove_competency_from_course_module($cmorid, $competency // First we do a permissions check. $context = context_module::instance($cm->id); - require_capability('tool/lp:coursecompetencymanage', $context); + require_capability('moodle/competency:coursecompetencymanage', $context); $record = new stdClass(); $record->cmid = $cm->id; @@ -1456,7 +1456,7 @@ public static function remove_competency_from_course_module($cmorid, $competency /** * Move the course module competency up or down in the display list. * - * Requires tool/lp:coursecompetencymanage capability at the course module context. + * Requires moodle/competency:coursecompetencymanage capability at the course module context. * * @param mixed $cmorid The course module, or id of the course module * @param int $competencyidfrom The id of the competency we are moving. @@ -1475,7 +1475,7 @@ public static function reorder_course_module_competency($cmorid, $competencyidfr // First we do a permissions check. $context = context_module::instance($cm->id); - require_capability('tool/lp:coursecompetencymanage', $context); + require_capability('moodle/competency:coursecompetencymanage', $context); $down = true; $matches = course_module_competency::get_records(array('cmid' => $cm->id, 'competencyid' => $competencyidfrom)); @@ -1531,7 +1531,7 @@ public static function set_course_module_competency_ruleoutcome($coursemodulecom self::validate_course_module($cm); $context = context_module::instance($cm->id); - require_capability('tool/lp:coursecompetencymanage', $context); + require_capability('moodle/competency:coursecompetencymanage', $context); $coursemodulecompetency->set_ruleoutcome($ruleoutcome); return $coursemodulecompetency->update(); @@ -1552,7 +1552,7 @@ public static function add_competency_to_course($courseid, $competencyid) { // First we do a permissions check. $context = context_course::instance($courseid); - require_capability('tool/lp:coursecompetencymanage', $context); + require_capability('moodle/competency:coursecompetencymanage', $context); $record = new stdClass(); $record->courseid = $courseid; @@ -1591,7 +1591,7 @@ public static function remove_competency_from_course($courseid, $competencyid) { // First we do a permissions check. $context = context_course::instance($courseid); - require_capability('tool/lp:coursecompetencymanage', $context); + require_capability('moodle/competency:coursecompetencymanage', $context); $record = new stdClass(); $record->courseid = $courseid; @@ -1614,7 +1614,7 @@ public static function remove_competency_from_course($courseid, $competencyid) { /** * Move the course competency up or down in the display list. * - * Requires tool/lp:coursecompetencymanage capability at the course context. + * Requires moodle/competency:coursecompetencymanage capability at the course context. * * @param int $courseid The course * @param int $competencyidfrom The id of the competency we are moving. @@ -1629,7 +1629,7 @@ public static function reorder_course_competency($courseid, $competencyidfrom, $ // First we do a permissions check. $context = context_course::instance($courseid); - require_capability('tool/lp:coursecompetencymanage', $context); + require_capability('moodle/competency:coursecompetencymanage', $context); $down = true; $coursecompetency = new course_competency(); @@ -1685,7 +1685,7 @@ public static function set_course_competency_ruleoutcome($coursecompetencyorid, self::validate_course($courseid); $coursecontext = context_course::instance($courseid); - require_capability('tool/lp:coursecompetencymanage', $coursecontext); + require_capability('moodle/competency:coursecompetencymanage', $coursecontext); $coursecompetency->set_ruleoutcome($ruleoutcome); return $coursecompetency->update(); @@ -1694,7 +1694,7 @@ public static function set_course_competency_ruleoutcome($coursecompetencyorid, /** * Create a learning plan template from a record containing all the data for the class. * - * Requires tool/lp:templatemanage capability. + * Requires moodle/competency:templatemanage capability. * * @param stdClass $record Record containing all the data for an instance of the class. * @return template @@ -1705,7 +1705,7 @@ public static function create_template(stdClass $record) { // First we do a permissions check. if (!$template->can_manage()) { - throw new required_capability_exception($template->get_context(), 'tool/lp:templatemanage', 'nopermissions', ''); + throw new required_capability_exception($template->get_context(), 'moodle/competency:templatemanage', 'nopermissions', ''); } // OK - all set. @@ -1720,7 +1720,7 @@ public static function create_template(stdClass $record) { /** * Duplicate a learning plan template. * - * Requires tool/lp:templatemanage capability at the template context. + * Requires moodle/competency:templatemanage capability at the template context. * * @param int $id the template id. * @return template @@ -1731,7 +1731,7 @@ public static function duplicate_template($id) { // First we do a permissions check. if (!$template->can_manage()) { - throw new required_capability_exception($template->get_context(), 'tool/lp:templatemanage', 'nopermissions', ''); + throw new required_capability_exception($template->get_context(), 'moodle/competency:templatemanage', 'nopermissions', ''); } // OK - all set. @@ -1758,7 +1758,7 @@ public static function duplicate_template($id) { * Delete a learning plan template by id. * If the learning plan template has associated cohorts they will be deleted. * - * Requires tool/lp:templatemanage capability. + * Requires moodle/competency:templatemanage capability. * * @param int $id The record to delete. * @param boolean $deleteplans True to delete plans associaated to template, false to unlink them. @@ -1771,7 +1771,7 @@ public static function delete_template($id, $deleteplans = true) { // First we do a permissions check. if (!$template->can_manage()) { - throw new required_capability_exception($template->get_context(), 'tool/lp:templatemanage', 'nopermissions', ''); + throw new required_capability_exception($template->get_context(), 'moodle/competency:templatemanage', 'nopermissions', ''); } $transaction = $DB->start_delegated_transaction(); @@ -1826,7 +1826,7 @@ public static function delete_template($id, $deleteplans = true) { /** * Update the details for a learning plan template. * - * Requires tool/lp:templatemanage capability. + * Requires moodle/competency:templatemanage capability. * * @param stdClass $record The new details for the template. Note - must contain an id that points to the template to update. * @return boolean @@ -1838,7 +1838,7 @@ public static function update_template($record) { // First we do a permissions check. if (!$template->can_manage()) { - throw new required_capability_exception($template->get_context(), 'tool/lp:templatemanage', 'nopermissions', ''); + throw new required_capability_exception($template->get_context(), 'moodle/competency:templatemanage', 'nopermissions', ''); } else if (isset($record->contextid) && $record->contextid != $template->get_contextid()) { // We can never change the context of a template. @@ -1883,7 +1883,7 @@ public static function update_template($record) { /** * Read a the details for a single learning plan template and return a record. * - * Requires tool/lp:templateview capability at the system context. + * Requires moodle/competency:templateview capability at the system context. * * @param int $id The id of the template to read. * @return template @@ -1895,7 +1895,7 @@ public static function read_template($id) { // First we do a permissions check. 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', ''); } // OK - all set. @@ -1905,7 +1905,7 @@ public static function read_template($id) { /** * Perform a search based on the provided filters and return a paginated list of records. * - * Requires tool/lp:templateview capability at the system context. + * Requires moodle/competency:templateview capability at the system context. * * @param string $sort The column to sort on * @param string $order ('ASC' or 'DESC') @@ -1926,11 +1926,11 @@ public static function list_templates($sort, $order, $skip, $limit, $context, $i // Get all the relevant contexts. $contexts = self::get_related_contexts($context, $includes, - array('tool/lp:templateview', 'tool/lp:templatemanage')); + array('moodle/competency:templateview', 'moodle/competency:templatemanage')); // First we do a permissions check. if (empty($contexts)) { - throw new required_capability_exception($context, 'tool/lp:templateview', 'nopermissions', ''); + throw new required_capability_exception($context, 'moodle/competency:templateview', 'nopermissions', ''); } // Make the order by. @@ -1954,7 +1954,7 @@ public static function list_templates($sort, $order, $skip, $limit, $context, $i /** * Perform a search based on the provided filters and return how many results there are. * - * Requires tool/lp:templateview capability at the system context. + * Requires moodle/competency:templateview capability at the system context. * * @param context $context The parent context of the frameworks. * @param string $includes Defines what other contexts to fetch frameworks from. @@ -1970,10 +1970,10 @@ public static function count_templates($context, $includes) { // First we do a permissions check. $contexts = self::get_related_contexts($context, $includes, - array('tool/lp:templateview', 'tool/lp:templatemanage')); + array('moodle/competency:templateview', 'moodle/competency:templatemanage')); if (empty($contexts)) { - throw new required_capability_exception($context, 'tool/lp:templateview', 'nopermissions', ''); + throw new required_capability_exception($context, 'moodle/competency:templateview', 'nopermissions', ''); } // OK - all set. @@ -1994,12 +1994,12 @@ public static function count_templates_using_competency($competencyid) { $context = context_system::instance(); $onlyvisible = 1; - $capabilities = array('tool/lp:templateview', 'tool/lp:templatemanage'); + $capabilities = array('moodle/competency:templateview', 'moodle/competency:templatemanage'); if (!has_any_capability($capabilities, $context)) { - throw new required_capability_exception($context, 'tool/lp:templateview', 'nopermissions', ''); + throw new required_capability_exception($context, 'moodle/competency:templateview', 'nopermissions', ''); } - if (has_capability('tool/lp:templatemanage', $context)) { + if (has_capability('moodle/competency:templatemanage', $context)) { $onlyvisible = 0; } @@ -2019,12 +2019,12 @@ public static function list_templates_using_competency($competencyid) { $context = context_system::instance(); $onlyvisible = 1; - $capabilities = array('tool/lp:templateview', 'tool/lp:templatemanage'); + $capabilities = array('moodle/competency:templateview', 'moodle/competency:templatemanage'); if (!has_any_capability($capabilities, $context)) { - throw new required_capability_exception($context, 'tool/lp:templateview', 'nopermissions', ''); + throw new required_capability_exception($context, 'moodle/competency:templateview', 'nopermissions', ''); } - if (has_capability('tool/lp:templatemanage', $context)) { + if (has_capability('moodle/competency:templatemanage', $context)) { $onlyvisible = 0; } @@ -2048,7 +2048,7 @@ public static function count_competencies_in_template($templateorid) { } 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', ''); } // OK - all set. @@ -2069,7 +2069,7 @@ public static function count_competencies_in_template_with_no_courses($templateo } 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', ''); } // OK - all set. @@ -2091,7 +2091,7 @@ public static function list_competencies_in_template($templateorid) { } 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', ''); } // OK - all set. @@ -2110,7 +2110,7 @@ public static function add_competency_to_template($templateid, $competencyid) { // First we do a permissions check. $template = new template($templateid); if (!$template->can_manage()) { - throw new required_capability_exception($template->get_context(), 'tool/lp:templatemanage', 'nopermissions', ''); + throw new required_capability_exception($template->get_context(), 'moodle/competency:templatemanage', 'nopermissions', ''); } $record = new stdClass(); @@ -2145,7 +2145,7 @@ public static function remove_competency_from_template($templateid, $competencyi // First we do a permissions check. $template = new template($templateid); if (!$template->can_manage()) { - throw new required_capability_exception($template->get_context(), 'tool/lp:templatemanage', 'nopermissions', ''); + throw new required_capability_exception($template->get_context(), 'moodle/competency:templatemanage', 'nopermissions', ''); } $record = new stdClass(); @@ -2165,7 +2165,7 @@ public static function remove_competency_from_template($templateid, $competencyi /** * Move the template competency up or down in the display list. * - * Requires tool/lp:templatemanage capability at the system context. + * Requires moodle/competency:templatemanage capability at the system context. * * @param int $templateid The template id * @param int $competencyidfrom The id of the competency we are moving. @@ -2177,7 +2177,7 @@ public static function reorder_template_competency($templateid, $competencyidfro // First we do a permissions check. $context = context_system::instance(); - require_capability('tool/lp:templatemanage', $context); + require_capability('moodle/competency:templatemanage', $context); $down = true; $matches = template_competency::get_records(array('templateid' => $templateid, 'competencyid' => $competencyidfrom)); @@ -2231,7 +2231,7 @@ public static function create_template_cohort($templateorid, $cohortorid) { if (!is_object($template)) { $template = new template($template); } - require_capability('tool/lp:templatemanage', $template->get_context()); + require_capability('moodle/competency:templatemanage', $template->get_context()); $cohort = $cohortorid; if (!is_object($cohort)) { @@ -2267,7 +2267,7 @@ public static function delete_template_cohort($templateorid, $cohortorid) { if (!is_object($template)) { $template = new template($template); } - require_capability('tool/lp:templatemanage', $template->get_context()); + require_capability('moodle/competency:templatemanage', $template->get_context()); $cohort = $cohortorid; if (!is_object($cohort)) { @@ -2297,7 +2297,7 @@ public static function list_user_plans($userid) { // Check that we can read something here. if (!plan::can_read_user($userid) && !plan::can_read_user_draft($userid)) { - throw new required_capability_exception($context, 'tool/lp:planview', 'nopermissions', ''); + throw new required_capability_exception($context, 'moodle/competency:planview', 'nopermissions', ''); } // The user cannot view the drafts. @@ -2382,7 +2382,7 @@ public static function list_plans_to_review($skip = 0, $limit = 100, $userid = n } // TODO MDL-52243 Use core function. - list($insql, $inparams) = external::filter_users_with_capability_on_user_context_sql('tool/lp:planreview', + list($insql, $inparams) = external::filter_users_with_capability_on_user_context_sql('moodle/competency:planreview', $userid, SQL_PARAMS_NAMED); $sql .= " AND p.userid $insql"; $params += $inparams; @@ -2430,7 +2430,7 @@ public static function create_plan(stdClass $record) { if (!$plan->can_manage()) { $context = context_user::instance($plan->get_userid()); - throw new required_capability_exception($context, 'tool/lp:planmanage', 'nopermissions', ''); + throw new required_capability_exception($context, 'moodle/competency:planmanage', 'nopermissions', ''); } $plan->create(); @@ -2456,7 +2456,7 @@ public static function create_plan_from_template($templateorid, $userid) { // The user must be able to view the template to use it as a base for a plan. 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', ''); } // Can not create plan from a hidden template. if ($template->get_visible() == false) { @@ -2485,7 +2485,7 @@ public static function create_plan_from_template($templateorid, $userid) { $plan = new plan(0, $record); if (!$plan->can_manage()) { - throw new required_capability_exception($plan->get_context(), 'tool/lp:planmanage', 'nopermissions', ''); + throw new required_capability_exception($plan->get_context(), 'moodle/competency:planmanage', 'nopermissions', ''); } // We first apply the permission checks as we wouldn't want to leak information by returning early that @@ -2522,7 +2522,7 @@ public static function create_plans_from_template_cohort($templateorid, $cohorti // The user must be able to view the template to use it as a base for a plan. 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', ''); } // Can not create plan from a hidden template. @@ -2595,7 +2595,7 @@ public static function unlink_plan_from_template($planorid) { // The user must be allowed to manage the plans of the user, nothing about the template. if (!$plan->can_manage()) { - throw new required_capability_exception($plan->get_context(), 'tool/lp:planmanage', 'nopermissions', ''); + throw new required_capability_exception($plan->get_context(), 'moodle/competency:planmanage', 'nopermissions', ''); } // Only plan with status DRAFT or ACTIVE can be unliked.. @@ -2648,7 +2648,7 @@ public static function update_plan(stdClass $record) { // Validate that the plan as it is can be managed. if (!$plan->can_manage()) { - throw new required_capability_exception($plan->get_context(), 'tool/lp:planmanage', 'nopermissions', ''); + throw new required_capability_exception($plan->get_context(), 'moodle/competency:planmanage', 'nopermissions', ''); } else if ($plan->get_status() == plan::STATUS_COMPLETE) { // A completed plan cannot be edited. @@ -2693,7 +2693,7 @@ public static function read_plan($id) { if (!$plan->can_read()) { $context = context_user::instance($plan->get_userid()); - throw new required_capability_exception($context, 'tool/lp:planview', 'nopermissions', ''); + throw new required_capability_exception($context, 'moodle/competency:planview', 'nopermissions', ''); } return $plan; @@ -2715,7 +2715,7 @@ public static function plan_viewed($planorid) { // First we do a permissions check. if (!$plan->can_read()) { $context = context_user::instance($plan->get_userid()); - throw new required_capability_exception($context, 'tool/lp:planview', 'nopermissions', ''); + throw new required_capability_exception($context, 'moodle/competency:planview', 'nopermissions', ''); } // Trigger a template viewed event. @@ -2740,7 +2740,7 @@ public static function delete_plan($id) { if (!$plan->can_manage()) { $context = context_user::instance($plan->get_userid()); - throw new required_capability_exception($context, 'tool/lp:planmanage', 'nopermissions', ''); + throw new required_capability_exception($context, 'moodle/competency:planmanage', 'nopermissions', ''); } // Wrap the suppression in a DB transaction. @@ -2782,7 +2782,7 @@ public static function plan_cancel_review_request($planorid) { // We need to be able to view the plan at least. if (!$plan->can_read()) { - throw new required_capability_exception($plan->get_context(), 'tool/lp:planview', 'nopermissions', ''); + throw new required_capability_exception($plan->get_context(), 'moodle/competency:planview', 'nopermissions', ''); } if ($plan->is_based_on_template()) { @@ -2790,7 +2790,7 @@ public static function plan_cancel_review_request($planorid) { } else if ($plan->get_status() != plan::STATUS_WAITING_FOR_REVIEW) { throw new coding_exception('The plan review cannot be cancelled at this stage.'); } else if (!$plan->can_request_review()) { - throw new required_capability_exception($plan->get_context(), 'tool/lp:planmanage', 'nopermissions', ''); + throw new required_capability_exception($plan->get_context(), 'moodle/competency:planmanage', 'nopermissions', ''); } $plan->set_status(plan::STATUS_DRAFT); @@ -2817,7 +2817,7 @@ public static function plan_request_review($planorid) { // We need to be able to view the plan at least. if (!$plan->can_read()) { - throw new required_capability_exception($plan->get_context(), 'tool/lp:planview', 'nopermissions', ''); + throw new required_capability_exception($plan->get_context(), 'moodle/competency:planview', 'nopermissions', ''); } if ($plan->is_based_on_template()) { @@ -2825,7 +2825,7 @@ public static function plan_request_review($planorid) { } else if ($plan->get_status() != plan::STATUS_DRAFT) { throw new coding_exception('The plan cannot be sent for review at this stage.'); } else if (!$plan->can_request_review()) { - throw new required_capability_exception($plan->get_context(), 'tool/lp:planmanage', 'nopermissions', ''); + throw new required_capability_exception($plan->get_context(), 'moodle/competency:planmanage', 'nopermissions', ''); } $plan->set_status(plan::STATUS_WAITING_FOR_REVIEW); @@ -2853,7 +2853,7 @@ public static function plan_start_review($planorid) { // We need to be able to view the plan at least. if (!$plan->can_read()) { - throw new required_capability_exception($plan->get_context(), 'tool/lp:planview', 'nopermissions', ''); + throw new required_capability_exception($plan->get_context(), 'moodle/competency:planview', 'nopermissions', ''); } if ($plan->is_based_on_template()) { @@ -2861,7 +2861,7 @@ public static function plan_start_review($planorid) { } else if ($plan->get_status() != plan::STATUS_WAITING_FOR_REVIEW) { throw new coding_exception('The plan review cannot be started at this stage.'); } else if (!$plan->can_review()) { - throw new required_capability_exception($plan->get_context(), 'tool/lp:planmanage', 'nopermissions', ''); + throw new required_capability_exception($plan->get_context(), 'moodle/competency:planmanage', 'nopermissions', ''); } $plan->set_status(plan::STATUS_IN_REVIEW); @@ -2889,7 +2889,7 @@ public static function plan_stop_review($planorid) { // We need to be able to view the plan at least. if (!$plan->can_read()) { - throw new required_capability_exception($plan->get_context(), 'tool/lp:planview', 'nopermissions', ''); + throw new required_capability_exception($plan->get_context(), 'moodle/competency:planview', 'nopermissions', ''); } if ($plan->is_based_on_template()) { @@ -2897,7 +2897,7 @@ public static function plan_stop_review($planorid) { } else if ($plan->get_status() != plan::STATUS_IN_REVIEW) { throw new coding_exception('The plan review cannot be stopped at this stage.'); } else if (!$plan->can_review()) { - throw new required_capability_exception($plan->get_context(), 'tool/lp:planmanage', 'nopermissions', ''); + throw new required_capability_exception($plan->get_context(), 'moodle/competency:planmanage', 'nopermissions', ''); } $plan->set_status(plan::STATUS_DRAFT); @@ -2927,7 +2927,7 @@ public static function approve_plan($planorid) { // We need to be able to view the plan at least. if (!$plan->can_read()) { - throw new required_capability_exception($plan->get_context(), 'tool/lp:planview', 'nopermissions', ''); + throw new required_capability_exception($plan->get_context(), 'moodle/competency:planview', 'nopermissions', ''); } // We can approve a plan that is either a draft, in review, or waiting for review. @@ -2936,7 +2936,7 @@ public static function approve_plan($planorid) { } else if (!$plan->is_draft()) { throw new coding_exception('The plan cannot be approved at this stage.'); } else if (!$plan->can_review()) { - throw new required_capability_exception($plan->get_context(), 'tool/lp:planmanage', 'nopermissions', ''); + throw new required_capability_exception($plan->get_context(), 'moodle/competency:planmanage', 'nopermissions', ''); } $plan->set_status(plan::STATUS_ACTIVE); @@ -2966,7 +2966,7 @@ public static function unapprove_plan($planorid) { // We need to be able to view the plan at least. if (!$plan->can_read()) { - throw new required_capability_exception($plan->get_context(), 'tool/lp:planview', 'nopermissions', ''); + throw new required_capability_exception($plan->get_context(), 'moodle/competency:planview', 'nopermissions', ''); } if ($plan->is_based_on_template()) { @@ -2974,7 +2974,7 @@ public static function unapprove_plan($planorid) { } else if ($plan->get_status() != plan::STATUS_ACTIVE) { throw new coding_exception('The plan cannot be sent back to draft at this stage.'); } else if (!$plan->can_review()) { - throw new required_capability_exception($plan->get_context(), 'tool/lp:planmanage', 'nopermissions', ''); + throw new required_capability_exception($plan->get_context(), 'moodle/competency:planmanage', 'nopermissions', ''); } $plan->set_status(plan::STATUS_DRAFT); @@ -3003,7 +3003,7 @@ public static function complete_plan($planorid) { // Validate that the plan can be managed. if (!$plan->can_manage()) { - throw new required_capability_exception($plan->get_context(), 'tool/lp:planmanage', 'nopermissions', ''); + throw new required_capability_exception($plan->get_context(), 'moodle/competency:planmanage', 'nopermissions', ''); } // Check if the plan was already completed. @@ -3016,7 +3016,7 @@ public static function complete_plan($planorid) { // The user should also be able to manage the plan when it's completed. if (!$plan->can_manage()) { - throw new required_capability_exception($plan->get_context(), 'tool/lp:planmanage', 'nopermissions', ''); + throw new required_capability_exception($plan->get_context(), 'moodle/competency:planmanage', 'nopermissions', ''); } // Put back original status because archive needs it to extract competencies from the right table. @@ -3059,7 +3059,7 @@ public static function reopen_plan($planorid) { // Validate that the plan as it is can be managed. if (!$plan->can_manage()) { $context = context_user::instance($plan->get_userid()); - throw new required_capability_exception($context, 'tool/lp:planmanage', 'nopermissions', ''); + throw new required_capability_exception($context, 'moodle/competency:planmanage', 'nopermissions', ''); } $beforestatus = $plan->get_status(); @@ -3068,7 +3068,7 @@ public static function reopen_plan($planorid) { // Validate if status can be changed. if (!$plan->can_manage()) { $context = context_user::instance($plan->get_userid()); - throw new required_capability_exception($context, 'tool/lp:planmanage', 'nopermissions', ''); + throw new required_capability_exception($context, 'moodle/competency:planmanage', 'nopermissions', ''); } // Wrap the updates in a DB transaction. @@ -3120,7 +3120,7 @@ public static function get_plan_competency($planorid, $competencyid) { } if (!user_competency::can_read_user($plan->get_userid())) { - throw new required_capability_exception($plan->get_context(), 'tool/lp:usercompetencyview', 'nopermissions', ''); + throw new required_capability_exception($plan->get_context(), 'moodle/competency:usercompetencyview', 'nopermissions', ''); } $competency = $plan->get_competency($competencyid); @@ -3178,7 +3178,7 @@ public static function list_plan_competencies($planorid) { if (!$plan->can_read()) { $context = context_user::instance($plan->get_userid()); - throw new required_capability_exception($context, 'tool/lp:planview', 'nopermissions', ''); + throw new required_capability_exception($context, 'moodle/competency:planview', 'nopermissions', ''); } $result = array(); @@ -3239,7 +3239,7 @@ public static function add_competency_to_plan($planid, $competencyid) { // First we do a permissions check. if (!$plan->can_manage()) { - throw new required_capability_exception($plan->get_context(), 'tool/lp:planmanage', 'nopermissions', ''); + throw new required_capability_exception($plan->get_context(), 'moodle/competency:planmanage', 'nopermissions', ''); } else if ($plan->is_based_on_template()) { throw new coding_exception('A competency can not be added to a learning plan based on a template'); @@ -3282,7 +3282,7 @@ public static function remove_competency_from_plan($planid, $competencyid) { // First we do a permissions check. if (!$plan->can_manage()) { $context = context_user::instance($plan->get_userid()); - throw new required_capability_exception($context, 'tool/lp:planmanage', 'nopermissions', ''); + throw new required_capability_exception($context, 'moodle/competency:planmanage', 'nopermissions', ''); } else if ($plan->is_based_on_template()) { throw new coding_exception('A competency can not be removed from a learning plan based on a template'); @@ -3302,7 +3302,7 @@ public static function remove_competency_from_plan($planid, $competencyid) { /** * Move the plan competency up or down in the display list. * - * Requires tool/lp:planmanage capability at the system context. + * Requires moodle/competency:planmanage capability at the system context. * * @param int $planid The plan id * @param int $competencyidfrom The id of the competency we are moving. @@ -3316,7 +3316,7 @@ public static function reorder_plan_competency($planid, $competencyidfrom, $comp // First we do a permissions check. if (!$plan->can_manage()) { $context = context_user::instance($plan->get_userid()); - throw new required_capability_exception($context, 'tool/lp:planmanage', 'nopermissions', ''); + throw new required_capability_exception($context, 'moodle/competency:planmanage', 'nopermissions', ''); } else if ($plan->is_based_on_template()) { throw new coding_exception('A competency can not be reordered in a learning plan based on a template'); @@ -3373,11 +3373,11 @@ public static function user_competency_cancel_review_request($userid, $competenc $context = context_user::instance($userid); $uc = user_competency::get_record(array('userid' => $userid, 'competencyid' => $competencyid)); if (!$uc || !$uc->can_read()) { - throw new required_capability_exception($context, 'tool/lp:usercompetencyview', 'nopermissions', ''); + throw new required_capability_exception($context, 'moodle/competency:usercompetencyview', 'nopermissions', ''); } else if ($uc->get_status() != user_competency::STATUS_WAITING_FOR_REVIEW) { throw new coding_exception('The competency can not be cancel review request at this stage.'); } else if (!$uc->can_request_review()) { - throw new required_capability_exception($context, 'tool/lp:usercompetencyrequestreview', 'nopermissions', ''); + throw new required_capability_exception($context, 'moodle/competency:usercompetencyrequestreview', 'nopermissions', ''); } $uc->set_status(user_competency::STATUS_IDLE); @@ -3404,11 +3404,11 @@ public static function user_competency_request_review($userid, $competencyid) { } if (!$uc->can_read()) { - throw new required_capability_exception($uc->get_context(), 'tool/lp:usercompetencyview', 'nopermissions', ''); + throw new required_capability_exception($uc->get_context(), 'moodle/competency:usercompetencyview', 'nopermissions', ''); } else if ($uc->get_status() != user_competency::STATUS_IDLE) { throw new coding_exception('The competency can not be sent for review at this stage.'); } else if (!$uc->can_request_review()) { - throw new required_capability_exception($uc->get_context(), 'tool/lp:usercompetencyrequestreview', 'nopermissions', ''); + throw new required_capability_exception($uc->get_context(), 'moodle/competency:usercompetencyrequestreview', 'nopermissions', ''); } $uc->set_status(user_competency::STATUS_WAITING_FOR_REVIEW); @@ -3433,11 +3433,11 @@ public static function user_competency_start_review($userid, $competencyid) { $context = context_user::instance($userid); $uc = user_competency::get_record(array('userid' => $userid, 'competencyid' => $competencyid)); if (!$uc || !$uc->can_read()) { - throw new required_capability_exception($context, 'tool/lp:usercompetencyview', 'nopermissions', ''); + throw new required_capability_exception($context, 'moodle/competency:usercompetencyview', 'nopermissions', ''); } else if ($uc->get_status() != user_competency::STATUS_WAITING_FOR_REVIEW) { throw new coding_exception('The competency review can not be started at this stage.'); } else if (!$uc->can_review()) { - throw new required_capability_exception($context, 'tool/lp:usercompetencyreview', 'nopermissions', ''); + throw new required_capability_exception($context, 'moodle/competency:usercompetencyreview', 'nopermissions', ''); } $uc->set_status(user_competency::STATUS_IN_REVIEW); @@ -3461,11 +3461,11 @@ public static function user_competency_stop_review($userid, $competencyid) { $context = context_user::instance($userid); $uc = user_competency::get_record(array('userid' => $userid, 'competencyid' => $competencyid)); if (!$uc || !$uc->can_read()) { - throw new required_capability_exception($context, 'tool/lp:usercompetencyview', 'nopermissions', ''); + throw new required_capability_exception($context, 'moodle/competency:usercompetencyview', 'nopermissions', ''); } else if ($uc->get_status() != user_competency::STATUS_IN_REVIEW) { throw new coding_exception('The competency review can not be stopped at this stage.'); } else if (!$uc->can_review()) { - throw new required_capability_exception($context, 'tool/lp:usercompetencyreview', 'nopermissions', ''); + throw new required_capability_exception($context, 'moodle/competency:usercompetencyreview', 'nopermissions', ''); } $uc->set_status(user_competency::STATUS_IDLE); @@ -3490,7 +3490,7 @@ public static function user_competency_viewed($usercompetencyorid) { } if (!$uc || !$uc->can_read()) { - throw new required_capability_exception($uc->get_context(), 'tool/lp:usercompetencyview', 'nopermissions', ''); + throw new required_capability_exception($uc->get_context(), 'moodle/competency:usercompetencyview', 'nopermissions', ''); } \tool_lp\event\user_competency_viewed::create_from_user_competency_viewed($uc)->trigger(); @@ -3512,7 +3512,7 @@ public static function user_competency_viewed_in_plan($usercompetencyorid, $plan } if (!$uc || !$uc->can_read()) { - throw new required_capability_exception($uc->get_context(), 'tool/lp:usercompetencyview', 'nopermissions', ''); + throw new required_capability_exception($uc->get_context(), 'moodle/competency:usercompetencyview', 'nopermissions', ''); } $plan = new plan($planid); if ($plan->get_status() == plan::STATUS_COMPLETE) { @@ -3538,7 +3538,7 @@ public static function user_competency_viewed_in_course($usercoursecompetencyori } if (!$ucc || !user_competency::can_read_user_in_course($ucc->get_userid(), $ucc->get_courseid())) { - throw new required_capability_exception($ucc->get_context(), 'tool/lp:usercompetencyview', 'nopermissions', ''); + throw new required_capability_exception($ucc->get_context(), 'moodle/competency:usercompetencyview', 'nopermissions', ''); } // Validate the course, this will throw an exception if not valid. @@ -3562,7 +3562,7 @@ public static function user_competency_plan_viewed($usercompetencyplanorid) { } if (!$ucp || !user_competency::can_read_user($ucp->get_userid())) { - throw new required_capability_exception($ucp->get_context(), 'tool/lp:usercompetencyview', 'nopermissions', ''); + throw new required_capability_exception($ucp->get_context(), 'moodle/competency:usercompetencyview', 'nopermissions', ''); } $plan = new plan($ucp->get_planid()); if ($plan->get_status() != plan::STATUS_COMPLETE) { @@ -3586,7 +3586,7 @@ public static function template_has_related_data($templateid) { $template = new template($templateid); 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', ''); } // OK - all set. @@ -3603,8 +3603,8 @@ public static function list_related_competencies($competencyid) { static::require_enabled(); $competency = new competency($competencyid); - if (!has_any_capability(array('tool/lp:competencyview', 'tool/lp:competencymanage'), $competency->get_context())) { - throw new required_capability_exception($competency->get_context(), 'tool/lp:competencyview', 'nopermissions', ''); + if (!has_any_capability(array('moodle/competency:competencyview', 'moodle/competency:competencymanage'), $competency->get_context())) { + throw new required_capability_exception($competency->get_context(), 'moodle/competency:competencyview', 'nopermissions', ''); } return $competency->get_related_competencies(); @@ -3622,7 +3622,7 @@ public static function add_related_competency($competencyid, $relatedcompetencyi $competency1 = new competency($competencyid); $competency2 = new competency($relatedcompetencyid); - require_capability('tool/lp:competencymanage', $competency1->get_context()); + require_capability('moodle/competency:competencymanage', $competency1->get_context()); $relatedcompetency = related_competency::get_relation($competency1->get_id(), $competency2->get_id()); if (!$relatedcompetency->get_id()) { @@ -3646,7 +3646,7 @@ public static function remove_related_competency($competencyid, $relatedcompeten // This only check if we have the permission in either competency because both competencies // should belong to the same framework. - require_capability('tool/lp:competencymanage', $competency->get_context()); + require_capability('moodle/competency:competencymanage', $competency->get_context()); $relatedcompetency = related_competency::get_relation($competencyid, $relatedcompetencyid); if ($relatedcompetency->get_id()) { @@ -3668,7 +3668,7 @@ public static function read_user_evidence($id) { if (!$userevidence->can_read()) { $context = $userevidence->get_context(); - throw new required_capability_exception($context, 'tool/lp:userevidenceview', 'nopermissions', ''); + throw new required_capability_exception($context, 'moodle/competency:userevidenceview', 'nopermissions', ''); } return $userevidence; @@ -3687,7 +3687,7 @@ public static function create_user_evidence($data, $draftitemid = null) { $context = $userevidence->get_context(); if (!$userevidence->can_manage()) { - throw new required_capability_exception($context, 'tool/lp:userevidencemanage', 'nopermissions', ''); + throw new required_capability_exception($context, 'moodle/competency:userevidencemanage', 'nopermissions', ''); } $userevidence->create(); @@ -3716,7 +3716,7 @@ public static function update_user_evidence($data, $draftitemid = null) { $context = $userevidence->get_context(); if (!$userevidence->can_manage()) { - throw new required_capability_exception($context, 'tool/lp:userevidencemanage', 'nopermissions', ''); + throw new required_capability_exception($context, 'moodle/competency:userevidencemanage', 'nopermissions', ''); } else if (array_key_exists('userid', $data) && $data->userid != $userevidence->get_userid()) { throw new coding_exception('Can not change the userid of a user evidence.'); @@ -3749,7 +3749,7 @@ public static function delete_user_evidence($id) { $context = $userevidence->get_context(); if (!$userevidence->can_manage()) { - throw new required_capability_exception($context, 'tool/lp:userevidencemanage', 'nopermissions', ''); + throw new required_capability_exception($context, 'moodle/competency:userevidencemanage', 'nopermissions', ''); } // Delete the user evidence. @@ -3784,7 +3784,7 @@ public static function list_user_evidence($userid) { static::require_enabled(); if (!user_evidence::can_read_user($userid)) { $context = context_user::instance($userid); - throw new required_capability_exception($context, 'tool/lp:userevidenceview', 'nopermissions', ''); + throw new required_capability_exception($context, 'moodle/competency:userevidenceview', 'nopermissions', ''); } $evidence = user_evidence::get_records(array('userid' => $userid), 'name'); @@ -3810,7 +3810,7 @@ public static function create_user_evidence_competency($userevidenceorid, $compe // Perform user evidence capability checks. if (!$userevidence->can_manage()) { $context = $userevidence->get_context(); - throw new required_capability_exception($context, 'tool/lp:userevidencemanage', 'nopermissions', ''); + throw new required_capability_exception($context, 'moodle/competency:userevidencemanage', 'nopermissions', ''); } // Perform competency capability checks. @@ -3859,7 +3859,7 @@ public static function delete_user_evidence_competency($userevidenceorid, $compe // Perform user evidence capability checks. if (!$userevidence->can_manage()) { $context = $userevidence->get_context(); - throw new required_capability_exception($context, 'tool/lp:userevidencemanage', 'nopermissions', ''); + throw new required_capability_exception($context, 'moodle/competency:userevidencemanage', 'nopermissions', ''); } // Get (and delete) the relation. @@ -3900,7 +3900,7 @@ public static function request_review_of_user_evidence_linked_competencies($id) $userid = $userevidence->get_userid(); if (!$userevidence->can_manage()) { - throw new required_capability_exception($context, 'tool/lp:userevidencemanage', 'nopermissions', ''); + throw new required_capability_exception($context, 'moodle/competency:userevidencemanage', 'nopermissions', ''); } $usercompetencies = user_evidence_competency::get_user_competencies_by_userevidenceid($id); @@ -4077,7 +4077,7 @@ public static function list_evidence($userid = 0, if (!user_competency::can_read_user($userid)) { $context = context_user::instance($userid); - throw new required_capability_exception($context, 'tool/lp:usercompetencyview', 'nopermissions', ''); + throw new required_capability_exception($context, 'moodle/competency:usercompetencyview', 'nopermissions', ''); } $usercompetency = user_competency::get_record(array('userid' => $userid, 'competencyid' => $competencyid)); @@ -4130,7 +4130,7 @@ public static function list_evidence_in_course($userid = 0, if (!user_competency::can_read_user_in_course($userid, $courseid)) { $context = context_user::instance($userid); - throw new required_capability_exception($context, 'tool/lp:usercompetencyview', 'nopermissions', ''); + throw new required_capability_exception($context, 'moodle/competency:usercompetencyview', 'nopermissions', ''); } $usercompetency = user_competency::get_record(array('userid' => $userid, 'competencyid' => $competencyid)); @@ -4626,14 +4626,14 @@ public static function grade_competency($userid, $competencyid, $grade, $note = $uc = static::get_user_competency($userid, $competencyid); $context = $uc->get_context(); if (!user_competency::can_grade_user($uc->get_userid())) { - throw new required_capability_exception($context, 'tool/lp:competencygrade', 'nopermissions', ''); + throw new required_capability_exception($context, 'moodle/competency:competencygrade', 'nopermissions', ''); } // Throws exception if competency not in plan. $competency = $uc->get_competency(); $competencycontext = $competency->get_context(); - if (!has_any_capability(array('tool/lp:competencyview', 'tool/lp:competencymanage'), $competencycontext)) { - throw new required_capability_exception($competencycontext, 'tool/lp:competencyview', 'nopermissions', ''); + if (!has_any_capability(array('moodle/competency:competencyview', 'moodle/competency:competencymanage'), $competencycontext)) { + throw new required_capability_exception($competencycontext, 'moodle/competency:competencyview', 'nopermissions', ''); } $action = evidence::ACTION_OVERRIDE; @@ -4679,14 +4679,14 @@ public static function grade_competency_in_plan($planorid, $competencyid, $grade $context = $plan->get_context(); if (!user_competency::can_grade_user($plan->get_userid())) { - throw new required_capability_exception($context, 'tool/lp:competencygrade', 'nopermissions', ''); + throw new required_capability_exception($context, 'moodle/competency:competencygrade', 'nopermissions', ''); } // Throws exception if competency not in plan. $competency = $plan->get_competency($competencyid); $competencycontext = $competency->get_context(); - if (!has_any_capability(array('tool/lp:competencyview', 'tool/lp:competencymanage'), $competencycontext)) { - throw new required_capability_exception($competencycontext, 'tool/lp:competencyview', 'nopermissions', ''); + if (!has_any_capability(array('moodle/competency:competencyview', 'moodle/competency:competencymanage'), $competencycontext)) { + throw new required_capability_exception($competencycontext, 'moodle/competency:competencyview', 'nopermissions', ''); } $action = evidence::ACTION_OVERRIDE; @@ -4737,23 +4737,23 @@ public static function grade_competency_in_course($courseorid, $userid, $compete // Check that we can view the user competency details in the course. if (!user_competency::can_read_user_in_course($userid, $course->id)) { - throw new required_capability_exception($context, 'tool/lp:usercompetencyview', 'nopermissions', ''); + throw new required_capability_exception($context, 'moodle/competency:usercompetencyview', 'nopermissions', ''); } // Validate the permission to grade. if (!user_competency::can_grade_user_in_course($userid, $course->id)) { - throw new required_capability_exception($context, 'tool/lp:competencygrade', 'nopermissions', ''); + throw new required_capability_exception($context, 'moodle/competency:competencygrade', 'nopermissions', ''); } // Check that competency is in course and visible to the current user. $competency = course_competency::get_competency($course->id, $competencyid); $competencycontext = $competency->get_context(); - if (!has_any_capability(array('tool/lp:competencyview', 'tool/lp:competencymanage'), $competencycontext)) { - throw new required_capability_exception($competencycontext, 'tool/lp:competencyview', 'nopermissions', ''); + if (!has_any_capability(array('moodle/competency:competencyview', 'moodle/competency:competencymanage'), $competencycontext)) { + throw new required_capability_exception($competencycontext, 'moodle/competency:competencyview', 'nopermissions', ''); } // Check that the user is enrolled in the course, and is "gradable". - if (!is_enrolled($context, $userid, 'tool/lp:coursecompetencygradable')) { + if (!is_enrolled($context, $userid, 'moodle/competency:coursecompetencygradable')) { throw new coding_exception('The competency may not be rated at this time.'); } @@ -4784,7 +4784,7 @@ public static function grade_competency_in_course($courseorid, $userid, $compete /** * Count the plans in the template, filtered by status. * - * Requires tool/lp:templateview capability at the system context. + * Requires moodle/competency:templateview capability at the system context. * * @param mixed $templateorid The id or the template. * @param int $status One of the plan status constants (or 0 for all plans). @@ -4799,7 +4799,7 @@ public static function count_plans_for_template($templateorid, $status = 0) { // First we do a permissions check. 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', ''); } return plan::count_records_for_template($template->get_id(), $status); @@ -4808,7 +4808,7 @@ public static function count_plans_for_template($templateorid, $status = 0) { /** * Count the user-completency-plans in the template, optionally filtered by proficiency. * - * Requires tool/lp:templateview capability at the system context. + * Requires moodle/competency:templateview capability at the system context. * * @param mixed $templateorid The id or the template. * @param mixed $proficiency If true, filter by proficiency, if false filter by not proficient, if null - no filter. @@ -4823,7 +4823,7 @@ public static function count_user_competency_plans_for_template($templateorid, $ // First we do a permissions check. 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', ''); } return user_competency_plan::count_records_for_template($template->get_id(), $proficiency); @@ -4832,7 +4832,7 @@ public static function count_user_competency_plans_for_template($templateorid, $ /** * List the plans in the template, filtered by status. * - * Requires tool/lp:templateview capability at the system context. + * Requires moodle/competency:templateview capability at the system context. * * @param mixed $templateorid The id or the template. * @param int $status One of the plan status constants (or 0 for all plans). @@ -4848,7 +4848,7 @@ public static function list_plans_for_template($templateorid, $status = 0, $skip // First we do a permissions check. 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', ''); } return plan::get_records_for_template($template->get_id(), $status, $skip, $limit); @@ -4857,7 +4857,7 @@ public static function list_plans_for_template($templateorid, $status = 0, $skip /** * Get the most often not completed competency for this course. * - * Requires tool/lp:coursecompetencyview capability at the course context. + * Requires moodle/competency:coursecompetencyview capability at the course context. * * @param int $courseid The course id * @param int $skip The number of records to skip @@ -4868,8 +4868,8 @@ public static function get_least_proficient_competencies_for_course($courseid, $ static::require_enabled(); $coursecontext = context_course::instance($courseid); - if (!has_any_capability(array('tool/lp:competencyview', 'tool/lp:competencymanage'), $coursecontext)) { - throw new required_capability_exception($coursecontext, 'tool/lp:competencyview', 'nopermissions', ''); + if (!has_any_capability(array('moodle/competency:competencyview', 'moodle/competency:competencymanage'), $coursecontext)) { + throw new required_capability_exception($coursecontext, 'moodle/competency:competencyview', 'nopermissions', ''); } return user_competency_course::get_least_proficient_competencies_for_course($courseid, $skip, $limit); @@ -4878,7 +4878,7 @@ public static function get_least_proficient_competencies_for_course($courseid, $ /** * Get the most often not completed competency for this template. * - * Requires tool/lp:templateview capability at the system context. + * Requires moodle/competency:templateview capability at the system context. * * @param mixed $templateorid The id or the template. * @param int $skip The number of records to skip @@ -4894,7 +4894,7 @@ public static function get_least_proficient_competencies_for_template($templateo // First we do a permissions check. 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', ''); } return user_competency_plan::get_least_proficient_competencies_for_template($template->get_id(), $skip, $limit); @@ -4903,7 +4903,7 @@ public static function get_least_proficient_competencies_for_template($templateo /** * Template event viewed. * - * Requires tool/lp:templateview capability at the system context. + * Requires moodle/competency:templateview capability at the system context. * * @param mixed $templateorid The id or the template. * @return boolean @@ -4917,7 +4917,7 @@ public static function template_viewed($templateorid) { // First we do a permissions check. 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', ''); } // Trigger a template viewed event. @@ -4929,7 +4929,7 @@ public static function template_viewed($templateorid) { /** * Get the competency settings for a course. * - * Requires tool/lp:coursecompetencyview capability at the course context. + * Requires moodle/competency:coursecompetencyview capability at the course context. * * @param int $courseid The course id * @return course_competency_settings @@ -4940,7 +4940,7 @@ public static function read_course_competency_settings($courseid) { // First we do a permissions check. if (!course_competency_settings::can_read($courseid)) { $context = context_course::instance($courseid); - throw new required_capability_exception($context, 'tool/lp:coursecompetencyview', 'nopermissions', ''); + throw new required_capability_exception($context, 'moodle/competency:coursecompetencyview', 'nopermissions', ''); } return course_competency_settings::get_by_courseid($courseid); @@ -4949,7 +4949,7 @@ public static function read_course_competency_settings($courseid) { /** * Update the competency settings for a course. * - * Requires tool/lp:coursecompetencyconfigure capability at the course context. + * Requires moodle/competency:coursecompetencyconfigure capability at the course context. * * @param int $courseid The course id * @param stdClass $settings List of settings. The only valid setting ATM is pushratginstouserplans (boolean). @@ -4966,7 +4966,7 @@ public static function update_course_competency_settings($courseid, $settings) { // First we do a permissions check. if (!course_competency_settings::can_manage_course($courseid)) { $context = context_course::instance($courseid); - throw new required_capability_exception($context, 'tool/lp:coursecompetencyconfigure', 'nopermissions', ''); + throw new required_capability_exception($context, 'moodle/competency:coursecompetencyconfigure', 'nopermissions', ''); } $exists = course_competency_settings::get_record(array('courseid' => $courseid)); diff --git a/admin/tool/lp/classes/competency_framework.php b/admin/tool/lp/classes/competency_framework.php index 3f21052ed0b0a..8e19658393e4a 100644 --- a/admin/tool/lp/classes/competency_framework.php +++ b/admin/tool/lp/classes/competency_framework.php @@ -488,7 +488,7 @@ public function can_manage() { * @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 @@ public function can_read() { * @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); } } diff --git a/admin/tool/lp/classes/course_competency_settings.php b/admin/tool/lp/classes/course_competency_settings.php index 729902075b57d..88b55fdb8d45f 100644 --- a/admin/tool/lp/classes/course_competency_settings.php +++ b/admin/tool/lp/classes/course_competency_settings.php @@ -88,7 +88,7 @@ public static function get_by_courseid($courseid) { 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 @@ public static function can_read($courseid) { 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); } diff --git a/admin/tool/lp/classes/external/competency_framework_exporter.php b/admin/tool/lp/classes/external/competency_framework_exporter.php index 4d53edef58a99..3987ce5f8c1cf 100644 --- a/admin/tool/lp/classes/external/competency_framework_exporter.php +++ b/admin/tool/lp/classes/external/competency_framework_exporter.php @@ -54,7 +54,7 @@ protected function get_other_values(renderer_base $output) { $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) diff --git a/admin/tool/lp/classes/external/course_competency_statistics_exporter.php b/admin/tool/lp/classes/external/course_competency_statistics_exporter.php index 32a88efb0612e..9eec8dab69a56 100644 --- a/admin/tool/lp/classes/external/course_competency_statistics_exporter.php +++ b/admin/tool/lp/classes/external/course_competency_statistics_exporter.php @@ -96,8 +96,8 @@ protected function get_other_values(renderer_base $output) { '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']) ); } } diff --git a/admin/tool/lp/classes/form/framework_autocomplete.php b/admin/tool/lp/classes/form/framework_autocomplete.php index 0ee20dbac3a26..59f78f73f160d 100644 --- a/admin/tool/lp/classes/form/framework_autocomplete.php +++ b/admin/tool/lp/classes/form/framework_autocomplete.php @@ -106,7 +106,7 @@ public function setValue($value) { 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; diff --git a/admin/tool/lp/classes/form/plan.php b/admin/tool/lp/classes/form/plan.php index d536406845a21..ce0593d63834a 100644 --- a/admin/tool/lp/classes/form/plan.php +++ b/admin/tool/lp/classes/form/plan.php @@ -75,7 +75,7 @@ public function definition() { // 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. diff --git a/admin/tool/lp/classes/form/template_plans.php b/admin/tool/lp/classes/form/template_plans.php index 86f7ad7fa9f0c..862a3836f97b6 100644 --- a/admin/tool/lp/classes/form/template_plans.php +++ b/admin/tool/lp/classes/form/template_plans.php @@ -44,7 +44,7 @@ public function definition() { $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')); diff --git a/admin/tool/lp/classes/output/course_competencies_page.php b/admin/tool/lp/classes/output/course_competencies_page.php index 45082f04c9bcc..362974bb7cead 100644 --- a/admin/tool/lp/classes/output/course_competencies_page.php +++ b/admin/tool/lp/classes/output/course_competencies_page.php @@ -78,8 +78,8 @@ public function __construct($courseid) { $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 @@ public function __construct($courseid) { $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 @@ public function export_for_template(renderer_base $output) { $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; diff --git a/admin/tool/lp/classes/output/manage_competencies_page.php b/admin/tool/lp/classes/output/manage_competencies_page.php index ae0009fa8e184..370c56355679b 100644 --- a/admin/tool/lp/classes/output/manage_competencies_page.php +++ b/admin/tool/lp/classes/output/manage_competencies_page.php @@ -79,7 +79,7 @@ public function __construct($framework, $search, $pagecontext) { ); $this->navigation[] = $addpage; - $this->canmanage = has_capability('tool/lp:competencymanage', $framework->get_context()); + $this->canmanage = has_capability('moodle/competency:competencymanage', $framework->get_context()); } /** diff --git a/admin/tool/lp/classes/output/template_cohorts_table.php b/admin/tool/lp/classes/output/template_cohorts_table.php index 45a7f47cabc3b..878fc528256c1 100644 --- a/admin/tool/lp/classes/output/template_cohorts_table.php +++ b/admin/tool/lp/classes/output/template_cohorts_table.php @@ -61,7 +61,7 @@ public function __construct($uniqueid, \tool_lp\template $template) { // 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. diff --git a/admin/tool/lp/classes/output/template_competencies_page.php b/admin/tool/lp/classes/output/template_competencies_page.php index 1df97399d4277..b444e174f8282 100644 --- a/admin/tool/lp/classes/output/template_competencies_page.php +++ b/admin/tool/lp/classes/output/template_competencies_page.php @@ -78,8 +78,8 @@ public function __construct(template $template, context $pagecontext) { $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)); } diff --git a/admin/tool/lp/classes/output/template_plans_table.php b/admin/tool/lp/classes/output/template_plans_table.php index ffe798c5b61bb..28636e3c2b961 100644 --- a/admin/tool/lp/classes/output/template_plans_table.php +++ b/admin/tool/lp/classes/output/template_plans_table.php @@ -61,7 +61,7 @@ public function __construct($uniqueid, \tool_lp\template $template) { // 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. diff --git a/admin/tool/lp/classes/output/user_competency_course_navigation.php b/admin/tool/lp/classes/output/user_competency_course_navigation.php index e7d162ac09b28..eaabed5e432eb 100644 --- a/admin/tool/lp/classes/output/user_competency_course_navigation.php +++ b/admin/tool/lp/classes/output/user_competency_course_navigation.php @@ -85,7 +85,7 @@ public function export_for_template(renderer_base $output) { $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 @@ public function export_for_template(renderer_base $output) { $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(); diff --git a/admin/tool/lp/classes/plan.php b/admin/tool/lp/classes/plan.php index d617406f13cf9..fbb4655ed3fae 100644 --- a/admin/tool/lp/classes/plan.php +++ b/admin/tool/lp/classes/plan.php @@ -364,9 +364,9 @@ protected function validate_userid($value) { 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 @@ public static function can_manage_user($planuserid) { 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 @@ public static function can_manage_user_draft($planuserid) { 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 @@ public static function can_read_user($planuserid) { 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 @@ public static function can_read_user_draft($planuserid) { 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 @@ public static function can_read_user_draft($planuserid) { 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 @@ public static function can_request_review_user($planuserid) { * @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); } diff --git a/admin/tool/lp/classes/template.php b/admin/tool/lp/classes/template.php index d9f0c64546d5c..01f16c901bd62 100644 --- a/admin/tool/lp/classes/template.php +++ b/admin/tool/lp/classes/template.php @@ -114,7 +114,7 @@ public function can_manage() { * @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 @@ public function can_read() { * @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); } /** diff --git a/admin/tool/lp/classes/user_competency.php b/admin/tool/lp/classes/user_competency.php index c759bedc75dc7..a885798ba2895 100644 --- a/admin/tool/lp/classes/user_competency.php +++ b/admin/tool/lp/classes/user_competency.php @@ -335,9 +335,9 @@ protected function validate_grade($value) { 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 @@ public static function can_comment_user($userid) { * @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 @@ public static function can_grade_user($userid) { * @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 @@ public static function can_read_comments_user($userid) { * @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 @@ public static function can_read_user_in_course($userid, $courseid) { * @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 @@ public static function can_read_user($userid) { 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 @@ public static function can_request_review_user($userid) { * @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)); } diff --git a/admin/tool/lp/classes/user_evidence.php b/admin/tool/lp/classes/user_evidence.php index e16885e96da3b..55d3141eff0bd 100644 --- a/admin/tool/lp/classes/user_evidence.php +++ b/admin/tool/lp/classes/user_evidence.php @@ -170,9 +170,9 @@ public static function can_manage_user($evidenceuserid) { 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 @@ public static function can_manage_user($evidenceuserid) { 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); } diff --git a/admin/tool/lp/competencies.php b/admin/tool/lp/competencies.php index 782514023c55a..14ba787398ea1 100644 --- a/admin/tool/lp/competencies.php +++ b/admin/tool/lp/competencies.php @@ -37,7 +37,7 @@ $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'); diff --git a/admin/tool/lp/competencyframeworks.php b/admin/tool/lp/competencyframeworks.php index 643df410e8917..e248c7cd67244 100644 --- a/admin/tool/lp/competencyframeworks.php +++ b/admin/tool/lp/competencyframeworks.php @@ -35,7 +35,7 @@ \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'); diff --git a/admin/tool/lp/db/access.php b/admin/tool/lp/db/access.php deleted file mode 100644 index 28a009e5695e3..0000000000000 --- a/admin/tool/lp/db/access.php +++ /dev/null @@ -1,263 +0,0 @@ -. - -/** - * 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' - ), -); diff --git a/admin/tool/lp/db/services.php b/admin/tool/lp/db/services.php index 044584e46aef3..21891b8f33238 100644 --- a/admin/tool/lp/db/services.php +++ b/admin/tool/lp/db/services.php @@ -36,7 +36,7 @@ '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 @@ '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 @@ '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 @@ '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 @@ '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 @@ '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 @@ '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 @@ '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 @@ '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 @@ '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 @@ '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 @@ '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 @@ '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 @@ '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 @@ '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 @@ '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 @@ '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 @@ '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 @@ '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 @@ '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 @@ '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 @@ '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 @@ '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 @@ '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 @@ '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 @@ '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 @@ '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 @@ '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 @@ '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 @@ '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 @@ '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 @@ '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 @@ '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 @@ '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 @@ '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 @@ '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 @@ '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 @@ '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 @@ '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 @@ '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 @@ '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 @@ '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 @@ '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 @@ '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 @@ '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 @@ '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 @@ '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 @@ '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 @@ '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 @@ '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 @@ '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 @@ '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 @@ '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 @@ '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 @@ '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 @@ '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 @@ '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 @@ '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 @@ '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 @@ '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 @@ '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 @@ '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 @@ '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 @@ '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 @@ '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 @@ '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 @@ '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 @@ '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 @@ '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 @@ '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 @@ '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 @@ '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 @@ '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 @@ '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 @@ '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 @@ '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 @@ '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 @@ '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 @@ '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 @@ '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 @@ 'classpath' => '', 'description' => 'Stop a review.', 'type' => 'write', - 'capabilities' => 'tool/lp:competencygrade', + 'capabilities' => 'moodle/competency:competencygrade', 'ajax' => true, ), @@ -788,7 +788,7 @@ '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 @@ '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 @@ '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 @@ '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 @@ '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 @@ '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 @@ '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 @@ '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 @@ '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 @@ '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 @@ '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 @@ '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 @@ '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 @@ 'classpath' => '', 'description' => 'Update the course competency settings', 'type' => 'write', - 'capabilities' => 'tool/lp:coursecompetencyconfigure', + 'capabilities' => 'moodle/competency:coursecompetencyconfigure', 'ajax' => true, ), ); diff --git a/admin/tool/lp/editcompetencyframework.php b/admin/tool/lp/editcompetencyframework.php index 9726dc3896b76..983520e0e7370 100644 --- a/admin/tool/lp/editcompetencyframework.php +++ b/admin/tool/lp/editcompetencyframework.php @@ -41,7 +41,7 @@ // 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, diff --git a/admin/tool/lp/editplan.php b/admin/tool/lp/editplan.php index a5337b1e443a8..be414b6e76336 100644 --- a/admin/tool/lp/editplan.php +++ b/admin/tool/lp/editplan.php @@ -62,13 +62,13 @@ // 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); diff --git a/admin/tool/lp/edittemplate.php b/admin/tool/lp/edittemplate.php index 1c421bee03b63..820c7a047e4a0 100644 --- a/admin/tool/lp/edittemplate.php +++ b/admin/tool/lp/edittemplate.php @@ -41,7 +41,7 @@ // 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", [ diff --git a/admin/tool/lp/lang/en/tool_lp.php b/admin/tool/lp/lang/en/tool_lp.php index f1375a495f840..51693eda163f4 100644 --- a/admin/tool/lp/lang/en/tool_lp.php +++ b/admin/tool/lp/lang/en/tool_lp.php @@ -201,37 +201,6 @@ $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.'; diff --git a/admin/tool/lp/learningplans.php b/admin/tool/lp/learningplans.php index 53bbd8cabc76b..dfdd9ba5ed2e6 100644 --- a/admin/tool/lp/learningplans.php +++ b/admin/tool/lp/learningplans.php @@ -31,7 +31,7 @@ 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)); diff --git a/admin/tool/lp/lib.php b/admin/tool/lp/lib.php index 0fcde71c14caf..eb6a89f285985 100644 --- a/admin/tool/lp/lib.php +++ b/admin/tool/lp/lib.php @@ -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; } diff --git a/admin/tool/lp/settings.php b/admin/tool/lp/settings.php index 2c26e94d71366..00dcf38ac210f 100644 --- a/admin/tool/lp/settings.php +++ b/admin/tool/lp/settings.php @@ -37,7 +37,7 @@ '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 @@ '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); } diff --git a/admin/tool/lp/template_cohorts.php b/admin/tool/lp/template_cohorts.php index b7ada226457b0..23dc529b43a38 100644 --- a/admin/tool/lp/template_cohorts.php +++ b/admin/tool/lp/template_cohorts.php @@ -37,7 +37,7 @@ $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. diff --git a/admin/tool/lp/template_plans.php b/admin/tool/lp/template_plans.php index 368c5884ed274..4c11837693d03 100644 --- a/admin/tool/lp/template_plans.php +++ b/admin/tool/lp/template_plans.php @@ -35,7 +35,7 @@ $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. diff --git a/admin/tool/lp/templatecompetencies.php b/admin/tool/lp/templatecompetencies.php index e0cfb4c388a90..64225e4cb0a79 100644 --- a/admin/tool/lp/templatecompetencies.php +++ b/admin/tool/lp/templatecompetencies.php @@ -35,7 +35,7 @@ $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. diff --git a/admin/tool/lp/tests/api_test.php b/admin/tool/lp/tests/api_test.php index 876a840b77deb..ececae8d8fdbe 100644 --- a/admin/tool/lp/tests/api_test.php +++ b/admin/tool/lp/tests/api_test.php @@ -80,18 +80,18 @@ public function test_get_framework_related_contexts_with_capabilities() { $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 @@ public function test_get_template_related_contexts_with_capabilities() { $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 @@ public function test_update_plan() { '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 @@ protected function setup_workflow_data() { $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 @@ public function test_update_plan_manage_archived_competencies() { '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 @@ public function test_delete_plan_manage_archived_competencies() { '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 @@ public function test_list_plan_competencies_manage_archived_competencies() { '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 @@ public function test_create_template_cohort_permissions() { $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 @@ public function test_grade_competency_in_course_permissions() { $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); diff --git a/admin/tool/lp/tests/behat/plan_workflow.feature b/admin/tool/lp/tests/behat/plan_workflow.feature index 0ee13fc2ca5e5..42b074f12e9e7 100644 --- a/admin/tool/lp/tests/behat/plan_workflow.feature +++ b/admin/tool/lp/tests/behat/plan_workflow.feature @@ -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 diff --git a/admin/tool/lp/tests/course_competency_settings_test.php b/admin/tool/lp/tests/course_competency_settings_test.php index ed3a9985153f2..c0ec3c8f2663c 100644 --- a/admin/tool/lp/tests/course_competency_settings_test.php +++ b/admin/tool/lp/tests/course_competency_settings_test.php @@ -47,12 +47,12 @@ public function test_who_can_change_settings() { $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(); diff --git a/admin/tool/lp/tests/externallib_test.php b/admin/tool/lp/tests/externallib_test.php index c10fc54389204..a5dc704f71724 100644 --- a/admin/tool/lp/tests/externallib_test.php +++ b/admin/tool/lp/tests/externallib_test.php @@ -105,39 +105,39 @@ protected function setUp() { $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 @@ public function test_create_and_update_plans() { $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 @@ public function test_create_and_update_plans() { $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 @@ public function test_create_and_update_plans() { $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 @@ public function test_complete_plan() { $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 @@ public function test_reopen_plan() { $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 @@ public function test_read_plans() { $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 @@ public function test_read_plans() { } // 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 @@ public function test_read_plans() { $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 @@ public function test_read_plans() { } // 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 @@ public function test_delete_plans() { $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 @@ public function test_delete_plans() { $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 @@ public function test_add_competency_to_template() { $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 @@ public function test_remove_competency_from_template() { $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 @@ public function test_read_template() { $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 @@ public function test_read_template() { } // 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 @@ public function test_read_template() { $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 @@ public function test_list_templates() { // 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 @@ public function test_list_templates() { } // 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 @@ public function test_list_templates() { $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 @@ public function test_count_templates() { // 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 @@ public function test_count_templates() { } // 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 @@ public function test_add_competency_to_plan() { '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 @@ public function test_remove_competency_from_plan() { '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 @@ public function test_reorder_plan_competency() { '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 @@ public function test_search_users_by_capability() { // 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 @@ public function test_search_users_by_capability() { // 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 @@ public function test_search_users_by_capability() { $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 @@ public function test_search_users_by_capability() { $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 @@ public function test_search_users_by_capability() { $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 @@ public function test_search_users() { // 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 @@ public function test_search_users() { // 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 @@ public function test_search_users() { // 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 @@ public function test_search_users() { // 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 @@ public function test_search_users() { // 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 @@ public function test_search_users() { $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 @@ public function test_update_course_competency_settings() { $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); diff --git a/admin/tool/lp/tests/lib_test.php b/admin/tool/lp/tests/lib_test.php index 7f1e7fb786fac..567463bb4ac3b 100644 --- a/admin/tool/lp/tests/lib_test.php +++ b/admin/tool/lp/tests/lib_test.php @@ -48,8 +48,8 @@ public function test_comment_add_user_competency() { $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 @@ public function test_comment_add_plan() { $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()); diff --git a/admin/tool/lp/tests/plan_test.php b/admin/tool/lp/tests/plan_test.php index 43ea6f86a1f7f..79fac986de1a7 100644 --- a/admin/tool/lp/tests/plan_test.php +++ b/admin/tool/lp/tests/plan_test.php @@ -51,8 +51,8 @@ public function test_can_manage_user() { $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 @@ public function test_can_manage_user_draft() { $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 @@ public function test_can_read_user() { $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 @@ public function test_can_read_user_draft() { $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); diff --git a/admin/tool/lp/user_competency_in_course.php b/admin/tool/lp/user_competency_in_course.php index 7d9a41529dcf1..8de8b94079970 100644 --- a/admin/tool/lp/user_competency_in_course.php +++ b/admin/tool/lp/user_competency_in_course.php @@ -38,14 +38,14 @@ $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))) { diff --git a/admin/tool/lp/user_evidence_edit.php b/admin/tool/lp/user_evidence_edit.php index 224c60aafd072..a8457328d7248 100644 --- a/admin/tool/lp/user_evidence_edit.php +++ b/admin/tool/lp/user_evidence_edit.php @@ -68,12 +68,12 @@ // 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); diff --git a/lang/en/role.php b/lang/en/role.php index bb2868dbd877e..c65d2d02e5ec9 100644 --- a/lang/en/role.php +++ b/lang/en/role.php @@ -106,6 +106,37 @@ $string['comment:view'] = 'View comments'; $string['community:add'] = 'Use the community block to search hubs and find courses'; $string['community:download'] = 'Download a course from the community block'; +$string['competency:competencymanage'] = 'Manage competency frameworks'; +$string['competency:competencygrade'] = 'Set competency grade'; +$string['competency:competencyview'] = 'View competency frameworks'; +$string['competency:coursecompetencygradable'] = 'Receive competency marks'; +$string['competency:coursecompetencyconfigure'] = 'Configure course competency settings'; +$string['competency:coursecompetencymanage'] = 'Manage course competencies'; +$string['competency:coursecompetencyview'] = 'View course competencies'; +$string['competency:plancomment'] = 'Comment on a learning plan'; +$string['competency:plancommentown'] = 'Comment on own learning plan'; +$string['competency:planmanage'] = 'Manage learning plans'; +$string['competency:planmanagedraft'] = 'Manage draft learning plans'; +$string['competency:planmanageown'] = 'Manage own learning plans'; +$string['competency:planmanageowndraft'] = 'Manage own draft learning plans'; +$string['competency:planrequestreview'] = 'Request the review of a learning plan'; +$string['competency:planrequestreviewown'] = 'Request the review of own learning plan'; +$string['competency:planreview'] = 'Review a learning plan'; +$string['competency:planview'] = 'View all learning plans'; +$string['competency:planviewdraft'] = 'View draft learning plans'; +$string['competency:planviewown'] = 'View own learning plans'; +$string['competency:planviewowndraft'] = 'View own draft learning plans'; +$string['competency:templatemanage'] = 'Manage templates'; +$string['competency:templateview'] = 'View template'; +$string['competency:usercompetencycomment'] = 'Comment on a user competency'; +$string['competency:usercompetencycommentown'] = 'Comment on own user competency'; +$string['competency:usercompetencyrequestreview'] = 'Request the review of a user competency'; +$string['competency:usercompetencyrequestreviewown'] = 'Request the review of own user competency'; +$string['competency:usercompetencyreview'] = 'Review a user competency'; +$string['competency:usercompetencyview'] = 'View a user competency'; +$string['competency:userevidencemanage'] = 'Manage evidence of prior learning'; +$string['competency:userevidencemanageown'] = 'Manage own evidence of prior learning'; +$string['competency:userevidenceview'] = 'View evidence of prior learning of a user'; $string['confirmaddadmin'] = 'Do you really want to add user {$a} as new site administrator?'; $string['confirmdeladmin'] = 'Do you really want to remove user {$a} from the list of site administrators?'; $string['confirmroleprevent'] = 'Do you really want to remove "{$a->role}" from the list of allowed roles for capability "{$a->cap}" in context "{$a->context}"?'; diff --git a/lib/db/access.php b/lib/db/access.php index 47ee5ea827db7..c90f302d83d3a 100644 --- a/lib/db/access.php +++ b/lib/db/access.php @@ -2056,6 +2056,239 @@ 'editingteacher' => CAP_ALLOW, 'manager' => CAP_ALLOW ) - ) + ), + + // Competencies. + 'moodle/competency:competencymanage' => array( + 'captype' => 'write', + 'contextlevel' => CONTEXT_COURSECAT, + 'archetypes' => array( + 'manager' => CAP_ALLOW + ) + ), + 'moodle/competency:competencyview' => array( + 'captype' => 'read', + 'contextlevel' => CONTEXT_COURSECAT, + 'archetypes' => array( + 'user' => CAP_ALLOW + ), + 'clonepermissionsfrom' => 'moodle/block:view' + ), + 'moodle/competency:competencygrade' => array( + 'captype' => 'write', + 'contextlevel' => CONTEXT_COURSE, // And CONTEXT_USER. + 'archetypes' => array( + 'editingteacher' => CAP_ALLOW, + 'teacher' => CAP_ALLOW, + 'manager' => CAP_ALLOW + ), + ), + // Course competencies. + 'moodle/competency:coursecompetencymanage' => array( + 'captype' => 'write', + 'contextlevel' => CONTEXT_COURSE, + 'archetypes' => array( + 'editingteacher' => CAP_ALLOW, + 'manager' => CAP_ALLOW + ), + 'clonepermissionsfrom' => 'moodle/site:backup' + ), + 'moodle/competency:coursecompetencyconfigure' => array( + 'captype' => 'write', + 'contextlevel' => CONTEXT_MODULE, + 'archetypes' => array( + 'manager' => CAP_ALLOW + ), + 'clonepermissionsfrom' => 'moodle/site:backup' + ), + 'moodle/competency:coursecompetencygradable' => array( + 'captype' => 'read', + 'contextlevel' => CONTEXT_COURSE, + 'archetypes' => array( + 'student' => CAP_ALLOW + ), + 'clonepermissionsfrom' => 'moodle/course:isincompletionreports' + ), + 'moodle/competency:coursecompetencyview' => array( + 'captype' => 'read', + 'contextlevel' => CONTEXT_COURSE, + 'archetypes' => array( + 'user' => CAP_ALLOW + ), + 'clonepermissionsfrom' => 'moodle/block:view' + ), + // User plans. + 'moodle/competency:planmanage' => array( + 'captype' => 'write', + 'contextlevel' => CONTEXT_USER, + 'archetypes' => array( + ), + 'clonepermissionsfrom' => 'moodle/site:config' + ), + 'moodle/competency:planmanagedraft' => array( + 'captype' => 'write', + 'contextlevel' => CONTEXT_USER, + 'archetypes' => array( + ), + 'clonepermissionsfrom' => 'moodle/site:config' + ), + 'moodle/competency:planmanageown' => array( + 'captype' => 'write', + 'contextlevel' => CONTEXT_USER, + 'archetypes' => array( + ), + 'clonepermissionsfrom' => 'moodle/site:config' + ), + 'moodle/competency:planmanageowndraft' => array( + 'captype' => 'write', + 'contextlevel' => CONTEXT_USER, + 'archetypes' => array( + ), + 'clonepermissionsfrom' => 'moodle/site:config' + ), + 'moodle/competency:planview' => array( + 'captype' => 'read', + 'contextlevel' => CONTEXT_USER, + 'archetypes' => array( + ), + 'clonepermissionsfrom' => 'moodle/site:config' + ), + 'moodle/competency:planviewdraft' => array( + 'captype' => 'read', + 'contextlevel' => CONTEXT_USER, + 'archetypes' => array( + ), + 'clonepermissionsfrom' => 'moodle/site:config' + ), + 'moodle/competency:planviewown' => array( + 'captype' => 'read', + 'contextlevel' => CONTEXT_USER, + 'archetypes' => array( + 'user' => CAP_ALLOW + ), + 'clonepermissionsfrom' => 'moodle/block:view' + ), + 'moodle/competency:planviewowndraft' => array( + 'captype' => 'read', + 'contextlevel' => CONTEXT_USER, + 'archetypes' => array( + ), + 'clonepermissionsfrom' => 'moodle/site:config' + ), + 'moodle/competency:planrequestreview' => array( + 'captype' => 'write', + 'contextlevel' => CONTEXT_USER, + 'archetypes' => array( + ) + ), + 'moodle/competency:planrequestreviewown' => array( + 'captype' => 'write', + 'contextlevel' => CONTEXT_USER, + 'archetypes' => array( + 'user' => CAP_ALLOW + ) + ), + 'moodle/competency:planreview' => array( + 'captype' => 'write', + 'contextlevel' => CONTEXT_USER, + 'archetypes' => array( + ), + 'clonepermissionsfrom' => 'moodle/site:config' + ), + 'moodle/competency:plancomment' => array( + 'captype' => 'write', + 'contextlevel' => CONTEXT_USER, + 'archetypes' => array( + ), + 'clonepermissionsfrom' => 'moodle/site:config' + ), + 'moodle/competency:plancommentown' => array( + 'captype' => 'write', + 'contextlevel' => CONTEXT_USER, + 'archetypes' => array( + 'user' => CAP_ALLOW + ), + ), + // User competencies. + 'moodle/competency:usercompetencyview' => array( + 'captype' => 'read', + 'contextlevel' => CONTEXT_USER, // And CONTEXT_COURSE. + 'archetypes' => array( + 'editingteacher' => CAP_ALLOW, + 'teacher' => CAP_ALLOW + ) + ), + 'moodle/competency:usercompetencyrequestreview' => array( + 'captype' => 'write', + 'contextlevel' => CONTEXT_USER, + 'archetypes' => array( + ) + ), + 'moodle/competency:usercompetencyrequestreviewown' => array( + 'captype' => 'write', + 'contextlevel' => CONTEXT_USER, + 'archetypes' => array( + 'user' => CAP_ALLOW + ) + ), + 'moodle/competency:usercompetencyreview' => array( + 'captype' => 'write', + 'contextlevel' => CONTEXT_USER, + 'archetypes' => array( + ), + 'clonepermissionsfrom' => 'moodle/site:config' + ), + 'moodle/competency:usercompetencycomment' => array( + 'captype' => 'write', + 'contextlevel' => CONTEXT_USER, + 'archetypes' => array( + ), + 'clonepermissionsfrom' => 'moodle/site:config' + ), + 'moodle/competency:usercompetencycommentown' => array( + 'captype' => 'write', + 'contextlevel' => CONTEXT_USER, + 'archetypes' => array( + 'user' => CAP_ALLOW + ), + ), + // Template. + 'moodle/competency:templatemanage' => array( + 'captype' => 'write', + 'contextlevel' => CONTEXT_COURSECAT, + 'archetypes' => array( + ), + 'clonepermissionsfrom' => 'moodle/site:config' + ), + 'moodle/competency:templateview' => array( + 'captype' => 'read', + 'contextlevel' => CONTEXT_COURSECAT, + 'archetypes' => array( + ), + 'clonepermissionsfrom' => 'moodle/site:config' + ), + // User evidence. + 'moodle/competency:userevidencemanage' => array( + 'captype' => 'write', + 'contextlevel' => CONTEXT_USER, + 'archetypes' => array( + ), + 'clonepermissionsfrom' => 'moodle/site:config' + ), + 'moodle/competency:userevidencemanageown' => array( + 'captype' => 'write', + 'contextlevel' => CONTEXT_USER, + 'archetypes' => array( + 'user' => CAP_ALLOW + ), + 'clonepermissionsfrom' => 'moodle/block:view' + ), + 'moodle/competency:userevidenceview' => array( + 'captype' => 'read', + 'contextlevel' => CONTEXT_USER, + 'archetypes' => array( + ), + 'clonepermissionsfrom' => 'moodle/site:config' + ), );