}
require_login();
- if (!isteacher($course->id)) {
- error("You need to be a teacher to use this page");
+ $context = get_context_instance(CONTEXT_COURSE, $course->id);
+
+ if (!has_capability('moodle/site:viewreports', $context)) {
+ error('You need do not have the required permission to view reports for this course');
}
stats_check_uptodate($course->id);
}
require_login();
- if (!isteacher($course->id)) {
- error("You need to be a teacher to use this page");
+ $context = get_context_instance(CONTEXT_COURSE, $course->id);
+
+ if (!has_capability('moodle/site:viewreports', $context)) {
+ error('You need do not have the required permission to view reports for this course');
}
add_to_log($course->id, "course", "report stats", "report/stats/index.php?course=$course->id", $course->id);
$courseoptions = array();
foreach ($courses as $c) {
- if (isteacher($c->id)) {
+ $context = get_context_instance(CONTEXT_COURSE, $c->id);
+
+ if (has_capability('moodle/site:viewreports', $context)) {
$courseoptions[$c->id] = $c->shortname;
}
}