error/error_question_answers_missing_in_db when importing a quiz

Re: error/error_question_answers_missing_in_db when importing a quiz

by Jean-Michel Védrine -
Number of replies: 0

Hello Joe,

sorry it tooks so long to answer your message.
I have spend many hours trying to reproduce your problem but I must admit that I fails.
This is rather frustrating because I really think that if I managed to reproduce the problem solving it would be rather simple.
Additionnaly I don't really understand the informations we have gathered so far.
If we look at debug infos:
Error code: error_question_answers_missing_in_db
$a contents: stdClass Object
(
[filequestionid] => 21775
[dbquestionid] => 56234
[answer] => 3.14
Moodle is trying to find an answer with value 3.14 for question 56234
But if we look at the results of your sql query
 SELECT * FROM mdl_question_answers WHERE question = 56234\G
*************************** 1. row ***************************
id: 289186
question: 56234
answer: 3.14
answerformat: 0
fraction: 0.0000000
feedback:
feedbackformat: 1
*************************** 2. row ***************************
id: 289187
question: 56234
answer: 2.71828
answerformat: 0
fraction: 0.0000000
feedback:
feedbackformat: 1
*************************** 3. row ***************************
id: 289189
question: 56234
answer: 6.02 x 10^23
answerformat: 0
fraction: 1.0000000
feedback:
feedbackformat: 1
*************************** 4. row ***************************
id: 289190
question: 56234
answer: 6 x 10^23
answerformat: 0
fraction: 0.5000000
feedback:
feedbackformat: 1
We clearly see that in fact there is a record in mdl_question_answers for questionid=56234 with answer = 3.14 (this is the first row returned)

Last element: if we compare the result of the query for questionid= 21775 with the results of the query for questionid= 56234 we see that there is an answer missing: the one with the garbled characters; This is surely an important part of the problem.

Maybe the garbled characters in the database are not the same as the garbled characters in the XML file included in the backup ? I am nearly sure that if there are non UTF-8 characters in the database they are modified by the backup/restore process.

I don't really know what to investigate to understand this issue better ?