Quiz

 
 
Picture of Rob Johnson
Re: error/error_question_answers_missing_in_db when importing a quiz
Group Particularly helpful Moodlers

Does your ability to import depend on the question category?  Please see MDL-26442.  The error message you posted has been a nuisance for me since upgrading from 1.9 over two years ago.  I posted in the tracker comments some lines of code that can be commented out so the error is not thrown.  If you read through the comments, you will find them.  Imports worked fine after the change.  I am currently using Moodle 2.3.3.

 
Average of ratings: -
Picture of Melissa Benson
Re: error/error_question_answers_missing_in_db when importing a quiz
Group Testers

No, the questions are course level. I don't even think our teachers can make questions at the system level.

I'm working with our server support and the commenting out of those lines did work. We think maybe the PI math symbol could be messing up the database queries.

 
Average of ratings: -
Picture of Rob Johnson
Re: error/error_question_answers_missing_in_db when importing a quiz
Group Particularly helpful Moodlers

Our teacher can't make system level questions either, but we have questions used in district assessments there.  This way one change deals with all courses where the quiz is used.  Most of our math questions were imported using Examview.  I too suspect there are some characters in questions that Moodle 2 does not like.  Moodle 1.9 was much more  tolerant of sloppiness.  I find Examview hit and miss for some math symbols.

Do your teachers import using Examview?

 
Average of ratings: -
Picture of Melissa Benson
Re: error/error_question_answers_missing_in_db when importing a quiz
Group Testers

I don't believe they are using questions from the system level, although we do have some I think when I was testing out sharing of questions.

 

Yep! They do import from examview. I'm not sure if these quizzes were from examview or not but I do know that sometimes they do import. I believe this teacher has done the imports before we upgraded to 2.4 and it worked. I don't know if he was importing the exact same quizzes he's trying now. It's a very large course and takes a long time to even get to the error at the end. Other quizzes from other courses work.

I'm trying to remove the pi symbol now and import. *Crossing fingers*

 
Average of ratings: -
Picture of Melissa Benson
Re: error/error_question_answers_missing_in_db when importing a quiz
Group Testers

Okay, so the pi symbol isn't the problem I don't think. Or any symbol or anything. I think it's the specific course that is the problem. here's why:

 

I importd a quiz from another course into a testing course.

I then imported that same quiz into the problem course.

I then tried to export (import into the test course) that same quiz from the problem course to a testing course. It didn't work.

 

The same quiz that works to import it another course does not work to import from the problem course. sad

 

This course has a ton of activites, labels, resources. It takes forever to even try and import it.

 
Average of ratings: -
Picture of Jean-Michel Védrine
Re: error/error_question_answers_missing_in_db when importing a quiz
Group DevelopersGroup Particularly helpful Moodlers

Hello Melissa,

We will wait for Tim comment, but if I correctly analyse your problem, I don't think your tests permit any conclusions. here is why:

The "error_question_answers_missing_in_db" error message can only be triggered when the question in backup is not created during restore because it already exists. This message appears if when trying to "map" the question existing in backup with the question existing in database Moodle can't find one or more of this questions's answers.

This is what makes this issue difficult to reproduce or to analyse: if you send me your backup, it will not permit us to understand the problem because it will restore with no problem in my Moodle because as the question doesn't exist it will be created during restore and the code that can lead to this message will not be executed so there is no chance this message is displayed.

What we need to understand is why when moodle is comparing the answers of the problematic question(s) it fails to find a match in your database. This part of the code try to find an answer in database with the same questionid and with the same content for the "answer" field.

I am very interested by the fact that several people report that maybe these questions were imported from Examview because as you may know I changed a lot of code in the import formats last year including the ones used to import Examview files.

Maybe I am not cleaning enough the text of answers in my code so the content of answers in database contains characters that should not be here. Later when these question are backuped these illegal characters are removed and later when the question is restored the comparison between "cleaned" answers in backup and "uncleaned" answers in database fails ? This is just an idea but maybe this is the solution to the problem.

What makes me think that is the fact that a similar bug related with answers containing carriage return was already fixed in MDL-30018.

I must also add that I don't think Rob's solution is good : muting the fire alarm when it gives too much false alarms can be dangerous. We must understand why this exception is thrown.

 
Average of ratings: -
Tim at Lone Pine Koala Sanctuary
Re: error/error_question_answers_missing_in_db when importing a quiz
Group DevelopersGroup Documentation writersGroup Particularly helpful Moodlers

Well, I was trying to avoid commenting. Backup and restore problems can be nasty.

Acutally, you can use someone else's backup to reproduce the issue. The restore will work the first time, because it is creating all new questions. However, if you restore the backup a second time, that will break, and you can investigate the problem. If you are lucky. For some meanings of the word lucky.

 
Average of ratings: -
Picture of Rob Johnson
Re: error/error_question_answers_missing_in_db when importing a quiz
Group Particularly helpful Moodlers

I agree that commenting out the lines of code is not good practice.  I only did that as a temporary solution.  My current installation (2.3.3)  has been consistently importing with the code intact.

The questions from Examview I suspect have issues were imported prior to your code changes to the BB import.  Some were imported using the original 1.9 plugin, and others with yours and Gerry Jenkins plugins when we upgraded to 2.1.  What was interesting about the error when I first encountered it was I could get imports to work by moving questions out of the system level category.

 
Average of ratings: -
Picture of Melissa Benson
Re: error/error_question_answers_missing_in_db when importing a quiz
Group Testers

Alright, so I think I'm more confused that i started out smile I read the responses a fewtimes but I'm not sure if 1.) do we know what caused the issue? and 2.) Is there a solution or not, besides commenting out the code?

So is it an issue with the course, the question, the quiz? Doesn't it have to be the course? I can import all I want with one quiz but as soon as it gets into this specific course...it's not able to be imported anywhere else.

On a side note (or maybe not a side note) in Moodle 1.9 we used an examview plugin that successfully imported examview questions WITH images. I believe this non-core plugin was needed to bring over the images.

We are now on a Moodle 2 server and I uploaded that same examview plugin because I figured I still needed it. Now, I think that's not needed - is it? If the core plugin for examview works, with images and all, I'd like to remove the one that's not needed.

 

 
Average of ratings: -
Picture of Jean-Michel Védrine
Re: error/error_question_answers_missing_in_db when importing a quiz
Group DevelopersGroup Particularly helpful Moodlers

Its an isssue with a question that exists both in the course and in the backup file (well in fact it can be several questions not one. impossible to say now)

I would be very interested to find what are the characters in questions causing that problem but unfortunately that's a difficult problem. I think we need to log the offending questions during backup rather than raising an exception so that the backup don't stop and you can send me the log and we finally nail this bug.

What precise version of Moodle are you using ? To my best knowledge all zip files created by Examview recent versions can be imported without any plugin in Moodle starting with versions 2.2.5, 2.3.2, 2.4. 

You just select Question Bank -> import and choose the "Blackboard V6+" file format. Images are imported too. If it doesn't work, please can you send me a file that fails to import so that I can correct the code.

Side note: You say "I uploaded the same plugin because I figured I still needed it" but I don't think any plugin made for Moodle 1.9 can work with Moodle 2.x. How is this possible (just curious) ?

In any case I would be very interested by your backup file if there is no confidentiality problem that prevent you from sending it to me.

 
Average of ratings: -
Picture of Melissa Benson
Re: error/error_question_answers_missing_in_db when importing a quiz
Group Testers

Moodle 2.4.1+ (Build: 20130131)

It was from this thread I think: https://moodle.org/mod/forum/discuss.php?d=117876#p517004 . I emailed someone from that thread asking if this plugin works in Moodle 2 and he said yes.

Perhaps you can clarify the difference (if any?) between the plugin I'm using and the one that comes in the core. I see some posts by you in that thread.

I will have to check to see if importing with the core process works (I think it does with images and stuff, where I didn't think it did in 1.9). I thought I still needed this plugin so I installed it in Moodle 2 as well.

Sure, I can send you the backup file, I'd prefer over email or somehow so it's not public. I will have to get a fresh backup and make sure there's no user data.

I'm working with our linux server support so I can see if we can get some logs and stuff. I'll connect with him tomorrow.

 

 
Average of ratings: -
Picture of Jean-Michel Védrine
Re: error/error_question_answers_missing_in_db when importing a quiz
Group DevelopersGroup Particularly helpful Moodlers

The code wich is now in Moodle "Balckboard V6+" import format and the plugin you were using are quite similar but there are some differences

  • The core format has code to import all variants of "Blackboard" files, not only the one from Examview you are using, but also files generated by Testgen and Blackboard itself. So the core format is more general. It is in fact 2 formats in one : the "Blackboard V6+" format that was in Moodle 1.9 and the Examview format that was contributed by Micheal Tanczos and many others. My goal in writting it was that it was able to import "all" Blackboard files so that Moodle users don't have to think "What import format should I use for my Blackboard file ?" they just select "Blackboard V6+" and that's all smile.
  • I fixed some bugs in the code while testing it on a lot of files send by users. For instance match questions were not always imported, Now all match questions should import fine unless they don't have enough subquestions/subanswers (Moodle has some rules on this that Blackboard hasn't)
  • The code to import images in core is completely new and should use less memory so you can import bigger files

As a general rule I would advise anybody to use the core import format and report if a file fails to import.

My mail so you can send me your backup file is vedrine _AT__ vedrine __DOT_ net.

 

 
Average of ratings: -
Picture of Melissa Benson
Re: error/error_question_answers_missing_in_db when importing a quiz
Group Testers

Okay...well now this is weird. I'm trying to back the course up and it's giving me a "You must enter a valid filename for this backup". I've tried renaming it to a shorter name thinking that was the issue but still the error.

What in the world???

I do see backups from the auto backup we do twice a week though. It is almost 900 MB though..not going to fly over email :/ any way else? Or should I try backing up just a few quizzes?

By the way - other courses back up just fine.

 

Also, I belive the "examview" one is the one I should remove. Why is there two other blackboard ones?

 


 
Average of ratings: -
Picture of Jean-Michel Védrine
Re: error/error_question_answers_missing_in_db when importing a quiz
Group DevelopersGroup Particularly helpful Moodlers

His as I said only the "Blackboard V6+" is now really needed and is able to import all Blackboard files. The  "Blackboard" format is no more needed and we should certainly remove it in Moodle 2.5 because it is confusing. In the past it was used to import some Blackboard files that the Blackboard V6+ is now able to handle.

I will create a tracker issue.

 
Average of ratings: -
Picture of Melissa Benson
Re: error/error_question_answers_missing_in_db when importing a quiz
Group Testers

Oh, gotchya. I thought blackboard was already removed.

 

What do you think about me not being able to back up the problem course to send to you?

 
Average of ratings: -
Picture of Jean-Michel Védrine
Re: error/error_question_answers_missing_in_db when importing a quiz
Group DevelopersGroup Particularly helpful Moodlers

To Melissa:

I am puzzled by your problem to backup the course. Looking at the code the only way you can get the  "You must enter a valid filename for this backup" error message is if the filename is invalid or empty !

To Rob:

The key point for this error message is that it can only happens if Moodle think that the question is already existing in that context, so if moving something solves this issue it is because in the new context Moodle think the question doesn't exist so it creates it and this part of the code is not executed so the error cannot occur.

 
Average of ratings: -
Picture of Melissa Benson
Re: error/error_question_answers_missing_in_db when importing a quiz
Group Testers

Argh. More confused than ever. So do you think Rob and my issue are different? He's talking about where the questions are-course and system. I don't see any difference between the quizzes in the problem course and quizzes in other working courses. Quizzes that work in every other course don't work once in the problem course sad

Where can I go from here, anything to try?- is there a ticket for this specific issue?

On another note, what's the best way remove the extra examview import type. Simply deleting the files via FTP? Or is there somewhere in the moodle interface ro disable it? Thanks!

 
Average of ratings: -
Picture of Jean-Michel Védrine
Re: error/error_question_answers_missing_in_db when importing a quiz
Group DevelopersGroup Particularly helpful Moodlers

hello Melissa,

Sorry English is not my native language so it seems I confused you.

  1. I think your problem about problem during restore of a backup with questions with the message "error_question_answers_missing in_db" and Rob's one are the same
  2. Your problem of not being able to backup this course is something totally different and IMHO totally unrelated to your problem with questions. It is something with the name of your backup not with its content and I don't understand with Moodle think your backup's name is empty. But it has nothing to do with the message "error_question_answers_missing_in_db". Absolutely nothing.
  3. Simply deleting the content of the subfolder is OK for a question import format because they don't have any database tables associated. Currently there is no way to simply disable a question import format without removing the files.
 
Average of ratings: -
Picture of Joe Chapman
Re: error/error_question_answers_missing_in_db when importing a quiz
 

Here's some more info on the Exact issue Melissa is experiencing:

With full debug on, this fails with this output:

error/error_question_answers_missing_in_db

More information about this error

Debug info: 
Error code: error_question_answers_missing_in_db
$a contents: stdClass Object
(
[filequestionid] => 21775
[dbquestionid] => 56234
[answer] => 3.14
)
Stack trace:
line 182 of /backup/moodle2/restore_qtype_plugin.class.php: restore_step_exception thrown
line 131 of /backup/util/plan/restore_structure_step.class.php: call to restore_qtype_plugin->process_question_answer()
line 103 of /backup/util/helper/restore_structure_parser_processor.class.php: call to restore_structure_step->process()
line 125 of /backup/util/xml/parser/processors/grouped_parser_processor.class.php: call to restore_structure_parser_processor->dispatch_chunk()
line 91 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 169 of /backup/util/xml/parser/progressive_parser.class.php: call to progressive_parser_processor->receive_chunk()
line 253 of /backup/util/xml/parser/progressive_parser.class.php: call to progressive_parser->publish()
line ? of unknownfile: call to progressive_parser->end_tag()
line 158 of /backup/util/xml/parser/progressive_parser.class.php: call to xml_parse()
line 137 of /backup/util/xml/parser/progressive_parser.class.php: call to progressive_parser->parse()
line 105 of /backup/util/plan/restore_structure_step.class.php: call to progressive_parser->process()
line 153 of /backup/util/plan/base_task.class.php: call to restore_structure_step->execute()
line 163 of /backup/util/plan/base_plan.class.php: call to base_task->execute()
line 157 of /backup/util/plan/restore_plan.class.php: call to base_plan->execute()
line 315 of /backup/controller/restore_controller.class.php: call to restore_plan->execute()
line 130 of /backup/import.php: call to restore_controller->execute_plan()

=====

mysql> SELECT * FROM mdl_question_answers WHERE question = 21775\G
*************************** 1. row ***************************
            id: 108797
      question: 21775
        answer: 3.14
  answerformat: 0
      fraction: 0.0000000
      feedback: 
feedbackformat: 1
*************************** 2. row ***************************
            id: 108798
      question: 21775
        answer: 2.71828
  answerformat: 0
      fraction: 0.0000000
      feedback: 
feedbackformat: 1
*************************** 3. row ***************************
            id: 108799
      question: 21775
        answer: π,
  answerformat: 0
      fraction: 0.0000000
      feedback: 
feedbackformat: 1
*************************** 4. row ***************************
            id: 108800
      question: 21775
        answer: 6.02 x 10^23
  answerformat: 0
      fraction: 1.0000000
      feedback: 
feedbackformat: 1
*************************** 5. row ***************************
            id: 108801
      question: 21775
        answer: 6 x 10^23
  answerformat: 0
      fraction: 0.5000000
      feedback: 
feedbackformat: 1
5 rows in set (0.00 sec)

If we comment out line 182 from /moodle/backup/moodle2/restore_qtype_plugin.class.php:
throw new restore_step_exception('error_question_answers_missing_in_db', $info);
it seems to work, however this isn't a proper solution.

If there's more info I can get to assist with this please let me know.

Thanks!

 
Average of ratings: -
Picture of Jean-Michel Védrine
Re: error/error_question_answers_missing_in_db when importing a quiz
Group DevelopersGroup Particularly helpful Moodlers

Hello Joe,

Thanks a lot for this report, this is exactly what is needed.

The stack trace seems to be what I was expecting but I am rather puzzled by the other infos:

If I read it correctly 21775 is the question id in the backup and 56234 is the question id in database. So the code is trying to find a record in the mdl_question_answers table with 56234 as question value and 3.14 as answer value

Can you give me the result of the query SELECT * FROM mdl_question_answers WHERE question = 56234

Now that we have a precise question where restore is failing I am sure we will manage to find what the bug is.

 
Average of ratings: -
Picture of Jean-Michel Védrine
Re: error/error_question_answers_missing_in_db when importing a quiz
Group DevelopersGroup Particularly helpful Moodlers

I forgot to ask if you can get some info about the π, answer

This seems to be some garbled characters (maybe a pi character) resulting from a wrong encoding during import.

 
Average of ratings: -
Picture of Joe Chapman
Re: error/error_question_answers_missing_in_db when importing a quiz
 

Here's the query you asked for:

 

mysql> 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
4 rows in set (0.00 sec)

mysql>

 

as for the extraneous character, there seem to be a lot in the database... my best guess is it was a pi symbol

 
Average of ratings: -
Picture of Joe Chapman
Re: error/error_question_answers_missing_in_db when importing a quiz
 

Any additional thoughts on this?
Thanks

-Joe

 

 
Average of ratings: -
Picture of Jean-Michel Védrine
Re: error/error_question_answers_missing_in_db when importing a quiz
Group DevelopersGroup Particularly helpful Moodlers

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 ?

 
Average of ratings: -
Picture of Melissa Benson
Re: error/error_question_answers_missing_in_db when importing a quiz
Group Testers

Hi Jean, this is regarding the blackboard v6+ import of questions. You said that the "blackboard" format should be removed in 2.5 because blackboard v6+ does the same thing. I was wondering what file format the "blackboard" format takes though (just out of curiosity) because the zip file won't work.

But my main question is what does "Examview" do? I thought that was the plugin that I installed but it's not, the core of Moodle contains an "Examview" format. Is this needed? What is it for?

Thanks, just trying to wrap my head around it as I'm making instructions for our teachers to use the blackboard v7+.

 
Average of ratings: -
Picture of Rob Johnson
Re: error/error_question_answers_missing_in_db when importing a quiz
Group Particularly helpful Moodlers

Hi Melissa,

The Examview import is for Examview XML files generated with Examview 4.  This is a very old version of Examview, though I have heard that the Mac version of Examview 5 still had that option (our recent textbooks come with Examview 7).  Those XML files will import questions, but not images withing the questions.

 
Average of ratings: -
Picture of Melissa Benson
Re: error/error_question_answers_missing_in_db when importing a quiz
Group Testers

Thank you!

 
Average of ratings: -
Tim at Lone Pine Koala Sanctuary
Re: error/error_question_answers_missing_in_db when importing a quiz
Group DevelopersGroup Documentation writersGroup Particularly helpful Moodlers

Well, then someone should make some Examview 7 files publicly available, so that it is possible to fix Moodle to import them. Without example files, we (and by that I probably mean Jean-Michel who seem to be the only person who every fixes import formats) cannot do anything.

 
Average of ratings: -
Picture of Rob Johnson
Re: error/error_question_answers_missing_in_db when importing a quiz
Group Particularly helpful Moodlers

The updates Jean Michel made last year to the Blackboard V6+ import work for BB files exported with Examview 5, 6 and 7.   Those versions can export as BB 6 or 7.1.

 
Average of ratings: -
Picture of Jean-Michel Védrine
Re: error/error_question_answers_missing_in_db when importing a quiz
Group DevelopersGroup Particularly helpful Moodlers

Rob is right,

All files created by recent Examview versions should import without any problem (including images !) using the "Blackboard v6+" Moodle import format as long as you select the correct Blackboard format in Examview when doing the export.

if an imprt fail using "Blackboard v6+" this is a bug, report it opening a new issue in the Moodle Tracker and don't forget to join a sample file failing to import if you want me to be able to look at the problem.

 

 
Average of ratings: -
Picture of Jean-Michel Védrine
Re: error/error_question_answers_missing_in_db when importing a quiz
Group DevelopersGroup Particularly helpful Moodlers

Hello Melissa,

the old "Blackboard" was accepting only .dat files and "Blackboard V6+" was accepting either .dat (but not the same ones  wink !) or .zip files and there was a contributed "Examview" format different from the "Examview" format in Moodle core that was accepting some other .zip files not correctly imported by "Blackboard V6+" big grin;

As you can guess the situation was a nightmare and teachers most often didn't know what format to use to import their files !!

Since last year there is an unique format to import all files .dat and .zip

In Moodle 2.3 and 2.4 this format "to import them all" is labelled "Blackbard v6+" on the screen where you choose your import format when importing a file.

It is not possible to remove a plugin in Moodle stable branchs after they are released so there is also another format labeled "Blackboard" in the list. You should never choose this format always choose "Blackboard V6+"; Always, always, always ;...

In Moodle 2.5 there will be only a single line labelled simply "Blackboard" so I hope all Moodle users will know what format they need to choose smile without any risk of confusion !

of course when you choose "Blackboard" in moodle 2.5 you are in fact using the same code as "Blackboard v6+" in previous Moodle versions.

 
Average of ratings: -
Picture of Rob Johnson
Re: error/error_question_answers_missing_in_db when importing a quiz
Group Particularly helpful Moodlers

What is most confusing for me with this error is why quizzes that throw the error with questions at the system level will import fine if I move those questions to a course level category.

 
Average of ratings: -