diff --git a/admin/tool/lp/classes/api.php b/admin/tool/lp/classes/api.php index 9dcdcbcd72824..819fc9540bd2f 100644 --- a/admin/tool/lp/classes/api.php +++ b/admin/tool/lp/classes/api.php @@ -401,7 +401,7 @@ public static function update_competency($record) { /** * Read a the details for a single competency and return a record. * - * Requires tool/lp:competencyread capability at the system context. + * Requires tool/lp:competencyview capability at the system context. * * @param int $id The id of the competency to read. * @param bool $includerelated Include related tags or not. @@ -413,8 +413,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:competencyread', 'tool/lp:competencymanage'), $context)) { - throw new required_capability_exception($context, 'tool/lp:competencyread', 'nopermissions', ''); + if (!has_any_capability(array('tool/lp:competencyview', 'tool/lp:competencymanage'), $context)) { + throw new required_capability_exception($context, 'tool/lp:competencyview', 'nopermissions', ''); } // OK - all set. @@ -431,7 +431,7 @@ public static function read_competency($id, $includerelated = false) { /** * Perform a text search based and return all results and their parents. * - * Requires tool/lp:competencyread capability at the framework context. + * Requires tool/lp: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. @@ -443,8 +443,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:competencyread', 'tool/lp:competencymanage'), $context)) { - throw new required_capability_exception($context, 'tool/lp:competencyread', 'nopermissions', ''); + if (!has_any_capability(array('tool/lp:competencyview', 'tool/lp:competencymanage'), $context)) { + throw new required_capability_exception($context, 'tool/lp:competencyview', 'nopermissions', ''); } // OK - all set. @@ -455,7 +455,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:competencyread capability at some context. + * Requires tool/lp: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 @@ -474,8 +474,8 @@ public static function list_competencies($filters, $sort = '', $order = 'ASC', $ } // First we do a permissions check. - if (!has_any_capability(array('tool/lp:competencyread', 'tool/lp:competencymanage'), $context)) { - throw new required_capability_exception($context, 'tool/lp:competencyread', 'nopermissions', ''); + if (!has_any_capability(array('tool/lp:competencyview', 'tool/lp:competencymanage'), $context)) { + throw new required_capability_exception($context, 'tool/lp:competencyview', 'nopermissions', ''); } // OK - all set. @@ -485,7 +485,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:competencyread capability at some context. + * Requires tool/lp:competencyview capability at some context. * * @param array $filters A list of filters to apply to the list. * @return int @@ -500,8 +500,8 @@ public static function count_competencies($filters) { } // First we do a permissions check. - if (!has_any_capability(array('tool/lp:competencyread', 'tool/lp:competencymanage'), $context)) { - throw new required_capability_exception($context, 'tool/lp:competencyread', 'nopermissions', ''); + if (!has_any_capability(array('tool/lp:competencyview', 'tool/lp:competencymanage'), $context)) { + throw new required_capability_exception($context, 'tool/lp:competencyview', 'nopermissions', ''); } // OK - all set. @@ -691,7 +691,7 @@ public static function update_framework($record) { /** * Read a the details for a single competency framework and return a record. * - * Requires tool/lp:competencyread capability at the system context. + * Requires tool/lp:competencyview capability at the system context. * * @param int $id The id of the framework to read. * @return competency_framework @@ -699,8 +699,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:competencyread', 'tool/lp:competencymanage'), $framework->get_context())) { - throw new required_capability_exception($framework->get_context(), 'tool/lp:competencyread', 'nopermissions', ''); + 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', ''); } return $framework; } @@ -717,8 +717,8 @@ public static function competency_framework_viewed($frameworkorid) { if (!is_object($framework)) { $framework = new competency_framework($framework); } - if (!has_any_capability(array('tool/lp:competencyread', 'tool/lp:competencymanage'), $framework->get_context())) { - throw new required_capability_exception($framework->get_context(), 'tool/lp:competencyread', 'nopermissions', ''); + 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', ''); } \tool_lp\event\competency_framework_viewed::create_from_framework($framework)->trigger(); return true; @@ -737,8 +737,8 @@ public static function competency_viewed($competencyorid) { $competency = new competency($competency); } - if (!has_any_capability(array('tool/lp:competencyread', 'tool/lp:competencymanage'), $competency->get_context())) { - throw new required_capability_exception($competency->get_context(), 'tool/lp:competencyread', 'nopermissions', ''); + 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', ''); } \tool_lp\event\competency_viewed::create_from_competency($competency)->trigger(); @@ -748,7 +748,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:competencyread capability at the system context. + * Requires tool/lp:competencyview capability at the system context. * * @param string $sort The column to sort on * @param string $order ('ASC' or 'DESC') @@ -771,10 +771,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:competencyread', 'tool/lp:competencymanage')); + array('tool/lp:competencyview', 'tool/lp:competencymanage')); if (empty($contexts)) { - throw new required_capability_exception($context, 'tool/lp:competencyread', 'nopermissions', ''); + throw new required_capability_exception($context, 'tool/lp:competencyview', 'nopermissions', ''); } // OK - all set. @@ -800,7 +800,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:competencyread capability at the system context. + * Requires tool/lp: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. @@ -816,10 +816,10 @@ public static function count_frameworks($context, $includes) { // Get all the relevant contexts. $contexts = self::get_related_contexts($context, $includes, - array('tool/lp:competencyread', 'tool/lp:competencymanage')); + array('tool/lp:competencyview', 'tool/lp:competencymanage')); if (empty($contexts)) { - throw new required_capability_exception($context, 'tool/lp:competencyread', 'nopermissions', ''); + throw new required_capability_exception($context, 'tool/lp:competencyview', 'nopermissions', ''); } // OK - all set. @@ -909,7 +909,7 @@ public static function count_courses_using_competency($competencyid) { } $context = context_course::instance($course->id); - $capabilities = array('tool/lp:coursecompetencyread', 'tool/lp:coursecompetencymanage'); + $capabilities = array('tool/lp:coursecompetencyview', 'tool/lp:coursecompetencymanage'); if (!has_any_capability($capabilities, $context)) { continue; } @@ -936,9 +936,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:coursecompetencyread', 'tool/lp:coursecompetencymanage'); + $capabilities = array('tool/lp:coursecompetencyview', 'tool/lp:coursecompetencymanage'); if (!has_any_capability($capabilities, $coursecontext)) { - throw new required_capability_exception($coursecontext, 'tool/lp:coursecompetencyread', 'nopermissions', ''); + throw new required_capability_exception($coursecontext, 'tool/lp:coursecompetencyview', 'nopermissions', ''); } $cmlist = course_module_competency::list_course_modules($competencyid, $courseid); @@ -968,9 +968,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:coursecompetencyread', 'tool/lp:coursecompetencymanage'); + $capabilities = array('tool/lp:coursecompetencyview', 'tool/lp:coursecompetencymanage'); if (!has_any_capability($capabilities, $context)) { - throw new required_capability_exception($context, 'tool/lp:coursecompetencyread', 'nopermissions', ''); + throw new required_capability_exception($context, 'tool/lp:coursecompetencyview', 'nopermissions', ''); } $result = array(); @@ -999,7 +999,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:coursecompetencyread', 'tool/lp:coursecompetencymanage'); + $capabilities = array('tool/lp:coursecompetencyview', 'tool/lp:coursecompetencymanage'); if (!has_any_capability($capabilities, $context)) { unset($courses[$id]); continue; @@ -1028,9 +1028,9 @@ public static function count_competencies_in_course($courseid) { // First we do a permissions check. $context = context_course::instance($courseid); - $capabilities = array('tool/lp:coursecompetencyread', 'tool/lp:coursecompetencymanage'); + $capabilities = array('tool/lp:coursecompetencyview', 'tool/lp:coursecompetencymanage'); if (!has_any_capability($capabilities, $context)) { - throw new required_capability_exception($context, 'tool/lp:coursecompetencyread', 'nopermissions', ''); + throw new required_capability_exception($context, 'tool/lp:coursecompetencyview', 'nopermissions', ''); } // OK - all set. @@ -1057,9 +1057,9 @@ public static function list_course_competencies($courseorid) { self::validate_course($course); $context = context_course::instance($course->id); - $capabilities = array('tool/lp:coursecompetencyread', 'tool/lp:coursecompetencymanage'); + $capabilities = array('tool/lp:coursecompetencyview', 'tool/lp:coursecompetencymanage'); if (!has_any_capability($capabilities, $context)) { - throw new required_capability_exception($context, 'tool/lp:coursecompetencyread', 'nopermissions', ''); + throw new required_capability_exception($context, 'tool/lp:coursecompetencyview', 'nopermissions', ''); } $result = array(); @@ -1137,9 +1137,9 @@ public static function list_course_module_competencies($cmorid) { self::validate_course_module($cm); $context = context_module::instance($cm->id); - $capabilities = array('tool/lp:coursecompetencyread', 'tool/lp:coursecompetencymanage'); + $capabilities = array('tool/lp:coursecompetencyview', 'tool/lp:coursecompetencymanage'); if (!has_any_capability($capabilities, $context)) { - throw new required_capability_exception($context, 'tool/lp:coursecompetencyread', 'nopermissions', ''); + throw new required_capability_exception($context, 'tool/lp:coursecompetencyview', 'nopermissions', ''); } $result = array(); @@ -1172,9 +1172,9 @@ 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:coursecompetencyread', 'tool/lp:coursecompetencymanage'); + $capabilities = array('tool/lp:coursecompetencyview', 'tool/lp:coursecompetencymanage'); if (!has_any_capability($capabilities, $context)) { - throw new required_capability_exception($context, 'tool/lp:coursecompetencyread', 'nopermissions', ''); + throw new required_capability_exception($context, 'tool/lp:coursecompetencyview', 'nopermissions', ''); } else if (!user_competency::can_read_user_in_course($userid, $courseid)) { throw new required_capability_exception($context, 'tool/lp:usercompetencyview', 'nopermissions', ''); } @@ -1208,9 +1208,9 @@ public static function list_user_competencies_in_course($courseid, $userid) { $context = context_course::instance($courseid); $onlyvisible = 1; - $capabilities = array('tool/lp:coursecompetencyread', 'tool/lp:coursecompetencymanage'); + $capabilities = array('tool/lp:coursecompetencyview', 'tool/lp:coursecompetencymanage'); if (!has_any_capability($capabilities, $context)) { - throw new required_capability_exception($context, 'tool/lp:coursecompetencyread', 'nopermissions', ''); + throw new required_capability_exception($context, 'tool/lp:coursecompetencyview', 'nopermissions', ''); } else if (!user_competency::can_read_user_in_course($userid, $courseid)) { throw new required_capability_exception($context, 'tool/lp:usercompetencyview', 'nopermissions', ''); } @@ -1836,7 +1836,7 @@ public static function update_template($record) { /** * Read a the details for a single learning plan template and return a record. * - * Requires tool/lp:templateread capability at the system context. + * Requires tool/lp:templateview capability at the system context. * * @param int $id The id of the template to read. * @return template @@ -1848,7 +1848,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:templateread', 'nopermissions', ''); + throw new required_capability_exception($template->get_context(), 'tool/lp:templateview', 'nopermissions', ''); } // OK - all set. @@ -1858,7 +1858,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:templateread capability at the system context. + * Requires tool/lp:templateview capability at the system context. * * @param string $sort The column to sort on * @param string $order ('ASC' or 'DESC') @@ -1879,11 +1879,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:templateread', 'tool/lp:templatemanage')); + array('tool/lp:templateview', 'tool/lp:templatemanage')); // First we do a permissions check. if (empty($contexts)) { - throw new required_capability_exception($context, 'tool/lp:templateread', 'nopermissions', ''); + throw new required_capability_exception($context, 'tool/lp:templateview', 'nopermissions', ''); } // Make the order by. @@ -1907,7 +1907,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:templateread capability at the system context. + * Requires tool/lp: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. @@ -1923,10 +1923,10 @@ public static function count_templates($context, $includes) { // First we do a permissions check. $contexts = self::get_related_contexts($context, $includes, - array('tool/lp:templateread', 'tool/lp:templatemanage')); + array('tool/lp:templateview', 'tool/lp:templatemanage')); if (empty($contexts)) { - throw new required_capability_exception($context, 'tool/lp:templateread', 'nopermissions', ''); + throw new required_capability_exception($context, 'tool/lp:templateview', 'nopermissions', ''); } // OK - all set. @@ -1947,9 +1947,9 @@ public static function count_templates_using_competency($competencyid) { $context = context_system::instance(); $onlyvisible = 1; - $capabilities = array('tool/lp:templateread', 'tool/lp:templatemanage'); + $capabilities = array('tool/lp:templateview', 'tool/lp:templatemanage'); if (!has_any_capability($capabilities, $context)) { - throw new required_capability_exception($context, 'tool/lp:templateread', 'nopermissions', ''); + throw new required_capability_exception($context, 'tool/lp:templateview', 'nopermissions', ''); } if (has_capability('tool/lp:templatemanage', $context)) { @@ -1972,9 +1972,9 @@ public static function list_templates_using_competency($competencyid) { $context = context_system::instance(); $onlyvisible = 1; - $capabilities = array('tool/lp:templateread', 'tool/lp:templatemanage'); + $capabilities = array('tool/lp:templateview', 'tool/lp:templatemanage'); if (!has_any_capability($capabilities, $context)) { - throw new required_capability_exception($context, 'tool/lp:templateread', 'nopermissions', ''); + throw new required_capability_exception($context, 'tool/lp:templateview', 'nopermissions', ''); } if (has_capability('tool/lp:templatemanage', $context)) { @@ -2001,7 +2001,7 @@ public static function count_competencies_in_template($templateorid) { } if (!$template->can_read()) { - throw new required_capability_exception($template->get_context(), 'tool/lp:templateread', 'nopermissions', ''); + throw new required_capability_exception($template->get_context(), 'tool/lp:templateview', 'nopermissions', ''); } // OK - all set. @@ -2022,7 +2022,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:templateread', 'nopermissions', ''); + throw new required_capability_exception($template->get_context(), 'tool/lp:templateview', 'nopermissions', ''); } // OK - all set. @@ -2044,7 +2044,7 @@ public static function list_competencies_in_template($templateorid) { } if (!$template->can_read()) { - throw new required_capability_exception($template->get_context(), 'tool/lp:templateread', 'nopermissions', ''); + throw new required_capability_exception($template->get_context(), 'tool/lp:templateview', 'nopermissions', ''); } // OK - all set. @@ -2409,7 +2409,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:templateread', 'nopermissions', ''); + throw new required_capability_exception($template->get_context(), 'tool/lp:templateview', 'nopermissions', ''); } // Can not create plan from a hidden template. if ($template->get_visible() == false) { @@ -2475,7 +2475,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:templateread', 'nopermissions', ''); + throw new required_capability_exception($template->get_context(), 'tool/lp:templateview', 'nopermissions', ''); } // Can not create plan from a hidden template. @@ -3326,7 +3326,7 @@ 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:usercompetencyread', 'nopermissions', ''); + throw new required_capability_exception($context, 'tool/lp: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()) { @@ -3357,7 +3357,7 @@ public static function user_competency_request_review($userid, $competencyid) { } if (!$uc->can_read()) { - throw new required_capability_exception($uc->get_context(), 'tool/lp:usercompetencyread', 'nopermissions', ''); + throw new required_capability_exception($uc->get_context(), 'tool/lp: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()) { @@ -3386,7 +3386,7 @@ 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:usercompetencyread', 'nopermissions', ''); + throw new required_capability_exception($context, 'tool/lp: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()) { @@ -3414,7 +3414,7 @@ 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:usercompetencyread', 'nopermissions', ''); + throw new required_capability_exception($context, 'tool/lp: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()) { @@ -3443,7 +3443,7 @@ public static function user_competency_viewed($usercompetencyorid) { } if (!$uc || !$uc->can_read()) { - throw new required_capability_exception($uc->get_context(), 'tool/lp:usercompetencyread', 'nopermissions', ''); + throw new required_capability_exception($uc->get_context(), 'tool/lp:usercompetencyview', 'nopermissions', ''); } \tool_lp\event\user_competency_viewed::create_from_user_competency_viewed($uc)->trigger(); @@ -3465,7 +3465,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:usercompetencyread', 'nopermissions', ''); + throw new required_capability_exception($uc->get_context(), 'tool/lp:usercompetencyview', 'nopermissions', ''); } $plan = new plan($planid); if ($plan->get_status() == plan::STATUS_COMPLETE) { @@ -3491,7 +3491,7 @@ public static function user_competency_viewed_in_course($usercompetencyorid, $co } if (!$uc || !$uc->can_read()) { - throw new required_capability_exception($uc->get_context(), 'tool/lp:usercompetencyread', 'nopermissions', ''); + throw new required_capability_exception($uc->get_context(), 'tool/lp:usercompetencyview', 'nopermissions', ''); } // Validate the course, this will throw an exception if not valid. self::validate_course($courseid); @@ -3514,7 +3514,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:usercompetencyread', 'nopermissions', ''); + throw new required_capability_exception($ucp->get_context(), 'tool/lp:usercompetencyview', 'nopermissions', ''); } $plan = new plan($ucp->get_planid()); if ($plan->get_status() != plan::STATUS_COMPLETE) { @@ -3538,7 +3538,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:templateread', 'nopermissions', ''); + throw new required_capability_exception($template->get_context(), 'tool/lp:templateview', 'nopermissions', ''); } // OK - all set. @@ -3555,8 +3555,8 @@ public static function list_related_competencies($competencyid) { static::require_enabled(); $competency = new competency($competencyid); - if (!has_any_capability(array('tool/lp:competencyread', 'tool/lp:competencymanage'), $competency->get_context())) { - throw new required_capability_exception($competency->get_context(), 'tool/lp:competencyread', 'nopermissions', ''); + 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', ''); } return $competency->get_related_competencies(); @@ -3620,7 +3620,7 @@ public static function read_user_evidence($id) { if (!$userevidence->can_read()) { $context = $userevidence->get_context(); - throw new required_capability_exception($context, 'tool/lp:userevidenceread', 'nopermissions', ''); + throw new required_capability_exception($context, 'tool/lp:userevidenceview', 'nopermissions', ''); } return $userevidence; @@ -3736,7 +3736,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:userevidenceread', 'nopermissions', ''); + throw new required_capability_exception($context, 'tool/lp:userevidenceview', 'nopermissions', ''); } $evidence = user_evidence::get_records(array('userid' => $userid), 'name'); @@ -4545,8 +4545,8 @@ public static function grade_competency($userid, $competencyid, $grade, $overrid // Throws exception if competency not in plan. $competency = $uc->get_competency(); $competencycontext = $competency->get_context(); - if (!has_any_capability(array('tool/lp:competencyread', 'tool/lp:competencymanage'), $competencycontext)) { - throw new required_capability_exception($competencycontext, 'tool/lp:competencyread', 'nopermissions', ''); + if (!has_any_capability(array('tool/lp:competencyview', 'tool/lp:competencymanage'), $competencycontext)) { + throw new required_capability_exception($competencycontext, 'tool/lp:competencyview', 'nopermissions', ''); } $action = evidence::ACTION_OVERRIDE; @@ -4613,8 +4613,8 @@ public static function grade_competency_in_plan($planorid, $competencyid, $grade // Throws exception if competency not in plan. $competency = $plan->get_competency($competencyid); $competencycontext = $competency->get_context(); - if (!has_any_capability(array('tool/lp:competencyread', 'tool/lp:competencymanage'), $competencycontext)) { - throw new required_capability_exception($competencycontext, 'tool/lp:competencyread', 'nopermissions', ''); + if (!has_any_capability(array('tool/lp:competencyview', 'tool/lp:competencymanage'), $competencycontext)) { + throw new required_capability_exception($competencycontext, 'tool/lp:competencyview', 'nopermissions', ''); } $action = evidence::ACTION_OVERRIDE; @@ -4691,8 +4691,8 @@ public static function grade_competency_in_course($courseorid, $userid, $compete // 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:competencyread', 'tool/lp:competencymanage'), $competencycontext)) { - throw new required_capability_exception($competencycontext, 'tool/lp:competencyread', 'nopermissions', ''); + if (!has_any_capability(array('tool/lp:competencyview', 'tool/lp:competencymanage'), $competencycontext)) { + throw new required_capability_exception($competencycontext, 'tool/lp:competencyview', 'nopermissions', ''); } // Check that the user is enrolled in the course, and is "gradable". @@ -4738,7 +4738,7 @@ public static function grade_competency_in_course($courseorid, $userid, $compete /** * Count the plans in the template, filtered by status. * - * Requires tool/lp:templateread capability at the system context. + * Requires tool/lp: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). @@ -4752,7 +4752,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:templateread', 'nopermissions', ''); + throw new required_capability_exception($template->get_context(), 'tool/lp:templateview', 'nopermissions', ''); } return plan::count_records_for_template($template->get_id(), $status); @@ -4761,7 +4761,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:templateread capability at the system context. + * Requires tool/lp: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. @@ -4775,7 +4775,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:templateread', 'nopermissions', ''); + throw new required_capability_exception($template->get_context(), 'tool/lp:templateview', 'nopermissions', ''); } return user_competency_plan::count_records_for_template($template->get_id(), $proficiency); @@ -4784,7 +4784,7 @@ public static function count_user_competency_plans_for_template($templateorid, $ /** * List the plans in the template, filtered by status. * - * Requires tool/lp:templateread capability at the system context. + * Requires tool/lp: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). @@ -4800,7 +4800,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:templateread', 'nopermissions', ''); + throw new required_capability_exception($template->get_context(), 'tool/lp:templateview', 'nopermissions', ''); } return plan::get_records_for_template($template->get_id(), $status, $skip, $limit); @@ -4809,7 +4809,7 @@ public static function list_plans_for_template($templateorid, $status = 0, $skip /** * Get the most often not completed competency for this template. * - * Requires tool/lp:templateread capability at the system context. + * Requires tool/lp:templateview capability at the system context. * * @param mixed $templateorid The id or the template. * @param int $skip The number of records to skip @@ -4824,7 +4824,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:templateread', 'nopermissions', ''); + throw new required_capability_exception($template->get_context(), 'tool/lp:templateview', 'nopermissions', ''); } return user_competency_plan::get_least_proficient_competencies_for_template($template->get_id(), $skip, $limit); @@ -4833,7 +4833,7 @@ public static function get_least_proficient_competencies_for_template($templateo /** * Template event viewed. * - * Requires tool/lp:templateread capability at the system context. + * Requires tool/lp:templateview capability at the system context. * * @param mixed $templateorid The id or the template. * @return boolean @@ -4847,7 +4847,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:templateread', 'nopermissions', ''); + throw new required_capability_exception($template->get_context(), 'tool/lp:templateview', 'nopermissions', ''); } // Trigger a template viewed event. diff --git a/admin/tool/lp/classes/form/framework_autocomplete.php b/admin/tool/lp/classes/form/framework_autocomplete.php index c3249e806ba7d..0ee20dbac3a26 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:competencyread', 'tool/lp:competencymanage'), $framework->get_context())) { + if (!has_any_capability(array('tool/lp:competencyview', 'tool/lp:competencymanage'), $framework->get_context())) { continue; } else if ($this->onlyvisible && !$framework->get_visible()) { continue; diff --git a/admin/tool/lp/classes/output/template_cohorts_table.php b/admin/tool/lp/classes/output/template_cohorts_table.php index 7fa5ffc74be4c..0655b4721dde7 100644 --- a/admin/tool/lp/classes/output/template_cohorts_table.php +++ b/admin/tool/lp/classes/output/template_cohorts_table.php @@ -62,7 +62,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:templateread', 'nopermissions', ''); + throw new required_capability_exception($template->get_context(), 'tool/lp:templateview', 'nopermissions', ''); } // Set protected properties. diff --git a/admin/tool/lp/classes/output/template_plans_table.php b/admin/tool/lp/classes/output/template_plans_table.php index 76211329659bb..2842c67d1916f 100644 --- a/admin/tool/lp/classes/output/template_plans_table.php +++ b/admin/tool/lp/classes/output/template_plans_table.php @@ -62,7 +62,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:templateread', 'nopermissions', ''); + throw new required_capability_exception($template->get_context(), 'tool/lp:templateview', 'nopermissions', ''); } // Set protected properties. diff --git a/admin/tool/lp/classes/template.php b/admin/tool/lp/classes/template.php index f884feb6f16ff..d9f0c64546d5c 100644 --- a/admin/tool/lp/classes/template.php +++ b/admin/tool/lp/classes/template.php @@ -133,7 +133,7 @@ public function can_read() { * @return bool */ public static function can_read_context($context) { - return has_capability('tool/lp:templateread', $context) || self::can_manage_context($context); + return has_capability('tool/lp:templateview', $context) || self::can_manage_context($context); } /** diff --git a/admin/tool/lp/classes/user_evidence.php b/admin/tool/lp/classes/user_evidence.php index 5f992b8314c51..e16885e96da3b 100644 --- a/admin/tool/lp/classes/user_evidence.php +++ b/admin/tool/lp/classes/user_evidence.php @@ -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:userevidenceread'); + $capabilities = array('tool/lp:userevidenceview'); return has_any_capability($capabilities, $context) || self::can_manage_user($evidenceuserid); } diff --git a/admin/tool/lp/db/access.php b/admin/tool/lp/db/access.php index 6deeeb092245a..788c9f2d2a754 100644 --- a/admin/tool/lp/db/access.php +++ b/admin/tool/lp/db/access.php @@ -36,7 +36,7 @@ 'manager' => CAP_ALLOW ) ), - 'tool/lp:competencyread' => array( + 'tool/lp:competencyview' => array( 'captype' => 'read', 'contextlevel' => CONTEXT_COURSECAT, 'archetypes' => array( @@ -78,7 +78,7 @@ ), 'clonepermissionsfrom' => 'moodle/course:isincompletionreports' ), - 'tool/lp:coursecompetencyread' => array( + 'tool/lp:coursecompetencyview' => array( 'captype' => 'read', 'contextlevel' => CONTEXT_COURSE, 'archetypes' => array( @@ -229,7 +229,7 @@ ), 'clonepermissionsfrom' => 'moodle/site:config' ), - 'tool/lp:templateread' => array( + 'tool/lp:templateview' => array( 'captype' => 'read', 'contextlevel' => CONTEXT_COURSECAT, 'archetypes' => array( @@ -252,7 +252,7 @@ ), 'clonepermissionsfrom' => 'moodle/block:view' ), - 'tool/lp:userevidenceread' => array( + 'tool/lp:userevidenceview' => array( 'captype' => 'read', 'contextlevel' => CONTEXT_USER, 'archetypes' => array( diff --git a/admin/tool/lp/db/services.php b/admin/tool/lp/db/services.php index 946bca083c720..760e958bc6e24 100644 --- a/admin/tool/lp/db/services.php +++ b/admin/tool/lp/db/services.php @@ -45,7 +45,7 @@ 'classpath' => '', 'description' => 'Load a summary of a competency framework.', 'type' => 'read', - 'capabilities' => 'tool/lp:competencyread', + 'capabilities' => 'tool/lp:competencyview', 'ajax' => true, ), 'tool_lp_duplicate_competency_framework' => array( @@ -81,7 +81,7 @@ 'classpath' => '', 'description' => 'Load a list of a competency frameworks.', 'type' => 'read', - 'capabilities' => 'tool/lp:competencyread', + 'capabilities' => 'tool/lp: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:competencyread', + 'capabilities' => 'tool/lp: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:competencyread', + 'capabilities' => 'tool/lp: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:competencyread', + 'capabilities' => 'tool/lp:competencyview', 'ajax' => true, ), 'tool_lp_create_competency' => array( @@ -126,7 +126,7 @@ 'classpath' => '', 'description' => 'Load a summary of a competency.', 'type' => 'read', - 'capabilities' => 'tool/lp:competencyread', + 'capabilities' => 'tool/lp:competencyview', 'ajax' => true, ), 'tool_lp_competency_viewed' => array( @@ -135,7 +135,7 @@ 'classpath' => '', 'description' => 'Log event competency viewed', 'type' => 'read', - 'capabilities' => 'tool/lp:competencyread', + 'capabilities' => 'tool/lp:competencyview', 'ajax' => true, ), 'tool_lp_delete_competency' => array( @@ -162,7 +162,7 @@ 'classpath' => '', 'description' => 'Load competency data for summary template.', 'type' => 'read', - 'capabilities' => 'tool/lp:competencyread', + 'capabilities' => 'tool/lp: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:competencyread', + 'capabilities' => 'tool/lp: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:competencyread', + 'capabilities' => 'tool/lp: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:competencyread', + 'capabilities' => 'tool/lp: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:competencyread', + 'capabilities' => 'tool/lp: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:competencyread', + 'capabilities' => 'tool/lp: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:competencyread', + 'capabilities' => 'tool/lp:competencyview', 'ajax' => true, ), 'tool_lp_set_parent_competency' => array( @@ -252,7 +252,7 @@ 'classpath' => '', 'description' => 'List the competencies in a course', 'type' => 'read', - 'capabilities' => 'tool/lp:coursecompetencyread', + 'capabilities' => 'tool/lp: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:coursecompetencyread', + 'capabilities' => 'tool/lp: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:coursecompetencyread', + 'capabilities' => 'tool/lp: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:coursecompetencyread', + 'capabilities' => 'tool/lp:coursecompetencyview', 'ajax' => true, ), 'tool_lp_add_competency_to_course' => array( @@ -333,7 +333,7 @@ 'classpath' => '', 'description' => 'Load the data for the course competencies page template.', 'type' => 'read', - 'capabilities' => 'tool/lp:coursecompetencyread', + 'capabilities' => 'tool/lp: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:templateread', + 'capabilities' => 'tool/lp:templateview', 'ajax' => true, ), 'tool_lp_reorder_course_competency' => array( @@ -387,7 +387,7 @@ 'classpath' => '', 'description' => 'Load a summary of a learning plan template.', 'type' => 'read', - 'capabilities' => 'tool/lp:templateread', + 'capabilities' => 'tool/lp:templateview', 'ajax' => true, ), 'tool_lp_delete_template' => array( @@ -414,7 +414,7 @@ 'classpath' => '', 'description' => 'Load a list of a learning plan templates.', 'type' => 'read', - 'capabilities' => 'tool/lp:templateread', + 'capabilities' => 'tool/lp: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:templateread', + 'capabilities' => 'tool/lp: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:templateread', + 'capabilities' => 'tool/lp: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:templateread', + 'capabilities' => 'tool/lp: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:templateread', + 'capabilities' => 'tool/lp:templateview', 'ajax' => true, ), 'tool_lp_create_plan' => array( @@ -630,7 +630,7 @@ 'classpath' => '', 'description' => 'Check if a template has related data', 'type' => 'read', - 'capabilities' => 'tool/lp:templateread', + 'capabilities' => 'tool/lp:templateview', 'ajax' => true, ), 'tool_lp_get_scale_values' => array( @@ -666,7 +666,7 @@ 'classpath' => '', 'description' => 'Load the data for the related competencies template.', 'type' => 'read', - 'capabilities' => 'tool/lp:competencyread', + 'capabilities' => 'tool/lp: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:userevidenceread', + 'capabilities' => 'tool/lp:userevidenceview', 'ajax' => true, ), 'tool_lp_delete_user_evidence' => array( @@ -713,7 +713,7 @@ 'classpath' => '', 'description' => 'Load the data for the user evidence list page template', 'type' => 'read', - 'capabilities' => 'tool/lp:userevidenceread', + 'capabilities' => 'tool/lp: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:userevidenceread', + 'capabilities' => 'tool/lp: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:competencyread', + 'capabilities' => 'tool/lp:userevidencemanageown, tool/lp:competencyview', 'ajax' => true, ), 'tool_lp_delete_user_evidence_competency' => array( @@ -869,7 +869,7 @@ 'classpath' => '', 'description' => 'Load a summary of a user competency.', 'type' => 'read', - 'capabilities' => 'tool/lp:coursecompetencyread', + 'capabilities' => 'tool/lp:coursecompetencyview', 'ajax' => true, ), 'tool_lp_unlink_plan_from_template' => array( @@ -887,7 +887,7 @@ 'classpath' => '', 'description' => 'Log event template viewed', 'type' => 'read', - 'capabilities' => 'tool/lp:templateread', + 'capabilities' => 'tool/lp:templateview', 'ajax' => true, ), 'tool_lp_request_review_of_user_evidence_linked_competencies' => array( diff --git a/admin/tool/lp/lang/en/tool_lp.php b/admin/tool/lp/lang/en/tool_lp.php index b1bee6bd93717..63b34c55e8b5c 100644 --- a/admin/tool/lp/lang/en/tool_lp.php +++ b/admin/tool/lp/lang/en/tool_lp.php @@ -204,10 +204,10 @@ $string['lp:competencymanage'] = 'Manage competency frameworks'; $string['lp:competencysuggestgrade'] = 'Suggest competency grade'; $string['lp:competencygrade'] = 'Set competency grade'; -$string['lp:competencyread'] = 'View competency frameworks'; +$string['lp:competencyview'] = 'View competency frameworks'; $string['lp:coursecompetencygradable'] = 'Receive competency marks'; $string['lp:coursecompetencymanage'] = 'Manage course competencies'; -$string['lp:coursecompetencyread'] = 'View 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'; @@ -222,7 +222,7 @@ $string['lp:planviewown'] = 'View own learning plans'; $string['lp:planviewowndraft'] = 'View own draft learning plans'; $string['lp:templatemanage'] = 'Manage templates'; -$string['lp:templateread'] = 'View template'; +$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'; @@ -231,7 +231,7 @@ $string['lp:usercompetencyview'] = 'View a user competency'; $string['lp:userevidencemanage'] = 'Manage evidence of prior learning'; $string['lp:userevidencemanageown'] = 'Manage own evidence of prior learning'; -$string['lp:userevidenceread'] = 'View evidence of prior learning of a user'; +$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 31628794bfe26..53bbd8cabc76b 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:templateread', 'nopermissions', ''); + throw new required_capability_exception($context, 'tool/lp:templateview', 'nopermissions', ''); } $url = new moodle_url('/admin/tool/lp/learningplans.php', array('pagecontextid' => $pagecontextid)); diff --git a/admin/tool/lp/template_cohorts.php b/admin/tool/lp/template_cohorts.php index 3371fc29f7a2c..b7ada226457b0 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:templateread', 'nopermissions', ''); + throw new required_capability_exception($context, 'tool/lp:templateview', 'nopermissions', ''); } // Set up the page. diff --git a/admin/tool/lp/template_plans.php b/admin/tool/lp/template_plans.php index c118a4e3e3699..368c5884ed274 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:templateread', 'nopermissions', ''); + throw new required_capability_exception($context, 'tool/lp:templateview', 'nopermissions', ''); } // Set up the page. diff --git a/admin/tool/lp/templatecompetencies.php b/admin/tool/lp/templatecompetencies.php index 7dbbbaab0351c..e0cfb4c388a90 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:templateread', 'nopermissions', ''); + throw new required_capability_exception($context, 'tool/lp: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 6896e9e1127bc..8f103ea4ab9a9 100644 --- a/admin/tool/lp/tests/api_test.php +++ b/admin/tool/lp/tests/api_test.php @@ -79,18 +79,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:competencyread', CAP_ALLOW, $roleallow, $sysctx->id); + assign_capability('tool/lp:competencyview', CAP_ALLOW, $roleallow, $sysctx->id); role_assign($roleallow, $user->id, $sysctx->id); $roleprevent = create_role('Prevent', 'prevent', 'Prevent read'); - assign_capability('tool/lp:competencyread', CAP_PROHIBIT, $roleprevent, $sysctx->id); + assign_capability('tool/lp: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:competencyread', $cat2ctx)); + $this->assertFalse(has_capability('tool/lp:competencyview', $cat2ctx)); - $requiredcap = array('tool/lp:competencyread'); + $requiredcap = array('tool/lp:competencyview'); $expected = array(); $this->assertEquals($expected, api::get_related_contexts($cat2ctx, 'self', $requiredcap)); @@ -140,18 +140,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:templateread', CAP_ALLOW, $roleallow, $sysctx->id); + assign_capability('tool/lp:templateview', CAP_ALLOW, $roleallow, $sysctx->id); role_assign($roleallow, $user->id, $sysctx->id); $roleprevent = create_role('Prevent', 'prevent', 'Prevent read'); - assign_capability('tool/lp:templateread', CAP_PROHIBIT, $roleprevent, $sysctx->id); + assign_capability('tool/lp: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:templateread', $cat2ctx)); + $this->assertFalse(has_capability('tool/lp:templateview', $cat2ctx)); - $requiredcap = array('tool/lp:templateread'); + $requiredcap = array('tool/lp:templateview'); $expected = array(); $this->assertEquals($expected, api::get_related_contexts($cat2ctx, 'self', $requiredcap)); @@ -3973,7 +3973,7 @@ public function test_grade_competency_in_course_permissions() { assign_capability('tool/lp:usercompetencyview', CAP_ALLOW, $canviewucrole, $sysctx->id); $cannotviewcomp = $dg->create_role(); - assign_capability('tool/lp:competencyread', CAP_PROHIBIT, $cannotviewcomp, $sysctx->id); + assign_capability('tool/lp:competencyview', CAP_PROHIBIT, $cannotviewcomp, $sysctx->id); $canmanagecomp = $dg->create_role(); assign_capability('tool/lp:competencymanage', CAP_ALLOW, $canmanagecomp, $sysctx->id); diff --git a/admin/tool/lp/tests/behat/behat_tool_lp_data_generators.php b/admin/tool/lp/tests/behat/behat_tool_lp_data_generators.php index 3c8b391afc9f2..ff403564ae36d 100644 --- a/admin/tool/lp/tests/behat/behat_tool_lp_data_generators.php +++ b/admin/tool/lp/tests/behat/behat_tool_lp_data_generators.php @@ -80,6 +80,10 @@ class behat_tool_lp_data_generators extends behat_base { 'userevidencecompetencies' => array( 'datagenerator' => 'user_evidence_competency', 'required' => array('userevidence', 'competency') + ), + 'usercompetencies' => array( + 'datagenerator' => 'user_competency', + 'required' => array('user', 'competency') ) ); @@ -295,4 +299,28 @@ protected function preprocess_user_evidence_competency($data) { return $data; } + /** + * Adapt creating user_evidence from user username. + * + * @param array $data + * @return array + */ + protected function preprocess_user_competency($data) { + global $DB; + + if (isset($data['user'])) { + $user = $DB->get_record('user', array('username' => $data['user']), '*', MUST_EXIST); + $data['userid'] = $user->id; + } + unset($data['user']); + + if (isset($data['competency'])) { + $competency = $DB->get_record('tool_lp_competency', array('shortname' => $data['competency']), '*', MUST_EXIST); + $data['competencyid'] = $competency->id; + } + unset($data['competency']); + + return $data; + } + } diff --git a/admin/tool/lp/tests/behat/user_evidence_comp_link.feature b/admin/tool/lp/tests/behat/user_evidence_comp_link.feature index 8354d8c0f6450..4ebd5c920ab31 100644 --- a/admin/tool/lp/tests/behat/user_evidence_comp_link.feature +++ b/admin/tool/lp/tests/behat/user_evidence_comp_link.feature @@ -54,6 +54,10 @@ Feature: Manage competencies linked to evidence of prior learning | userevidence | competency | | Test-Evidence | Test-Comp1 | | Test-Evidence | Test-Comp2 | + Given the following lp "usercompetencies" exist: + | user | competency | + | admin | Test-Comp1 | + | admin | Test-Comp2 | And I follow "Evidence of prior learning" And I should see "List of evidence" And I should see "Test-Evidence" diff --git a/admin/tool/lp/tests/externallib_test.php b/admin/tool/lp/tests/externallib_test.php index 0c4798bb691ca..104a1b2880b41 100644 --- a/admin/tool/lp/tests/externallib_test.php +++ b/admin/tool/lp/tests/externallib_test.php @@ -107,7 +107,7 @@ protected function setUp() { unassign_capability('tool/lp:competencygrade', $authrole->id); unassign_capability('tool/lp:competencysuggestgrade', $authrole->id); unassign_capability('tool/lp:competencymanage', $authrole->id); - unassign_capability('tool/lp:competencyread', $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); @@ -116,7 +116,7 @@ protected function setUp() { 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:templateread', $authrole->id); + unassign_capability('tool/lp:templateview', $authrole->id); unassign_capability('moodle/cohort:manage', $authrole->id); // Creating specific roles. @@ -124,7 +124,7 @@ protected function setUp() { $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:competencyread', CAP_ALLOW, $this->userrole, $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); @@ -134,7 +134,7 @@ protected function setUp() { assign_capability('tool/lp:competencygrade', CAP_ALLOW, $this->creatorrole, $syscontext->id); assign_capability('tool/lp:competencysuggestgrade', CAP_ALLOW, $this->creatorrole, $syscontext->id); assign_capability('moodle/cohort:manage', CAP_ALLOW, $this->creatorrole, $syscontext->id); - assign_capability('tool/lp:templateread', CAP_ALLOW, $this->userrole, $syscontext->id); + assign_capability('tool/lp:templateview', CAP_ALLOW, $this->userrole, $syscontext->id); assign_capability('tool/lp:competencysuggestgrade', 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); @@ -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:templateread', CAP_PROHIBIT, $this->userrole, $syscontextid, true); + assign_capability('tool/lp:templateview', CAP_PROHIBIT, $this->userrole, $syscontextid, true); accesslib_clear_all_caches_for_unit_testing(); $this->setUser($this->user); - $this->assertFalse(has_capability('tool/lp:templateread', context_system::instance())); + $this->assertFalse(has_capability('tool/lp: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:templateread', CAP_PREVENT, $this->userrole, $syscontextid, true); - assign_capability('tool/lp:templateread', CAP_ALLOW, $this->userrole, $catcontextid, true); + assign_capability('tool/lp:templateview', CAP_PREVENT, $this->userrole, $syscontextid, true); + assign_capability('tool/lp:templateview', CAP_ALLOW, $this->userrole, $catcontextid, true); accesslib_clear_all_caches_for_unit_testing(); - $this->assertFalse(has_capability('tool/lp:templateread', context_system::instance())); - $this->assertTrue(has_capability('tool/lp:templateread', context_coursecat::instance($this->category->id))); + $this->assertFalse(has_capability('tool/lp:templateview', context_system::instance())); + $this->assertTrue(has_capability('tool/lp: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:templateread', CAP_ALLOW, $this->userrole, $syscontextid, true); + assign_capability('tool/lp:templateview', CAP_ALLOW, $this->userrole, $syscontextid, true); accesslib_clear_all_caches_for_unit_testing(); - $this->assertTrue(has_capability('tool/lp:templateread', context_system::instance())); + $this->assertTrue(has_capability('tool/lp: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:templateread', CAP_PROHIBIT, $this->userrole, $syscontextid, true); + assign_capability('tool/lp: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:templateread', CAP_PREVENT, $this->userrole, $syscontextid, true); - assign_capability('tool/lp:templateread', CAP_ALLOW, $this->userrole, $catcontextid, true); + assign_capability('tool/lp:templateview', CAP_PREVENT, $this->userrole, $syscontextid, true); + assign_capability('tool/lp: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:templateread', CAP_ALLOW, $this->userrole, $syscontextid, true); + assign_capability('tool/lp: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:templateread', CAP_PROHIBIT, $this->userrole, $syscontextid, true); + assign_capability('tool/lp: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:templateread', CAP_PREVENT, $this->userrole, $syscontextid, true); - assign_capability('tool/lp:templateread', CAP_ALLOW, $this->userrole, $catcontextid, true); + assign_capability('tool/lp:templateview', CAP_PREVENT, $this->userrole, $syscontextid, true); + assign_capability('tool/lp: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:templateread', CAP_ALLOW, $this->userrole, $syscontextid, true); + assign_capability('tool/lp: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); diff --git a/admin/tool/lp/version.php b/admin/tool/lp/version.php index bbfa216bdb712..ee09209a387ef 100644 --- a/admin/tool/lp/version.php +++ b/admin/tool/lp/version.php @@ -25,6 +25,6 @@ defined('MOODLE_INTERNAL') || die(); -$plugin->version = 2016020919; // The current plugin version (Date: YYYYMMDDXX). +$plugin->version = 2016020920; // The current plugin version (Date: YYYYMMDDXX). $plugin->requires = 2014110400; // Requires this Moodle version. $plugin->component = 'tool_lp'; // Full name of the plugin (used for diagnostics). diff --git a/report/competency/db/services.php b/report/competency/db/services.php index 4d4a2c7d33c00..efa9be07872cd 100644 --- a/report/competency/db/services.php +++ b/report/competency/db/services.php @@ -36,7 +36,7 @@ 'classpath' => '', 'description' => 'Load the data for the competency report in a course.', 'type' => 'read', - 'capabilities' => 'tool/lp:coursecompetencyread', + 'capabilities' => 'tool/lp:coursecompetencyview', 'ajax' => true, ) ); diff --git a/report/competency/lib.php b/report/competency/lib.php index fe1a3bfa11e9c..9f9a54a77731d 100644 --- a/report/competency/lib.php +++ b/report/competency/lib.php @@ -34,7 +34,7 @@ * @param stdClass $context The context of the course */ function report_competency_extend_navigation_course($navigation, $course, $context) { - if (has_capability('tool/lp:coursecompetencyread', $context)) { + if (has_capability('tool/lp:coursecompetencyview', $context)) { $url = new moodle_url('/report/competency/index.php', array('id' => $course->id)); $name = get_string('pluginname', 'report_competency'); $navigation->add($name, $url, navigation_node::TYPE_SETTING, null, null, new pix_icon('i/report', ''));