Moodle 3.10 - Failed to find an answer matching "" in the question_answers database table

Moodle 3.10 - Failed to find an answer matching "" in the question_answers database table

by Peter Svec -
Number of replies: 9

Hi, after upgrade to 3.10 we have a problem which used to be in old version of Moodle. Our portal is regularly upgraded since 1.x and we had no problem so far. We checked everything - legacy files, capabilities, backup / restore settings. I have no clue what is the reason of this behaviour.  

What is "line ? of unknownfile: call to progressive_parser->end_tag()" ?

Failed to find an answer matching "" in the question_answers database table. This occurred while restoring the question with id 82794 in the backup file, which has been matched to the existing question with id 82794 in the database.

Error code: error_question_answers_missing_in_db
* line 199 of /backup/moodle2/restore_qtype_plugin.class.php: restore_step_exception thrown
* line 137 of /backup/util/plan/restore_structure_step.class.php: call to restore_qtype_plugin->process_question_answer()
* line 121 of /backup/util/helper/restore_structure_parser_processor.class.php: call to restore_structure_step->process()
* line 178 of /backup/util/xml/parser/processors/grouped_parser_processor.class.php: call to restore_structure_parser_processor->dispatch_chunk()
* line 109 of /backup/util/helper/restore_structure_parser_processor.class.php: call to grouped_parser_processor->postprocess_chunk()
* line 148 of /backup/util/xml/parser/processors/simplified_parser_processor.class.php: call to restore_structure_parser_processor->postprocess_chunk()
* line 92 of /backup/util/xml/parser/processors/progressive_parser_processor.class.php: call to simplified_parser_processor->process_chunk()
* line 190 of /backup/util/xml/parser/progressive_parser.class.php: call to progressive_parser_processor->receive_chunk()
* line 278 of /backup/util/xml/parser/progressive_parser.class.php: call to progressive_parser->publish()
* line ? of unknownfile: call to progressive_parser->end_tag()
* line 179 of /backup/util/xml/parser/progressive_parser.class.php: call to xml_parse()
* line 158 of /backup/util/xml/parser/progressive_parser.class.php: call to progressive_parser->parse()
* line 110 of /backup/util/plan/restore_structure_step.class.php: call to progressive_parser->process()
* line 181 of /backup/util/plan/base_task.class.php: call to restore_structure_step->execute()
* line 178 of /backup/util/plan/base_plan.class.php: call to base_task->execute()
* line 168 of /backup/util/plan/restore_plan.class.php: call to base_plan->execute()
* line 385 of /backup/controller/restore_controller.class.php: call to restore_plan->execute()
* line 3494 of /course/lib.php: call to restore_controller->execute_plan()
* line 3544 of /course/externallib.php: call to duplicate_module()
* line 261 of /lib/externallib.php: call to core_course_external::edit_module()
* line 81 of /lib/ajax/service.php: call to external_api::call_external_function()

Average of ratings: -
In reply to Peter Svec

Re: Moodle 3.10 - Failed to find an answer matching "" in the question_answers database table

by Emma Richardson -
Picture of Documentation writers Picture of Particularly helpful Moodlers Picture of Plugin developers
Have you looked at the question that is referenced? It looks like it has no answers set to it - when are you seeing this error?
In reply to Emma Richardson

Re: Moodle 3.10 - Failed to find an answer matching "" in the question_answers database table

by Peter Svec -
The question has answers. It's existing quiz used several years. The same problem have all teachers. In each course there is another problematic question ID. I found out, that there is no problem when I duplicate quiz which has questions in quiz context. When I use questions from course context, there is this error.

In this case the question 82794 belong to category of another course. This is really strange. We upgraded mariadb to higher version but this can't be the origin of the problem. There are two other instances of moodle on the same server without this problem.
In reply to Peter Svec

Re: Moodle 3.10 - Failed to find an answer matching "" in the question_answers database table

by Ken Task -
Picture of Particularly helpful Moodlers

Run 'hidden' /admin/tool/health/ as admin level user via web browser.

Will check questionbank and present a screen showing issues it found as well as a button for 'suggested solutions' ... which are usually SQL queries to run from mysql client or phpmyadmin on the DB of the site having issues.

If suggestion to fix not presented at least you might have some more info to share back here.

'SoS', Ken

Average of ratings: Useful (2)
In reply to Ken Task

Re: Moodle 3.10 - Failed to find an answer matching "" in the question_answers database table

by Peter Svec -
Oh, I didn't know about this tool. Thanks a lot Ken. I fixed some problems but few of them still remains.

Multi-answer questions data consistency. I used the script from Moodle 1.9 and generated SQL with more than 2.000 queries, but none of them returned updated record. The query is like "UPDATE mdl_question SET parent = 390362, category = 18823 WHERE id IN (390363,390364) AND parent <> 0;"

Only multianswer and random questions should be the parent of another question. There is no suggestion, only to ask in moodle forum.

Question categories should belong to a valid context. All question categories are linked to a context id, and, the context they are linked to must exist. How to fix this? The context to which the category is linked do not exist anymore.

Question categories should belong to the same context as their parent. When one question category is the parent of another, then they should both belong to the same context. I see child category id, name and contextid and parent category id, name and contextid. But I cannot just update the db record in mdl_question_categories because it creates duplicate key. Do you have any idea how to correctly update these categories?

Peter
Attachment Snímka obrazovky 2021-01-01 o 18.05.48.png
Attachment Snímka obrazovky 2021-01-01 o 18.06.24.png
In reply to Peter Svec

Re: Moodle 3.10 - Failed to find an answer matching "" in the question_answers database table

by Ken Task -
Picture of Particularly helpful Moodlers

Don't understand this:

"I used the script from Moodle 1.9"?

The health check exist in 3.10!

Am not a quiz expert.   As far as those things not fixed or the check suggested post in forms, the forum where one would find quiz experts is:

https://moodle.org/mod/forum/view.php?id=737

Maybe moderators of 'backup and restore' could  split your last posting off and create a new one in the Quiz forum.

If not, repost there.

'SoS', Ken


In reply to Ken Task

Re: Moodle 3.10 - Failed to find an answer matching "" in the question_answers database table

by Peter Svec -
The health script of 3.10 recommended to use the function question_multianswer_fix_subquestion_parents_and_categories() of question/type/multianswer/db/upgrade.php from moodle 1.9 branch to solve the problem with Multi-answer questions data consistency.
In reply to Peter Svec

Re: Moodle 3.10 - Failed to find an answer matching "" in the question_answers database table

by Ken Task -
Picture of Particularly helpful Moodlers

Didn't see that in screen you shared ... but ...

Dunno if it's related or not, but there is a script in code/admin/cli/ called 'fix_orphaned_question_categories.php'.   Have blindly fixed things in past by running something which triggers other.

Sounds like you might be in for some pain ... editing rows one at a time - once you match up module id with question having issues.  :|

Sorry ... like I said ... maybe in the quiz forums one will attract attention of quiz experts.

'SoS', Ken


In reply to Ken Task

Re: Moodle 3.10 - Failed to find an answer matching "" in the question_answers database table

by Peter Svec -
Dear Ken,
thank you for your time. We found out, that the problem was one of our custom modules. The backup/restore function caused all those problems. I don't know how yet, but after uninstall of this module, everything works as expected.
In reply to Peter Svec

Re: Moodle 3.10 - Failed to find an answer matching "" in the question_answers database table

by Ken Task -
Picture of Particularly helpful Moodlers

By 'module' you mean a quiz in a course, right?

Been working through quiz bank issues reported by Health Check as well this past week.   Site has been used since 2009 and is now a 3.5.highest ... there have been 5 Moodle Admins ... 2 of whom got the 'hat' but never any understanding of what that meant ... am now working with the 6th MA.

Example:

    6583    Default for Plate Tectonics-Plate Motions Quiz    44286    4844    top    88943
    6584    Default for Plate Tectonics Motions Lab    44286    4382    top    44762

I finally used an adhoc query report for quizzes that allowed me to find reported quizzes.

Number of Quizes per Course

SELECT COUNT(*)
,concat('<a target="_new" href="%%WWWROOT%%/course/view.php?id=',c.id,'">',c.fullname,'</a>') AS Course
,concat('<a target="_new" href="%%WWWROOT%%/mod/quiz/index.php?id=',c.id,'">Link</a>') AS Quizes
 
FROM prefix_course_modules cm
JOIN prefix_course c ON c.id = cm.course
JOIN prefix_modules AS m ON m.id = cm.module
WHERE m.name LIKE 'quiz'
GROUP BY c.id

I put into a Webmin Tool Custom buttons Query outside of Moodle and through a little less effort found the 2 examples in a hidden/unused course from 2014-2015 Academic year.   No reason to keep a course that old in production Moodle.

The things we 'admins' do!!!   Of course, that's why we make the big bucks, right? Yeah, right! :|

Anyhoo, thanks for sharing back ... while neither of our post will be specific enough to help another OP solve similar, they will at least put them in the 'ball park' ... it is hoped! smile

'SoS', Ken