Skip to content

Commit

Permalink
MDL-20355 teachers may not see overview of all students in course bec…
Browse files Browse the repository at this point in the history
…ause they might not have access in all their courses - please use profile instead; merged from MOODLE_19_STABLE
  • Loading branch information
skodak committed Sep 26, 2009
1 parent 9c2d535 commit 02b5087
Showing 1 changed file with 12 additions and 6 deletions.
18 changes: 12 additions & 6 deletions grade/report/overview/index.php
Expand Up @@ -30,10 +30,11 @@
require_login($course);

$context = get_context_instance(CONTEXT_COURSE, $course->id);
$systemcontext = get_context_instance(CONTEXT_SYSTEM);
require_capability('gradereport/overview:view', $context);

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

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

$access = false;
if (has_capability('moodle/grade:viewall', $context)) {
if (has_capability('moodle/grade:viewall', $systemcontext)) {
//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
$access = true;

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

} else if (has_capability('moodle/grade:viewall', get_context_instance(CONTEXT_USER, $userid)) and $course->showgrades) {
Expand All @@ -72,7 +77,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', $context)) { //Teachers will see all student reports
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
$groupmode = groups_get_course_groupmode($course); // Groups are being used
$currentgroup = groups_get_course_group($course, true);

Expand Down Expand Up @@ -122,7 +128,7 @@
}
}
}
} else { //Students will see just their own report
} else { //Non-admins will see just their own report

// Create a report instance
$report = new grade_report_overview($userid, $gpr, $context);
Expand All @@ -137,4 +143,4 @@

echo $OUTPUT->footer();

?>

0 comments on commit 02b5087

Please sign in to comment.