Make changes needed after the fix of MDL-83541 #74
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
With the fix of MDL-83541, Moodle will calculate a hash of all relevant fields of a question and its answers during the restore process. This allows to avoid duplicating questions during imports while still being able to distinguish different questions with the same "stamp".
This PR makes the necessary changes.
It can be tested using the
mod/quiz/tests/backup/repeated_restore_test.php
unit tests in Moodle 4.5 and upcoming 5.0. You may want to tweak the test a bit by changing itsget_qtype_generators()
data provider and addingat the end, in order to just check this question type (instead of all installed types) and to make sure it uses the three questions with a
get_pmatch_question_form_data_*
method, instead of just the first one that can be found.