From 7b54e9335fc568dbd544575cf692823db260194f Mon Sep 17 00:00:00 2001 From: Mark Johnson Date: Wed, 21 Feb 2024 09:23:21 +0000 Subject: [PATCH] MDL-68806 backup: Fix faulty question attempt step restore test Previously, the test was passing by fluke because all question attempt steps had the same timecreated date. However, the $originaliterator only contained the first step of the question, not all 3 attempts that were being backed up and restored. This means we were comparing the timecreated of the first backed-up step with the timecreated on the third restored step. As of MDL-68806, the first step's timecreated is question_attempt_step::TIMECREATED_ON_FIRST_RENDER, which shows up this error. This change gets the question_usage_by_activity object back from the attempt object which contains all the attempt steps, rather than using the one created in the test, which doesn't. --- backup/moodle2/tests/restore_stepslib_date_test.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/backup/moodle2/tests/restore_stepslib_date_test.php b/backup/moodle2/tests/restore_stepslib_date_test.php index 836107a0e3af..4fa9ae64b03f 100644 --- a/backup/moodle2/tests/restore_stepslib_date_test.php +++ b/backup/moodle2/tests/restore_stepslib_date_test.php @@ -412,7 +412,7 @@ public function test_question_attempt_steps_date_restore() { $attemptobj->process_grade_submission($timenow); $questionattemptstepdates = []; - $originaliterator = $quba->get_attempt_iterator(); + $originaliterator = $attemptobj->get_question_usage()->get_attempt_iterator(); foreach ($originaliterator as $questionattempt) { $questionattemptstepdates[] = ['originaldate' => $questionattempt->get_last_action_time()]; }