Skip to content

Commit

Permalink
MDL-68806 backup: Fix faulty question attempt step restore test
Browse files Browse the repository at this point in the history
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.
  • Loading branch information
marxjohnson committed Jul 31, 2024
1 parent 00a2c43 commit 9cda944
Showing 1 changed file with 1 addition and 1 deletion.
2 changes: 1 addition & 1 deletion backup/moodle2/tests/restore_stepslib_date_test.php
Original file line number Diff line number Diff line change
Expand Up @@ -413,7 +413,7 @@ public function test_question_attempt_steps_date_restore(): void {
$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()];
}
Expand Down

0 comments on commit 9cda944

Please sign in to comment.