Commit 30ebb74f authored by skodak's avatar skodak
Browse files

MDL-18951 standardised group support in grader report

parent 9e322c8c
......@@ -159,6 +159,20 @@ class grade_report_grader extends grade_report {
global $DB;
$warnings = array();
$separategroups = false;
$mygroups = array();
if ($this->groupmode == SEPARATEGROUPS and !has_capability('moodle/site:accessallgroups', $this->context)) {
$separategroups = true;
$mygroups = groups_get_user_groups($this->course->id);
$mygroups = $mygroups[0]; // ignore groupings
// reorder the groups fro better perf bellow
$current = array_search($this->currentgroup, $mygroups);
if ($current !== false) {
unset($mygroups[$current]);
array_unshift($mygroups, $this->currentgroup);
}
}
// always initialize all arrays
$queue = array();
foreach ($data as $varname => $postedvalue) {
......@@ -233,6 +247,24 @@ class grade_report_grader extends grade_report {
}
}
// group access control
if ($separategroups) {
// note: we can not use $this->currentgroup because it would fail badly
// when having two browser windows each with different group
$sharinggroup = false;
foreach($mygroups as $groupid) {
if (groups_is_member($groupid, $userid)) {
$sharinggroup = true;
break;
}
}
if (!$sharinggroup) {
// either group membership changed or somebedy is hacking grades of other group
$warnings[] = get_string('errorsavegrade', 'grades');
continue;
}
}
$grade_item->update_final_grade($userid, $finalgrade, 'gradebook', $feedback, FORMAT_MOODLE);
}
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment