mirror of
https://github.com/moodle/moodle.git
synced 2025-04-24 09:55:33 +02:00
MDL-53700 competency: Making CiBoT happier
This commit is contained in:
parent
8d0c57ed08
commit
91e5464282
admin/tool
blocks/lp/classes/output
competency
classes
api.phpcompetency.phpcourse_competency_settings.phpexternal.phpuser_competency_course.phpuser_evidence.php
tests
course
@ -196,11 +196,10 @@ class external extends external_api {
|
||||
public static function data_for_competencies_manage_page($competencyframeworkid, $search) {
|
||||
global $PAGE;
|
||||
|
||||
$params = self::validate_parameters(self::data_for_competencies_manage_page_parameters(),
|
||||
array(
|
||||
'competencyframeworkid' => $competencyframeworkid,
|
||||
'search' => $search
|
||||
));
|
||||
$params = self::validate_parameters(self::data_for_competencies_manage_page_parameters(), array(
|
||||
'competencyframeworkid' => $competencyframeworkid,
|
||||
'search' => $search
|
||||
));
|
||||
|
||||
$framework = api::read_framework($params['competencyframeworkid']);
|
||||
self::validate_context($framework->get_context());
|
||||
@ -272,12 +271,11 @@ class external extends external_api {
|
||||
*/
|
||||
public static function data_for_competency_summary($competencyid, $includerelated = false, $includecourses = false) {
|
||||
global $PAGE;
|
||||
$params = self::validate_parameters(self::data_for_competency_summary_parameters(),
|
||||
array(
|
||||
'competencyid' => $competencyid,
|
||||
'includerelated' => $includerelated,
|
||||
'includecourses' => $includecourses
|
||||
));
|
||||
$params = self::validate_parameters(self::data_for_competency_summary_parameters(), array(
|
||||
'competencyid' => $competencyid,
|
||||
'includerelated' => $includerelated,
|
||||
'includecourses' => $includecourses
|
||||
));
|
||||
|
||||
$competency = api::read_competency($params['competencyid']);
|
||||
$framework = api::read_framework($competency->get_competencyframeworkid());
|
||||
@ -376,10 +374,9 @@ class external extends external_api {
|
||||
*/
|
||||
public static function data_for_course_competencies_page($courseid) {
|
||||
global $PAGE;
|
||||
$params = self::validate_parameters(self::data_for_course_competencies_page_parameters(),
|
||||
array(
|
||||
'courseid' => $courseid,
|
||||
));
|
||||
$params = self::validate_parameters(self::data_for_course_competencies_page_parameters(), array(
|
||||
'courseid' => $courseid,
|
||||
));
|
||||
self::validate_context(context_course::instance($params['courseid']));
|
||||
|
||||
$renderable = new output\course_competencies_page($params['courseid']);
|
||||
@ -418,7 +415,8 @@ class external extends external_api {
|
||||
'value' => new external_value(PARAM_INT, 'The option value'),
|
||||
'text' => new external_value(PARAM_NOTAGS, 'The name of the option'),
|
||||
'selected' => new external_value(PARAM_BOOL, 'If this is the currently selected option'),
|
||||
))),
|
||||
))
|
||||
),
|
||||
'comppath' => competency_path_exporter::get_read_structure(),
|
||||
))),
|
||||
'manageurl' => new external_value(PARAM_LOCALURL, 'Url to the manage competencies page.'),
|
||||
@ -503,11 +501,10 @@ class external extends external_api {
|
||||
*/
|
||||
public static function data_for_template_competencies_page($templateid, $pagecontext) {
|
||||
global $PAGE;
|
||||
$params = self::validate_parameters(self::data_for_template_competencies_page_parameters(),
|
||||
array(
|
||||
'templateid' => $templateid,
|
||||
'pagecontext' => $pagecontext
|
||||
));
|
||||
$params = self::validate_parameters(self::data_for_template_competencies_page_parameters(), array(
|
||||
'templateid' => $templateid,
|
||||
'pagecontext' => $pagecontext
|
||||
));
|
||||
|
||||
$context = self::get_context_from_params($params['pagecontext']);
|
||||
self::validate_context($context);
|
||||
@ -565,10 +562,9 @@ class external extends external_api {
|
||||
*/
|
||||
public static function data_for_plan_page($planid) {
|
||||
global $PAGE;
|
||||
$params = self::validate_parameters(self::data_for_plan_page_parameters(),
|
||||
array(
|
||||
'planid' => $planid
|
||||
));
|
||||
$params = self::validate_parameters(self::data_for_plan_page_parameters(), array(
|
||||
'planid' => $planid
|
||||
));
|
||||
$plan = api::read_plan($params['planid']);
|
||||
self::validate_context($plan->get_context());
|
||||
|
||||
@ -635,10 +631,9 @@ class external extends external_api {
|
||||
public static function data_for_plans_page($userid) {
|
||||
global $PAGE;
|
||||
|
||||
$params = self::validate_parameters(self::data_for_plans_page_parameters(),
|
||||
array(
|
||||
'userid' => $userid,
|
||||
));
|
||||
$params = self::validate_parameters(self::data_for_plans_page_parameters(), array(
|
||||
'userid' => $userid,
|
||||
));
|
||||
|
||||
$context = context_user::instance($params['userid']);
|
||||
self::validate_context($context);
|
||||
@ -781,10 +776,9 @@ class external extends external_api {
|
||||
public static function data_for_related_competencies_section($competencyid) {
|
||||
global $PAGE;
|
||||
|
||||
$params = self::validate_parameters(self::data_for_related_competencies_section_parameters(),
|
||||
array(
|
||||
'competencyid' => $competencyid,
|
||||
));
|
||||
$params = self::validate_parameters(self::data_for_related_competencies_section_parameters(), array(
|
||||
'competencyid' => $competencyid,
|
||||
));
|
||||
$competency = api::read_competency($params['competencyid']);
|
||||
self::validate_context($competency->get_context());
|
||||
|
||||
@ -852,13 +846,12 @@ class external extends external_api {
|
||||
public static function search_users($query, $capability = '', $limitfrom = 0, $limitnum = 100) {
|
||||
global $DB, $CFG, $PAGE, $USER;
|
||||
|
||||
$params = self::validate_parameters(self::search_users_parameters(),
|
||||
array(
|
||||
'query' => $query,
|
||||
'capability' => $capability,
|
||||
'limitfrom' => $limitfrom,
|
||||
'limitnum' => $limitnum,
|
||||
));
|
||||
$params = self::validate_parameters(self::search_users_parameters(), array(
|
||||
'query' => $query,
|
||||
'capability' => $capability,
|
||||
'limitfrom' => $limitfrom,
|
||||
'limitnum' => $limitnum,
|
||||
));
|
||||
$query = $params['query'];
|
||||
$cap = $params['capability'];
|
||||
$limitfrom = $params['limitfrom'];
|
||||
@ -977,14 +970,13 @@ class external extends external_api {
|
||||
global $DB, $CFG, $PAGE;
|
||||
require_once($CFG->dirroot . '/cohort/lib.php');
|
||||
|
||||
$params = self::validate_parameters(self::search_cohorts_parameters(),
|
||||
array(
|
||||
'query' => $query,
|
||||
'context' => $context,
|
||||
'includes' => $includes,
|
||||
'limitfrom' => $limitfrom,
|
||||
'limitnum' => $limitnum,
|
||||
));
|
||||
$params = self::validate_parameters(self::search_cohorts_parameters(), array(
|
||||
'query' => $query,
|
||||
'context' => $context,
|
||||
'includes' => $includes,
|
||||
'limitfrom' => $limitfrom,
|
||||
'limitnum' => $limitnum,
|
||||
));
|
||||
$query = $params['query'];
|
||||
$includes = $params['includes'];
|
||||
$context = self::get_context_from_params($params['context']);
|
||||
@ -1126,11 +1118,10 @@ class external extends external_api {
|
||||
*/
|
||||
public static function data_for_user_competency_summary_in_plan($competencyid, $planid) {
|
||||
global $PAGE;
|
||||
$params = self::validate_parameters(self::data_for_user_competency_summary_in_plan_parameters(),
|
||||
array(
|
||||
'competencyid' => $competencyid,
|
||||
'planid' => $planid
|
||||
));
|
||||
$params = self::validate_parameters(self::data_for_user_competency_summary_in_plan_parameters(), array(
|
||||
'competencyid' => $competencyid,
|
||||
'planid' => $planid
|
||||
));
|
||||
|
||||
$plan = api::read_plan($params['planid']);
|
||||
$context = $plan->get_context();
|
||||
@ -1190,12 +1181,11 @@ class external extends external_api {
|
||||
*/
|
||||
public static function data_for_user_competency_summary_in_course($userid, $competencyid, $courseid) {
|
||||
global $PAGE;
|
||||
$params = self::validate_parameters(self::data_for_user_competency_summary_in_course_parameters(),
|
||||
array(
|
||||
'userid' => $userid,
|
||||
'competencyid' => $competencyid,
|
||||
'courseid' => $courseid
|
||||
));
|
||||
$params = self::validate_parameters(self::data_for_user_competency_summary_in_course_parameters(), array(
|
||||
'userid' => $userid,
|
||||
'competencyid' => $competencyid,
|
||||
'courseid' => $courseid
|
||||
));
|
||||
$context = context_user::instance($params['userid']);
|
||||
self::validate_context($context);
|
||||
$output = $PAGE->get_renderer('tool_lp');
|
||||
|
@ -79,7 +79,8 @@ class course_competency_statistics_exporter extends \core_competency\external\ex
|
||||
$proficientcompetencypercentage = 0;
|
||||
$proficientcompetencypercentageformatted = '';
|
||||
if ($this->data->competencycount > 0) {
|
||||
$proficientcompetencypercentage = ((float) $this->data->proficientcompetencycount / (float) $this->data->competencycount) * 100.0;
|
||||
$proficientcompetencypercentage = ((float) $this->data->proficientcompetencycount
|
||||
/ (float) $this->data->competencycount) * 100.0;
|
||||
$proficientcompetencypercentageformatted = format_float($proficientcompetencypercentage);
|
||||
}
|
||||
$competencies = array();
|
||||
|
@ -113,8 +113,8 @@ class template_statistics_exporter extends \core_competency\external\exporter {
|
||||
$proficientusercompetencyplanpercentage = 0;
|
||||
$proficientusercompetencyplanpercentageformatted = '';
|
||||
if ($this->data->usercompetencyplancount > 0) {
|
||||
$proficientusercompetencyplanpercentage = ((float) $this->data->proficientusercompetencyplancount /
|
||||
(float) $this->data->usercompetencyplancount) * 100.0;
|
||||
$proficientusercompetencyplanpercentage = ((float) $this->data->proficientusercompetencyplancount
|
||||
/ (float) $this->data->usercompetencyplancount) * 100.0;
|
||||
$proficientusercompetencyplanpercentageformatted = format_float($proficientusercompetencyplanpercentage);
|
||||
}
|
||||
$competencies = array();
|
||||
|
@ -106,7 +106,8 @@ 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('moodle/competency:competencyview', 'moodle/competency:competencymanage'), $framework->get_context())) {
|
||||
if (!has_any_capability(array('moodle/competency:competencyview', 'moodle/competency:competencymanage'),
|
||||
$framework->get_context())) {
|
||||
continue;
|
||||
} else if ($this->onlyvisible && !$framework->get_visible()) {
|
||||
continue;
|
||||
|
@ -134,7 +134,7 @@ class renderer extends plugin_renderer_base {
|
||||
/**
|
||||
* Defer to template.
|
||||
*
|
||||
* @param renderable $page
|
||||
* @param user_competency_summary_in_course $page
|
||||
* @return string
|
||||
*/
|
||||
public function render_user_competency_summary_in_course(user_competency_summary_in_course $page) {
|
||||
@ -145,7 +145,7 @@ class renderer extends plugin_renderer_base {
|
||||
/**
|
||||
* Defer to template.
|
||||
*
|
||||
* @param renderable $page
|
||||
* @param user_competency_summary_in_plan $page
|
||||
* @return string
|
||||
*/
|
||||
public function render_user_competency_summary_in_plan(user_competency_summary_in_plan $page) {
|
||||
@ -209,7 +209,7 @@ class renderer extends plugin_renderer_base {
|
||||
/**
|
||||
* Defer to template.
|
||||
*
|
||||
* @param user_competency_page $page
|
||||
* @param user_competency_summary $page
|
||||
* @return string
|
||||
*/
|
||||
public function render_user_competency_summary(user_competency_summary $page) {
|
||||
|
@ -61,7 +61,8 @@ 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(), 'moodle/competency:templateview', 'nopermissions', '');
|
||||
throw new \required_capability_exception($template->get_context(), 'moodle/competency:templateview',
|
||||
'nopermissions', '');
|
||||
}
|
||||
|
||||
// Set protected properties.
|
||||
|
@ -61,7 +61,8 @@ 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(), 'moodle/competency:templateview', 'nopermissions', '');
|
||||
throw new \required_capability_exception($template->get_context(), 'moodle/competency:templateview',
|
||||
'nopermissions', '');
|
||||
}
|
||||
|
||||
// Set protected properties.
|
||||
|
@ -464,8 +464,8 @@ class framework_processor {
|
||||
$competenciestoremovefromcourse[$competencyid] = true;
|
||||
$this->coursecompetencymigrations++;
|
||||
|
||||
// The competency was already in the course...
|
||||
} else {
|
||||
// The competency was already in the course...
|
||||
if ($this->removeoriginalwhenalreadypresent) {
|
||||
$competenciestoremovefromcourse[$competencyid] = true;
|
||||
} else {
|
||||
@ -474,8 +474,8 @@ class framework_processor {
|
||||
}
|
||||
}
|
||||
|
||||
// There was a major problem with this competency, we will ignore it entirely for the course.
|
||||
} catch (moodle_exception $e) {
|
||||
// There was a major problem with this competency, we will ignore it entirely for the course.
|
||||
$skipcompetencies[$competencyid] = true;
|
||||
|
||||
$this->log_error($courseid, $competencyid, null,
|
||||
@ -512,8 +512,8 @@ class framework_processor {
|
||||
$remove = false;
|
||||
}
|
||||
|
||||
// We have a mapping.
|
||||
} else {
|
||||
// We have a mapping.
|
||||
$transaction = $DB->start_delegated_transaction();
|
||||
try {
|
||||
// The competency was added successfully.
|
||||
@ -531,8 +531,8 @@ class framework_processor {
|
||||
|
||||
$this->modulecompetencymigrations++;
|
||||
|
||||
// The competency was already in the module.
|
||||
} else {
|
||||
// The competency was already in the module.
|
||||
if (!$this->removeoriginalwhenalreadypresent) {
|
||||
$remove = false;
|
||||
$competencieswithissues[$competencyid] = true;
|
||||
@ -541,8 +541,8 @@ class framework_processor {
|
||||
}
|
||||
}
|
||||
|
||||
// There was a major problem with this competency in this module.
|
||||
} catch (moodle_exception $e) {
|
||||
// There was a major problem with this competency in this module.
|
||||
$message = get_string('errorwhilemigratingmodulecompetencywithexception', 'tool_lpmigrate',
|
||||
$e->getMessage());
|
||||
$this->log_error($courseid, $competencyid, $cmid, $message);
|
||||
|
@ -59,7 +59,7 @@ class renderer extends plugin_renderer_base {
|
||||
|
||||
/**
|
||||
* Defer to template.
|
||||
* @param renderable $page
|
||||
* @param renderable $summary
|
||||
* @return string
|
||||
*/
|
||||
public function render_summary(renderable $summary) {
|
||||
|
@ -723,8 +723,10 @@ class api {
|
||||
public static function read_framework($id) {
|
||||
static::require_enabled();
|
||||
$framework = new competency_framework($id);
|
||||
if (!has_any_capability(array('moodle/competency:competencyview', 'moodle/competency:competencymanage'), $framework->get_context())) {
|
||||
throw new required_capability_exception($framework->get_context(), 'moodle/competency:competencyview', 'nopermissions', '');
|
||||
if (!has_any_capability(array('moodle/competency:competencyview', 'moodle/competency:competencymanage'),
|
||||
$framework->get_context())) {
|
||||
throw new required_capability_exception($framework->get_context(), 'moodle/competency:competencyview',
|
||||
'nopermissions', '');
|
||||
}
|
||||
return $framework;
|
||||
}
|
||||
@ -741,8 +743,10 @@ class api {
|
||||
if (!is_object($framework)) {
|
||||
$framework = new competency_framework($framework);
|
||||
}
|
||||
if (!has_any_capability(array('moodle/competency:competencyview', 'moodle/competency:competencymanage'), $framework->get_context())) {
|
||||
throw new required_capability_exception($framework->get_context(), 'moodle/competency:competencyview', 'nopermissions', '');
|
||||
if (!has_any_capability(array('moodle/competency:competencyview', 'moodle/competency:competencymanage'),
|
||||
$framework->get_context())) {
|
||||
throw new required_capability_exception($framework->get_context(), 'moodle/competency:competencyview',
|
||||
'nopermissions', '');
|
||||
}
|
||||
\core\event\competency_framework_viewed::create_from_framework($framework)->trigger();
|
||||
return true;
|
||||
@ -761,8 +765,10 @@ class api {
|
||||
$competency = new competency($competency);
|
||||
}
|
||||
|
||||
if (!has_any_capability(array('moodle/competency:competencyview', 'moodle/competency:competencymanage'), $competency->get_context())) {
|
||||
throw new required_capability_exception($competency->get_context(), 'moodle/competency:competencyview', 'nopermissions', '');
|
||||
if (!has_any_capability(array('moodle/competency:competencyview', 'moodle/competency:competencymanage'),
|
||||
$competency->get_context())) {
|
||||
throw new required_capability_exception($competency->get_context(), 'moodle/competency:competencyview',
|
||||
'nopermissions', '');
|
||||
}
|
||||
|
||||
\core\event\competency_viewed::create_from_competency($competency)->trigger();
|
||||
@ -1145,7 +1151,8 @@ class api {
|
||||
}
|
||||
|
||||
if (!$uc->can_read()) {
|
||||
throw new required_capability_exception($uc->get_context(), 'moodle/competency:usercompetencyview', 'nopermissions', '');
|
||||
throw new required_capability_exception($uc->get_context(), 'moodle/competency:usercompetencyview',
|
||||
'nopermissions', '');
|
||||
}
|
||||
return $uc;
|
||||
}
|
||||
@ -1160,7 +1167,8 @@ class api {
|
||||
static::require_enabled();
|
||||
$uc = new user_competency($usercompetencyid);
|
||||
if (!$uc->can_read()) {
|
||||
throw new required_capability_exception($uc->get_context(), 'moodle/competency:usercompetencyview', 'nopermissions', '');
|
||||
throw new required_capability_exception($uc->get_context(), 'moodle/competency:usercompetencyview',
|
||||
'nopermissions', '');
|
||||
}
|
||||
return $uc;
|
||||
}
|
||||
@ -1706,7 +1714,8 @@ class api {
|
||||
|
||||
// First we do a permissions check.
|
||||
if (!$template->can_manage()) {
|
||||
throw new required_capability_exception($template->get_context(), 'moodle/competency:templatemanage', 'nopermissions', '');
|
||||
throw new required_capability_exception($template->get_context(), 'moodle/competency:templatemanage',
|
||||
'nopermissions', '');
|
||||
}
|
||||
|
||||
// OK - all set.
|
||||
@ -1732,7 +1741,8 @@ class api {
|
||||
|
||||
// First we do a permissions check.
|
||||
if (!$template->can_manage()) {
|
||||
throw new required_capability_exception($template->get_context(), 'moodle/competency:templatemanage', 'nopermissions', '');
|
||||
throw new required_capability_exception($template->get_context(), 'moodle/competency:templatemanage',
|
||||
'nopermissions', '');
|
||||
}
|
||||
|
||||
// OK - all set.
|
||||
@ -1772,7 +1782,8 @@ class api {
|
||||
|
||||
// First we do a permissions check.
|
||||
if (!$template->can_manage()) {
|
||||
throw new required_capability_exception($template->get_context(), 'moodle/competency:templatemanage', 'nopermissions', '');
|
||||
throw new required_capability_exception($template->get_context(), 'moodle/competency:templatemanage',
|
||||
'nopermissions', '');
|
||||
}
|
||||
|
||||
$transaction = $DB->start_delegated_transaction();
|
||||
@ -1839,10 +1850,11 @@ class api {
|
||||
|
||||
// First we do a permissions check.
|
||||
if (!$template->can_manage()) {
|
||||
throw new required_capability_exception($template->get_context(), 'moodle/competency:templatemanage', 'nopermissions', '');
|
||||
throw new required_capability_exception($template->get_context(), 'moodle/competency:templatemanage',
|
||||
'nopermissions', '');
|
||||
|
||||
} else if (isset($record->contextid) && $record->contextid != $template->get_contextid()) {
|
||||
// We can never change the context of a template.
|
||||
// We can never change the context of a template.
|
||||
throw new coding_exception('Changing the context of an existing tempalte is forbidden.');
|
||||
|
||||
}
|
||||
@ -1896,7 +1908,8 @@ class api {
|
||||
|
||||
// First we do a permissions check.
|
||||
if (!$template->can_read()) {
|
||||
throw new required_capability_exception($template->get_context(), 'moodle/competency:templateview', 'nopermissions', '');
|
||||
throw new required_capability_exception($template->get_context(), 'moodle/competency:templateview',
|
||||
'nopermissions', '');
|
||||
}
|
||||
|
||||
// OK - all set.
|
||||
@ -2049,7 +2062,8 @@ class api {
|
||||
}
|
||||
|
||||
if (!$template->can_read()) {
|
||||
throw new required_capability_exception($template->get_context(), 'moodle/competency:templateview', 'nopermissions', '');
|
||||
throw new required_capability_exception($template->get_context(), 'moodle/competency:templateview',
|
||||
'nopermissions', '');
|
||||
}
|
||||
|
||||
// OK - all set.
|
||||
@ -2070,7 +2084,8 @@ class api {
|
||||
}
|
||||
|
||||
if (!$template->can_read()) {
|
||||
throw new required_capability_exception($template->get_context(), 'moodle/competency:templateview', 'nopermissions', '');
|
||||
throw new required_capability_exception($template->get_context(), 'moodle/competency:templateview',
|
||||
'nopermissions', '');
|
||||
}
|
||||
|
||||
// OK - all set.
|
||||
@ -2092,7 +2107,8 @@ class api {
|
||||
}
|
||||
|
||||
if (!$template->can_read()) {
|
||||
throw new required_capability_exception($template->get_context(), 'moodle/competency:templateview', 'nopermissions', '');
|
||||
throw new required_capability_exception($template->get_context(), 'moodle/competency:templateview',
|
||||
'nopermissions', '');
|
||||
}
|
||||
|
||||
// OK - all set.
|
||||
@ -2111,7 +2127,8 @@ class api {
|
||||
// First we do a permissions check.
|
||||
$template = new template($templateid);
|
||||
if (!$template->can_manage()) {
|
||||
throw new required_capability_exception($template->get_context(), 'moodle/competency:templatemanage', 'nopermissions', '');
|
||||
throw new required_capability_exception($template->get_context(), 'moodle/competency:templatemanage',
|
||||
'nopermissions', '');
|
||||
}
|
||||
|
||||
$record = new stdClass();
|
||||
@ -2146,7 +2163,8 @@ class api {
|
||||
// First we do a permissions check.
|
||||
$template = new template($templateid);
|
||||
if (!$template->can_manage()) {
|
||||
throw new required_capability_exception($template->get_context(), 'moodle/competency:templatemanage', 'nopermissions', '');
|
||||
throw new required_capability_exception($template->get_context(), 'moodle/competency:templatemanage',
|
||||
'nopermissions', '');
|
||||
}
|
||||
|
||||
$record = new stdClass();
|
||||
@ -2457,7 +2475,8 @@ 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(), 'moodle/competency:templateview', 'nopermissions', '');
|
||||
throw new required_capability_exception($template->get_context(), 'moodle/competency:templateview',
|
||||
'nopermissions', '');
|
||||
}
|
||||
// Can not create plan from a hidden template.
|
||||
if ($template->get_visible() == false) {
|
||||
@ -2486,7 +2505,8 @@ class api {
|
||||
|
||||
$plan = new plan(0, $record);
|
||||
if (!$plan->can_manage()) {
|
||||
throw new required_capability_exception($plan->get_context(), 'moodle/competency:planmanage', 'nopermissions', '');
|
||||
throw new required_capability_exception($plan->get_context(), 'moodle/competency:planmanage',
|
||||
'nopermissions', '');
|
||||
}
|
||||
|
||||
// We first apply the permission checks as we wouldn't want to leak information by returning early that
|
||||
@ -2523,7 +2543,8 @@ 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(), 'moodle/competency:templateview', 'nopermissions', '');
|
||||
throw new required_capability_exception($template->get_context(), 'moodle/competency:templateview',
|
||||
'nopermissions', '');
|
||||
}
|
||||
|
||||
// Can not create plan from a hidden template.
|
||||
@ -3121,7 +3142,8 @@ class api {
|
||||
}
|
||||
|
||||
if (!user_competency::can_read_user($plan->get_userid())) {
|
||||
throw new required_capability_exception($plan->get_context(), 'moodle/competency:usercompetencyview', 'nopermissions', '');
|
||||
throw new required_capability_exception($plan->get_context(), 'moodle/competency:usercompetencyview',
|
||||
'nopermissions', '');
|
||||
}
|
||||
|
||||
$competency = $plan->get_competency($competencyid);
|
||||
@ -3405,11 +3427,13 @@ class api {
|
||||
}
|
||||
|
||||
if (!$uc->can_read()) {
|
||||
throw new required_capability_exception($uc->get_context(), 'moodle/competency:usercompetencyview', 'nopermissions', '');
|
||||
throw new required_capability_exception($uc->get_context(), 'moodle/competency:usercompetencyview',
|
||||
'nopermissions', '');
|
||||
} else if ($uc->get_status() != user_competency::STATUS_IDLE) {
|
||||
throw new coding_exception('The competency can not be sent for review at this stage.');
|
||||
} else if (!$uc->can_request_review()) {
|
||||
throw new required_capability_exception($uc->get_context(), 'moodle/competency:usercompetencyrequestreview', 'nopermissions', '');
|
||||
throw new required_capability_exception($uc->get_context(), 'moodle/competency:usercompetencyrequestreview',
|
||||
'nopermissions', '');
|
||||
}
|
||||
|
||||
$uc->set_status(user_competency::STATUS_WAITING_FOR_REVIEW);
|
||||
@ -3491,7 +3515,8 @@ class api {
|
||||
}
|
||||
|
||||
if (!$uc || !$uc->can_read()) {
|
||||
throw new required_capability_exception($uc->get_context(), 'moodle/competency:usercompetencyview', 'nopermissions', '');
|
||||
throw new required_capability_exception($uc->get_context(), 'moodle/competency:usercompetencyview',
|
||||
'nopermissions', '');
|
||||
}
|
||||
|
||||
\core\event\competency_user_competency_viewed::create_from_user_competency_viewed($uc)->trigger();
|
||||
@ -3513,7 +3538,8 @@ class api {
|
||||
}
|
||||
|
||||
if (!$uc || !$uc->can_read()) {
|
||||
throw new required_capability_exception($uc->get_context(), 'moodle/competency:usercompetencyview', 'nopermissions', '');
|
||||
throw new required_capability_exception($uc->get_context(), 'moodle/competency:usercompetencyview',
|
||||
'nopermissions', '');
|
||||
}
|
||||
$plan = new plan($planid);
|
||||
if ($plan->get_status() == plan::STATUS_COMPLETE) {
|
||||
@ -3527,7 +3553,7 @@ class api {
|
||||
/**
|
||||
* Log user competency viewed in course event.
|
||||
*
|
||||
* @param user_competency|int $usercompetencyorid The user competency object or user competency id
|
||||
* @param user_competency_course|int $usercoursecompetencyorid The user competency course object or its ID.
|
||||
* @param int $courseid The course ID
|
||||
* @return bool
|
||||
*/
|
||||
@ -3539,7 +3565,8 @@ class api {
|
||||
}
|
||||
|
||||
if (!$ucc || !user_competency::can_read_user_in_course($ucc->get_userid(), $ucc->get_courseid())) {
|
||||
throw new required_capability_exception($ucc->get_context(), 'moodle/competency:usercompetencyview', 'nopermissions', '');
|
||||
throw new required_capability_exception($ucc->get_context(), 'moodle/competency:usercompetencyview',
|
||||
'nopermissions', '');
|
||||
}
|
||||
|
||||
// Validate the course, this will throw an exception if not valid.
|
||||
@ -3563,7 +3590,8 @@ class api {
|
||||
}
|
||||
|
||||
if (!$ucp || !user_competency::can_read_user($ucp->get_userid())) {
|
||||
throw new required_capability_exception($ucp->get_context(), 'moodle/competency:usercompetencyview', 'nopermissions', '');
|
||||
throw new required_capability_exception($ucp->get_context(), 'moodle/competency:usercompetencyview',
|
||||
'nopermissions', '');
|
||||
}
|
||||
$plan = new plan($ucp->get_planid());
|
||||
if ($plan->get_status() != plan::STATUS_COMPLETE) {
|
||||
@ -3587,7 +3615,8 @@ class api {
|
||||
$template = new template($templateid);
|
||||
|
||||
if (!$template->can_read()) {
|
||||
throw new required_capability_exception($template->get_context(), 'moodle/competency:templateview', 'nopermissions', '');
|
||||
throw new required_capability_exception($template->get_context(), 'moodle/competency:templateview',
|
||||
'nopermissions', '');
|
||||
}
|
||||
|
||||
// OK - all set.
|
||||
@ -3604,8 +3633,10 @@ class api {
|
||||
static::require_enabled();
|
||||
$competency = new competency($competencyid);
|
||||
|
||||
if (!has_any_capability(array('moodle/competency:competencyview', 'moodle/competency:competencymanage'), $competency->get_context())) {
|
||||
throw new required_capability_exception($competency->get_context(), 'moodle/competency:competencyview', 'nopermissions', '');
|
||||
if (!has_any_capability(array('moodle/competency:competencyview', 'moodle/competency:competencymanage'),
|
||||
$competency->get_context())) {
|
||||
throw new required_capability_exception($competency->get_context(), 'moodle/competency:competencyview',
|
||||
'nopermissions', '');
|
||||
}
|
||||
|
||||
return $competency->get_related_competencies();
|
||||
@ -4217,13 +4248,14 @@ class api {
|
||||
// Completing a competency.
|
||||
case evidence::ACTION_COMPLETE:
|
||||
// The logic here goes like this:
|
||||
//
|
||||
// if rating outside a course
|
||||
// set the default grade and proficiency ONLY if there is no current grade
|
||||
// - set the default grade and proficiency ONLY if there is no current grade
|
||||
// else we are in a course
|
||||
// set the defautl grade and proficiency in the course ONLY if there is no current grade in the course
|
||||
// then check the course settings to see if we should push the rating outside the course
|
||||
// if we should push it
|
||||
// push it only if the user_competency (outside the course) has no grade
|
||||
// - set the defautl grade and proficiency in the course ONLY if there is no current grade in the course
|
||||
// - then check the course settings to see if we should push the rating outside the course
|
||||
// - if we should push it
|
||||
// --- push it only if the user_competency (outside the course) has no grade
|
||||
// Done.
|
||||
|
||||
if ($grade !== null) {
|
||||
@ -4449,7 +4481,6 @@ class api {
|
||||
return;
|
||||
}
|
||||
|
||||
|
||||
// Fetch or create the user competency for the parent.
|
||||
$userid = $usercompetency->get_userid();
|
||||
$parentuc = user_competency::get_record(array('userid' => $userid, 'competencyid' => $parent->get_id()));
|
||||
@ -4458,7 +4489,6 @@ class api {
|
||||
$parentuc->create();
|
||||
}
|
||||
|
||||
|
||||
// Does the rule match?
|
||||
if (!$rule->matches($parentuc)) {
|
||||
return;
|
||||
@ -4635,7 +4665,8 @@ class api {
|
||||
// Throws exception if competency not in plan.
|
||||
$competency = $uc->get_competency();
|
||||
$competencycontext = $competency->get_context();
|
||||
if (!has_any_capability(array('moodle/competency:competencyview', 'moodle/competency:competencymanage'), $competencycontext)) {
|
||||
if (!has_any_capability(array('moodle/competency:competencyview', 'moodle/competency:competencymanage'),
|
||||
$competencycontext)) {
|
||||
throw new required_capability_exception($competencycontext, 'moodle/competency:competencyview', 'nopermissions', '');
|
||||
}
|
||||
|
||||
@ -4688,7 +4719,8 @@ class api {
|
||||
// Throws exception if competency not in plan.
|
||||
$competency = $plan->get_competency($competencyid);
|
||||
$competencycontext = $competency->get_context();
|
||||
if (!has_any_capability(array('moodle/competency:competencyview', 'moodle/competency:competencymanage'), $competencycontext)) {
|
||||
if (!has_any_capability(array('moodle/competency:competencyview', 'moodle/competency:competencymanage'),
|
||||
$competencycontext)) {
|
||||
throw new required_capability_exception($competencycontext, 'moodle/competency:competencyview', 'nopermissions', '');
|
||||
}
|
||||
|
||||
@ -4751,7 +4783,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('moodle/competency:competencyview', 'moodle/competency:competencymanage'), $competencycontext)) {
|
||||
if (!has_any_capability(array('moodle/competency:competencyview', 'moodle/competency:competencymanage'),
|
||||
$competencycontext)) {
|
||||
throw new required_capability_exception($competencycontext, 'moodle/competency:competencyview', 'nopermissions', '');
|
||||
}
|
||||
|
||||
@ -4802,7 +4835,8 @@ class api {
|
||||
|
||||
// First we do a permissions check.
|
||||
if (!$template->can_read()) {
|
||||
throw new required_capability_exception($template->get_context(), 'moodle/competency:templateview', 'nopermissions', '');
|
||||
throw new required_capability_exception($template->get_context(), 'moodle/competency:templateview',
|
||||
'nopermissions', '');
|
||||
}
|
||||
|
||||
return plan::count_records_for_template($template->get_id(), $status);
|
||||
@ -4826,7 +4860,8 @@ class api {
|
||||
|
||||
// First we do a permissions check.
|
||||
if (!$template->can_read()) {
|
||||
throw new required_capability_exception($template->get_context(), 'moodle/competency:templateview', 'nopermissions', '');
|
||||
throw new required_capability_exception($template->get_context(), 'moodle/competency:templateview',
|
||||
'nopermissions', '');
|
||||
}
|
||||
|
||||
return user_competency_plan::count_records_for_template($template->get_id(), $proficiency);
|
||||
@ -4851,7 +4886,8 @@ class api {
|
||||
|
||||
// First we do a permissions check.
|
||||
if (!$template->can_read()) {
|
||||
throw new required_capability_exception($template->get_context(), 'moodle/competency:templateview', 'nopermissions', '');
|
||||
throw new required_capability_exception($template->get_context(), 'moodle/competency:templateview',
|
||||
'nopermissions', '');
|
||||
}
|
||||
|
||||
return plan::get_records_for_template($template->get_id(), $status, $skip, $limit);
|
||||
@ -4897,7 +4933,8 @@ class api {
|
||||
|
||||
// First we do a permissions check.
|
||||
if (!$template->can_read()) {
|
||||
throw new required_capability_exception($template->get_context(), 'moodle/competency:templateview', 'nopermissions', '');
|
||||
throw new required_capability_exception($template->get_context(), 'moodle/competency:templateview',
|
||||
'nopermissions', '');
|
||||
}
|
||||
|
||||
return user_competency_plan::get_least_proficient_competencies_for_template($template->get_id(), $skip, $limit);
|
||||
@ -4920,7 +4957,8 @@ class api {
|
||||
|
||||
// First we do a permissions check.
|
||||
if (!$template->can_read()) {
|
||||
throw new required_capability_exception($template->get_context(), 'moodle/competency:templateview', 'nopermissions', '');
|
||||
throw new required_capability_exception($template->get_context(), 'moodle/competency:templateview',
|
||||
'nopermissions', '');
|
||||
}
|
||||
|
||||
// Trigger a template viewed event.
|
||||
|
@ -141,8 +141,8 @@ class competency extends persistent {
|
||||
$this->set_new_sortorder();
|
||||
}
|
||||
|
||||
// During create.
|
||||
} else {
|
||||
// During create.
|
||||
|
||||
$this->set_new_path();
|
||||
// Always generate new sortorder when we create new competency.
|
||||
@ -458,8 +458,8 @@ class competency extends persistent {
|
||||
return new lang_string('invaliddata', 'error');
|
||||
}
|
||||
|
||||
// During create.
|
||||
} else {
|
||||
// During create.
|
||||
|
||||
// Check that the framework exists.
|
||||
if (!competency_framework::record_exists($value)) {
|
||||
@ -503,12 +503,12 @@ class competency extends persistent {
|
||||
if (substr($value, -(strlen($id) + 2)) != '/' . $id . '/') {
|
||||
return new lang_string('invaliddata', 'error');
|
||||
|
||||
// The format of the path should be as follows.
|
||||
} else if (!preg_match('@/([0-9]+/)+@', $value)) {
|
||||
// The format of the path is not correct.
|
||||
return new lang_string('invaliddata', 'error');
|
||||
|
||||
// Validate the depth of the path.
|
||||
} else if ((substr_count($value, '/') - 1) > competency_framework::get_taxonomies_max_level()) {
|
||||
// Validate the depth of the path.
|
||||
return new lang_string('invaliddata', 'error');
|
||||
}
|
||||
|
||||
|
@ -82,7 +82,7 @@ class course_competency_settings extends persistent {
|
||||
/**
|
||||
* Can the current user view competency settings for this course.
|
||||
*
|
||||
* @param int $data The course ID.
|
||||
* @param int $courseid The course ID.
|
||||
* @return bool
|
||||
*/
|
||||
public static function can_read($courseid) {
|
||||
@ -96,7 +96,7 @@ class course_competency_settings extends persistent {
|
||||
/**
|
||||
* Can the current user change competency settings for this course.
|
||||
*
|
||||
* @param int $data The course ID.
|
||||
* @param int $courseid The course ID.
|
||||
* @return bool
|
||||
*/
|
||||
public static function can_manage_course($courseid) {
|
||||
|
@ -4238,16 +4238,15 @@ class external extends external_api {
|
||||
/**
|
||||
* Update the course competency settings
|
||||
*
|
||||
* @param int $id the course id
|
||||
* @param int $courseid the course id
|
||||
* @param stdClass $settings The list of settings (currently only pushratingstouserplans).
|
||||
* @throws moodle_exception
|
||||
*/
|
||||
public static function update_course_competency_settings($courseid, $settings) {
|
||||
$params = self::validate_parameters(self::update_course_competency_settings_parameters(),
|
||||
array(
|
||||
'courseid' => $courseid,
|
||||
'settings' => $settings
|
||||
));
|
||||
$params = self::validate_parameters(self::update_course_competency_settings_parameters(), array(
|
||||
'courseid' => $courseid,
|
||||
'settings' => $settings
|
||||
));
|
||||
|
||||
$context = context_course::instance($params['courseid']);
|
||||
self::validate_context($context);
|
||||
|
@ -269,14 +269,14 @@ class user_competency_course extends persistent {
|
||||
' FROM {' . competency::TABLE . '} c
|
||||
JOIN {' . course_competency::TABLE . '} cc
|
||||
ON c.id = cc.competencyid
|
||||
LEFT JOIN {' . user_competency_course::TABLE . '} ucc
|
||||
LEFT JOIN {' . self::TABLE . '} ucc
|
||||
ON ucc.competencyid = c.id AND ucc.courseid = cc.courseid
|
||||
WHERE cc.courseid = :courseid
|
||||
GROUP BY c.id
|
||||
ORDER BY timesproficient ASC, c.id DESC';
|
||||
|
||||
$results = $DB->get_records_sql($sql, $params, $skip, $limit);
|
||||
$a = $DB->get_records_sql('SELECT * from {' . user_competency_course::TABLE . '}');
|
||||
$a = $DB->get_records_sql('SELECT * from {' . self::TABLE . '}');
|
||||
|
||||
$comps = array();
|
||||
foreach ($results as $r) {
|
||||
|
@ -117,7 +117,8 @@ class user_evidence extends persistent {
|
||||
*/
|
||||
public function get_files() {
|
||||
$fs = get_file_storage();
|
||||
$files = $fs->get_area_files($this->get_context()->id, 'core_competency', 'userevidence', $this->get_id(), 'filename', false);
|
||||
$files = $fs->get_area_files($this->get_context()->id, 'core_competency', 'userevidence', $this->get_id(),
|
||||
'filename', false);
|
||||
return $files;
|
||||
}
|
||||
|
||||
|
@ -1829,8 +1829,10 @@ class core_competency_api_testcase extends advanced_testcase {
|
||||
$this->assertInstanceOf('core_competency\template_cohort', $result);
|
||||
$this->assertEquals($c2->id, $result->get_cohortid());
|
||||
$this->assertEquals($t1->get_id(), $result->get_templateid());
|
||||
$this->assertEquals(2, \core_competency\template_cohort::count_records_select('templateid = :id', array('id' => $t1->get_id())));
|
||||
$this->assertEquals(0, \core_competency\template_cohort::count_records_select('templateid = :id', array('id' => $t2->get_id())));
|
||||
$this->assertEquals(2, \core_competency\template_cohort::count_records_select('templateid = :id',
|
||||
array('id' => $t1->get_id())));
|
||||
$this->assertEquals(0, \core_competency\template_cohort::count_records_select('templateid = :id',
|
||||
array('id' => $t2->get_id())));
|
||||
}
|
||||
|
||||
public function test_create_template_cohort_permissions() {
|
||||
@ -1865,7 +1867,7 @@ class core_competency_api_testcase extends advanced_testcase {
|
||||
try {
|
||||
$result = api::create_template_cohort($t1, $c2);
|
||||
$this->fail('Permission required.');
|
||||
} catch(required_capability_exception $e) {
|
||||
} catch (required_capability_exception $e) {
|
||||
// That's what should happen.
|
||||
}
|
||||
|
||||
@ -1922,22 +1924,28 @@ class core_competency_api_testcase extends advanced_testcase {
|
||||
$tc1 = $lpg->create_template_cohort(array('templateid' => $t2->get_id(), 'cohortid' => $c2->id));
|
||||
|
||||
$this->assertEquals(2, \core_competency\template_cohort::count_records());
|
||||
$this->assertEquals(1, \core_competency\template_cohort::count_records_select('templateid = :id', array('id' => $t1->get_id())));
|
||||
$this->assertEquals(1, \core_competency\template_cohort::count_records_select('templateid = :id', array('id' => $t2->get_id())));
|
||||
$this->assertEquals(1, \core_competency\template_cohort::count_records_select('templateid = :id',
|
||||
array('id' => $t1->get_id())));
|
||||
$this->assertEquals(1, \core_competency\template_cohort::count_records_select('templateid = :id',
|
||||
array('id' => $t2->get_id())));
|
||||
|
||||
// Delete existing.
|
||||
$result = api::delete_template_cohort($t1->get_id(), $c1->id);
|
||||
$this->assertTrue($result);
|
||||
$this->assertEquals(1, \core_competency\template_cohort::count_records());
|
||||
$this->assertEquals(0, \core_competency\template_cohort::count_records_select('templateid = :id', array('id' => $t1->get_id())));
|
||||
$this->assertEquals(1, \core_competency\template_cohort::count_records_select('templateid = :id', array('id' => $t2->get_id())));
|
||||
$this->assertEquals(0, \core_competency\template_cohort::count_records_select('templateid = :id',
|
||||
array('id' => $t1->get_id())));
|
||||
$this->assertEquals(1, \core_competency\template_cohort::count_records_select('templateid = :id',
|
||||
array('id' => $t2->get_id())));
|
||||
|
||||
// Delete non-existant.
|
||||
$result = api::delete_template_cohort($t1->get_id(), $c1->id);
|
||||
$this->assertTrue($result);
|
||||
$this->assertEquals(1, \core_competency\template_cohort::count_records());
|
||||
$this->assertEquals(0, \core_competency\template_cohort::count_records_select('templateid = :id', array('id' => $t1->get_id())));
|
||||
$this->assertEquals(1, \core_competency\template_cohort::count_records_select('templateid = :id', array('id' => $t2->get_id())));
|
||||
$this->assertEquals(0, \core_competency\template_cohort::count_records_select('templateid = :id',
|
||||
array('id' => $t1->get_id())));
|
||||
$this->assertEquals(1, \core_competency\template_cohort::count_records_select('templateid = :id',
|
||||
array('id' => $t2->get_id())));
|
||||
}
|
||||
|
||||
public function test_add_evidence_log() {
|
||||
@ -1952,7 +1960,8 @@ class core_competency_api_testcase extends advanced_testcase {
|
||||
$c2 = $lpg->create_competency(array('competencyframeworkid' => $f1->get_id()));
|
||||
|
||||
// Creating a standard evidence with minimal information.
|
||||
$evidence = api::add_evidence($u1->id, $c1->get_id(), $u1ctx->id, \core_competency\evidence::ACTION_LOG, 'invaliddata', 'error');
|
||||
$evidence = api::add_evidence($u1->id, $c1->get_id(), $u1ctx->id, \core_competency\evidence::ACTION_LOG,
|
||||
'invaliddata', 'error');
|
||||
$evidence->read();
|
||||
$uc = \core_competency\user_competency::get_record(array('userid' => $u1->id, 'competencyid' => $c1->get_id()));
|
||||
$this->assertEquals(\core_competency\user_competency::STATUS_IDLE, $uc->get_status());
|
||||
@ -1969,8 +1978,8 @@ class core_competency_api_testcase extends advanced_testcase {
|
||||
$this->assertSame(null, $evidence->get_actionuserid());
|
||||
|
||||
// Creating a standard evidence with more information.
|
||||
$evidence = api::add_evidence($u1->id, $c1->get_id(), $u1ctx->id, \core_competency\evidence::ACTION_LOG, 'invaliddata', 'error',
|
||||
'$a', false, 'http://moodle.org', null, 2, 'The evidence of prior learning were reviewed.');
|
||||
$evidence = api::add_evidence($u1->id, $c1->get_id(), $u1ctx->id, \core_competency\evidence::ACTION_LOG, 'invaliddata',
|
||||
'error', '$a', false, 'http://moodle.org', null, 2, 'The evidence of prior learning were reviewed.');
|
||||
$evidence->read();
|
||||
$uc = \core_competency\user_competency::get_record(array('userid' => $u1->id, 'competencyid' => $c1->get_id()));
|
||||
$this->assertEquals(\core_competency\user_competency::STATUS_IDLE, $uc->get_status());
|
||||
@ -2655,7 +2664,8 @@ class core_competency_api_testcase extends advanced_testcase {
|
||||
// Check record was created with default rule value Evidence.
|
||||
$this->assertEquals(1, \core_competency\course_competency::count_records());
|
||||
$recordscc = api::list_course_competencies($course->id);
|
||||
$this->assertEquals(\core_competency\course_competency::OUTCOME_EVIDENCE, $recordscc[0]['coursecompetency']->get_ruleoutcome());
|
||||
$this->assertEquals(\core_competency\course_competency::OUTCOME_EVIDENCE,
|
||||
$recordscc[0]['coursecompetency']->get_ruleoutcome());
|
||||
|
||||
// Check ruleoutcome value is updated to None.
|
||||
$this->assertTrue(api::set_course_competency_ruleoutcome($recordscc[0]['coursecompetency']->get_id(),
|
||||
@ -3887,7 +3897,7 @@ class core_competency_api_testcase extends advanced_testcase {
|
||||
$this->assertExceptionWithGradeCompetencyInCourse('coding_exception', 'The competency may not be rated at this time.',
|
||||
$c1->id, $notstudent1->id, $comp1->get_id());
|
||||
|
||||
// Give permission for non-editing teacher to grade.
|
||||
// Give permission for non-editing teacher to grade.
|
||||
$dg->role_assign($canviewucrole, $noneditingteacher->id, $c1ctx->id);
|
||||
$dg->role_assign($cangraderole, $noneditingteacher->id, $c1ctx->id);
|
||||
$this->setUser($noneditingteacher);
|
||||
|
@ -65,7 +65,7 @@ class core_competency_course_competency_settings_testcase extends advanced_testc
|
||||
$lpg->create_course_competency(array('competencyid' => $comp1->get_id(), 'courseid' => $c1->id));
|
||||
$lpg->create_course_competency(array('competencyid' => $comp2->get_id(), 'courseid' => $c1->id));
|
||||
|
||||
// Enrol the user
|
||||
// Enrol the user.
|
||||
$dg->enrol_user($u1->id, $c1->id);
|
||||
role_assign($gradedrole, $u1->id, $syscontext->id);
|
||||
|
||||
|
@ -650,7 +650,7 @@ class core_competency_external_testcase extends externallib_advanced_testcase {
|
||||
$this->assertEquals(true, $result->visible);
|
||||
}
|
||||
|
||||
public function list_competency_frameworks_with_query() {
|
||||
public function test_list_competency_frameworks_with_query() {
|
||||
$this->setUser($this->creator);
|
||||
$lpg = $this->getDataGenerator()->get_plugin_generator('core_competency');
|
||||
$framework1 = $lpg->create_framework(array(
|
||||
@ -676,9 +676,9 @@ class core_competency_external_testcase extends externallib_advanced_testcase {
|
||||
$result = external_api::clean_returnvalue(external::list_competency_frameworks_returns(), $result);
|
||||
$this->assertCount(2, $result);
|
||||
$f = (object) array_shift($result);
|
||||
$this->assertEquals($framework1->get_id(), $f->get_id());
|
||||
$this->assertEquals($framework1->get_id(), $f->id);
|
||||
$f = (object) array_shift($result);
|
||||
$this->assertEquals($framework2->get_id(), $f->get_id());
|
||||
$this->assertEquals($framework2->get_id(), $f->id);
|
||||
|
||||
// Search on ID number.
|
||||
$result = external::list_competency_frameworks('shortname', 'ASC', 0, 10,
|
||||
@ -686,7 +686,7 @@ class core_competency_external_testcase extends externallib_advanced_testcase {
|
||||
$result = external_api::clean_returnvalue(external::list_competency_frameworks_returns(), $result);
|
||||
$this->assertCount(1, $result);
|
||||
$f = (object) array_shift($result);
|
||||
$this->assertEquals($framework2->get_id(), $f->get_id());
|
||||
$this->assertEquals($framework2->get_id(), $f->id);
|
||||
|
||||
// Search on shortname.
|
||||
$result = external::list_competency_frameworks('shortname', 'ASC', 0, 10,
|
||||
@ -694,7 +694,7 @@ class core_competency_external_testcase extends externallib_advanced_testcase {
|
||||
$result = external_api::clean_returnvalue(external::list_competency_frameworks_returns(), $result);
|
||||
$this->assertCount(1, $result);
|
||||
$f = (object) array_shift($result);
|
||||
$this->assertEquals($framework1->get_id(), $f->get_id());
|
||||
$this->assertEquals($framework1->get_id(), $f->id);
|
||||
|
||||
// No match.
|
||||
$result = external::list_competency_frameworks('shortname', 'ASC', 0, 10,
|
||||
@ -1666,11 +1666,10 @@ class core_competency_external_testcase extends externallib_advanced_testcase {
|
||||
|
||||
// Test if removing competency from template don't create sortorder holes.
|
||||
external::remove_competency_from_template($template->id, $competency3->id);
|
||||
$templcomp4 = template_competency::get_record(
|
||||
array(
|
||||
'templateid' => $template->id,
|
||||
'competencyid' => $competency4->id
|
||||
));
|
||||
$templcomp4 = template_competency::get_record(array(
|
||||
'templateid' => $template->id,
|
||||
'competencyid' => $competency4->id
|
||||
));
|
||||
|
||||
$this->assertEquals(2, $templcomp4->get_sortorder());
|
||||
|
||||
@ -2496,23 +2495,16 @@ class core_competency_external_testcase extends externallib_advanced_testcase {
|
||||
|
||||
// Test if removing competency from plan don't create sortorder holes.
|
||||
external::remove_competency_from_plan($pl1->get_id(), $c4->get_id());
|
||||
$plancomp5 = plan_competency::get_record(
|
||||
array(
|
||||
'planid' => $pl1->get_id(),
|
||||
'competencyid' => $c5->get_id()
|
||||
));
|
||||
$plancomp5 = plan_competency::get_record(array(
|
||||
'planid' => $pl1->get_id(),
|
||||
'competencyid' => $c5->get_id()
|
||||
));
|
||||
|
||||
$this->assertEquals(3, $plancomp5->get_sortorder());
|
||||
|
||||
$this->assertTrue(external::reorder_plan_competency($pl1->get_id(), $c2->get_id(), $c5->get_id()));
|
||||
$this->assertTrue(external::reorder_plan_competency($pl1->get_id(), $c3->get_id(), $c1->get_id()));
|
||||
$plancompetencies = plan_competency::get_records(
|
||||
array(
|
||||
'planid' => $pl1->get_id()
|
||||
),
|
||||
'sortorder',
|
||||
'ASC'
|
||||
);
|
||||
$plancompetencies = plan_competency::get_records(array('planid' => $pl1->get_id()), 'sortorder', 'ASC');
|
||||
$plcmp1 = $plancompetencies[0];
|
||||
$plcmp2 = $plancompetencies[1];
|
||||
$plcmp3 = $plancompetencies[2];
|
||||
|
@ -50,7 +50,8 @@ class core_competency_lib_testcase extends advanced_testcase {
|
||||
$u3 = $dg->create_user();
|
||||
$reviewerroleid = $dg->create_role();
|
||||
assign_capability('moodle/competency:planview', CAP_ALLOW, $reviewerroleid, context_system::instance()->id, true);
|
||||
assign_capability('moodle/competency:usercompetencycomment', CAP_ALLOW, $reviewerroleid, context_system::instance()->id, true);
|
||||
assign_capability('moodle/competency:usercompetencycomment', CAP_ALLOW, $reviewerroleid,
|
||||
context_system::instance()->id, true);
|
||||
$dg->role_assign($reviewerroleid, $u2->id, context_user::instance($u1->id));
|
||||
$dg->role_assign($reviewerroleid, $u3->id, context_user::instance($u1->id));
|
||||
accesslib_clear_all_caches_for_unit_testing();
|
||||
|
@ -109,7 +109,7 @@ abstract class moodleform_mod extends moodleform {
|
||||
* Get the current data for the form.
|
||||
* @return stdClass|null
|
||||
*/
|
||||
function get_current() {
|
||||
public function get_current() {
|
||||
return $this->current;
|
||||
}
|
||||
|
||||
@ -117,7 +117,7 @@ abstract class moodleform_mod extends moodleform {
|
||||
* Get the DB record for the current instance.
|
||||
* @return stdClass|null
|
||||
*/
|
||||
function get_instance() {
|
||||
public function get_instance() {
|
||||
return $this->_instance;
|
||||
}
|
||||
|
||||
@ -125,7 +125,7 @@ abstract class moodleform_mod extends moodleform {
|
||||
* Get the course section number (relative).
|
||||
* @return int
|
||||
*/
|
||||
function get_section() {
|
||||
public function get_section() {
|
||||
return $this->_section;
|
||||
}
|
||||
|
||||
@ -133,7 +133,7 @@ abstract class moodleform_mod extends moodleform {
|
||||
* Get the course id.
|
||||
* @return int
|
||||
*/
|
||||
function get_course() {
|
||||
public function get_course() {
|
||||
return $this->_course;
|
||||
}
|
||||
|
||||
@ -141,7 +141,7 @@ abstract class moodleform_mod extends moodleform {
|
||||
* Get the course module object.
|
||||
* @return stdClass|null
|
||||
*/
|
||||
function get_coursemodule() {
|
||||
public function get_coursemodule() {
|
||||
return $this->_cm;
|
||||
}
|
||||
|
||||
@ -149,7 +149,7 @@ abstract class moodleform_mod extends moodleform {
|
||||
* Return the course context for new modules, or the module context for existing modules.
|
||||
* @return context
|
||||
*/
|
||||
function get_context() {
|
||||
public function get_context() {
|
||||
return $this->context;
|
||||
}
|
||||
|
||||
@ -157,7 +157,7 @@ abstract class moodleform_mod extends moodleform {
|
||||
* Return the features this module supports.
|
||||
* @return stdClass
|
||||
*/
|
||||
function get_features() {
|
||||
public function get_features() {
|
||||
return $this->_features;
|
||||
}
|
||||
|
||||
@ -439,7 +439,7 @@ abstract class moodleform_mod extends moodleform {
|
||||
* @param stdClass $data The form data.
|
||||
* @return array $errors The list of errors keyed by element name.
|
||||
*/
|
||||
function plugin_extend_coursemodule_validation($data) {
|
||||
protected function plugin_extend_coursemodule_validation($data) {
|
||||
$errors = array();
|
||||
|
||||
$callbacks = get_plugins_with_function('coursemodule_validation', 'lib.php');
|
||||
@ -708,7 +708,7 @@ abstract class moodleform_mod extends moodleform {
|
||||
/**
|
||||
* Plugins can extend the coursemodule settings form.
|
||||
*/
|
||||
function plugin_extend_coursemodule_standard_elements() {
|
||||
protected function plugin_extend_coursemodule_standard_elements() {
|
||||
$callbacks = get_plugins_with_function('coursemodule_standard_elements', 'lib.php');
|
||||
foreach ($callbacks as $type => $plugins) {
|
||||
foreach ($plugins as $plugin => $pluginfunction) {
|
||||
|
Loading…
x
Reference in New Issue
Block a user