* @param bool $changeuser Whether to switch user to the user being submitted as.
*/
protected function mark_submission($teacher, $assign, $student, $grade = 50.0, $data = [], $attempt = 0) {
+ global $DB;
+
// Mark the submission.
$this->setUser($teacher);
$data = (object) array_merge($data, [
'grade' => $grade,
]);
+ // Bump all timecreated and timemodified for this user back.
+ // The old assign_print_overview function includes submissions which have been graded where the grade modified
+ // date matches the submission modified date.
+ $DB->execute('UPDATE {assign_submission} SET timecreated = timecreated - 1, timemodified = timemodified - 1 WHERE userid = :userid',
+ ['userid' => $student->id]);
+
$assign->testable_apply_grade_to_user($data, $student->id, $attempt);
}
}
$this->assertEquals(1, count($overview));
// Submissions without a grade.
$this->assertRegExp('/.*Open Assignment.*/', $overview[$course->id]['assign']);
- $this->assertRegExp('/.*Assignment with submissions.*/', $overview[$course->id]['assign']);
+ $this->assertNotRegExp('/.*Assignment with submissions.*/', $overview[$course->id]['assign']);
$this->setUser($teacher);
$overview = array();
$this->assertEquals(1, count($overview));
// Submissions without a grade.
$this->assertRegExp('/.*Open Assignment.*/', $overview[$course->id]['assign']);
- $this->assertRegExp('/.*Assignment with submissions.*/', $overview[$course->id]['assign']);
+ $this->assertNotRegExp('/.*Assignment with submissions.*/', $overview[$course->id]['assign']);
// Let us grade a submission.
$this->setUser($teacher);
$overview = array();
assign_print_overview($courses, $overview);
- $this->assertDebuggingCalledCount(3);
- $this->assertEquals(1, count($overview));
// Now assignment 4 should not show up.
- $this->assertNotRegExp('/.*Open Assignment.*/', $overview[$course->id]['assign']);
- $this->assertRegExp('/.*Assignment with submissions.*/', $overview[$course->id]['assign']);
+ $this->assertDebuggingCalledCount(3);
+ $this->assertEmpty($overview);
$this->setUser($teacher);
$overview = array();
assign_print_overview($courses, $overview);
$this->assertDebuggingCalledCount(3);
- $this->assertEquals(1, count($overview));
// Now assignment 4 should not show up.
- $this->assertNotRegExp('/.*Open Assignment.*/', $overview[$course->id]['assign']);
- $this->assertRegExp('/.*Assignment with submissions.*/', $overview[$course->id]['assign']);
+ $this->assertEmpty($overview);
}
/**
$this->add_submission($student, $assign);
$this->submit_for_grading($student, $assign);
- // TODO Find a way to kill this waitForSecond
- // This is to make sure the grade happens after the submission because
- // we have no control over the timemodified values.
- $this->waitForSecond();
$this->mark_submission($teacher, $assign, $student, 50.0);
$data = new stdClass();
$this->add_submission($student, $assign);
$this->submit_for_grading($student, $assign);
- $this->waitForSecond();
$this->mark_submission($teacher, $assign, $student, 50.0);
// Although it has been graded, it is still marked as submitted.