Failed to find an answer matching "..." in the question_answers database table. (II)

Failed to find an answer matching "..." in the question_answers database table. (II)

by Visvanath Ratnaweera -
Number of replies: 2
Picture of Particularly helpful Moodlers Picture of Translators

Moodle 3.9.8+ (Build: 20210716)

A teacher trying to import from one course to the other is getting, 'Failed to find an answer matching "..." in the question_answers database table. This occurred while restoring the question with id 81890 in the backup file, which has been matched to the existing question with id 70191 in the database'.

The odd thing is, it happens even if the activities are not quizzes! The import breaks from about 5 courses. The target course is always the same. The teacher can import to other courses.


Here is the ./admin/tool/health/:


And the two proposed solutions are:



Here are the debug trace at DEVELOPER level:
Did you remember to make the first column something unique in your call to get_records? Duplicate value 'EXAMPLE.COM+130218203516+5VXUft EXAMPLE.COM+140303115101+E8F0Wq' found in column 'concat(stamp, ' ', version)'.
  • line 1282 of /lib/dml/mysqli_native_moodle_database.php: call to debugging()
  • line 1548 of /lib/dml/moodle_database.php: call to mysqli_native_moodle_database->get_records_sql()
  • line 680 of /backup/util/dbops/restore_dbops.class.php: call to moodle_database->get_records_sql_menu()
  • line 520 of /backup/util/dbops/restore_dbops.class.php: call to restore_dbops::prechek_precheck_qbanks_by_level()
  • line 178 of /backup/util/helper/restore_prechecks_helper.class.php: call to restore_dbops::precheck_categories_and_questions()
  • line 428 of /backup/controller/restore_controller.class.php: call to restore_prechecks_helper::execute_prechecks()
  • line 173 of /backup/import.php: call to restore_controller->execute_precheck()N
Noticed that EXAMPLE.COM is the former domain of the site!

About 60 identical blocks for different duplicate values, before the error:



This is an old Moodle site, probable since rel. 2.4 successively upgraded. Anybody has an idea what sort of data inconsistency it is complaining about?

BTW, there are only two quiz related additional plugins:
- StudentQuiz (mod_studentquiz) v4.5.0 2021071300
- Kprime (ETH) (qtype_kprime) 2.3 for Moodle 3.4+ 2020042901

Otherwise, there is a healthy bunch of 30 additional plugins.
Average of ratings: -
In reply to Visvanath Ratnaweera

Re: Failed to find an answer matching "..." in the question_answers database table. (II)

by Tim Hunt -
Picture of Core developers Picture of Documentation writers Picture of Particularly helpful Moodlers Picture of Peer reviewers Picture of Plugin developers
This is a problem that happens sometimes, and is almost certainly no related to any of the plugins. You will probably find more info if you search for the error message in the tracker.

Exactly what the restore code is trying to do is a bit complex. It's when it thinks that a question in the backup file matches one in the place you are resotring too, and then cannot match up the details. (That is: "I think this multi-choice question in the backup file should be the same as this one in the course I am restoring to, except that that in the backup file, one of the choices is 'die Bildauflosung', but the question in the target course does not see to have that choice".)
Average of ratings: Useful (1)
In reply to Tim Hunt

Re: Failed to find an answer matching "..." in the question_answers database table. (II)

by Visvanath Ratnaweera -
Picture of Particularly helpful Moodlers Picture of Translators
Indeed! questiontext of both records in mdl_question where id=81890 and id=70191 are the identical. But in mdl_question_answers there are five records where question=81890 whereas there are only two where question=70191.

My question is, how did the teacher create such an anomaly? Is it possible that she created a "new" question, which by chance identical to the dot to an old question, but the possible answers were not?

I don't think the loss of such a "quick question" is a big deal. Is it advisable to purge it in the database? Is there a safe way? She has close to 10 courses, where she imports activities, resources and quizzes in all directions!