Browse files

MDL-29892 grade: added a check to prevent hidden courses appearing on…

… student overview reports
  • Loading branch information...
1 parent 4d2f89f commit 2ad0278bd2976d97c83769b16912a49c6f5aff38 @andyjdavis andyjdavis committed Jan 23, 2012
Showing with 7 additions and 0 deletions.
  1. +7 −0 grade/report/overview/lib.php
View
7 grade/report/overview/lib.php
@@ -119,7 +119,14 @@ public function fill_table() {
if (!$course->showgrades) {
continue;
}
+
$coursecontext = get_context_instance(CONTEXT_COURSE, $course->id);
+
+ if (!$course->visible && !has_capability('moodle/course:viewhiddencourses', $coursecontext)) {
+ // The course is hidden and the user isn't allowed to see it
+ 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);

0 comments on commit 2ad0278

Please sign in to comment.