forked from moodle/moodle
-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
MDL-83541 question/quiz: restoring questions with identical stamps
Historically it was possible, through a series of question restores, moves and edits, to end up with multiple questions in the same category with the same stamp, but differences in other question or answer fields. This, combined with changes in versions, led to errors when restoring or duplicating quizzes using these questions. While recent changes have made it impossible to create this situation in current Moodle versions, as any edits will create a new question version with a new stamp, this situation may exist on long-standing Moodle sites which have been upgraded since pre-4.0. This change performs a much wider-ranging comparison of restored existing questions, generating a hash of all the data for a question in a backup file, and a corresponding hash for each question in the target category, to decide if a restored question matches a question already in the database.
- Loading branch information
1 parent
f91e3d4
commit 7b9f56a
Showing
6 changed files
with
938 additions
and
15 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,30 @@ | ||
issueNumber: MDL-83541 | ||
notes: | ||
core_question: | ||
- message: > | ||
Duplication or multiple restores of questions has been modified to avoid | ||
errors where a question with the same stamp already exists in the target | ||
category. | ||
To achieve this all data for the question is hashed, excluding any ID | ||
fields. | ||
If a qtype plugin calls any `$this->add_question_*()` methods in its | ||
`restore_qtype_*_plugin::define_question_plugin_structure()` method, the | ||
ID fields used in these records will be excluded automatically. | ||
If a qtype plugin defines its own tables with ID fields, it must define | ||
`restore_qtype_*_plugin::define_excluded_identity_hash_fields()` to return | ||
an array of paths to these fields within the question data. This should be | ||
all that is required for the majority of plugins. | ||
See the PHPDoc of `restore_qtype_plugin::define_excluded_identity_hash_fields()` | ||
for a full explanation of how these paths should be defined, and | ||
`restore_qtype_truefalse_plugin` for an example. | ||
If the data structure for a qtype returned by calling | ||
`get_question_options()` contains data other than ID fields that are not | ||
contained in the backup structure or vice-versa, it will need to | ||
override `restore_qtype_*_plugin::remove_excluded_question_data()` | ||
to remove the inconsistent data. See `restore_qtype_multianswer_plugin` as | ||
an example. | ||
type: fixed |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.