mirror of
https://github.com/moodle/moodle.git
synced 2025-01-19 14:27:22 +01:00
MDL-53590 tool_lp: Error when teacher view student course competencies
This commit is contained in:
parent
c11d30e2a8
commit
dff98d3316
@ -3490,9 +3490,14 @@ class api {
|
||||
$uc = new user_competency($uc);
|
||||
}
|
||||
|
||||
if (!$uc || !$uc->can_read()) {
|
||||
throw new required_capability_exception($uc->get_context(), 'tool/lp:usercompetencyview', 'nopermissions', '');
|
||||
$coursecontext = context_course::instance($courseid);
|
||||
$capabilities = array('tool/lp:coursecompetencyview', 'tool/lp:coursecompetencymanage');
|
||||
if (!has_any_capability($capabilities, $coursecontext)) {
|
||||
throw new required_capability_exception($context, 'tool/lp:coursecompetencyview', 'nopermissions', '');
|
||||
} else if (!user_competency::can_read_user_in_course($uc->get_userid(), $courseid)) {
|
||||
throw new required_capability_exception($context, 'tool/lp:usercompetencyview', 'nopermissions', '');
|
||||
}
|
||||
|
||||
// Validate the course, this will throw an exception if not valid.
|
||||
self::validate_course($courseid);
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user