Skip to content

Commit

Permalink
Merge branch 'MDL-47527_master' of https://github.com/StudiUM/moodle
Browse files Browse the repository at this point in the history
  • Loading branch information
Sam Hemelryk committed Nov 18, 2014
2 parents 817e901 + 7852746 commit 5b9a75e
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 9 deletions.
16 changes: 8 additions & 8 deletions grade/report/overview/index.php
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@
require_capability('gradereport/overview:view', $context);

if (empty($userid)) {
require_capability('moodle/grade:viewall', $systemcontext);
require_capability('moodle/grade:viewall', $context);

} else {
if (!$DB->get_record('user', array('id'=>$userid, 'deleted'=>0)) or isguestuser($userid)) {
Expand All @@ -53,19 +53,19 @@

$access = false;
if (has_capability('moodle/grade:viewall', $systemcontext)) {
//ok - can view all course grades
// Ok - can view all course grades.
$access = true;

} else if ($userid == $USER->id and has_capability('moodle/grade:viewall', $context)) {
//ok - can view any own grades
} else if (has_capability('moodle/grade:viewall', $context)) {
// Ok - can view any grades in context.
$access = true;

} else if ($userid == $USER->id and has_capability('moodle/grade:view', $context) and $course->showgrades) {
//ok - can view own course grades
// Ok - can view own course grades.
$access = true;

} else if (has_capability('moodle/grade:viewall', context_user::instance($userid)) and $course->showgrades) {
// ok - can view grades of this user- parent most probably
// Ok - can view grades of this user- parent most probably.
$access = true;
}

Expand All @@ -86,8 +86,8 @@
//first make sure we have proper final grades - this must be done before constructing of the grade tree
grade_regrade_final_grades($courseid);

if (has_capability('moodle/grade:viewall', $systemcontext)) { //Admins will see all student reports
// please note this would be extremely slow if we wanted to implement this properly for all teachers
if (has_capability('moodle/grade:viewall', $context)) {
// Please note this would be extremely slow if we wanted to implement this properly for all teachers.
$groupmode = groups_get_course_groupmode($course); // Groups are being used
$currentgroup = groups_get_course_group($course, true);

Expand Down
7 changes: 6 additions & 1 deletion grade/report/overview/lib.php
Original file line number Diff line number Diff line change
Expand Up @@ -135,7 +135,7 @@ public function setup_table() {
}

public function fill_table() {
global $CFG, $DB, $OUTPUT;
global $CFG, $DB, $OUTPUT, $USER;

// Only show user's courses instead of all courses.
if ($this->courses) {
Expand All @@ -153,6 +153,11 @@ public function fill_table() {
continue;
}

if ((!has_capability('moodle/grade:view', $coursecontext) || $this->user->id != $USER->id) &&
!has_capability('moodle/grade:viewall', $coursecontext)) {
continue;
}

$courseshortname = format_string($course->shortname, true, array('context' => $coursecontext));
$courselink = html_writer::link(new moodle_url('/grade/report/user/index.php', array('id' => $course->id, 'userid' => $this->user->id)), $courseshortname);
$canviewhidden = has_capability('moodle/grade:viewhidden', $coursecontext);
Expand Down

0 comments on commit 5b9a75e

Please sign in to comment.