MDL-18951 standardised group support in grader report
This commit is contained in:
@@ -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);
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user