diff --git a/mod/assign/locallib.php b/mod/assign/locallib.php index a64b22a1a8b..7362607b676 100644 --- a/mod/assign/locallib.php +++ b/mod/assign/locallib.php @@ -1316,12 +1316,13 @@ class assign { // Any changes to the list of dates that needs to be rolled should be same during course restore and course reset. // See MDL-9367. - shift_course_mod_dates( - 'assign', - ['duedate', 'allowsubmissionsfromdate', 'cutoffdate'], - $data->timeshift, - $data->courseid, $this->get_instance()->id, - ); + shift_course_mod_dates('assign', [ + 'allowsubmissionsfromdate', + 'duedate', + 'cutoffdate', + 'gradingduedate', + ], $data->timeshift, $data->courseid, $this->get_instance()->id); + $status[] = [ 'component' => $componentstr, 'item' => get_string('date'), diff --git a/mod/assign/tests/locallib_test.php b/mod/assign/tests/locallib_test.php index aa409b3313e..f0e1b8d7eba 100644 --- a/mod/assign/tests/locallib_test.php +++ b/mod/assign/tests/locallib_test.php @@ -613,6 +613,9 @@ final class locallib_test extends \advanced_testcase { $this->assertEquals(true, $assign->delete_instance()); } + /** + * @covers ::assign_reset_userdata + */ public function test_reset_userdata(): void { global $DB; @@ -624,9 +627,12 @@ final class locallib_test extends \advanced_testcase { $now = time(); $this->setUser($teacher); $assign = $this->create_instance($course, [ - 'assignsubmission_onlinetext_enabled' => 1, - 'duedate' => $now, - ]); + 'assignsubmission_onlinetext_enabled' => 1, + 'allowsubmissionsfromdate' => $now - HOURSECS, + 'duedate' => $now, + 'cutoffdate' => $now + HOURSECS, + 'gradingduedate' => $now + DAYSECS, + ]); // Simulate adding a grade. $this->add_submission($student, $assign); @@ -659,7 +665,10 @@ final class locallib_test extends \advanced_testcase { // Reload the instance data. $instance = $DB->get_record('assign', ['id' => $assign->get_instance()->id]); + $this->assertEquals($now - HOURSECS + DAYSECS, $instance->allowsubmissionsfromdate); $this->assertEquals($now + DAYSECS, $instance->duedate); + $this->assertEquals($now + HOURSECS + DAYSECS, $instance->cutoffdate); + $this->assertEquals($now + DAYSECS + DAYSECS, $instance->gradingduedate); // Test reset using assign_reset_userdata(). $assignduedate = $instance->duedate; // Keep old updated value for comparison.