mirror of
https://github.com/moodle/moodle.git
synced 2025-08-05 00:46:50 +02:00
MDL-72772 gradereport_overview: account for users with parent roles.
This commit is contained in:
parent
7cba3c5d13
commit
6d18f136ae
2 changed files with 13 additions and 3 deletions
|
@ -272,6 +272,12 @@ class grade_report_overview extends grade_report {
|
|||
if ($this->courses) {
|
||||
$coursesdata = $this->setup_courses_data($studentcoursesonly);
|
||||
|
||||
// Check whether current user can view all grades of this user - parent most probably.
|
||||
$viewasuser = $this->course->showgrades && has_any_capability([
|
||||
'moodle/grade:viewall',
|
||||
'moodle/user:viewuseractivitiesreport',
|
||||
], context_user::instance($this->user->id));
|
||||
|
||||
foreach ($coursesdata as $coursedata) {
|
||||
|
||||
$course = $coursedata['course'];
|
||||
|
@ -282,13 +288,15 @@ class grade_report_overview extends grade_report {
|
|||
$coursenamelink = format_string(get_course_display_name_for_list($course), true, ['context' => $coursecontext]);
|
||||
|
||||
// Link to the course grade report pages (performing same capability checks as the pages themselves).
|
||||
if ($activitylink && has_capability('gradereport/' . $CFG->grade_profilereport .':view', $coursecontext)) {
|
||||
if ($activitylink &&
|
||||
(has_capability('gradereport/' . $CFG->grade_profilereport .':view', $coursecontext) || $viewasuser)) {
|
||||
|
||||
$coursenamelink = html_writer::link(new moodle_url('/course/user.php', [
|
||||
'mode' => 'grade',
|
||||
'id' => $course->id,
|
||||
'user' => $this->user->id,
|
||||
]), $coursenamelink);
|
||||
} else if (!$activitylink && has_capability('gradereport/user:view', $coursecontext)) {
|
||||
} else if (!$activitylink && (has_capability('gradereport/user:view', $coursecontext) || $viewasuser)) {
|
||||
$coursenamelink = html_writer::link(new moodle_url('/grade/report/user/index.php', [
|
||||
'id' => $course->id,
|
||||
'userid' => $this->user->id,
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue