X-Git-Url: http://git.moodle.org/gw?p=moodle.git;a=blobdiff_plain;f=mod%2Fassign%2Flocallib.php;h=096a90e62d6814ca1e8e5dc5d0698ef00b7c446f;hp=6cfb48cdba66f85283682f7ee9b3f5d2224bf787;hb=37029775f9e54d18bafd537f3e150c22c512cd28;hpb=45f2e27c4dd0809e0aee79bd3899a8882ea1115b diff --git a/mod/assign/locallib.php b/mod/assign/locallib.php index 6cfb48cdba6..096a90e62d6 100644 --- a/mod/assign/locallib.php +++ b/mod/assign/locallib.php @@ -1521,7 +1521,7 @@ class assign { s.assignment = :assignid AND s.timemodified IS NOT NULL AND s.status = :submitted AND - (s.timemodified > g.timemodified OR g.timemodified IS NULL OR g.grade IS NULL)'; + (s.timemodified >= g.timemodified OR g.timemodified IS NULL)'; return $DB->count_records_sql($sql, $params); } @@ -2911,9 +2911,10 @@ class assign { if (!$userid) { $userid = $USER->id; } + $submission = null; $params = array('assignment'=>$this->get_instance()->id, 'userid'=>$userid); - if ($attemptnumber < 0) { + if ($attemptnumber < 0 || $create) { // Make sure this grade matches the latest submission attempt. if ($this->get_instance()->teamsubmission) { $submission = $this->get_group_submission($userid, 0, true); @@ -2939,7 +2940,14 @@ class assign { $grade->assignment = $this->get_instance()->id; $grade->userid = $userid; $grade->timecreated = time(); - $grade->timemodified = $grade->timecreated; + // If we are "auto-creating" a grade - and there is a submission + // the new grade should not have a more recent timemodified value + // than the submission. + if ($submission) { + $grade->timemodified = $submission->timemodified; + } else { + $grade->timemodified = $grade->timecreated; + } $grade->grade = -1; $grade->grader = $USER->id; if ($attemptnumber >= 0) {