-
Bug
-
Resolution: Unresolved
-
Major
-
None
-
4.3 regressions, 4.3.8, 4.4 regressions, 4.4.4, 4.5 regressions
Since the update from Moodle 4.4.3 to 4.4.4, we get this error when duplicating a quiz or if we perform a restore by overwriting the course (this doesn’t happen when we use the option to delete the course before restoring).
Here is an example of the error we get:
Failed to find an answer matching ‘conditional answer’ in the question_answers database table.
|
This occurred while restoring the question with id 6889 in the backup file, which has been matched to the existing question with id 6904 in the database. |
The problem is due to a change made in MDL-77625, in the file /backup/util/dbops/restore_dbops.class.php:
Before the modification, the question version was taken into account in this if statement:
if (isset($questioncache[$question->stamp." ".$question->version])) { |
$matchqid = $questioncache[$question->stamp." ".$question->version]; |
} else { |
$matchqid = false; |
}
|
After the fix, only the stamp is checked:
if (isset($questioncache[$question->stamp])) { |
$matchqid = $questioncache[$question->stamp];
|
} else { |
$matchqid = false; |
}
|
In our question bank, we have questions with repeated stamps. I don’t know why this happens or if it’s normal, but there seem to be more people facing this same issue with questions that have the same stamp.
I have verified that taking the version into account again in that if statement solves the problem, and we can duplicate and perform restores without any issues.
To reproduce the issue, I can’t provide steps to get questions with the same stamp, but if you manage to reach this state, to get the error you only need to:
In a course with a question bank that contains questions with the same stamp:
1.Create a quiz.
2.Add a question to the quiz.
3.Duplicate the quiz.
4.You’ll get the error I’ve mentioned.
- is a regression caused by
-
MDL-77625 Repeated quiz restoration to same course references original course questions
-
- Closed
-