Moodle 4.5.2: Failed to find an answer matching "" in the question_answers database table

Moodle 4.5.2: Failed to find an answer matching "" in the question_answers database table

avo user發表於
Number of replies: 12

Hi,

today I tried to clone a quiz in a course and for the first time I got the error:

Failed to find an answer matching "<p>i=9, j=7,  k=0<br></p>" in the question_answers database table. This occurred while restoring the question with id 60951 in the backup file, which has been matched to the existing question with id 60954 in the database.

This problem appeared after upgrading from 4.4.x to the newer 4.5.2, I'm pretty sure that with 4.4.x it was possible to clone quizzes there (questions have not changed before or after the update).

I've read that an old solution is to browse URL/admin/tool/health, but I found out that the plugin is deprecated. However, after installing it, it did not show any errors.

Health status

I don't know why, but cron.php works correctly (according to general->notifications). I tried going through all the quiz questions and figuring out what the problem was without success.

Within the question bank, I tried deleting both questions, but the problem is still there (questions are not listed, but are still accessible via URL).

URLquestion/bank/editquestion/question.php?returnurl=%2Fquestion%2Fedit.php%3Fcourseid%3D338&courseid=338&id=60951

URLquestion/bank/editquestion/question.php?returnurl=%2Fquestion%2Fedit.php%3Fcourseid%3D338&courseid=338&id=60954

Do you have any suggestion?

Thank you

評比平均分數: -
In reply to avo user

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

avo user發表於

After further investigation, I can confirm that the problem only occurs in a specific course when I try to duplicate a quiz. I am sure that the problem was not present before the upgrade from version 4.4.3 to the newer 4.5.2. So it could be a bug in version 4.5.2.
Also, the official documentation here does not help. Should I proceed by manually deleting the entries in the mySQL database as described here?

Failed to find an answer matching "<p>i=9, j=7,  k=0<br></p>" in the question_answers database table. This occurred while restoring the question with id 60951 in the backup file, which has been matched to the existing question with id 60954 in the database.

Debug info:
Error code: error_question_answers_missing_in_db×Dismiss this notification
Stack trace:
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 123 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 111 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 189 of /backup/util/xml/parser/progressive_parser.class.php: call to progressive_parser_processor->receive_chunk()
line 277 of /backup/util/xml/parser/progressive_parser.class.php: call to progressive_parser->publish()
line ? of unknownfile: call to progressive_parser->end_tag()
line 178 of /backup/util/xml/parser/progressive_parser.class.php: call to xml_parse()
line 157 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 199 of /backup/util/plan/base_task.class.php: call to restore_structure_step->execute()
line 191 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 411 of /backup/controller/restore_controller.class.php: call to restore_plan->execute()
line 3119 of /course/lib.php: call to restore_controller->execute_plan()
line 129 of /course/mod.php: call to duplicate_module()

In reply to avo user

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

avo user發表於
I found that it is a bug from 4.4.4 onward. This explain why up to 4.4.3 everything worked well. Do you think that this plugin could help since my two "incriminated" questions are of 2018?
In reply to avo user

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

Paul K發表於
This problem appears also in the lastest update for Moodle 4.3.10. (Build: 20250214). In the previous version of Moodle which we have used also for 4.3.7 everything worked smoothly.
In reply to Paul K

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

avo user發表於
Right, the bug was probably added in the trunk and propagated to the various branches. I read that there is a patch being tested and that it should be released in the April release cycle.
In reply to avo user

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

avo user發表於
Not sure if I was lucky, however this plugin fixed the problem. I set it to remove quiz attempts older than 5 years, the troubled questions were from 2018. Now the first one id=60951 is still present although not visible, while the second one id=60954 has been removed.
 
Delete attempts older than: 5 years old
Delete unused hidden questions: yes
Maybe someone else could try it and confirm if it works.
評比平均分數:Useful (1)
In reply to avo user

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

Visvanath Ratnaweera發表於
Particularly helpful Moodlers的相片 Translators的相片
This Old quiz and question attempts deletion plug-in would be very useful to clean up the exploding quiz questions these days. But the discussion on the plug-in page is not encouraging. The final two comments are, "With Moodle 4 it doesn't seem to work anymore. Correct?" 3 Sep 2022 and "Has anybody tested on moodle 4.1?" 11 Dec 2023.

Does anybody know whether the plug-in would delete attempts in 4.1 LTS without side-effects?
In reply to Visvanath Ratnaweera

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

avo user發表於
Hi,
according to the plugin change log, the support for moodle 4 arrived with version 3.0 released on 14/01/2024.
Release 3.0.0 (build 2024011400): - Moodle 4 support. - Dropped support for Moodle versions lower than 4.0 due to changes in core.
Moreover, it tested it with moodle 4.5.2 and everything seems to work properly.
評比平均分數:Useful (1)
In reply to avo user

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

Visvanath Ratnaweera發表於
Particularly helpful Moodlers的相片 Translators的相片
Thanks, it should work then.

I realize that, what we need is not only deleting old quiz attempts but whole question banks. Found this pair, https://moodle.org/plugins/qbank_purgecategory and https://moodle.org/plugins/local_purgequestioncategory. Installed on out 4.1.15 through the Moodle GUI, they passed the version tests. But no new item appear in the drop-down.
附件 Screenshot_2025-03-07_17-37-25.png
附件 Screenshot_2025-03-07_17-37-54.png
In reply to Visvanath Ratnaweera

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

avo user發表於
These plugins are developed by the same developer as the other one.
I installed the first one, which should be the one developed in the future, and it worked on moodle 4.5.2.
In reply to avo user

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

Visvanath Ratnaweera發表於
Particularly helpful Moodlers的相片 Translators的相片
Same developer? That guy have earned tons of karma. There is a whole club of stranded sysadmins of exploded question categories.

OK, ours is 4.1 LTS. May be that is the reason. Or I was impatient. I am enjoying every minute of the new found excitements of a fire fighter and a garbage collector. 傷心
In reply to Visvanath Ratnaweera

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

avo user發表於
Right, the same developer. I don't know what you are referring to, if plugins are approved, why should they do any harm?! However, in my case it solved the problem.
That is why it would be good to have confirmation from other users with versions 4.3, 4.4 and 4.5 affected by the reported problem.
In reply to avo user

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

Visvanath Ratnaweera發表於
Particularly helpful Moodlers的相片 Translators的相片
I was referring to the fact that it is quite "normal" for Moodle to multiply question categories, see for example MDL-41924. Sooner or later one is faced with clearing the mess. That why this cottage industry of purge questions, delete questions, find duplicates and that sort of plug-ins, I conclude.