mirror of
https://github.com/moodle/moodle.git
synced 2025-08-05 17:06:53 +02:00
MDL-53483 tool_lp: Normalise the names of capabilities
This commit is contained in:
parent
a4f1b030f2
commit
44e8cba48e
20 changed files with 202 additions and 170 deletions
|
@ -401,7 +401,7 @@ class api {
|
|||
/**
|
||||
* 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 @@ class api {
|
|||
|
||||
// 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 @@ class api {
|
|||
/**
|
||||
* 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 @@ class api {
|
|||
|
||||
// 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 @@ class api {
|
|||
/**
|
||||
* 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 @@ class api {
|
|||
}
|
||||
|
||||
// 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 @@ class api {
|
|||
/**
|
||||
* 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 @@ class api {
|
|||
}
|
||||
|
||||
// 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 @@ class api {
|
|||
/**
|
||||
* 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 @@ class api {
|
|||
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 @@ class api {
|
|||
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 @@ class api {
|
|||
$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 @@ class api {
|
|||
/**
|
||||
* 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 @@ class api {
|
|||
|
||||
// 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 @@ class api {
|
|||
/**
|
||||
* 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 @@ class api {
|
|||
|
||||
// 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 @@ class api {
|
|||
}
|
||||
|
||||
$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 @@ class api {
|
|||
$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 @@ class api {
|
|||
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 @@ class api {
|
|||
// 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 @@ class api {
|
|||
// 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 @@ class api {
|
|||
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 @@ class api {
|
|||
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 @@ class api {
|
|||
// 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 @@ class api {
|
|||
$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 @@ class api {
|
|||
/**
|
||||
* 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 @@ class api {
|
|||
|
||||
// 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 @@ class api {
|
|||
/**
|
||||
* 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 @@ class api {
|
|||
|
||||
// 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 @@ class api {
|
|||
/**
|
||||
* 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 @@ class api {
|
|||
|
||||
// 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 @@ class api {
|
|||
$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 @@ class api {
|
|||
$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 @@ class api {
|
|||
}
|
||||
|
||||
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 @@ class api {
|
|||
}
|
||||
|
||||
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 @@ class api {
|
|||
}
|
||||
|
||||
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 @@ class api {
|
|||
|
||||
// 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 @@ class api {
|
|||
|
||||
// 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 @@ class api {
|
|||
$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 @@ class api {
|
|||
}
|
||||
|
||||
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 @@ class api {
|
|||
$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 @@ class api {
|
|||
$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 @@ class api {
|
|||
}
|
||||
|
||||
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 @@ class api {
|
|||
}
|
||||
|
||||
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 @@ class api {
|
|||
}
|
||||
|
||||
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 @@ class api {
|
|||
}
|
||||
|
||||
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 @@ class api {
|
|||
$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 @@ class api {
|
|||
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 @@ class api {
|
|||
|
||||
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 @@ class api {
|
|||
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 @@ class api {
|
|||
// 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 @@ class api {
|
|||
// 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 @@ class api {
|
|||
// 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 @@ class api {
|
|||
/**
|
||||
* 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 @@ class api {
|
|||
|
||||
// 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 @@ class api {
|
|||
/**
|
||||
* 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 @@ class api {
|
|||
|
||||
// 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 @@ class api {
|
|||
/**
|
||||
* 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 @@ class api {
|
|||
|
||||
// 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 @@ class api {
|
|||
/**
|
||||
* 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 @@ class api {
|
|||
|
||||
// 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 @@ class api {
|
|||
/**
|
||||
* 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 @@ class api {
|
|||
|
||||
// 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.
|
||||
|
|
|
@ -106,7 +106,7 @@ class framework_autocomplete extends MoodleQuickForm_autocomplete {
|
|||
list($insql, $inparams) = $DB->get_in_or_equal($ids, SQL_PARAMS_NAMED, 'param');
|
||||
$frameworks = competency_framework::get_records_select("id $insql", $inparams, 'shortname');
|
||||
foreach ($frameworks as $framework) {
|
||||
if (!has_any_capability(array('tool/lp: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;
|
||||
|
|
|
@ -62,7 +62,7 @@ class template_cohorts_table extends table_sql {
|
|||
|
||||
// This object should not be used without the right permissions.
|
||||
if (!$template->can_read()) {
|
||||
throw new required_capability_exception($template->get_context(), 'tool/lp:templateread', 'nopermissions', '');
|
||||
throw new required_capability_exception($template->get_context(), 'tool/lp:templateview', 'nopermissions', '');
|
||||
}
|
||||
|
||||
// Set protected properties.
|
||||
|
|
|
@ -62,7 +62,7 @@ class template_plans_table extends table_sql {
|
|||
|
||||
// This object should not be used without the right permissions.
|
||||
if (!$template->can_read()) {
|
||||
throw new required_capability_exception($template->get_context(), 'tool/lp:templateread', 'nopermissions', '');
|
||||
throw new required_capability_exception($template->get_context(), 'tool/lp:templateview', 'nopermissions', '');
|
||||
}
|
||||
|
||||
// Set protected properties.
|
||||
|
|
|
@ -133,7 +133,7 @@ class template extends persistent {
|
|||
* @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);
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
|
@ -187,7 +187,7 @@ class user_evidence extends persistent {
|
|||
public static function can_read_user($evidenceuserid) {
|
||||
$context = context_user::instance($evidenceuserid);
|
||||
|
||||
$capabilities = array('tool/lp:userevidenceread');
|
||||
$capabilities = array('tool/lp:userevidenceview');
|
||||
|
||||
return has_any_capability($capabilities, $context) || self::can_manage_user($evidenceuserid);
|
||||
}
|
||||
|
|
|
@ -36,7 +36,7 @@ $capabilities = array(
|
|||
'manager' => CAP_ALLOW
|
||||
)
|
||||
),
|
||||
'tool/lp:competencyread' => array(
|
||||
'tool/lp:competencyview' => array(
|
||||
'captype' => 'read',
|
||||
'contextlevel' => CONTEXT_COURSECAT,
|
||||
'archetypes' => array(
|
||||
|
@ -78,7 +78,7 @@ $capabilities = array(
|
|||
),
|
||||
'clonepermissionsfrom' => 'moodle/course:isincompletionreports'
|
||||
),
|
||||
'tool/lp:coursecompetencyread' => array(
|
||||
'tool/lp:coursecompetencyview' => array(
|
||||
'captype' => 'read',
|
||||
'contextlevel' => CONTEXT_COURSE,
|
||||
'archetypes' => array(
|
||||
|
@ -229,7 +229,7 @@ $capabilities = array(
|
|||
),
|
||||
'clonepermissionsfrom' => 'moodle/site:config'
|
||||
),
|
||||
'tool/lp:templateread' => array(
|
||||
'tool/lp:templateview' => array(
|
||||
'captype' => 'read',
|
||||
'contextlevel' => CONTEXT_COURSECAT,
|
||||
'archetypes' => array(
|
||||
|
@ -252,7 +252,7 @@ $capabilities = array(
|
|||
),
|
||||
'clonepermissionsfrom' => 'moodle/block:view'
|
||||
),
|
||||
'tool/lp:userevidenceread' => array(
|
||||
'tool/lp:userevidenceview' => array(
|
||||
'captype' => 'read',
|
||||
'contextlevel' => CONTEXT_USER,
|
||||
'archetypes' => array(
|
||||
|
|
|
@ -45,7 +45,7 @@ $functions = array(
|
|||
'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 @@ $functions = array(
|
|||
'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 @@ $functions = array(
|
|||
'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 @@ $functions = array(
|
|||
'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 @@ $functions = array(
|
|||
'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 @@ $functions = array(
|
|||
'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 @@ $functions = array(
|
|||
'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 @@ $functions = array(
|
|||
'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 @@ $functions = array(
|
|||
'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 @@ $functions = array(
|
|||
'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 @@ $functions = array(
|
|||
'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 @@ $functions = array(
|
|||
'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 @@ $functions = array(
|
|||
'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 @@ $functions = array(
|
|||
'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 @@ $functions = array(
|
|||
'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 @@ $functions = array(
|
|||
'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 @@ $functions = array(
|
|||
'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 @@ $functions = array(
|
|||
'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 @@ $functions = array(
|
|||
'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 @@ $functions = array(
|
|||
'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 @@ $functions = array(
|
|||
'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 @@ $functions = array(
|
|||
'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 @@ $functions = array(
|
|||
'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 @@ $functions = array(
|
|||
'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 @@ $functions = array(
|
|||
'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 @@ $functions = array(
|
|||
'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 @@ $functions = array(
|
|||
'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 @@ $functions = array(
|
|||
'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 @@ $functions = array(
|
|||
'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 @@ $functions = array(
|
|||
'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 @@ $functions = array(
|
|||
'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 @@ $functions = array(
|
|||
'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 @@ $functions = array(
|
|||
'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 @@ $functions = array(
|
|||
'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(
|
||||
|
|
|
@ -204,10 +204,10 @@ $string['locatecompetency'] = 'Locate competency';
|
|||
$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: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: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:usercompetencyreview'] = 'Review a user competency';
|
|||
$string['lp:usercompetencyview'] = 'View a user competency';
|
||||
$string['lp:userevidencemanage'] = 'Manage evidence of prior learning';
|
||||
$string['lp:userevidencemanageown'] = 'Manage own evidence of prior learning';
|
||||
$string['lp:userevidenceread'] = 'View evidence of prior learning of a user';
|
||||
$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.';
|
||||
|
|
|
@ -31,7 +31,7 @@ $context = context::instance_by_id($pagecontextid);
|
|||
require_login(0, false);
|
||||
\tool_lp\api::require_enabled();
|
||||
if (!\tool_lp\template::can_read_context($context)) {
|
||||
throw new required_capability_exception($context, 'tool/lp:templateread', 'nopermissions', '');
|
||||
throw new required_capability_exception($context, 'tool/lp:templateview', 'nopermissions', '');
|
||||
}
|
||||
|
||||
$url = new moodle_url('/admin/tool/lp/learningplans.php', array('pagecontextid' => $pagecontextid));
|
||||
|
|
|
@ -37,7 +37,7 @@ $canmanagetemplate = $template->can_manage();
|
|||
$duedatereached = $template->get_duedate() > 0 && $template->get_duedate() < time();
|
||||
|
||||
if (!$canreadtemplate) {
|
||||
throw new required_capability_exception($context, 'tool/lp:templateread', 'nopermissions', '');
|
||||
throw new required_capability_exception($context, 'tool/lp:templateview', 'nopermissions', '');
|
||||
}
|
||||
|
||||
// Set up the page.
|
||||
|
|
|
@ -35,7 +35,7 @@ $context = $template->get_context();
|
|||
$canreadtemplate = $template->can_read();
|
||||
$canmanagetemplate = $template->can_manage();
|
||||
if (!$canreadtemplate) {
|
||||
throw new required_capability_exception($context, 'tool/lp:templateread', 'nopermissions', '');
|
||||
throw new required_capability_exception($context, 'tool/lp:templateview', 'nopermissions', '');
|
||||
}
|
||||
|
||||
// Set up the page.
|
||||
|
|
|
@ -35,7 +35,7 @@ $pagecontext = context::instance_by_id($pagecontextid);
|
|||
$template = \tool_lp\api::read_template($templateid);
|
||||
$context = $template->get_context();
|
||||
if (!$template->can_read()) {
|
||||
throw new required_capability_exception($context, 'tool/lp:templateread', 'nopermissions', '');
|
||||
throw new required_capability_exception($context, 'tool/lp:templateview', 'nopermissions', '');
|
||||
}
|
||||
|
||||
// Trigger a template viewed event.
|
||||
|
|
|
@ -79,18 +79,18 @@ class tool_lp_api_testcase extends advanced_testcase {
|
|||
$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 @@ class tool_lp_api_testcase extends advanced_testcase {
|
|||
$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 @@ class tool_lp_api_testcase extends advanced_testcase {
|
|||
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);
|
||||
|
|
|
@ -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 @@ class behat_tool_lp_data_generators extends behat_base {
|
|||
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;
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -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"
|
||||
|
|
|
@ -107,7 +107,7 @@ class tool_lp_external_testcase extends externallib_advanced_testcase {
|
|||
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 @@ class tool_lp_external_testcase extends externallib_advanced_testcase {
|
|||
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 @@ class tool_lp_external_testcase extends externallib_advanced_testcase {
|
|||
$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 @@ class tool_lp_external_testcase extends externallib_advanced_testcase {
|
|||
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 @@ class tool_lp_external_testcase extends externallib_advanced_testcase {
|
|||
$cattemplate = $this->create_template(2, false);
|
||||
|
||||
// User without permissions to read in system.
|
||||
assign_capability('tool/lp: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 @@ class tool_lp_external_testcase extends externallib_advanced_testcase {
|
|||
}
|
||||
|
||||
// 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 @@ class tool_lp_external_testcase extends externallib_advanced_testcase {
|
|||
$this->assertEquals(userdate(0), $result['duedateformatted']);
|
||||
|
||||
// User with permissions to read in the system.
|
||||
assign_capability('tool/lp: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 @@ class tool_lp_external_testcase extends externallib_advanced_testcase {
|
|||
|
||||
// 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 @@ class tool_lp_external_testcase extends externallib_advanced_testcase {
|
|||
}
|
||||
|
||||
// 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 @@ class tool_lp_external_testcase extends externallib_advanced_testcase {
|
|||
$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 @@ class tool_lp_external_testcase extends externallib_advanced_testcase {
|
|||
|
||||
// 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 @@ class tool_lp_external_testcase extends externallib_advanced_testcase {
|
|||
}
|
||||
|
||||
// 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);
|
||||
|
|
|
@ -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).
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue