Skip to content

Commit

Permalink
Merge branch 'MDL-62715-35' of git://github.com/andrewnicols/moodle i…
Browse files Browse the repository at this point in the history
…nto MOODLE_35_STABLE
  • Loading branch information
snake committed Jul 3, 2018
2 parents 49e435c + bea7b33 commit ff1fbf2
Show file tree
Hide file tree
Showing 3 changed files with 13 additions and 14 deletions.
8 changes: 8 additions & 0 deletions mod/assign/tests/generator.php
Expand Up @@ -119,12 +119,20 @@ public function submit_for_grading($student, $assign, $data = [], $changeuser =
* @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);
}
}
14 changes: 5 additions & 9 deletions mod/assign/tests/lib_test.php
Expand Up @@ -120,7 +120,7 @@ public function test_assign_print_overview() {
$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();
Expand All @@ -129,7 +129,7 @@ public function test_assign_print_overview() {
$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);
Expand All @@ -145,20 +145,16 @@ public function test_assign_print_overview() {

$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);
}

/**
Expand Down
5 changes: 0 additions & 5 deletions mod/assign/tests/locallib_test.php
Expand Up @@ -1065,10 +1065,6 @@ public function test_get_participant_with_graded_submission() {
$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();
Expand Down Expand Up @@ -1336,7 +1332,6 @@ public function test_count_submissions_graded() {

$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.
Expand Down

0 comments on commit ff1fbf2

Please sign in to comment.