MDL-53437 tool_lp: Hide competencies in CM edit when user cannot manage
This commit is contained in:
@@ -437,6 +437,8 @@ function tool_lp_coursemodule_standard_elements($formwrapper, $mform) {
|
||||
|
||||
if (!\tool_lp\api::is_enabled()) {
|
||||
return;
|
||||
} else if (!has_capability('tool/lp:coursecompetencymanage', $formwrapper->get_context())) {
|
||||
return;
|
||||
}
|
||||
|
||||
$mform->addElement('header', 'competenciessection', get_string('competencies', 'tool_lp'));
|
||||
@@ -472,6 +474,11 @@ function tool_lp_coursemodule_edit_post_actions($data, $course) {
|
||||
return $data;
|
||||
}
|
||||
|
||||
// It seems like the form did not contain any of the form fields, we can return.
|
||||
if (!isset($data->competency_rule) && !isset($data->competencies)) {
|
||||
return $data;
|
||||
}
|
||||
|
||||
// We bypass the API here and go direct to the persistent layer - because we don't want to do permission
|
||||
// checks here - we need to load the real list of existing course module competencies.
|
||||
$existing = \tool_lp\course_module_competency::list_course_module_competencies($data->coursemodule);
|
||||
|
||||
Reference in New Issue
Block a user