Skip to content

Commit

Permalink
Merge branch 'MDL-38732-27' of git://github.com/FMCorz/moodle into MO…
Browse files Browse the repository at this point in the history
…ODLE_27_STABLE
  • Loading branch information
danpoltawski committed Oct 14, 2014
2 parents 45f4833 + 84dd6d4 commit 450e3f2
Show file tree
Hide file tree
Showing 4 changed files with 21 additions and 2 deletions.
1 change: 1 addition & 0 deletions grade/report/grader/index.php
Expand Up @@ -184,6 +184,7 @@
echo '<div>';
echo '<input type="hidden" value="'.s($courseid).'" name="id" />';
echo '<input type="hidden" value="'.sesskey().'" name="sesskey" />';
echo '<input type="hidden" value="'.time().'" name="timepageload" />';
echo '<input type="hidden" value="grader" name="report"/>';
echo '<input type="hidden" value="'.$page.'" name="page"/>';
echo $reporthtml;
Expand Down
17 changes: 15 additions & 2 deletions grade/report/grader/lib.php
Expand Up @@ -177,6 +177,7 @@ public function process_data($data) {

// Were any changes made?
$changedgrades = false;
$timepageload = clean_param($data->timepageload, PARAM_INT);

foreach ($data as $varname => $students) {

Expand Down Expand Up @@ -251,22 +252,34 @@ public function process_data($data) {
}

$errorstr = '';
// Warn if the grade is out of bounds.
if (!is_null($finalgrade)) {
$skip = false;

$dategraded = $oldvalue->get_dategraded();
if (!empty($dategraded) && $timepageload < $dategraded) {
// Warn if the grade was updated while we were editing this form.
$errorstr = 'gradewasmodifiedduringediting';
$skip = true;
} else if (!is_null($finalgrade)) {
// Warn if the grade is out of bounds.
$bounded = $gradeitem->bounded_grade($finalgrade);
if ($bounded > $finalgrade) {
$errorstr = 'lessthanmin';
} else if ($bounded < $finalgrade) {
$errorstr = 'morethanmax';
}
}

if ($errorstr) {
$userfields = 'id, ' . get_all_user_name_fields(true);
$user = $DB->get_record('user', array('id' => $userid), $userfields);
$gradestr = new stdClass();
$gradestr->username = fullname($user);
$gradestr->itemname = $gradeitem->get_name();
$warnings[] = get_string($errorstr, 'grades', $gradestr);
if ($skip) {
// Skipping the update of this grade it failed the tests above.
continue;
}
}

} else if ($datatype == 'feedback') {
Expand Down
1 change: 1 addition & 0 deletions lang/en/grades.php
Expand Up @@ -309,6 +309,7 @@
Only value and scale grade types may be aggregated. The grade type for an activity-based grade item is set on the activity settings page.';
$string['gradeview'] = 'View grade';
$string['gradewasmodifiedduringediting'] = 'The grade entered for {$a->itemname} for {$a->username} was ignored because it was more recently updated by someone else.';
$string['gradeweighthelp'] = 'Grade weight help';
$string['groupavg'] = 'Group average';
$string['hidden'] = 'Hidden';
Expand Down
4 changes: 4 additions & 0 deletions lib/grade/grade_category.php
Expand Up @@ -564,6 +564,7 @@ private function aggregate_grades($userid, $items, $grade_values, $oldgrade, $ex
$grade->finalgrade = null;

if (!is_null($oldfinalgrade)) {
$grade->timemodified = time();
$grade->update('aggregation');
}
return;
Expand Down Expand Up @@ -606,6 +607,7 @@ private function aggregate_grades($userid, $items, $grade_values, $oldgrade, $ex
$grade->finalgrade = null;

if (!is_null($oldfinalgrade)) {
$grade->timemodified = time();
$grade->update('aggregation');
}
return;
Expand All @@ -622,6 +624,7 @@ private function aggregate_grades($userid, $items, $grade_values, $oldgrade, $ex

// update in db if changed
if (grade_floats_different($grade->finalgrade, $oldfinalgrade)) {
$grade->timemodified = time();
$grade->update('aggregation');
}

Expand Down Expand Up @@ -897,6 +900,7 @@ private function sum_grades(&$grade, $oldfinalgrade, $items, $grade_values, $exc

// update in db if changed
if (grade_floats_different($grade->finalgrade, $oldfinalgrade)) {
$grade->timemodified = time();
$grade->update('aggregation');
}

Expand Down

0 comments on commit 450e3f2

Please sign in to comment.