-
Bug
-
Resolution: Fixed
-
Major
-
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.
— Replicate steps by Mark —
- Install Moodle 3.11.
- Create a new course "Test course 1".
- Go the the course's question bank and create a new multiple choice question "Test question 1" with several answers.
- Create a copy of the course, "Test course 2".
- Go to the "Test course 2" question bank, edit "Test question 1" and change the answers.
- From the "Test course 2" question bank, select "Test question 1" and move it to the "Default for system" question category.
- Go to the "Test course 1" question bank, switch to the "Default for system" question category select "Test question 1", and move it to the "Default for Test course 1" category.
- You will now have two questions called "Test question 1" in the same context, with the same stamp but different answers.
- Upgrade to Moodle 4.1.
- Upgrade to Moodle 4.5 (requires upgrading PHP version).
- Go to "Test course 1"
- Create a quiz and add one of the instances of "Test question 1" to the quiz.
- Duplicate the quiz
- The error is displayed.
- has a non-specific relationship to
-
MDL-85018 Duplicate quiz containing a multianswer question gives dml_missing_record_exception
-
- Open
-
- is a regression caused by
-
MDL-77625 Repeated quiz restoration to same course references original course questions
-
- Closed
-
- is duplicated by
-
MDL-83731 quizz duplication fail cause of bad HTML conversion in XML (specialy on question_answers)
-
- Closed
-
-
MDL-83855 Bug with quiz during importation of a course
-
- Closed
-
- Testing discovered
-
MDL-84843 Performance issue when restoring questions on pgsql database.
-
- Open
-
-
MDL-84261 Error: mdb->get_record() found more than one record! When restoring question hints
-
- Reopened
-
-
MDL-83951 Questions are being duplicated on quiz duplication/restore
-
- Closed
-