Moodle
  1. Moodle
  2. MDL-26442

Error when importing quiz with system level questions from Moodle 2.0 course (which was imported from 1.9) to another Moodle 2.0 course on the same site

    Details

    • Type: Bug Bug
    • Status: Reopened
    • Priority: Critical Critical
    • Resolution: Unresolved
    • Affects Version/s: 2.0.1, 2.3.3, 2.4.4, 2.5.4
    • Fix Version/s: STABLE backlog
    • Component/s: Backup, Quiz
    • Environment:
      php: 5.3.3
      mysql: 5.5.9
      server: MacOS 10.6.6
    • Database:
      MySQL
    • Difficulty:
      Difficult
    • Affected Branches:
      MOODLE_20_STABLE, MOODLE_23_STABLE, MOODLE_24_STABLE, MOODLE_25_STABLE
    • Rank:
      16039

      Description

      Recently successfully upgraded 1.9.10+ to 2.0.1+. In 1.9.10+, the bulk of my questions were at the system level. Also in 1.9.10+, we had several non-standard question types: drag-and-drop matching, ordering...

      Here's what I did that caused the error:
      In 2.0.1+, I made a new course.
      From Course Administration of my new course, clicked 'Import'.
      Choose the course to import from (one that was upgraded from 1.9.10+ to 2.0.1). For backup settings, I only choose 'include activities' (i.e. unchecked include blocks and include filters)

      3 scenarios from here:
      1) If I choose to import a resource, the import was successful
      2) If I choose to import a quiz where the questions are course level, the import was successful
      3) If I choose to import a quiz where the questions are site level, the import fails and I get a white screen with this message:
      Fatal error: Call to undefined function restore_step_exception() in /Library/WebServer/Documents/moodle/question/type/match/backup/moodle2/restore_qtype_match_plugin.class.php on line 118

      I tried several different quizzes with the same results. None of quizzes used any non-standard type question types that were on the Moodle 1.9 system.

      If I create a new quiz, I can successfully use the existing questions in the question bank (the same ones that caused the import error).

      Any help resolving this issue would be greatly appreciated.

        Issue Links

          Activity

          Andrew Johnson created issue -
          Hide
          Eloy Lafuente (stronk7) added a comment -

          Hi Andrew,

          just some hours ago, we have fixed MDL-26405, that included two changes related with your problem.

          Can you confirm if current code available at git/cvs causes your problem to disappear?

          • In the worst case, you'll get a different error.
          • In the best one, the problem will be out (given your description, I think this has high chances to happen).

          I keep this open awaiting for feedback, thanks!

          PS: Note that I'm rebuilding the moodle download packages right now, so they don't contain the fix yet. In less than 1 hour from now, the fix will be included.

          Show
          Eloy Lafuente (stronk7) added a comment - Hi Andrew, just some hours ago, we have fixed MDL-26405 , that included two changes related with your problem. Can you confirm if current code available at git/cvs causes your problem to disappear? In the worst case, you'll get a different error. In the best one, the problem will be out (given your description, I think this has high chances to happen). I keep this open awaiting for feedback, thanks! PS: Note that I'm rebuilding the moodle download packages right now, so they don't contain the fix yet. In less than 1 hour from now, the fix will be included.
          Eloy Lafuente (stronk7) made changes -
          Field Original Value New Value
          Link This issue duplicates MDL-26405 [ MDL-26405 ]
          Eloy Lafuente (stronk7) made changes -
          Labels triaged
          Fix Version/s STABLE backlog [ 10463 ]
          Difficulty Difficult
          Hide
          Andrew Johnson added a comment -

          Hi Eloy,

          Thank you very much for your quick response and your help on this!

          We installed the latest Moodle (Build 20110217). Unfortunately, we are getting the same error as before:
          Fatal error: Call to undefined function restore_step_exception() in /Library/WebServer/Documents/moodle/question/type/match/backup/moodle2/restore_qtype_match_plugin.class.php on line 118

          Sorry we don't have anything more positive to report. Hopefully it's an easy fix
          Cheers,
          Andrew

          Show
          Andrew Johnson added a comment - Hi Eloy, Thank you very much for your quick response and your help on this! We installed the latest Moodle (Build 20110217). Unfortunately, we are getting the same error as before: Fatal error: Call to undefined function restore_step_exception() in /Library/WebServer/Documents/moodle/question/type/match/backup/moodle2/restore_qtype_match_plugin.class.php on line 118 Sorry we don't have anything more positive to report. Hopefully it's an easy fix Cheers, Andrew
          Hide
          Eloy Lafuente (stronk7) added a comment -

          Ah Andrew,

          I read your error way too quick, it is "similar" to the linked one, but not the same cause:

          1) There is one missing "new" there, so you should be getting exception instead of fatal error. That will be fixed for next week. 100% sure.
          2) The point above doesn't fix the original problem. It seems, given the error, that something is wrong with one of your "match" questions and there is one "submatch" question not found. Hence it throws one exception.

          Can you provide me one backup file, without users or anonymized, that doesn't matter, containing one quiz using those questions? That way, I'll be able to reproduce it here and:

          a) Tell you which questions are the problematic ones.
          b) Try to find some workaround for that situation (although initially I continue thinking restore code is ok, perhaps we'll detect some real bug).

          TIA and ciao

          Show
          Eloy Lafuente (stronk7) added a comment - Ah Andrew, I read your error way too quick, it is "similar" to the linked one, but not the same cause: 1) There is one missing "new" there, so you should be getting exception instead of fatal error. That will be fixed for next week. 100% sure. 2) The point above doesn't fix the original problem. It seems, given the error, that something is wrong with one of your "match" questions and there is one "submatch" question not found. Hence it throws one exception. Can you provide me one backup file, without users or anonymized, that doesn't matter, containing one quiz using those questions? That way, I'll be able to reproduce it here and: a) Tell you which questions are the problematic ones. b) Try to find some workaround for that situation (although initially I continue thinking restore code is ok, perhaps we'll detect some real bug). TIA and ciao
          Hide
          Andrew Johnson added a comment -

          After upgrading from 1.9.10+, I didn't expect 3rd party question types to be available in Moodle 2 since we haven't installed those question types yet. I'm not sure if that is a problem or not.
          We had 3 non-standard question types in our 1.9 installation:
          -drag & drop matching
          -ordering
          -ordering
          (Note: the two ordering types are different)

          Show
          Andrew Johnson added a comment - After upgrading from 1.9.10+, I didn't expect 3rd party question types to be available in Moodle 2 since we haven't installed those question types yet. I'm not sure if that is a problem or not. We had 3 non-standard question types in our 1.9 installation: -drag & drop matching -ordering -ordering (Note: the two ordering types are different)
          Andrew Johnson made changes -
          Hide
          Andrew Johnson added a comment -

          Hi again,

          Unfortunately I don't know which questions are the problematic ones.

          (Almost) all of my questions are at the system level (which were possibly reshuffled during the import from 1.9.10 to 2).
          If I try to import any quiz which utilizes the system level questions, I get the error. For example, I just tried an import with only one quiz that contained only short answer questions and I got the error. I seems the import is not only looking at the questions I am trying to import, but rather ALL the system level questions.

          I should also note that the quizzes I am trying to import use the random question pull.

          I added a screen shot of part of our question bank showing missing question types. I tried deleting the 'missing' questions from the system question bank, but that didn't seem to make a difference. Perhaps deleting them directly in the database via phpmyadmin or is that dangerous?

          Show
          Andrew Johnson added a comment - Hi again, Unfortunately I don't know which questions are the problematic ones. (Almost) all of my questions are at the system level (which were possibly reshuffled during the import from 1.9.10 to 2). If I try to import any quiz which utilizes the system level questions, I get the error. For example, I just tried an import with only one quiz that contained only short answer questions and I got the error. I seems the import is not only looking at the questions I am trying to import, but rather ALL the system level questions. I should also note that the quizzes I am trying to import use the random question pull. I added a screen shot of part of our question bank showing missing question types. I tried deleting the 'missing' questions from the system question bank, but that didn't seem to make a difference. Perhaps deleting them directly in the database via phpmyadmin or is that dangerous?
          Eloy Lafuente (stronk7) made changes -
          Status Open [ 1 ] In Progress [ 3 ]
          Hide
          Eloy Lafuente (stronk7) added a comment -

          Hi Andrew,

          as commented I've been able to restore your (huge) system category question bank here in my test server.

          So I guess that your problems are caused because, somehow, there are some "broken" questions in your server.

          So my plan is about:

          • Fix the missing "new" I commented above. It doesn't affect current behavior nor results but better to have it fixed.
          • Improve restore so it displays more information on error, making easier to detect the problematic question and so on (MDL-22149, MDL-25382)
          • Improve restore to avoid browser / timeouts and other errors that can lead to "broken" questions if the process stops in the middle (MDL-22143)

          I'll keep this open to see how things are progressing... ciao

          Show
          Eloy Lafuente (stronk7) added a comment - Hi Andrew, as commented I've been able to restore your (huge) system category question bank here in my test server. So I guess that your problems are caused because, somehow, there are some "broken" questions in your server. So my plan is about: Fix the missing "new" I commented above. It doesn't affect current behavior nor results but better to have it fixed. Improve restore so it displays more information on error, making easier to detect the problematic question and so on ( MDL-22149 , MDL-25382 ) Improve restore to avoid browser / timeouts and other errors that can lead to "broken" questions if the process stops in the middle ( MDL-22143 ) I'll keep this open to see how things are progressing... ciao
          Eloy Lafuente (stronk7) made changes -
          Link This issue has been marked as being related by PULL-338 [ PULL-338 ]
          Hide
          Eloy Lafuente (stronk7) added a comment -

          I've created PULL-338 to fix the missing "new" above.

          As commented, this will remain open until the issues above are fixed / improved.

          Ciao

          Show
          Eloy Lafuente (stronk7) added a comment - I've created PULL-338 to fix the missing "new" above. As commented, this will remain open until the issues above are fixed / improved. Ciao
          Hide
          Andrew Johnson added a comment -

          Thank you for digging deeper on this issue!

          As you noted, I've got a lot of system level questions. Due to the large number of courses I taught which often recycled the same questions and the ability to share with other teacher/admins, system level questions seemed the way to go way back in Moodle 1.7 or 1.8. With the new improvements in the file system in Moodle 2.0, your words of caution against such large system level question banks sound wise. It will take some time but I will try to start converting some of the system level to course/category level questions. Hopefully deleting unneeded system level questions via the question interface will not leave any residue in the database that can cause future problems.

          I will try to upgrade to your latest code this week. If it can help detect problem questions as you say it can, then hopefully deleting those questions will fix our problems.

          Cheers!

          Show
          Andrew Johnson added a comment - Thank you for digging deeper on this issue! As you noted, I've got a lot of system level questions. Due to the large number of courses I taught which often recycled the same questions and the ability to share with other teacher/admins, system level questions seemed the way to go way back in Moodle 1.7 or 1.8. With the new improvements in the file system in Moodle 2.0, your words of caution against such large system level question banks sound wise. It will take some time but I will try to start converting some of the system level to course/category level questions. Hopefully deleting unneeded system level questions via the question interface will not leave any residue in the database that can cause future problems. I will try to upgrade to your latest code this week. If it can help detect problem questions as you say it can, then hopefully deleting those questions will fix our problems. Cheers!
          Hide
          Eloy Lafuente (stronk7) added a comment -

          Thanks for feedback Andrew,

          just to clarify the change @ PULL-338 it's just one syntax fix but it won't cause any improvement in problems detection / restore robustness.

          On Mondays (today) we start the integration process so you won't see any improvement in those areas until, at least, next week's Wednesday.

          In any case I'd recommend you to upgrade also this Wednesday as far as some other issues have been lately fixed in backup & restore.

          Ciao, let's see how this evolves!

          Show
          Eloy Lafuente (stronk7) added a comment - Thanks for feedback Andrew, just to clarify the change @ PULL-338 it's just one syntax fix but it won't cause any improvement in problems detection / restore robustness. On Mondays (today) we start the integration process so you won't see any improvement in those areas until, at least, next week's Wednesday. In any case I'd recommend you to upgrade also this Wednesday as far as some other issues have been lately fixed in backup & restore. Ciao, let's see how this evolves!
          Hide
          Peter Ruthven-Stuart added a comment -

          Eloy,

          Thank you for working on this bug.

          I'm a colleague of Andrew, and have just upgraded our Moodle system via CVS to the most recent version. This didn't fix the import bug, as you pointed out above, so looking forward to next Wednesday's update.

          Show
          Peter Ruthven-Stuart added a comment - Eloy, Thank you for working on this bug. I'm a colleague of Andrew, and have just upgraded our Moodle system via CVS to the most recent version. This didn't fix the import bug, as you pointed out above, so looking forward to next Wednesday's update.
          Hide
          Emma Richardson added a comment -

          I was having this same error and also thought it was because my questions were at the system level. However, I found out that it was actually specific to one course. I could import the same exact quiz with same exact questions when they were created in another course. You might try loading the same quiz into a different course and seeing if it will import from there. I have not been able to figure what was causing the error within the course and gave up after finding the work around as my teacher now just creates the quizzes in a different section and has no problem now.

          Show
          Emma Richardson added a comment - I was having this same error and also thought it was because my questions were at the system level. However, I found out that it was actually specific to one course. I could import the same exact quiz with same exact questions when they were created in another course. You might try loading the same quiz into a different course and seeing if it will import from there. I have not been able to figure what was causing the error within the course and gave up after finding the work around as my teacher now just creates the quizzes in a different section and has no problem now.
          Hide
          Peter Ruthven-Stuart added a comment -

          Hello Eloy,

          I have just updated to Moodle 2.0.2+ (Build: 20110303).

          Doing the exact same thing as reported above by Andrew Johnson in the same Moodle system (http://tel.c.fun.ac.jp/FUNmoodleTWO), I now get a slightly less dramatic error:

          error/error_question_match_sub_missing_in_db

          So an improvement? Does this help us get closer to a solution?

          I attempted to import two different quizzes: one with a single standard matching type question, and another with some standard short answer type questions. Both attempts resulted in the same error message. You can confirm this with the login details that Andrew has supplied you with.

          Show
          Peter Ruthven-Stuart added a comment - Hello Eloy, I have just updated to Moodle 2.0.2+ (Build: 20110303). Doing the exact same thing as reported above by Andrew Johnson in the same Moodle system ( http://tel.c.fun.ac.jp/FUNmoodleTWO ), I now get a slightly less dramatic error: error/error_question_match_sub_missing_in_db So an improvement? Does this help us get closer to a solution? I attempted to import two different quizzes: one with a single standard matching type question, and another with some standard short answer type questions. Both attempts resulted in the same error message. You can confirm this with the login details that Andrew has supplied you with.
          Hide
          Brian Stocker added a comment -

          So if I understand correctly, courses with system level questions cannot be duplicated using import or backup/restore? Any suggestions?

          Here is the error I get:

          10 or 12 instances of this:

          Error: mdb->get_record() found more than one record!

          • line 1268 of /lib/dml/moodle_database.php: call to debugging()
          • line 1331 of /lib/dml/moodle_database.php: call to moodle_database->get_record_sql()
          • line 134 of /backup/moodle2/restore_qtype_plugin.class.php: call to moodle_database->get_field_sql()
          • line 119 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 106 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 127 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 243 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 99 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 148 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 299 of /backup/controller/restore_controller.class.php: call to restore_plan->execute()
          • line 130 of /backup/import.php: call to restore_controller->execute_plan()

          Fatal error: Call to undefined function restore_step_exception() in /home/public_html/backup/moodle2/restore_qtype_plugin.class.php on line 142

          Show
          Brian Stocker added a comment - So if I understand correctly, courses with system level questions cannot be duplicated using import or backup/restore? Any suggestions? Here is the error I get: 10 or 12 instances of this: Error: mdb->get_record() found more than one record! line 1268 of /lib/dml/moodle_database.php: call to debugging() line 1331 of /lib/dml/moodle_database.php: call to moodle_database->get_record_sql() line 134 of /backup/moodle2/restore_qtype_plugin.class.php: call to moodle_database->get_field_sql() line 119 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 106 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 127 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 243 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 99 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 148 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 299 of /backup/controller/restore_controller.class.php: call to restore_plan->execute() line 130 of /backup/import.php: call to restore_controller->execute_plan() Fatal error: Call to undefined function restore_step_exception() in /home/public_html/backup/moodle2/restore_qtype_plugin.class.php on line 142
          Hide
          Christian Stern added a comment -

          Hi,

          after upgrading to Moodle 2.0.2+ (Build 20110223) we encounterd an error trying to restore a question.

          One of our professors hat a separate course where he prepares quizes and questions for the students (not accessible to them). In Moodle 1.9.x he usually "copied" the questions to the student's course by importing them from the "test course".

          Using Moodle 2.0 this import routine fails with the error:
          "error/error_question_answers_missing_in_db".

          After setting the debugging mode, we could retrieve following error messages from the PHP-errorlog:

          [24-Mar-2011 10:55:06] instantiating backup controller 5987f524f65e20eff557335b24e11894
          [24-Mar-2011 10:55:06] setting controller status to 100
          [24-Mar-2011 10:55:06] loading controller plan
          [24-Mar-2011 10:55:06] setting controller status to 300
          [24-Mar-2011 10:55:06] applying plan defaults
          [24-Mar-2011 10:55:06] setting controller status to 400
          [24-Mar-2011 10:55:06] checking plan security
          [24-Mar-2011 10:55:07] setting controller status to 500
          [24-Mar-2011 10:55:07] checking plan security
          [24-Mar-2011 10:55:07] checking plan security
          [24-Mar-2011 10:55:07] checking plan security
          [24-Mar-2011 10:55:07] saving controller to db
          [24-Mar-2011 10:55:07] calculating controller checksum ed4d9c9f779bc79dfdf1e39940883613
          [24-Mar-2011 10:55:14] loading controller from db
          [24-Mar-2011 10:55:14] checking plan security
          [24-Mar-2011 10:55:14] checking plan security
          [24-Mar-2011 10:55:14] checking plan security
          [24-Mar-2011 10:55:14] saving controller to db
          [24-Mar-2011 10:55:14] calculating controller checksum 8dbcbd7c13d07d4fc8cb1ffaad84cd57
          [24-Mar-2011 10:55:57] loading controller from db
          [24-Mar-2011 10:55:57] checking plan security
          [24-Mar-2011 10:55:58] checking plan security
          [24-Mar-2011 10:55:58] checking plan security
          [24-Mar-2011 10:55:58] saving controller to db
          [24-Mar-2011 10:55:58] calculating controller checksum 93a94b9f4d165a71237d22cdc05884e0
          [24-Mar-2011 10:56:05] loading controller from db
          [24-Mar-2011 10:56:05] checking plan security
          [24-Mar-2011 10:56:05] checking plan security
          [24-Mar-2011 10:56:05] setting controller status to 700
          [24-Mar-2011 10:56:05] saving controller to db
          [24-Mar-2011 10:56:05] calculating controller checksum 4506230625321515c6fdc88c9327111a
          [24-Mar-2011 10:56:05] loading controller from db
          [24-Mar-2011 10:56:05] setting controller status to 800
          [24-Mar-2011 10:56:11] section skipped by _included setting
          [24-Mar-2011 10:56:11] activity skipped by _included setting Nachrichtenforum
          [24-Mar-2011 10:56:11] activity skipped by _included setting Allgemeines Forum zur Vorlesung
          [24-Mar-2011 10:56:11] activity skipped by _included setting Literaturliste zu den Vorlesungen Analysis und Lineare Algebra
          [24-Mar-2011 10:56:11] activity skipped by _included setting Einschreibung ins Tutorium
          [24-Mar-2011 10:56:11] activity skipped by _included setting Glossar Analysis 1
          [24-Mar-2011 10:56:11] section skipped by _included setting 1
          [24-Mar-2011 10:56:11] activity skipped by _included setting Übungsblatt 1
          [24-Mar-2011 10:56:11] activity skipped by _included setting Forum zum Thema "Grundlagen"
          [24-Mar-2011 10:56:11] activity skipped by _included setting Ihre Meinung zur Mathematik
          [24-Mar-2011 10:56:11] section skipped by _included setting 2
          [24-Mar-2011 10:56:11] activity skipped by _included setting Übungsblatt 2
          [24-Mar-2011 10:56:11] activity skipped by _included setting Forum zum Thema "Funktionen"
          [24-Mar-2011 10:56:11] activity skipped by _included setting Ihre Meinung zu Moodle
          [24-Mar-2011 10:56:11] section skipped by _included setting 3
          [24-Mar-2011 10:56:11] activity skipped by _included setting Übungsblatt 3
          [24-Mar-2011 10:56:11] activity skipped by _included setting Forum zum Thema "Elementare Funktionen - 1. Teil"
          [24-Mar-2011 10:56:11] activity skipped by _included setting Einstieg und Aufwand fürs Studium
          [24-Mar-2011 10:56:11] section skipped by _included setting 4
          [24-Mar-2011 10:56:11] activity skipped by _included setting Übungsblatt 4
          [24-Mar-2011 10:56:11] activity skipped by _included setting Forum zum Thema "Elementare Funktionen - 2. Teil"
          [24-Mar-2011 10:56:11] activity skipped by _included setting Bekanntheit des bisherigen Stoffes
          [24-Mar-2011 10:56:11] section skipped by _included setting 5
          [24-Mar-2011 10:56:11] activity skipped by _included setting Übungsblatt 5
          [24-Mar-2011 10:56:11] activity skipped by _included setting Forum zum Thema "Grenzwerte"
          [24-Mar-2011 10:56:11] activity skipped by _included setting Ihre Meinung zu den Übungsblättern
          [24-Mar-2011 10:56:11] activity skipped by _included setting Ihre Meinung zu den Pflichtabgaben
          [24-Mar-2011 10:56:11] section skipped by _included setting 6
          [24-Mar-2011 10:56:11] activity skipped by _included setting Übungsblatt 6
          [24-Mar-2011 10:56:11] activity skipped by _included setting Forum zum Thema "Differenzialrechnung"
          [24-Mar-2011 10:56:11] activity skipped by _included setting Ihre Meinung zum Tutorium
          [24-Mar-2011 10:56:11] section skipped by _included setting 7
          [24-Mar-2011 10:56:11] activity skipped by _included setting Übungsblatt 7
          [24-Mar-2011 10:56:11] activity skipped by _included setting Forum zum Thema "Anwendungen der Differenzialrechnung"
          [24-Mar-2011 10:56:11] activity skipped by _included setting Ihre Meinung zu Moodle (2. Umfrage)
          [24-Mar-2011 10:56:11] activity skipped by _included setting Angst vor der Klausur?
          [24-Mar-2011 10:56:11] activity skipped by _included setting Maple-Worksheet zum Newton-Verfahren
          [24-Mar-2011 10:56:11] activity skipped by _included setting 1. Aufgabe für Klausur WS 2010/11
          [24-Mar-2011 10:56:11] activity skipped by _included setting 2 Aufgabe für Klausur WS 2010/11
          [24-Mar-2011 10:56:11] activity skipped by _included setting 3 Aufgabe für Klausur WS 2010/11
          [24-Mar-2011 10:56:11] activity skipped by _included setting Klausurteil Analysis WS 2004/05
          [24-Mar-2011 10:56:11] activity skipped by _included setting Lösung zum Klausurteil Analysis WS 2004/05
          [24-Mar-2011 10:56:11] activity skipped by _included setting Klausurteil Analysis SS 2005
          [24-Mar-2011 10:56:11] activity skipped by _included setting Lösung zum Klausurteil Analysis SS 2005
          [24-Mar-2011 10:56:11] activity skipped by _included setting Klausurteil Analysis WS 2005/06
          [24-Mar-2011 10:56:11] activity skipped by _included setting Lösung zum Klausurteil Analysis WS 2005/06
          [24-Mar-2011 10:56:11] activity skipped by _included setting Klausurteil Analysis SS 2006
          [24-Mar-2011 10:56:11] activity skipped by _included setting Lösung zum Klausurteil Analysis SS 2006
          [24-Mar-2011 10:56:11] activity skipped by _included setting Klausurteil Analysis WS 2006/07
          [24-Mar-2011 10:56:11] activity skipped by _included setting Lösung zum Klausurteil Analysis WS 2006/07
          [24-Mar-2011 10:56:11] activity skipped by _included setting Klausurteil Analysis SS 2007
          [24-Mar-2011 10:56:11] activity skipped by _included setting Lösung zum Klausurteil Analysis SS 2007
          [24-Mar-2011 10:56:11] activity skipped by _included setting Klausurteil Analysis WS 2007/08
          [24-Mar-2011 10:56:11] activity skipped by _included setting Lösung zum Klausurteil Analysis WS 2007/08
          [24-Mar-2011 10:56:11] activity skipped by _included setting Klausurteil Analysis SS 2008
          [24-Mar-2011 10:56:11] activity skipped by _included setting Lösung zum Klausurteil Analysis SS 2008
          [24-Mar-2011 10:56:11] activity skipped by _included setting Klausurteil Analysis WS 2008/09
          [24-Mar-2011 10:56:11] activity skipped by _included setting Lösung zum Klausurteil Analysis WS 2008/09
          [24-Mar-2011 10:56:11] activity skipped by _included setting Klausurteil Analysis SS 2009
          [24-Mar-2011 10:56:11] activity skipped by _included setting Lösung zum Klausurteil Analysis SS 2009
          [24-Mar-2011 10:56:11] activity skipped by _included setting Klausurteil Analysis WS 2009/10
          [24-Mar-2011 10:56:11] activity skipped by _included setting Lösung zum Klausurteil Analysis WS 2009/10
          [24-Mar-2011 10:56:11] activity skipped by _included setting Klausurteil Analysis SS 2010
          [24-Mar-2011 10:56:11] activity skipped by _included setting Lösung zum Klausurteil Analysis SS 2010
          [24-Mar-2011 10:56:11] activity skipped by _included setting Forum zu den Klausuren
          [24-Mar-2011 10:56:12] activity skipped by _included setting Substitution
          [24-Mar-2011 10:56:12] activity skipped by _included setting Partielle Integration
          [24-Mar-2011 10:56:12] activity skipped by _included setting Integration durch Partialbruchzerlegung
          [24-Mar-2011 10:56:22] setting controller status to 1000
          [24-Mar-2011 10:56:22] instantiating restore controller c33a2294e9b769c6cc7313070d5f8ba3
          [24-Mar-2011 10:56:22] setting controller status to 100
          [24-Mar-2011 10:56:22] loading backup info
          [24-Mar-2011 10:56:22] loading controller plan
          [24-Mar-2011 10:56:22] setting controller status to 300
          [24-Mar-2011 10:56:22] checking plan security
          [24-Mar-2011 10:56:22] setting controller status to 500
          [24-Mar-2011 10:56:22] setting controller status to 600
          [24-Mar-2011 10:56:22] saving controller to db
          [24-Mar-2011 10:56:22] calculating controller checksum 6c53d37a2bf2e42b7570c3edd8a7fcd0
          [24-Mar-2011 10:56:22] loading controller from db
          [24-Mar-2011 10:58:02] setting controller status to 700
          [24-Mar-2011 10:58:02] saving controller to db
          [24-Mar-2011 10:58:02] calculating controller checksum 361538a37e33db353f88185177d65001
          [24-Mar-2011 10:58:02] loading controller from db
          [24-Mar-2011 10:58:02] setting controller status to 800
          [24-Mar-2011 10:58:35] Default exception handler: error/error_question_answers_missing_in_db Debug:

          • line 142 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 106 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 132 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 148 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 299 of \backup\controller\restore_controller.class.php: call to restore_plan->execute()
          • line 130 of \backup\import.php: call to restore_controller->execute_plan()

          [24-Mar-2011 10:58:37] Potential coding error - existing temptables found when disposing database. Must be dropped!

          Our system specifications:
          OS: Windows Server 2008 R2 Standard
          Webserver: IIS 7
          DB: mysql 5.5.8
          PHP: PHP 5.3.5 (fastCGI)
          Moodle: 2.0.2+ (Build 20110223)

          Thanks for answers / help

          Christian

          Show
          Christian Stern added a comment - Hi, after upgrading to Moodle 2.0.2+ (Build 20110223) we encounterd an error trying to restore a question. One of our professors hat a separate course where he prepares quizes and questions for the students (not accessible to them). In Moodle 1.9.x he usually "copied" the questions to the student's course by importing them from the "test course". Using Moodle 2.0 this import routine fails with the error: "error/error_question_answers_missing_in_db". After setting the debugging mode, we could retrieve following error messages from the PHP-errorlog: [24-Mar-2011 10:55:06] instantiating backup controller 5987f524f65e20eff557335b24e11894 [24-Mar-2011 10:55:06] setting controller status to 100 [24-Mar-2011 10:55:06] loading controller plan [24-Mar-2011 10:55:06] setting controller status to 300 [24-Mar-2011 10:55:06] applying plan defaults [24-Mar-2011 10:55:06] setting controller status to 400 [24-Mar-2011 10:55:06] checking plan security [24-Mar-2011 10:55:07] setting controller status to 500 [24-Mar-2011 10:55:07] checking plan security [24-Mar-2011 10:55:07] checking plan security [24-Mar-2011 10:55:07] checking plan security [24-Mar-2011 10:55:07] saving controller to db [24-Mar-2011 10:55:07] calculating controller checksum ed4d9c9f779bc79dfdf1e39940883613 [24-Mar-2011 10:55:14] loading controller from db [24-Mar-2011 10:55:14] checking plan security [24-Mar-2011 10:55:14] checking plan security [24-Mar-2011 10:55:14] checking plan security [24-Mar-2011 10:55:14] saving controller to db [24-Mar-2011 10:55:14] calculating controller checksum 8dbcbd7c13d07d4fc8cb1ffaad84cd57 [24-Mar-2011 10:55:57] loading controller from db [24-Mar-2011 10:55:57] checking plan security [24-Mar-2011 10:55:58] checking plan security [24-Mar-2011 10:55:58] checking plan security [24-Mar-2011 10:55:58] saving controller to db [24-Mar-2011 10:55:58] calculating controller checksum 93a94b9f4d165a71237d22cdc05884e0 [24-Mar-2011 10:56:05] loading controller from db [24-Mar-2011 10:56:05] checking plan security [24-Mar-2011 10:56:05] checking plan security [24-Mar-2011 10:56:05] setting controller status to 700 [24-Mar-2011 10:56:05] saving controller to db [24-Mar-2011 10:56:05] calculating controller checksum 4506230625321515c6fdc88c9327111a [24-Mar-2011 10:56:05] loading controller from db [24-Mar-2011 10:56:05] setting controller status to 800 [24-Mar-2011 10:56:11] section skipped by _included setting [24-Mar-2011 10:56:11] activity skipped by _included setting Nachrichtenforum [24-Mar-2011 10:56:11] activity skipped by _included setting Allgemeines Forum zur Vorlesung [24-Mar-2011 10:56:11] activity skipped by _included setting Literaturliste zu den Vorlesungen Analysis und Lineare Algebra [24-Mar-2011 10:56:11] activity skipped by _included setting Einschreibung ins Tutorium [24-Mar-2011 10:56:11] activity skipped by _included setting Glossar Analysis 1 [24-Mar-2011 10:56:11] section skipped by _included setting 1 [24-Mar-2011 10:56:11] activity skipped by _included setting Übungsblatt 1 [24-Mar-2011 10:56:11] activity skipped by _included setting Forum zum Thema "Grundlagen" [24-Mar-2011 10:56:11] activity skipped by _included setting Ihre Meinung zur Mathematik [24-Mar-2011 10:56:11] section skipped by _included setting 2 [24-Mar-2011 10:56:11] activity skipped by _included setting Übungsblatt 2 [24-Mar-2011 10:56:11] activity skipped by _included setting Forum zum Thema "Funktionen" [24-Mar-2011 10:56:11] activity skipped by _included setting Ihre Meinung zu Moodle [24-Mar-2011 10:56:11] section skipped by _included setting 3 [24-Mar-2011 10:56:11] activity skipped by _included setting Übungsblatt 3 [24-Mar-2011 10:56:11] activity skipped by _included setting Forum zum Thema "Elementare Funktionen - 1. Teil" [24-Mar-2011 10:56:11] activity skipped by _included setting Einstieg und Aufwand fürs Studium [24-Mar-2011 10:56:11] section skipped by _included setting 4 [24-Mar-2011 10:56:11] activity skipped by _included setting Übungsblatt 4 [24-Mar-2011 10:56:11] activity skipped by _included setting Forum zum Thema "Elementare Funktionen - 2. Teil" [24-Mar-2011 10:56:11] activity skipped by _included setting Bekanntheit des bisherigen Stoffes [24-Mar-2011 10:56:11] section skipped by _included setting 5 [24-Mar-2011 10:56:11] activity skipped by _included setting Übungsblatt 5 [24-Mar-2011 10:56:11] activity skipped by _included setting Forum zum Thema "Grenzwerte" [24-Mar-2011 10:56:11] activity skipped by _included setting Ihre Meinung zu den Übungsblättern [24-Mar-2011 10:56:11] activity skipped by _included setting Ihre Meinung zu den Pflichtabgaben [24-Mar-2011 10:56:11] section skipped by _included setting 6 [24-Mar-2011 10:56:11] activity skipped by _included setting Übungsblatt 6 [24-Mar-2011 10:56:11] activity skipped by _included setting Forum zum Thema "Differenzialrechnung" [24-Mar-2011 10:56:11] activity skipped by _included setting Ihre Meinung zum Tutorium [24-Mar-2011 10:56:11] section skipped by _included setting 7 [24-Mar-2011 10:56:11] activity skipped by _included setting Übungsblatt 7 [24-Mar-2011 10:56:11] activity skipped by _included setting Forum zum Thema "Anwendungen der Differenzialrechnung" [24-Mar-2011 10:56:11] activity skipped by _included setting Ihre Meinung zu Moodle (2. Umfrage) [24-Mar-2011 10:56:11] activity skipped by _included setting Angst vor der Klausur? [24-Mar-2011 10:56:11] activity skipped by _included setting Maple-Worksheet zum Newton-Verfahren [24-Mar-2011 10:56:11] activity skipped by _included setting 1. Aufgabe für Klausur WS 2010/11 [24-Mar-2011 10:56:11] activity skipped by _included setting 2 Aufgabe für Klausur WS 2010/11 [24-Mar-2011 10:56:11] activity skipped by _included setting 3 Aufgabe für Klausur WS 2010/11 [24-Mar-2011 10:56:11] activity skipped by _included setting Klausurteil Analysis WS 2004/05 [24-Mar-2011 10:56:11] activity skipped by _included setting Lösung zum Klausurteil Analysis WS 2004/05 [24-Mar-2011 10:56:11] activity skipped by _included setting Klausurteil Analysis SS 2005 [24-Mar-2011 10:56:11] activity skipped by _included setting Lösung zum Klausurteil Analysis SS 2005 [24-Mar-2011 10:56:11] activity skipped by _included setting Klausurteil Analysis WS 2005/06 [24-Mar-2011 10:56:11] activity skipped by _included setting Lösung zum Klausurteil Analysis WS 2005/06 [24-Mar-2011 10:56:11] activity skipped by _included setting Klausurteil Analysis SS 2006 [24-Mar-2011 10:56:11] activity skipped by _included setting Lösung zum Klausurteil Analysis SS 2006 [24-Mar-2011 10:56:11] activity skipped by _included setting Klausurteil Analysis WS 2006/07 [24-Mar-2011 10:56:11] activity skipped by _included setting Lösung zum Klausurteil Analysis WS 2006/07 [24-Mar-2011 10:56:11] activity skipped by _included setting Klausurteil Analysis SS 2007 [24-Mar-2011 10:56:11] activity skipped by _included setting Lösung zum Klausurteil Analysis SS 2007 [24-Mar-2011 10:56:11] activity skipped by _included setting Klausurteil Analysis WS 2007/08 [24-Mar-2011 10:56:11] activity skipped by _included setting Lösung zum Klausurteil Analysis WS 2007/08 [24-Mar-2011 10:56:11] activity skipped by _included setting Klausurteil Analysis SS 2008 [24-Mar-2011 10:56:11] activity skipped by _included setting Lösung zum Klausurteil Analysis SS 2008 [24-Mar-2011 10:56:11] activity skipped by _included setting Klausurteil Analysis WS 2008/09 [24-Mar-2011 10:56:11] activity skipped by _included setting Lösung zum Klausurteil Analysis WS 2008/09 [24-Mar-2011 10:56:11] activity skipped by _included setting Klausurteil Analysis SS 2009 [24-Mar-2011 10:56:11] activity skipped by _included setting Lösung zum Klausurteil Analysis SS 2009 [24-Mar-2011 10:56:11] activity skipped by _included setting Klausurteil Analysis WS 2009/10 [24-Mar-2011 10:56:11] activity skipped by _included setting Lösung zum Klausurteil Analysis WS 2009/10 [24-Mar-2011 10:56:11] activity skipped by _included setting Klausurteil Analysis SS 2010 [24-Mar-2011 10:56:11] activity skipped by _included setting Lösung zum Klausurteil Analysis SS 2010 [24-Mar-2011 10:56:11] activity skipped by _included setting Forum zu den Klausuren [24-Mar-2011 10:56:12] activity skipped by _included setting Substitution [24-Mar-2011 10:56:12] activity skipped by _included setting Partielle Integration [24-Mar-2011 10:56:12] activity skipped by _included setting Integration durch Partialbruchzerlegung [24-Mar-2011 10:56:22] setting controller status to 1000 [24-Mar-2011 10:56:22] instantiating restore controller c33a2294e9b769c6cc7313070d5f8ba3 [24-Mar-2011 10:56:22] setting controller status to 100 [24-Mar-2011 10:56:22] loading backup info [24-Mar-2011 10:56:22] loading controller plan [24-Mar-2011 10:56:22] setting controller status to 300 [24-Mar-2011 10:56:22] checking plan security [24-Mar-2011 10:56:22] setting controller status to 500 [24-Mar-2011 10:56:22] setting controller status to 600 [24-Mar-2011 10:56:22] saving controller to db [24-Mar-2011 10:56:22] calculating controller checksum 6c53d37a2bf2e42b7570c3edd8a7fcd0 [24-Mar-2011 10:56:22] loading controller from db [24-Mar-2011 10:58:02] setting controller status to 700 [24-Mar-2011 10:58:02] saving controller to db [24-Mar-2011 10:58:02] calculating controller checksum 361538a37e33db353f88185177d65001 [24-Mar-2011 10:58:02] loading controller from db [24-Mar-2011 10:58:02] setting controller status to 800 [24-Mar-2011 10:58:35] Default exception handler: error/error_question_answers_missing_in_db Debug: line 142 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 106 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 132 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 148 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 299 of \backup\controller\restore_controller.class.php: call to restore_plan->execute() line 130 of \backup\import.php: call to restore_controller->execute_plan() [24-Mar-2011 10:58:37] Potential coding error - existing temptables found when disposing database. Must be dropped! Our system specifications: OS: Windows Server 2008 R2 Standard Webserver: IIS 7 DB: mysql 5.5.8 PHP: PHP 5.3.5 (fastCGI) Moodle: 2.0.2+ (Build 20110223) Thanks for answers / help Christian
          Hide
          Michael Williams added a comment -

          Hi All,
          We are having very mixed results importing any content from other courses.
          Our issue is similar to Christian's.
          I cannot even import a lable. Last week was working ok and this week nothing, with no changes to the system.
          I get a blank import.php page after i try an import and if i refresh that page i get the cannot complete ui error or the "error/error_question_answers_missing_in_db".

          Here is the latest error dump.

          Error: mdb->get_record() found more than one record!

          • line 1268 of \lib\dml\moodle_database.php: call to debugging()
          • line 1331 of \lib\dml\moodle_database.php: call to moodle_database->get_record_sql()
          • line 134 of \backup\moodle2\restore_qtype_plugin.class.php: call to moodle_database->get_field_sql()
          • 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 106 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 132 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 148 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 299 of \backup\controller\restore_controller.class.php: call to restore_plan->execute()
          • line 130 of \backup\import.php: call to restore_controller->execute_plan()

          Fatal error: Maximum execution time of 30 seconds exceeded in C:\inetpub\wwwroot\lib\moodlelib.php on line 1045

          Fatal error: sqlsrv_warnings contains an invalid type in C:\inetpub\wwwroot\lib\dml\sqlsrv_native_moodle_database.php on line 358

          Fatal error: sqlsrv_warnings contains an invalid type in C:\inetpub\wwwroot\lib\dml\sqlsrv_native_moodle_database.php on line 1306

          Our system specifications:
          OS: Windows Server 2008 Enterprise x64
          Webserver: IIS 7
          DB: MS SQL 2008
          PHP: PHP 5.2.15
          Moodle: 2.0.2+ (Build 20110316)

          Show
          Michael Williams added a comment - Hi All, We are having very mixed results importing any content from other courses. Our issue is similar to Christian's. I cannot even import a lable. Last week was working ok and this week nothing, with no changes to the system. I get a blank import.php page after i try an import and if i refresh that page i get the cannot complete ui error or the "error/error_question_answers_missing_in_db". Here is the latest error dump. Error: mdb->get_record() found more than one record! line 1268 of \lib\dml\moodle_database.php: call to debugging() line 1331 of \lib\dml\moodle_database.php: call to moodle_database->get_record_sql() line 134 of \backup\moodle2\restore_qtype_plugin.class.php: call to moodle_database->get_field_sql() 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 106 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 132 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 148 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 299 of \backup\controller\restore_controller.class.php: call to restore_plan->execute() line 130 of \backup\import.php: call to restore_controller->execute_plan() Fatal error: Maximum execution time of 30 seconds exceeded in C:\inetpub\wwwroot\lib\moodlelib.php on line 1045 Fatal error: sqlsrv_warnings contains an invalid type in C:\inetpub\wwwroot\lib\dml\sqlsrv_native_moodle_database.php on line 358 Fatal error: sqlsrv_warnings contains an invalid type in C:\inetpub\wwwroot\lib\dml\sqlsrv_native_moodle_database.php on line 1306 Our system specifications: OS: Windows Server 2008 Enterprise x64 Webserver: IIS 7 DB: MS SQL 2008 PHP: PHP 5.2.15 Moodle: 2.0.2+ (Build 20110316)
          Hide
          Peter Ruthven-Stuart added a comment -

          Hello, I'm a colleague of the original reporter of this bug.

          Using the same system, I've discovered that even importing quizzes in which questions are not at the system level is not possible.

          I just tried to import one quiz from a different course. The quiz in that course works fine. The 21 questions in that quiz are not at the system level. On trying to import that quiz, I got a "Import complete. Click continue to return to the course." message but the quiz was NOT imported. However, a new question category in the Question Bank was created - but empty.

          Not being able to import quizzes from anywhere is a BIG problem. This worked in 1.9 .....

          Show
          Peter Ruthven-Stuart added a comment - Hello, I'm a colleague of the original reporter of this bug. Using the same system, I've discovered that even importing quizzes in which questions are not at the system level is not possible. I just tried to import one quiz from a different course. The quiz in that course works fine. The 21 questions in that quiz are not at the system level. On trying to import that quiz, I got a "Import complete. Click continue to return to the course." message but the quiz was NOT imported. However, a new question category in the Question Bank was created - but empty. Not being able to import quizzes from anywhere is a BIG problem. This worked in 1.9 .....
          Martin Dougiamas made changes -
          Workflow MDL Workflow [ 68000 ] MDL Full Workflow [ 76681 ]
          Hide
          Rob added a comment -

          I am seeing this using the latest 2.1.1+. I tried to import some DDMatch questions that were at the course level and get error/error_question_match_sub_missing_in_db. This the source course has several thousand questions in a few hundred categories. I have also been unable to import anything with system level questions. We place questions at the system level for common assessments in our school district. This way revisions only need to be done in one place. Moving all questions to the course level is not an option for me. The error with system level imports/restore is error/question_answers_missing_in_database.

          Show
          Rob added a comment - I am seeing this using the latest 2.1.1+. I tried to import some DDMatch questions that were at the course level and get error/error_question_match_sub_missing_in_db. This the source course has several thousand questions in a few hundred categories. I have also been unable to import anything with system level questions. We place questions at the system level for common assessments in our school district. This way revisions only need to be done in one place. Moving all questions to the course level is not an option for me. The error with system level imports/restore is error/question_answers_missing_in_database.
          Hide
          David added a comment -

          I'm having the same issues and I also use all Category level questions for a group of physics classes so all instructors can share one question banks.

          I'm using build 2.1.1+ and I'm just duplicating an existing quiz to the same course. The error I get is error/error_question_answers_missing_in_db

          I hope this is resolved soon.

          Show
          David added a comment - I'm having the same issues and I also use all Category level questions for a group of physics classes so all instructors can share one question banks. I'm using build 2.1.1+ and I'm just duplicating an existing quiz to the same course. The error I get is error/error_question_answers_missing_in_db I hope this is resolved soon.
          Hide
          Kyle Decot added a comment -

          I'm experiencing this issue as well. Any word as to when this will be fixed?

          Show
          Kyle Decot added a comment - I'm experiencing this issue as well. Any word as to when this will be fixed?
          Hide
          Kyle Decot added a comment -

          Hello Everyone:

          I just wanted to let you know that I was able to fix this (in my installation at least). The problem seemed to be that in the `questions_answers` table some of my `answer` fields had an extra leading space in them. For example: " Columbus, Ohio" instead of "Columbus, Ohio". When the import script would run it would attempt to find a record w/ "Columbus, Ohio" (which I assume is due to some call to trim() somewhere). Obviously an answer w/ "Columbus, Ohio" doesn't exist in my table and the error/error_question_answers_missing_in_db exception would then get thrown. There are two possible solutions to this as I see it: Either remove the logic that does the trim() before finding the record, or when questions_answers records are are added trim() them before hand.

          Hopefully this helps at least some of you w/ this problem.

          Kyle Decot

          Show
          Kyle Decot added a comment - Hello Everyone: I just wanted to let you know that I was able to fix this (in my installation at least). The problem seemed to be that in the `questions_answers` table some of my `answer` fields had an extra leading space in them. For example: " Columbus, Ohio" instead of "Columbus, Ohio". When the import script would run it would attempt to find a record w/ "Columbus, Ohio" (which I assume is due to some call to trim() somewhere). Obviously an answer w/ "Columbus, Ohio" doesn't exist in my table and the error/error_question_answers_missing_in_db exception would then get thrown. There are two possible solutions to this as I see it: Either remove the logic that does the trim() before finding the record, or when questions_answers records are are added trim() them before hand. Hopefully this helps at least some of you w/ this problem. Kyle Decot
          Hide
          Rob added a comment -

          Thank you for this information Kyle. However, I feel there is more to the problem on my installation. If I move some of the questions out of the system level, and into a course category level category, they import just fine. If too many questions populate the category level category, the error recurs. If the problem was an extra space in the answer field, it should behave the same no matter the category.

          I have been moving questions around since upgrading in August when I need to import to a course. It has led to a great deal of extra work. I hope this issue will get resolved soon.

          Show
          Rob added a comment - Thank you for this information Kyle. However, I feel there is more to the problem on my installation. If I move some of the questions out of the system level, and into a course category level category, they import just fine. If too many questions populate the category level category, the error recurs. If the problem was an extra space in the answer field, it should behave the same no matter the category. I have been moving questions around since upgrading in August when I need to import to a course. It has led to a great deal of extra work. I hope this issue will get resolved soon.
          Hide
          Rob added a comment - - edited

          I also noticed this tracker issue is listed as affecting Moodle 2.0+. I have seen it since upgrading from 1.9 to 2.1, and then to 2.1.1 and 2.1.2+. I skipped 2.0.

          Show
          Rob added a comment - - edited I also noticed this tracker issue is listed as affecting Moodle 2.0+. I have seen it since upgrading from 1.9 to 2.1, and then to 2.1.1 and 2.1.2+. I skipped 2.0.
          Hide
          Tyler Bannister added a comment - - edited

          This issue could be related to MDL-30018. In that issue carriage returns (\r) in multiple choice question answers trigger the error_question_answers_missing_in_db error message. The reason it only shows up with site or category level shared questions is because there is an error when trying to ensure that there is only one copy of the question. The xml function strips out carriage returns (and some other invisible characters) but afterwards the answers in the database and the backup file no longer match. This is why the bug only affects questions that are shared.

          Show
          Tyler Bannister added a comment - - edited This issue could be related to MDL-30018 . In that issue carriage returns (\r) in multiple choice question answers trigger the error_question_answers_missing_in_db error message. The reason it only shows up with site or category level shared questions is because there is an error when trying to ensure that there is only one copy of the question. The xml function strips out carriage returns (and some other invisible characters) but afterwards the answers in the database and the backup file no longer match. This is why the bug only affects questions that are shared.
          Hide
          Rob added a comment -

          I would like to think this is the cause, I do not see this bug with all shared questions. It only occurs if the system level category is populated with too many questions. I have been moving questions in and out of the system level since upgrading to Moodle 2.1. If I need to import a quiz using shared questions into a course, I move the questions I want into a course category level question category (I know that sounds confusing). For example, if I need to import a quiz into one of our high school courses, I move the questions into the high school course category. There they copy fine, but if I move all questions into the high school category, the error occurs. It seems there is a limit somewhere. Currently, my high school category has around 500 questions in 50 or so sub-categories. If I move more into it, I get the error.

          Show
          Rob added a comment - I would like to think this is the cause, I do not see this bug with all shared questions. It only occurs if the system level category is populated with too many questions. I have been moving questions in and out of the system level since upgrading to Moodle 2.1. If I need to import a quiz using shared questions into a course, I move the questions I want into a course category level question category (I know that sounds confusing). For example, if I need to import a quiz into one of our high school courses, I move the questions into the high school course category. There they copy fine, but if I move all questions into the high school category, the error occurs. It seems there is a limit somewhere. Currently, my high school category has around 500 questions in 50 or so sub-categories. If I move more into it, I get the error.
          Hide
          Jared Planter added a comment - - edited

          Hello,

          I am getting the same "error/error_question_answers_missing_in_db" error after attempting to restore a quiz from my 2.1.1 moodle running on MySQL into my 2.1.2 moodle running on PostGreSQL.

          [IMPORTING FROM: Moodle 2.1.1+]
          OS: Ubuntu Server 10.04.2
          DB: MySQL 5.1.41
          PHP: 5.3.2-1ubuntu4.9
          Webserver: Apache/2.2.14 (Ubuntu)
          Moodle: 2.1.1+ (Build: 20110817)

          [IMPORTING TO: Moodle 2.1.2+]
          OS: Ubuntu Server 10.04.3
          DB: PostGreSQL 8.4.3
          PHP: 5.3.2-1ubuntu4.10
          Webserver: Apache/2.2.14 (Ubuntu)
          Moodle 2.1.2+ (Build: 20111027)

          At this point we are dead in the water as to restoring any backups, quizes etc.

          Any help would be greatly appreciated.

          Best Regards,

          Jared

          Show
          Jared Planter added a comment - - edited Hello, I am getting the same "error/error_question_answers_missing_in_db" error after attempting to restore a quiz from my 2.1.1 moodle running on MySQL into my 2.1.2 moodle running on PostGreSQL. [IMPORTING FROM: Moodle 2.1.1+] OS: Ubuntu Server 10.04.2 DB: MySQL 5.1.41 PHP: 5.3.2-1ubuntu4.9 Webserver: Apache/2.2.14 (Ubuntu) Moodle: 2.1.1+ (Build: 20110817) [IMPORTING TO: Moodle 2.1.2+] OS: Ubuntu Server 10.04.3 DB: PostGreSQL 8.4.3 PHP: 5.3.2-1ubuntu4.10 Webserver: Apache/2.2.14 (Ubuntu) Moodle 2.1.2+ (Build: 20111027) At this point we are dead in the water as to restoring any backups, quizes etc. Any help would be greatly appreciated. Best Regards, Jared
          Hide
          Rob added a comment -

          Hi Jared,

          You might try moving the questions out of the system category before backing up the course. You can move them back after restore. Because of this problem, I have been moving questions around every time I need to restore/import.

          Rob

          Show
          Rob added a comment - Hi Jared, You might try moving the questions out of the system category before backing up the course. You can move them back after restore. Because of this problem, I have been moving questions around every time I need to restore/import. Rob
          Hide
          Sebastien Ross added a comment -

          Same error with our 2.1.4+ upgraded from 2.0.

          I tried to create a new question at the category (or system) level, put it in a quizz and restore just don't work. In fact, I'm using the x2 feature ont the quiz to test it, it's faster than restore a course part (same script I think)). When I use questions at the system level, the restore works perfect. I only have about 200 questions at the category level in my site (a chance for me, this feature is underused by my teachers) but I will need to increase them soon.
          Even if Rob's trick do the job, it is very long to create a copy of courses with many quizzes!
          Also, it could be great to upgrade MDL-26442 to include others versions affected by this bug.
          Thank's a lot,
          Sebastien Ross

          Show
          Sebastien Ross added a comment - Same error with our 2.1.4+ upgraded from 2.0. I tried to create a new question at the category (or system) level, put it in a quizz and restore just don't work. In fact, I'm using the x2 feature ont the quiz to test it, it's faster than restore a course part (same script I think)). When I use questions at the system level, the restore works perfect. I only have about 200 questions at the category level in my site (a chance for me, this feature is underused by my teachers) but I will need to increase them soon. Even if Rob's trick do the job, it is very long to create a copy of courses with many quizzes! Also, it could be great to upgrade MDL-26442 to include others versions affected by this bug. Thank's a lot, Sebastien Ross
          Hide
          Jared Planter added a comment -

          Hello

          I am still experiencing this problem even while restoring within the same moodle.

          Has any progress been made on this bug? This is becoming a huge inconvenience for our School.

          Best Regards,

          Jared

          Show
          Jared Planter added a comment - Hello I am still experiencing this problem even while restoring within the same moodle. Has any progress been made on this bug? This is becoming a huge inconvenience for our School. Best Regards, Jared
          Hide
          Rob added a comment -

          Hi Jared,

          I have not made any progress, but I can stop the error from happening by commenting out the line of /backup/moodle2/restore_qtype_plugin.class.php mentioned in the stack trace. I also commented out the line in restore_qtype_plugin.class.php in the backup/moodle2 folders for matching and DDmatching. I would sometimes get a sub_type missing error.

          I imagine it is unwise to comment out these lines, but I have not seen any problems so far.

          Rob

          Show
          Rob added a comment - Hi Jared, I have not made any progress, but I can stop the error from happening by commenting out the line of /backup/moodle2/restore_qtype_plugin.class.php mentioned in the stack trace. I also commented out the line in restore_qtype_plugin.class.php in the backup/moodle2 folders for matching and DDmatching. I would sometimes get a sub_type missing error. I imagine it is unwise to comment out these lines, but I have not seen any problems so far. Rob
          Hide
          Peter Ruthven-Stuart added a comment - - edited

          Hello,

          Is this getting any closer to being fixed?

          Having just recently upgraded to 2.2.2, I've been trying to import and restore some courses, but keep getting the following error message:

          error_question_match_sub_missing_in_db

          so the only way to import or restore courses is by not importing/restoring quizzes that contain questions that are at the system level.

          Show
          Peter Ruthven-Stuart added a comment - - edited Hello, Is this getting any closer to being fixed? Having just recently upgraded to 2.2.2, I've been trying to import and restore some courses, but keep getting the following error message: error_question_match_sub_missing_in_db so the only way to import or restore courses is by not importing/restoring quizzes that contain questions that are at the system level.
          Hide
          Rob added a comment -

          Hi Peter,

          I commented out line 144 of /question/type/backup/moodle2/restore_qtype_match_plugin.class.php to get around that error. I also had to comment out a line in the restore... file in the DDmatch question folder.

          Rob

          Show
          Rob added a comment - Hi Peter, I commented out line 144 of /question/type/backup/moodle2/restore_qtype_match_plugin.class.php to get around that error. I also had to comment out a line in the restore... file in the DDmatch question folder. Rob
          Hide
          Antonio Beermann added a comment -

          Hi,
          we have 2.2.1+ and still hope that this bug can be fixed. We have a course with more than 650 questions. This questions should be on systemlevel so they are always uptodate, I don't know how long moodle will work fine after bringing all the questions to courselevel and duplicating the course several times each week |-).
          This system started from 2.0x so the problem should have nothing to do with 1.9 directly!?
          Did anyone trie to export the questions within 2.2.2x and reimport them to a new clean 2.2.2x and check if that would solve the problem?
          best regards
          Antonio

          Show
          Antonio Beermann added a comment - Hi, we have 2.2.1+ and still hope that this bug can be fixed. We have a course with more than 650 questions. This questions should be on systemlevel so they are always uptodate, I don't know how long moodle will work fine after bringing all the questions to courselevel and duplicating the course several times each week |-). This system started from 2.0x so the problem should have nothing to do with 1.9 directly!? Did anyone trie to export the questions within 2.2.2x and reimport them to a new clean 2.2.2x and check if that would solve the problem? best regards Antonio
          Hide
          Chris Collman added a comment -

          I have a 2.1.3 production Moodle. Tried to import an entire course into a new one. Then tried a backup/restore. Even backing up selective non quiz items, results in this error. Did a full backup (no students, no resources) of 100 quizzes, 10 lessons, 1 glossary, including over 1500 questions for that course. Created a 2.2.2 latest Moodle on a localhost, no issues with the restore and a random check of question categories (all are on the system level) show the questions are in quizzes and in question bank.

          We only use MC questions. I am not aware of any CRs in any answers. We do have special characters that have appeared in both question and answers that we try to delete when we see them. We did bring in our questions from a 1.5.x Moodle, that we upgraded step by step to 1.9 on a localhost, before restoring it to our new 2.1.3 production server.

          We repeat a course every semester. We created a clean course in semester 1 on a new server and Moodle 2.1.3, imported it into new course for semester 2. Some questions are added/edited/moved in/from question categories every semester. Now we can not import the semester 2 course into a new semester 3 course.

          When I get to work, I am going to try to selectively import 1 of the quizzes. Previously, I had only tried to backup/import some Questionnaires and got this error. I suspect Moodle performs this check even when quizzes are not going to be imported.

          I will look for the lines of Code to remark out as Rob reluctantly pointed out. I have 3 weeks to create the "new" course. Sure hate to create 50 quizzes in the 3rd semester course, then duplicate them for the makeup exams.

          Hope this helps

          Show
          Chris Collman added a comment - I have a 2.1.3 production Moodle. Tried to import an entire course into a new one. Then tried a backup/restore. Even backing up selective non quiz items, results in this error. Did a full backup (no students, no resources) of 100 quizzes, 10 lessons, 1 glossary, including over 1500 questions for that course. Created a 2.2.2 latest Moodle on a localhost, no issues with the restore and a random check of question categories (all are on the system level) show the questions are in quizzes and in question bank. We only use MC questions. I am not aware of any CRs in any answers. We do have special characters that have appeared in both question and answers that we try to delete when we see them. We did bring in our questions from a 1.5.x Moodle, that we upgraded step by step to 1.9 on a localhost, before restoring it to our new 2.1.3 production server. We repeat a course every semester. We created a clean course in semester 1 on a new server and Moodle 2.1.3, imported it into new course for semester 2. Some questions are added/edited/moved in/from question categories every semester. Now we can not import the semester 2 course into a new semester 3 course. When I get to work, I am going to try to selectively import 1 of the quizzes. Previously, I had only tried to backup/import some Questionnaires and got this error. I suspect Moodle performs this check even when quizzes are not going to be imported. I will look for the lines of Code to remark out as Rob reluctantly pointed out. I have 3 weeks to create the "new" course. Sure hate to create 50 quizzes in the 3rd semester course, then duplicate them for the makeup exams. Hope this helps
          Hide
          Chris Collman added a comment -

          An import of the course in 2.2.2+ (Build: 20120427) from a 2.1.3 backup, worked. Review: on a 2.1.3 Moodle, I did a backup of a course that gave an "error_question_answers_missing_in_db" when I tried to import it into a new course in 2.1.3. On a new 2.2.2 install on a localhost with its own database, the course restored without error. I just imported that course into a new course on the 2.2.2 Moodle without error.

          Note: I did not edit any questions, take any quizzes. Just created the new course and imported the other.

          Show
          Chris Collman added a comment - An import of the course in 2.2.2+ (Build: 20120427) from a 2.1.3 backup, worked. Review: on a 2.1.3 Moodle, I did a backup of a course that gave an "error_question_answers_missing_in_db" when I tried to import it into a new course in 2.1.3. On a new 2.2.2 install on a localhost with its own database, the course restored without error. I just imported that course into a new course on the 2.2.2 Moodle without error. Note: I did not edit any questions, take any quizzes. Just created the new course and imported the other.
          Hide
          Chris Collman added a comment -

          For what it is worth: the 2.1.3 production server is Ubuntu 11.04. My localhost 2.2.2+ is running on XAMPP 1.7.7 with mysql 5.5.16
          php 5.3.8. My localhost is running 1 mysql database that sets of tables for both 1.9 and 2.1 versions. The 2.2.2 is in it's own mysql database. Just trying to be helpful

          Show
          Chris Collman added a comment - For what it is worth: the 2.1.3 production server is Ubuntu 11.04. My localhost 2.2.2+ is running on XAMPP 1.7.7 with mysql 5.5.16 php 5.3.8. My localhost is running 1 mysql database that sets of tables for both 1.9 and 2.1 versions. The 2.2.2 is in it's own mysql database. Just trying to be helpful
          Hide
          Rob Monk added a comment -

          We really need this fixed.
          I have a backup of last years exam course that I can't restore. Exam is in 3 weeks and we are getting anxious.

          Show
          Rob Monk added a comment - We really need this fixed. I have a backup of last years exam course that I can't restore. Exam is in 3 weeks and we are getting anxious.
          Hide
          Rob added a comment -

          Hi Rob,

          You should be able to get the course to restore if you comment out the lines of code that throw the error. Please find my comment above telling what files to edit.

          Show
          Rob added a comment - Hi Rob, You should be able to get the course to restore if you comment out the lines of code that throw the error. Please find my comment above telling what files to edit.
          Hide
          Chris Collman added a comment -

          Interesting. Back at work where I can access my internal network and 3 Moodle Servers. Each sever is 2.1.3 version and courses on all of them are similar. To confirm one server has the questions stored on the course level, there was no issue in duplicating the course with exams for a new semester. The other server has the question categories stored on the system level and that is where the issue is.

          I see that when a course is imported and the quiz questions are stored on the course level, it creates a new question.

          Show
          Chris Collman added a comment - Interesting. Back at work where I can access my internal network and 3 Moodle Servers. Each sever is 2.1.3 version and courses on all of them are similar. To confirm one server has the questions stored on the course level, there was no issue in duplicating the course with exams for a new semester. The other server has the question categories stored on the system level and that is where the issue is. I see that when a course is imported and the quiz questions are stored on the course level, it creates a new question.
          Hide
          Chris Collman added a comment -

          Hi Rob Johnson,
          In my restore_qtype_Plugin.class.php line 144 is the start of an else statement.

          What did the lines say in each file that you remarked out.
          Thanks.

          Show
          Chris Collman added a comment - Hi Rob Johnson, In my restore_qtype_Plugin.class.php line 144 is the start of an else statement. What did the lines say in each file that you remarked out. Thanks.
          Hide
          Rob added a comment -

          Hi Chris,

          Are you able to restore the course if you comment out the line in /backup/moodle2/restore_qtype_plugin.class.php that throws the exception? It worked for me.

          Show
          Rob added a comment - Hi Chris, Are you able to restore the course if you comment out the line in /backup/moodle2/restore_qtype_plugin.class.php that throws the exception? It worked for me.
          Hide
          Rob added a comment -

          Hi Chris,

          I am running 2.1.5+ from about two weeks ago, and it is line 159 in /backup/moodle2/restore_qtype_plugin.php. I also ran into errors from two other files. I commented out line 144 in question/match/backup/moodle2/restore_qtype_plugin.php and line 131 in question/ddmatch/backup/moodle2/restore_qtype_plugin.php. If you have not installed the drag/drop matching question, you can ignore the ddmatch file.

          This has worked for me for the past month. I have not seen any ill effect because of it. Please report back if it works for you.

          Rob

          Show
          Rob added a comment - Hi Chris, I am running 2.1.5+ from about two weeks ago, and it is line 159 in /backup/moodle2/restore_qtype_plugin.php. I also ran into errors from two other files. I commented out line 144 in question/match/backup/moodle2/restore_qtype_plugin.php and line 131 in question/ddmatch/backup/moodle2/restore_qtype_plugin.php. If you have not installed the drag/drop matching question, you can ignore the ddmatch file. This has worked for me for the past month. I have not seen any ill effect because of it. Please report back if it works for you. Rob
          Hide
          Paul Nijbakker added a comment -

          In our Moodle 2.2.3 those files mentioned by Rob were:
          /backup/moodle2/restore_qtype_plugin.class.php
          and
          /question/type/match/backup/moodle2/restore_qtype_match_plugin.class.php

          Commenting out the proposed lines did make the error go away for us, but one never knows if it does not cause errors under the hood. We hope that a real fix can be found.

          Show
          Paul Nijbakker added a comment - In our Moodle 2.2.3 those files mentioned by Rob were: /backup/moodle2/restore_qtype_plugin.class.php and /question/type/match/backup/moodle2/restore_qtype_match_plugin.class.php Commenting out the proposed lines did make the error go away for us, but one never knows if it does not cause errors under the hood. We hope that a real fix can be found.
          Matt Fedorko made changes -
          Link This issue has been marked as being related by MDL-33863 [ MDL-33863 ]
          Hide
          Don Hinkelman added a comment -

          In Moodle 2.2.3, during quiz copy (clicking on the 'x2' icon), I have been receiving the error message: "error/error_question_match_sub_missing_in_db" numerous times. I can make the quiz OK from scratch using the Question Bank, but I cannot copy it. The original questions came from Moodle 1.9 and were upgraded to 2.2 using a course-by-course upgrade method.

          Show
          Don Hinkelman added a comment - In Moodle 2.2.3, during quiz copy (clicking on the 'x2' icon), I have been receiving the error message: "error/error_question_match_sub_missing_in_db" numerous times. I can make the quiz OK from scratch using the Question Bank, but I cannot copy it. The original questions came from Moodle 1.9 and were upgraded to 2.2 using a course-by-course upgrade method.
          Hide
          Rob added a comment -

          Hi Don,

          Does commenting out the line in /question/type/match/backup/moodle2/restore_qtype_match_plugin.class.php, mentioned in my post above, make the error go away?

          Show
          Rob added a comment - Hi Don, Does commenting out the line in /question/type/match/backup/moodle2/restore_qtype_match_plugin.class.php, mentioned in my post above, make the error go away?
          Hide
          Don Hinkelman added a comment -

          Yes, Rob, just now our server admin commented out both lines (we use ddmatch) and immediately the problem disappeared. Thank you so much!

          We use the Sharing Cart (co-developed by Andy Johnson who initiated this issue), so naturally, this issue has affected every user of the Sharing Cart, which utilizes standard core backup/restore code. I thought the Sharing Cart was the problem until I tried duplicating a quiz using the 'x2' icon, and got the same error message.

          I should also mention that originally the question bank categories for our 1.9 questions were course level. We then upgraded the 1.9 course to 2.2 last March, which maintained the course level question categories. Then in May/June, I changed all the question categories to System level. I don't know if this affected the problem.

          Show
          Don Hinkelman added a comment - Yes, Rob, just now our server admin commented out both lines (we use ddmatch) and immediately the problem disappeared. Thank you so much! We use the Sharing Cart (co-developed by Andy Johnson who initiated this issue), so naturally, this issue has affected every user of the Sharing Cart, which utilizes standard core backup/restore code. I thought the Sharing Cart was the problem until I tried duplicating a quiz using the 'x2' icon, and got the same error message. I should also mention that originally the question bank categories for our 1.9 questions were course level. We then upgraded the 1.9 course to 2.2 last March, which maintained the course level question categories. Then in May/June, I changed all the question categories to System level. I don't know if this affected the problem.
          Hide
          Matt Fedorko added a comment -

          I was inspired by this most recent round of comments to try commenting out these lines as well. I was having a similar, but not exactly the same problem – see MDL-33863 where I will be making a similar comment to this effect. Commenting out the lines Rob mentions seems to have solved this problem, but as always I'm waiting for the other shoe to drop. I was concerned mostly with the integrity of my Question Bank, and especially with the hints inside many dozens of questions (because of the nature of the error I was getting – and no, I don't think this is a rational fear, but it's the fear I had). As the other people have said, I have a category-level question bank.

          So...we'll see. Would like to see a less crude fix to this problem at some point.

          Show
          Matt Fedorko added a comment - I was inspired by this most recent round of comments to try commenting out these lines as well. I was having a similar, but not exactly the same problem – see MDL-33863 where I will be making a similar comment to this effect. Commenting out the lines Rob mentions seems to have solved this problem, but as always I'm waiting for the other shoe to drop. I was concerned mostly with the integrity of my Question Bank, and especially with the hints inside many dozens of questions (because of the nature of the error I was getting – and no, I don't think this is a rational fear, but it's the fear I had). As the other people have said, I have a category-level question bank. So...we'll see. Would like to see a less crude fix to this problem at some point.
          Hide
          Mark van Hoek added a comment - - edited

          I've just seen this with 2.2.4+ (Build: 20120809) on MySQLi when restoring an activity backup back into the same course it came from. A copy of all the errors shown in below.

          Seems to me it's just not able to find the correct answer in the database. In that query a few lines above...
          $sql = 'SELECT id
          FROM

          {question_answers}

          WHERE question = ?
          AND ' . $DB->sql_compare_text('answer', 255) . ' = ' . $DB->sql_compare_text('?', 255);

          ... while the question-mark param will get escaped in emulate_bound_params(), this query doesn't seem to escape the answertext on the left of the comparison. Many of our answers have the fancy single quote. Maybe I missed it, though, or perhaps one side is being double-escaped.

          Error: mdb->get_record() f ound more than one record!
          line 1309 of /lib/dml/moodle_database.php: call to debugging()
          line 1372 of /lib/dml/moodle_database.php: call to moodle_database->get_record_sql()
          line 151 of /backup/moodle2/restore_qty pe_plugin.class.php: call to moodle_database->get_f ield_sql()
          line 131 of /backup/util/plan/restore_structure_step.class.php: call to restore_qty pe_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/simplif ied_parser_processor.class.php: call to restore_structure_parser_processor->postprocess_chunk()
          line 92 of /backup/util/xml/parser/processors/progressiv e_parser_processor.class.php: call to simplif ied_parser_processor->process_chunk()
          line 169 of /backup/util/xml/parser/progressiv e_parser.class.php: call to progressiv e_parser_processor->receiv e_chunk()
          line 253 of /backup/util/xml/parser/progressiv e_parser.class.php: call to progressiv e_parser->publish()
          line ? of unknownf ile: call to progressiv e_parser->end_tag()
          line 158 of /backup/util/xml/parser/progressiv e_parser.class.php: call to xml_parse()
          line 137 of /backup/util/xml/parser/progressiv e_parser.class.php: call to progressiv e_parser->parse()
          line 105 of /backup/util/plan/restore_structure_step.class.php: call to progressiv e_parser->process()
          line 153 of /backup/util/plan/base_task.class.php: call to restore_structure_step->execute()
          line 148 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 147 of /backup/util/ui/restore_ui.class.php: call to restore_controller->execute_plan()
          line 46 of /backup/restore.php: call to restore_ui->execute()
          Error: mdb->get_record() f ound more than one record!
          line 1309 of /lib/dml/moodle_database.php: call to debugging()
          line 1372 of /lib/dml/moodle_database.php: call to moodle_database->get_record_sql()
          line 151 of /backup/moodle2/restore_qty pe_plugin.class.php: call to moodle_database->get_f ield_sql()
          line 131 of /backup/util/plan/restore_structure_step.class.php: call to restore_qty pe_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/simplif ied_parser_processor.class.php: call to restore_structure_parser_processor->postprocess_chunk()
          line 92 of /backup/util/xml/parser/processors/progressiv e_parser_processor.class.php: call to simplif ied_parser_processor->process_chunk()
          line 169 of /backup/util/xml/parser/progressiv e_parser.class.php: call to progressiv e_parser_processor->receiv e_chunk()
          line 253 of /backup/util/xml/parser/progressiv e_parser.class.php: call to progressiv e_parser->publish()
          line ? of unknownf ile: call to progressiv e_parser->end_tag()
          line 158 of /backup/util/xml/parser/progressiv e_parser.class.php: call to xml_parse()
          line 137 of /backup/util/xml/parser/progressiv e_parser.class.php: call to progressiv e_parser->parse()
          line 105 of /backup/util/plan/restore_structure_step.class.php: call to progressiv e_parser->process()
          line 153 of /backup/util/plan/base_task.class.php: call to restore_structure_step->execute()
          line 148 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 147 of /backup/util/ui/restore_ui.class.php: call to restore_controller->execute_plan()
          line 46 of /backup/restore.php: call to restore_ui->execute()

          error/error_question_answers_missing_in_db
          More information about this error

          Stack trace:
          line 159 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 148 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 147 of /backup/util/ui/restore_ui.class.php: call to restore_controller->execute_plan()
          line 46 of /backup/restore.php: call to restore_ui->execute()

          Show
          Mark van Hoek added a comment - - edited I've just seen this with 2.2.4+ (Build: 20120809) on MySQLi when restoring an activity backup back into the same course it came from. A copy of all the errors shown in below. Seems to me it's just not able to find the correct answer in the database. In that query a few lines above... $sql = 'SELECT id FROM {question_answers} WHERE question = ? AND ' . $DB->sql_compare_text('answer', 255) . ' = ' . $DB->sql_compare_text('?', 255); ... while the question-mark param will get escaped in emulate_bound_params(), this query doesn't seem to escape the answertext on the left of the comparison. Many of our answers have the fancy single quote. Maybe I missed it, though, or perhaps one side is being double-escaped. – Error: mdb->get_record() f ound more than one record! line 1309 of /lib/dml/moodle_database.php: call to debugging() line 1372 of /lib/dml/moodle_database.php: call to moodle_database->get_record_sql() line 151 of /backup/moodle2/restore_qty pe_plugin.class.php: call to moodle_database->get_f ield_sql() line 131 of /backup/util/plan/restore_structure_step.class.php: call to restore_qty pe_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/simplif ied_parser_processor.class.php: call to restore_structure_parser_processor->postprocess_chunk() line 92 of /backup/util/xml/parser/processors/progressiv e_parser_processor.class.php: call to simplif ied_parser_processor->process_chunk() line 169 of /backup/util/xml/parser/progressiv e_parser.class.php: call to progressiv e_parser_processor->receiv e_chunk() line 253 of /backup/util/xml/parser/progressiv e_parser.class.php: call to progressiv e_parser->publish() line ? of unknownf ile: call to progressiv e_parser->end_tag() line 158 of /backup/util/xml/parser/progressiv e_parser.class.php: call to xml_parse() line 137 of /backup/util/xml/parser/progressiv e_parser.class.php: call to progressiv e_parser->parse() line 105 of /backup/util/plan/restore_structure_step.class.php: call to progressiv e_parser->process() line 153 of /backup/util/plan/base_task.class.php: call to restore_structure_step->execute() line 148 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 147 of /backup/util/ui/restore_ui.class.php: call to restore_controller->execute_plan() line 46 of /backup/restore.php: call to restore_ui->execute() Error: mdb->get_record() f ound more than one record! line 1309 of /lib/dml/moodle_database.php: call to debugging() line 1372 of /lib/dml/moodle_database.php: call to moodle_database->get_record_sql() line 151 of /backup/moodle2/restore_qty pe_plugin.class.php: call to moodle_database->get_f ield_sql() line 131 of /backup/util/plan/restore_structure_step.class.php: call to restore_qty pe_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/simplif ied_parser_processor.class.php: call to restore_structure_parser_processor->postprocess_chunk() line 92 of /backup/util/xml/parser/processors/progressiv e_parser_processor.class.php: call to simplif ied_parser_processor->process_chunk() line 169 of /backup/util/xml/parser/progressiv e_parser.class.php: call to progressiv e_parser_processor->receiv e_chunk() line 253 of /backup/util/xml/parser/progressiv e_parser.class.php: call to progressiv e_parser->publish() line ? of unknownf ile: call to progressiv e_parser->end_tag() line 158 of /backup/util/xml/parser/progressiv e_parser.class.php: call to xml_parse() line 137 of /backup/util/xml/parser/progressiv e_parser.class.php: call to progressiv e_parser->parse() line 105 of /backup/util/plan/restore_structure_step.class.php: call to progressiv e_parser->process() line 153 of /backup/util/plan/base_task.class.php: call to restore_structure_step->execute() line 148 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 147 of /backup/util/ui/restore_ui.class.php: call to restore_controller->execute_plan() line 46 of /backup/restore.php: call to restore_ui->execute() error/error_question_answers_missing_in_db More information about this error Stack trace: line 159 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 148 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 147 of /backup/util/ui/restore_ui.class.php: call to restore_controller->execute_plan() line 46 of /backup/restore.php: call to restore_ui->execute()
          Mike Churchward made changes -
          Link This issue has a non-specific relationship to MDL-30018 [ MDL-30018 ]
          Hide
          Eloy Lafuente (stronk7) added a comment -

          Hi Andrew et all,

          this really seems to be a dupe of MDL-30680 where the issue is being fixed. So, if you can try this patch:

          https://github.com/stronk7/moodle/compare/MDL-30018

          and send some feedback here / there, it would be really helpful.

          TIA and ciao

          Show
          Eloy Lafuente (stronk7) added a comment - Hi Andrew et all, this really seems to be a dupe of MDL-30680 where the issue is being fixed. So, if you can try this patch: https://github.com/stronk7/moodle/compare/MDL-30018 and send some feedback here / there, it would be really helpful. TIA and ciao
          Hide
          Brian King added a comment - - edited

          I'm seeing this problem on Moodle 2.2.4 (upgraded from 1.9.x), with or without the patch Eloy mentions above.

          It's failing when trying to restore a system-level question. There are hundreds of system level questions. The question that is failing to restore is not used in a quiz in this course. In fact, it's not used in any quiz at the moment. Is there some reason to include system-level questions in a course backup when they are not used by any quiz in the course?

          Show
          Brian King added a comment - - edited I'm seeing this problem on Moodle 2.2.4 (upgraded from 1.9.x), with or without the patch Eloy mentions above. It's failing when trying to restore a system-level question. There are hundreds of system level questions. The question that is failing to restore is not used in a quiz in this course. In fact, it's not used in any quiz at the moment. Is there some reason to include system-level questions in a course backup when they are not used by any quiz in the course?
          Brian King made changes -
          Labels triaged partner triaged
          Hide
          Anna Krassa added a comment -

          Hi I am facing the same problem, getting the "error/error_question_answers_missing_in_db" when trying to backup a course that contains a quiz where its questions are stored in system level.

          It doesn't matter if they are old questions (the site had migrate from 1.9 to 2.0, then 2.2+) or new ones. The System level quiz question category is the problem.

          To restore these courses I have to move the quiz category from system level to a lower one (course category, or course level).

          Here is a screencast of what's going on: http://youtu.be/3ifUPwelgvM

          I think we have this problem after the latter update into 2.2.4, we hadn't this problem earlier this year.

          Show
          Anna Krassa added a comment - Hi I am facing the same problem, getting the "error/error_question_answers_missing_in_db" when trying to backup a course that contains a quiz where its questions are stored in system level. It doesn't matter if they are old questions (the site had migrate from 1.9 to 2.0, then 2.2+) or new ones. The System level quiz question category is the problem. To restore these courses I have to move the quiz category from system level to a lower one (course category, or course level). Here is a screencast of what's going on: http://youtu.be/3ifUPwelgvM I think we have this problem after the latter update into 2.2.4, we hadn't this problem earlier this year.
          Hide
          Eloy Lafuente (stronk7) added a comment -

          U P S T R E A M I Z E D !

          Many thanks, this is now available in all the repos (git & cvs).

          Closing, ciao

          Show
          Eloy Lafuente (stronk7) added a comment - U P S T R E A M I Z E D ! Many thanks, this is now available in all the repos (git & cvs). Closing, ciao
          Eloy Lafuente (stronk7) made changes -
          Status Development in progress [ 3 ] Closed [ 6 ]
          Resolution Fixed [ 1 ]
          Hide
          Eloy Lafuente (stronk7) added a comment -

          Doh,

          somehow this issue was closed incorrectly when processing all the integrated issues this week. (sort of most voted and current in integration filters mix). Apologies for the confusion, reseting to previous status!

          Ciao, Eloy

          Show
          Eloy Lafuente (stronk7) added a comment - Doh, somehow this issue was closed incorrectly when processing all the integrated issues this week. (sort of most voted and current in integration filters mix). Apologies for the confusion, reseting to previous status! Ciao, Eloy
          Eloy Lafuente (stronk7) made changes -
          Resolution Fixed [ 1 ]
          Status Closed [ 6 ] Reopened [ 4 ]
          Hide
          omer added a comment -

          anything new on this subject ?
          workarounds maybe ?

          Thanks

          Show
          omer added a comment - anything new on this subject ? workarounds maybe ? Thanks
          Hide
          Rob added a comment -

          Hi Omer,
          There are lines of code that you can comment out to clear the error. Read through the comment to find out which ones.

          Show
          Rob added a comment - Hi Omer, There are lines of code that you can comment out to clear the error. Read through the comment to find out which ones.
          Hide
          omer added a comment -

          just comment out the "throw exception" lines ?
          isnt this "cheating" ?
          the real problem is still there ?

          or was it just throwing exceptions for no reason ?

          Show
          omer added a comment - just comment out the "throw exception" lines ? isnt this "cheating" ? the real problem is still there ? or was it just throwing exceptions for no reason ?
          Hide
          Matt Fedorko added a comment -

          That's what we did and haven't had a problem since. I, too, would love the 'actual problem' to be solved, but if the 'actual problem' is that its throwing exceptions when it shouldn't, that's fine with me too.

          Show
          Matt Fedorko added a comment - That's what we did and haven't had a problem since. I, too, would love the 'actual problem' to be solved, but if the 'actual problem' is that its throwing exceptions when it shouldn't, that's fine with me too.
          Tim Hunt made changes -
          Link This issue has been marked as being related by MDL-36683 [ MDL-36683 ]
          Hide
          Jean-Michel Vedrine added a comment - - edited

          Even if MDL-36683 title is about quiz duplication, not backup/restore, my tests show that it will resolve this issue too !

          Show
          Jean-Michel Vedrine added a comment - - edited Even if MDL-36683 title is about quiz duplication, not backup/restore, my tests show that it will resolve this issue too !
          Jean-Michel Vedrine made changes -
          Link This issue will be resolved by MDL-36683 [ MDL-36683 ]
          Jean-Michel Vedrine made changes -
          Link This issue has been marked as being related by MDL-36683 [ MDL-36683 ]
          Nadav Kavalerchik made changes -
          Link This issue has been marked as being related by MDL-30680 [ MDL-30680 ]
          Chris Follin made changes -
          Labels partner triaged moodlerooms partner triaged
          Hide
          Chris Follin added a comment -

          We have several clients reporting an inability to import or restore certain courses. With debugging on and importing one particular course with one quiz, we're seeing multiple instances of this error:

          Error: mdb->get_record() found more than one record!

          • line 1372 of /lib/dml/moodle_database.php: call to debugging()
          • line 1332 of /lib/dml/moodle_database.php: call to moodle_database->get_record_sql()
          • line 1311 of /lib/dml/moodle_database.php: call to moodle_database->get_record_select()
          • line 624 of /backup/util/dbops/restore_dbops.class.php: call to moodle_database->get_record()
          • line 490 of /backup/util/dbops/restore_dbops.class.php: call to restore_dbops::prechek_precheck_qbanks_by_level()
          • line 135 of /backup/util/helper/restore_prechecks_helper.class.php: call to restore_dbops::precheck_categories_and_questions()
          • line 338 of /backup/controller/restore_controller.class.php: call to restore_prechecks_helper::execute_prechecks()
          • line 114 of /backup/import.php: call to restore_controller->execute_precheck()

          Followed by multiple instances of this error:

          Error: mdb->get_record() found more than one record!

          • line 1372 of /lib/dml/moodle_database.php: call to debugging()
          • line 1433 of /lib/dml/moodle_database.php: call to moodle_database->get_record_sql()
          • line 156 of /backup/moodle2/restore_qtype_plugin.class.php: call to moodle_database->get_field_sql()
          • 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()

          Then the whole process ultimately dies with this error:

          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] => xxxxxx
          [dbquestionid] => xxxxxx
          [answer] => xxxxxx
          )
          Stack trace:

          • line 180 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()

          I've stepped through this to find what the duplicate data is. What follows is where the "more than one record" debug message is thrown while trying to match up questions, categories, and answers.

          SELECT * FROM {question} WHERE category = ? AND stamp = ? AND version = ?
          

          has 10 value combinations that return two records each. Moodle is expecting only one record.

          SELECT * FROM {question_categories} WHERE contextid = ? AND stamp = ?
          

          has 2 value combinations that return two records each. Again, it's expecting a single record.

          SELECT id FROM {question_answers} WHERE question = ? AND answer = ?
          

          has 33 value combinations that return either two or three records each. A single record is expected each time.

          The process does not halt on the duplicates, it only outputs a debugging message. But it seems to cause problems when the answers are matched, or I should say attempted to be matched. When more than one record is returned, the array is reset to the first item. I believe that the proper match would actually be on the id for the second record, so the match fails and Moodle throws the exception. That's where this:

          SELECT id
                                FROM {question_answers}
                               WHERE question = ?
                                 AND answer = ?
          

          finds no match.

          What I don't know is exactly how these duplicate records are getting into the database. So far we have not been able to reproduce the duplicates from scratch; we have only observed them in real-world data. Regardless of how they got there, if the code depends on lookup values to be unique, perhaps there should be a unique index to ensure that we don't have duplicates. Speaking of indexes, some of these columns being used as lookup fields are not indexed at all (uniquely or otherwise) and it is causing extreme slowness when importing/restoring quizzes. "Stamp," for example, is not indexed but is used for lookups on the question and question_categories tables.

          I'm also not sure of the best path forward to clean up the duplicates and restore the import functionality to these courses.

          Show
          Chris Follin added a comment - We have several clients reporting an inability to import or restore certain courses. With debugging on and importing one particular course with one quiz, we're seeing multiple instances of this error: Error: mdb->get_record() found more than one record! line 1372 of /lib/dml/moodle_database.php: call to debugging() line 1332 of /lib/dml/moodle_database.php: call to moodle_database->get_record_sql() line 1311 of /lib/dml/moodle_database.php: call to moodle_database->get_record_select() line 624 of /backup/util/dbops/restore_dbops.class.php: call to moodle_database->get_record() line 490 of /backup/util/dbops/restore_dbops.class.php: call to restore_dbops::prechek_precheck_qbanks_by_level() line 135 of /backup/util/helper/restore_prechecks_helper.class.php: call to restore_dbops::precheck_categories_and_questions() line 338 of /backup/controller/restore_controller.class.php: call to restore_prechecks_helper::execute_prechecks() line 114 of /backup/import.php: call to restore_controller->execute_precheck() Followed by multiple instances of this error: Error: mdb->get_record() found more than one record! line 1372 of /lib/dml/moodle_database.php: call to debugging() line 1433 of /lib/dml/moodle_database.php: call to moodle_database->get_record_sql() line 156 of /backup/moodle2/restore_qtype_plugin.class.php: call to moodle_database->get_field_sql() 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() Then the whole process ultimately dies with this error: 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] => xxxxxx [dbquestionid] => xxxxxx [answer] => xxxxxx ) Stack trace: line 180 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() I've stepped through this to find what the duplicate data is. What follows is where the "more than one record" debug message is thrown while trying to match up questions, categories, and answers. SELECT * FROM {question} WHERE category = ? AND stamp = ? AND version = ? has 10 value combinations that return two records each. Moodle is expecting only one record. SELECT * FROM {question_categories} WHERE contextid = ? AND stamp = ? has 2 value combinations that return two records each. Again, it's expecting a single record. SELECT id FROM {question_answers} WHERE question = ? AND answer = ? has 33 value combinations that return either two or three records each. A single record is expected each time. The process does not halt on the duplicates, it only outputs a debugging message. But it seems to cause problems when the answers are matched, or I should say attempted to be matched. When more than one record is returned, the array is reset to the first item. I believe that the proper match would actually be on the id for the second record, so the match fails and Moodle throws the exception. That's where this: SELECT id FROM {question_answers} WHERE question = ? AND answer = ? finds no match. What I don't know is exactly how these duplicate records are getting into the database. So far we have not been able to reproduce the duplicates from scratch; we have only observed them in real-world data. Regardless of how they got there, if the code depends on lookup values to be unique, perhaps there should be a unique index to ensure that we don't have duplicates. Speaking of indexes, some of these columns being used as lookup fields are not indexed at all (uniquely or otherwise) and it is causing extreme slowness when importing/restoring quizzes. "Stamp," for example, is not indexed but is used for lookups on the question and question_categories tables. I'm also not sure of the best path forward to clean up the duplicates and restore the import functionality to these courses.
          Hide
          Tim Hunt added a comment -

          Stamp should be unique. If it is not unique, Moodle will pick one of the two categories at random, and if it picks the wrong one, it will then later fail to find what it is looking for.

          My guess as to where the duplicates came from: some past backup and restore.

          Adding a unique index would be good, once we have eliminated the duplicates.

          The only way to eliminate the duplicates would to randomly change the stamp now. My guess is that the worst that could happen is this: When you restore a course that should be using shared questions, it will no longer find the shared questions (the stamps have changed) so it will restore new copies of the questions. Only you can say how bad that outcome would be for your clients.

          Show
          Tim Hunt added a comment - Stamp should be unique. If it is not unique, Moodle will pick one of the two categories at random, and if it picks the wrong one, it will then later fail to find what it is looking for. My guess as to where the duplicates came from: some past backup and restore. Adding a unique index would be good, once we have eliminated the duplicates. The only way to eliminate the duplicates would to randomly change the stamp now. My guess is that the worst that could happen is this: When you restore a course that should be using shared questions, it will no longer find the shared questions (the stamps have changed) so it will restore new copies of the questions. Only you can say how bad that outcome would be for your clients.
          Hide
          Kris Stokking added a comment -

          My guess as to where the duplicates came from: some past backup and restore.

          100% agree that backup and restore is the likely culprit, and hoping that there are no other cases. The solution will require more than fixing the duplicates and adding an index. Otherwise, we'll just be changing the way users get a fatal error in the restore process. Ideally, we'd need to change the logic such that if the restore attempts to create a question that was created by some other concurrent restore, it attempts to look it up again, but I am making a very strong assumption that we can even do that...

          Adding a unique index would be good, once we have eliminated the duplicates.

          Even finding the duplicates is a challenge on large sites since there is no index to utilize, unless you think we can somehow use the category in some way that is not obvious to me.

          The only way to eliminate the duplicates would to randomly change the stamp now. My guess is that the worst that could happen is this: When you restore a course that should be using shared questions, it will no longer find the shared questions (the stamps have changed) so it will restore new copies of the questions.

          Is that true? Assuming that you don't change one of the duplicates (aka "the original"), wouldn't the shared question continue to link to it?

          /end response to Tim

          On a related note, this is a common problem across Moodle, particularly with the restore process, that is actually magnified in a somewhat non-obvious way. If 2 instructors restore the same backup on the same server, their execution will appear to run almost exactly in parallel because performance improvements on the web server (mainly caching, inside and outside of Moodle) will allow the slower process to catch up. This is somewhat mitigated by the fact that most production environments typically spread requests across multiple servers, but the simple truth is that there is a very real possibility that duplication checks will fail - and we should be coding with that realization. While, cleaning up duplicates is a PITA, cleaning up duplicates on hundreds of sites can be an absolute nightmare...

          One solution is to implement unique constraints when the data should be considered unique (this is good practice anyway), and to simply lookup the record if the insert fails, as described above with the same strong assumption. It might be as easy as adding a function to the DML that does this for us based on a passed set of fields that can be used for the unique lookup. That won't work in every case, but any improvement to avoid duplicates will be one we thank ourselves for later without even realizing it!

          Show
          Kris Stokking added a comment - My guess as to where the duplicates came from: some past backup and restore. 100% agree that backup and restore is the likely culprit, and hoping that there are no other cases. The solution will require more than fixing the duplicates and adding an index. Otherwise, we'll just be changing the way users get a fatal error in the restore process. Ideally, we'd need to change the logic such that if the restore attempts to create a question that was created by some other concurrent restore, it attempts to look it up again, but I am making a very strong assumption that we can even do that... Adding a unique index would be good, once we have eliminated the duplicates. Even finding the duplicates is a challenge on large sites since there is no index to utilize, unless you think we can somehow use the category in some way that is not obvious to me. The only way to eliminate the duplicates would to randomly change the stamp now. My guess is that the worst that could happen is this: When you restore a course that should be using shared questions, it will no longer find the shared questions (the stamps have changed) so it will restore new copies of the questions. Is that true? Assuming that you don't change one of the duplicates (aka "the original"), wouldn't the shared question continue to link to it? /end response to Tim On a related note, this is a common problem across Moodle, particularly with the restore process, that is actually magnified in a somewhat non-obvious way. If 2 instructors restore the same backup on the same server, their execution will appear to run almost exactly in parallel because performance improvements on the web server (mainly caching, inside and outside of Moodle) will allow the slower process to catch up. This is somewhat mitigated by the fact that most production environments typically spread requests across multiple servers, but the simple truth is that there is a very real possibility that duplication checks will fail - and we should be coding with that realization. While, cleaning up duplicates is a PITA, cleaning up duplicates on hundreds of sites can be an absolute nightmare... One solution is to implement unique constraints when the data should be considered unique (this is good practice anyway), and to simply lookup the record if the insert fails, as described above with the same strong assumption. It might be as easy as adding a function to the DML that does this for us based on a passed set of fields that can be used for the unique lookup. That won't work in every case, but any improvement to avoid duplicates will be one we thank ourselves for later without even realizing it!
          Hide
          Kasper Lauest added a comment - - edited

          Is there a solution for this problem that works with Moodle 2.4.3?

          EDIT: To clarify, according to our systems administrator, the "commenting out" fix mentioned in this thread doesn't appear to be relevant for Moodle 2.4.3+. He cannot locate the relevant lines anywhere.

          Show
          Kasper Lauest added a comment - - edited Is there a solution for this problem that works with Moodle 2.4.3? EDIT: To clarify, according to our systems administrator, the "commenting out" fix mentioned in this thread doesn't appear to be relevant for Moodle 2.4.3+. He cannot locate the relevant lines anywhere.
          Russell Smith made changes -
          Link This issue has been marked as being related by MDL-29439 [ MDL-29439 ]
          Chris Follin made changes -
          Affects Version/s 2.3.3 [ 12373 ]
          Hide
          Eloy Lafuente (stronk7) added a comment -

          This issue was assigned to me automatically, however I will not be able to work on this issue in the immediate future. In order to create a truer sense of the state of this issue and to allow other developers to have chance to become involved, I am removing myself as the assignee of this issue.

          For more information, see http://docs.moodle.org/dev/Changes_to_issue_assignment

          Show
          Eloy Lafuente (stronk7) added a comment - This issue was assigned to me automatically, however I will not be able to work on this issue in the immediate future. In order to create a truer sense of the state of this issue and to allow other developers to have chance to become involved, I am removing myself as the assignee of this issue. For more information, see http://docs.moodle.org/dev/Changes_to_issue_assignment
          Eloy Lafuente (stronk7) made changes -
          Assignee Eloy Lafuente (stronk7) [ stronk7 ]
          Chris Follin made changes -
          Affects Version/s 2.4.4 [ 12575 ]
          Hide
          Michael de Raadt added a comment -

          Hi, all.

          I've just reviewed the long history of this issue and felt it necessary to make some points.

          • There appears to be a number of different errors that people are seeing and assuming they are the same error. It's likely there are multiple problems that need to be fixed, but at the moment they are not isolated.
          • No one has provided a set of replication steps, which makes it incredibly hard to isolate the cause of the problem. There may be a mix of core code and contributed code involved, which makes it even more difficult to debug. At the moment, people are making best guesses based on assumptions.
          • The problem is probably not in the current code, but in corrupted data caused by a problem in Moodle in the past. The result is that when the restore/import code encounters corrupted data, it is not able to deal with it. It's likely that the corrupted data will never be able to be restored properly and the best result we may be able to achieve is better detection of corrupted data. Assumptions made in the import/restore process need to be checked.

          I'm wondering if people who have encountered this problem have tried to export the questions using the facility in the Question bank and then import them. It won't fix the problem, but this would allow the question content to be reused.

          Show
          Michael de Raadt added a comment - Hi, all. I've just reviewed the long history of this issue and felt it necessary to make some points. There appears to be a number of different errors that people are seeing and assuming they are the same error. It's likely there are multiple problems that need to be fixed, but at the moment they are not isolated. No one has provided a set of replication steps, which makes it incredibly hard to isolate the cause of the problem. There may be a mix of core code and contributed code involved, which makes it even more difficult to debug. At the moment, people are making best guesses based on assumptions. The problem is probably not in the current code, but in corrupted data caused by a problem in Moodle in the past. The result is that when the restore/import code encounters corrupted data, it is not able to deal with it. It's likely that the corrupted data will never be able to be restored properly and the best result we may be able to achieve is better detection of corrupted data. Assumptions made in the import/restore process need to be checked. I'm wondering if people who have encountered this problem have tried to export the questions using the facility in the Question bank and then import them. It won't fix the problem, but this would allow the question content to be reused.
          Hide
          Don Hinkelman added a comment - - edited

          Hi Michael,
          Thank you very much for taking the time to sort through the issues and mysteries of the Quiz Module and Question Bank. I am inclined to say 'yes' to all your points. First, there are probably multiple types of errors. Second, there are likely conflicts with third party question types (particularly, old drag-and-drop matching/ordering which are very popular with our teachers (by the way, I believe the new ddmatch in recent versions is much improved). Third, a comprehensive solution for dealing with corrupted 1.9 quiz data is just not possible or worth the time. We just rebuild 1.9 quizzes item by item as needed and abandon most of them. I am more concerned with the ongoing issue of System Level questions causing so many problems with backup/restore, so much so that we have banned any use of System Level questions in our site. In so doing, we removed the ease of sharing that we once had. I hope a long look at the structure of the Question Bank can be made for 2.6 or 2.7.

          Show
          Don Hinkelman added a comment - - edited Hi Michael, Thank you very much for taking the time to sort through the issues and mysteries of the Quiz Module and Question Bank. I am inclined to say 'yes' to all your points. First, there are probably multiple types of errors. Second, there are likely conflicts with third party question types (particularly, old drag-and-drop matching/ordering which are very popular with our teachers (by the way, I believe the new ddmatch in recent versions is much improved). Third, a comprehensive solution for dealing with corrupted 1.9 quiz data is just not possible or worth the time. We just rebuild 1.9 quizzes item by item as needed and abandon most of them. I am more concerned with the ongoing issue of System Level questions causing so many problems with backup/restore, so much so that we have banned any use of System Level questions in our site. In so doing, we removed the ease of sharing that we once had. I hope a long look at the structure of the Question Bank can be made for 2.6 or 2.7.
          Hide
          Michael de Raadt added a comment -

          I suspect Tim is the best person to respond to that, having a good sense of Question Bank development.

          Show
          Michael de Raadt added a comment - I suspect Tim is the best person to respond to that, having a good sense of Question Bank development.
          Hide
          Tim Hunt added a comment -

          I don't know what sort of response you are after. I already know about the problem. No-one has yet thought of a solution. Until someone has worked out what the solution should look like, we can't code it. More detailed thoughts at http://docs.moodle.org/dev/Goals_of_an_online_assessment_system#Add_question_versioning_and_better_sharing_to_the_question_bank

          Show
          Tim Hunt added a comment - I don't know what sort of response you are after. I already know about the problem. No-one has yet thought of a solution. Until someone has worked out what the solution should look like, we can't code it. More detailed thoughts at http://docs.moodle.org/dev/Goals_of_an_online_assessment_system#Add_question_versioning_and_better_sharing_to_the_question_bank
          Hide
          raul added a comment -

          Hi

          I have a very simmilar issue, I'm call the core_course_import_course remote web service,
          and it calls import_course() in course/externallib.php module, after somewhere the code
          reach the importing core functions and the error_question_answers_missing_in_db error
          happens.

          I tried kyle's solution, to trim the answer field in the questions table, and then the
          problem solved

          We have installed moodle 2.4.5 and we have courses comming from 1.9, it looks that the
          course is imported ok but the problem arises where we try to copy content fron the
          course imported to new courses

          I hope this will be usefull to someone.

          Show
          raul added a comment - Hi I have a very simmilar issue, I'm call the core_course_import_course remote web service, and it calls import_course() in course/externallib.php module, after somewhere the code reach the importing core functions and the error_question_answers_missing_in_db error happens. I tried kyle's solution, to trim the answer field in the questions table, and then the problem solved We have installed moodle 2.4.5 and we have courses comming from 1.9, it looks that the course is imported ok but the problem arises where we try to copy content fron the course imported to new courses I hope this will be usefull to someone.
          Hide
          Rob added a comment -

          Hi Raul,

          Would you please detail the steps you took to trim the answer table? I would like to test it on a copy of my site.

          Show
          Rob added a comment - Hi Raul, Would you please detail the steps you took to trim the answer table? I would like to test it on a copy of my site.
          Hide
          raul added a comment - - edited

          Of course.

          I just run this command on the moodle mysql database:

          update mdl_question_answers set answer = ltrim (answer) where answer like ' %';

          maybe you also need to do a rtrim:

          update mdl_question_answers set answer = rtrim (answer) where answer like '% ';

          Show
          raul added a comment - - edited Of course. I just run this command on the moodle mysql database: update mdl_question_answers set answer = ltrim (answer) where answer like ' %'; maybe you also need to do a rtrim: update mdl_question_answers set answer = rtrim (answer) where answer like '% ';
          Hide
          Kris Stokking added a comment -

          This issue could be mitigated once Moodle Locking is implemented. A lock could be acquired when writing questions to the database based on the unique keys. If a subsequent process executes such that it would create duplicate records, it would hit the lock and we could either wait and re-process with the newly created records (if that's possible, I'm making assumptions) or at the very least throw an error to prevent faulty data. This won't fix the problem of legacy data that needs to be cleaned up, but it should be fairly straightforward and stop the bleeding.

          Cleaning up the data would likely need to be done during the upgrade process, or perhaps an admin tool. The steps would be:

          1. Create an index (non-unique) on the key fields.
          2. Find non-unique records and do something with them. We haven't yet figured out what that should be...
          3. Drop and re-create the index on the key fields, this time with a unique constraint to guarantee there are no duplicates.

          Tim, what do you think of this approach?

          Show
          Kris Stokking added a comment - This issue could be mitigated once Moodle Locking is implemented. A lock could be acquired when writing questions to the database based on the unique keys. If a subsequent process executes such that it would create duplicate records, it would hit the lock and we could either wait and re-process with the newly created records (if that's possible, I'm making assumptions) or at the very least throw an error to prevent faulty data. This won't fix the problem of legacy data that needs to be cleaned up, but it should be fairly straightforward and stop the bleeding. Cleaning up the data would likely need to be done during the upgrade process, or perhaps an admin tool. The steps would be: Create an index (non-unique) on the key fields. Find non-unique records and do something with them. We haven't yet figured out what that should be... Drop and re-create the index on the key fields, this time with a unique constraint to guarantee there are no duplicates. Tim, what do you think of this approach?
          Hide
          Jean-Francois Belisle added a comment - - edited

          We're having the same issue, I post the stack trace hoping it can give a bit more information for those working on the issue.

          Importing quiz from moodle2 into another course in moodle2 which was imported from 1.9.

          Debug info: 
          Error code: error_question_answers_missing_in_db
          $a contents: stdClass Object
          (
          [filequestionid] => 19974
          [dbquestionid] => 19837
          [answer] => O8. La perception du travailleur d’une surcharge subjective de travail
          )
          Stack trace:
          line 185 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 151 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 167 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 138 of /backup/import.php: call to restore_controller->execute_plan()
          
          Show
          Jean-Francois Belisle added a comment - - edited We're having the same issue, I post the stack trace hoping it can give a bit more information for those working on the issue. Importing quiz from moodle2 into another course in moodle2 which was imported from 1.9. Debug info: Error code: error_question_answers_missing_in_db $a contents: stdClass Object ( [filequestionid] => 19974 [dbquestionid] => 19837 [answer] => O8. La perception du travailleur d’une surcharge subjective de travail ) Stack trace: line 185 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 151 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 167 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 138 of /backup/ import .php: call to restore_controller->execute_plan()
          Hide
          Jean-Michel Vedrine added a comment -

          Hello Jean-François,
          In what version of Moodle 2 was the backup restored (first time it was restored from 1.9 backup) ? Do you have access to the database of this Moodle ?
          Unfortunately as you say "Importing quiz from moodle2 into another course in moodle2 which was imported from 1.9" it will probably be hard to find if the problem started when the question was first restored, or during the 2.x -> 2.x backup/restore.

          Show
          Jean-Michel Vedrine added a comment - Hello Jean-François, In what version of Moodle 2 was the backup restored (first time it was restored from 1.9 backup) ? Do you have access to the database of this Moodle ? Unfortunately as you say "Importing quiz from moodle2 into another course in moodle2 which was imported from 1.9" it will probably be hard to find if the problem started when the question was first restored, or during the 2.x -> 2.x backup/restore.
          Hide
          Jean-Francois Belisle added a comment -

          The backup was restore in version Moodle 2.5.2+ (Build: 20131101) and yes I do have access to the database.

          Show
          Jean-Francois Belisle added a comment - The backup was restore in version Moodle 2.5.2+ (Build: 20131101) and yes I do have access to the database.
          Hide
          David Lowe added a comment -

          Hey All,

          I was in a bind to get a course restored and kept getting an error message "Error code: error_question_answers_missing_in_db". I had no time to dig into the code so I found a quick fix that didn't involve making database queries. This fix was spawned from Kyle's and Raul's suggestions.

          1. Take your [backup].mbz and change the .mbz to .zip
          2. Unzip
          3. Open your questions.xml file and find/replace all "<answertext> " with "<answertext>" (we are removing the space after <answertext>)
          4. Zip all files and folders and rename .zip to .mbz
          5. restore and hopefully this will help someone else out there.

          Cheers.

          Show
          David Lowe added a comment - Hey All, I was in a bind to get a course restored and kept getting an error message "Error code: error_question_answers_missing_in_db". I had no time to dig into the code so I found a quick fix that didn't involve making database queries. This fix was spawned from Kyle's and Raul's suggestions. 1. Take your [backup] .mbz and change the .mbz to .zip 2. Unzip 3. Open your questions.xml file and find/replace all "<answertext> " with "<answertext>" (we are removing the space after <answertext>) 4. Zip all files and folders and rename .zip to .mbz 5. restore and hopefully this will help someone else out there. Cheers.
          Hide
          Jean-Michel Vedrine added a comment -

          Hello David Lowe,
          It seems to me you are into something that need been explored, it seems an untrimmed text is compared with a trimmed one and this is why the comparison is failing and the answer declared as missing.
          What version of Moodle was used to do the backup and to do the restore ?

          Show
          Jean-Michel Vedrine added a comment - Hello David Lowe, It seems to me you are into something that need been explored, it seems an untrimmed text is compared with a trimmed one and this is why the comparison is failing and the answer declared as missing. What version of Moodle was used to do the backup and to do the restore ?
          Hide
          Jean-Michel Vedrine added a comment -

          Of course solving this trimming problem will not work for all cases because I think that as Michael said "There appears to be a number of different errors that people are seeing and assuming they are the same error. It's likely there are multiple problems that need to be fixed,"

          Show
          Jean-Michel Vedrine added a comment - Of course solving this trimming problem will not work for all cases because I think that as Michael said "There appears to be a number of different errors that people are seeing and assuming they are the same error. It's likely there are multiple problems that need to be fixed,"
          Hide
          David Lowe added a comment -

          @Jean-Michel
          The course was backed up from 2.4.2 and restored into 2.5.1. Running a query against the 2.4.2 db did show that there were answers that had a leading blank space. Changing the .mbz was a shot in the dark......and worked.
          2.5.x may have solved this for the backup process? IDK as I haven't yet looked into the code.

          Show
          David Lowe added a comment - @Jean-Michel The course was backed up from 2.4.2 and restored into 2.5.1. Running a query against the 2.4.2 db did show that there were answers that had a leading blank space. Changing the .mbz was a shot in the dark......and worked. 2.5.x may have solved this for the backup process? IDK as I haven't yet looked into the code.
          Hide
          Paul Vaughan added a comment -

          Have voted for this to increase awareness of the issue, as have just had a report of this from one of our admins (backup from Moodle 2.5.4, restoring into same). I will attempt the fix suggested by David Lowe.

          Thanks.

          Show
          Paul Vaughan added a comment - Have voted for this to increase awareness of the issue, as have just had a report of this from one of our admins (backup from Moodle 2.5.4, restoring into same). I will attempt the fix suggested by David Lowe. Thanks.
          Paul Vaughan made changes -
          Affects Version/s 2.5.4 [ 12855 ]
          Hide
          Sam Alexander added a comment - - edited

          I would get the error code, "Error code: error_question_answers_missing_in_db", when trying to import from one class to the next. The class importing from was a 1.9 restore as well. The classes are running on a 2.5 server. Looking at these threads I did some research and found out that the database had answers that had leading and/or trailing spaces. I used the following query to check for them:

          SELECT answer FROM `mdl_question_answers` WHERE answer LIKE " %" OR "% ";

          At first I only looked for leading spaces, fixed them, and still had the issue. I then looked for trailing spaces, fixed them, and now there is no issue. Here is a line that will TRIM both leading and trailing spaces for those lines:

          UPDATE mdl_question_answers SET answer = TRIM(answer) WHERE answer LIKE " %" OR "% ";

          I hope this helps anyone else out there as well as getting the issue resolved.

          Show
          Sam Alexander added a comment - - edited I would get the error code, "Error code: error_question_answers_missing_in_db", when trying to import from one class to the next. The class importing from was a 1.9 restore as well. The classes are running on a 2.5 server. Looking at these threads I did some research and found out that the database had answers that had leading and/or trailing spaces. I used the following query to check for them: SELECT answer FROM `mdl_question_answers` WHERE answer LIKE " %" OR "% "; At first I only looked for leading spaces, fixed them, and still had the issue. I then looked for trailing spaces, fixed them, and now there is no issue. Here is a line that will TRIM both leading and trailing spaces for those lines: UPDATE mdl_question_answers SET answer = TRIM(answer) WHERE answer LIKE " %" OR "% "; I hope this helps anyone else out there as well as getting the issue resolved.