Uploaded image for project: 'Moodle'
  1. Moodle
  2. MDL-38117

Multiple warnings on questions restore

    XMLWordPrintable

    Details

    • Type: Bug
    • Status: Closed
    • Priority: Major
    • Resolution: Cannot Reproduce
    • Affects Version/s: 2.4.1
    • Fix Version/s: None
    • Component/s: Backup, Questions
    • Labels:
    • Affected Branches:
      MOODLE_24_STABLE

      Description

      Sometimes getting multiple warnings, when restoring question bank. Did you remember to make the first column something unique in your call to get_records?

      Duplicate value '1959' found in column 'contextid'.
      line 1032 of \lib\dml\mysqli_native_moodle_database.php: call to debugging()
      line 761 of \backup\util\dbops\restore_dbops.class.php: call to mysqli_native_moodle_database->get_records_sql()
      line 569 of \backup\util\dbops\restore_dbops.class.php: call to restore_dbops::restore_find_best_target_context()
      line 486 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()

      \backup\util\dbops\restore_dbops.class.php line 756
      I think SELECT DISTINCT should be used insetead of SELECT

      Error: mdb->get_record() found more than one record!
      line 1394 of \lib\dml\moodle_database.php: call to debugging()
      line 1455 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 139 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 suppose problem is because sometimes question bank contains questions with equal text.

      backup\moodle2\restore_qtype_plugin.class.php, line
      $sql = 'SELECT id
      FROM

      {question_answers}

      WHERE question = ?
      AND ' . $DB->sql_compare_text('answer', 255) . ' = ' . $DB->sql_compare_text('?', 255);
      $params = array($newquestionid, $data->answertext);
      $newitemid = $DB->get_field_sql($sql, $params);

      I think IGNORE_MULTIPLE should be added to get_field_sql. Maybe we should use more complex logic when multiple values are found

        Attachments

          Issue Links

            Activity

              People

              Assignee:
              Unassigned
              Reporter:
              vadimon Vadim Dvorovenko
              Participants:
              Component watchers:
              Adrian Greeve, Jake Dallimore, Mathew May, Mihail Geshoski, Peter Dias, Tim Hunt, Andrew Nicols, Jun Pataleta, Michael Hawkins, Shamim Rezaie, Simey Lameze
              Votes:
              1 Vote for this issue
              Watchers:
              6 Start watching this issue

                Dates

                Created:
                Updated:
                Resolved: