Details

    • Type: Bug
    • Status: Closed
    • Priority: Minor
    • Resolution: Fixed
    • Affects Version/s: 2.1, 2.2
    • Fix Version/s: 2.1.2
    • Component/s: Questions
    • Labels:
    • Database:
      MySQL
    • Testing Instructions:
      Hide

      1. Go to the question bank in any course.
      2. (Optionally) create a new question category called something like 'Import test'
      3. Select Question bank -> Import in the settings navigation.
      4. Import the example file you can find at question/format/aiken/simpletest/fixtures/questions.aiken.txt

      For a better test, make your own file to try importing.

      Show
      1. Go to the question bank in any course. 2. (Optionally) create a new question category called something like 'Import test' 3. Select Question bank -> Import in the settings navigation. 4. Import the example file you can find at question/format/aiken/simpletest/fixtures/questions.aiken.txt For a better test, make your own file to try importing.
    • Workaround:
      Hide

      The problem seems to be in 'question/format/aiken/format.php' around line 78.

      If you change it from...


      if (preg_match('/^[A-Z][).][ \t]/', $nowline))

      { // A choice. Trim off the label and space, then save $question->answer[] = htmlspecialchars(trim(substr($nowline, 2)), ENT_NOQUOTES); $question->fraction[] = 0; $question->feedback[] = ''; continue; }

      to....


      if (preg_match('/^[A-Z][).][ \t]/', $nowline))

      { // A choice. Trim off the label and space, then save $question->answer[] = array('text' => htmlspecialchars(trim(substr($nowline, 2)), ENT_NOQUOTES), 'format' => 0, 'files' => array()); $question->fraction[] = 0; $question->feedback[] = ''; continue; }

      it resolves the import issue.

      Show
      The problem seems to be in 'question/format/aiken/format.php' around line 78. If you change it from... if (preg_match('/^ [A-Z] [).] [ \t]/', $nowline)) { // A choice. Trim off the label and space, then save $question->answer[] = htmlspecialchars(trim(substr($nowline, 2)), ENT_NOQUOTES); $question->fraction[] = 0; $question->feedback[] = ''; continue; } to.... if (preg_match('/^ [A-Z] [).] [ \t]/', $nowline)) { // A choice. Trim off the label and space, then save $question->answer[] = array('text' => htmlspecialchars(trim(substr($nowline, 2)), ENT_NOQUOTES), 'format' => 0, 'files' => array()); $question->fraction[] = 0; $question->feedback[] = ''; continue; } it resolves the import issue.
    • Affected Branches:
      MOODLE_21_STABLE, MOODLE_22_STABLE
    • Fixed Branches:
      MOODLE_21_STABLE
    • Pull from Repository:
    • Pull Master Branch:

      Description

      When attempting to import questions in Aiken format, the upload fails with the following information...

      Parsing questions from import file.

      Importing 2 questions from file

      Notice: Undefined property: stdClass::$questiontextformat in /usr/local/moodle/question/format.php on line 874

      1. How can ecology best help each of us understand the role of humans in nature?

      Notice: Uninitialized string offset: 0 in /usr/local/moodle/question/type/questiontypebase.php on line 1066 Notice: Uninitialized string offset: 0 in /usr/local/moodle/question/type/multichoice/questiontype.php on line 90

      Error writing to database

      More information about this error

      Debug info: Incorrect integer value: 'E' for column 'answerformat' at row 1

      UPDATE mdl_question_answers SET question = ?,answer = ?,feedback = ?,answerformat = ?,fraction = ?,feedbackformat = ? WHERE id=?
      [array (
      0 => 12952,
      1 => 'E',
      2 => '',
      3 => 'E',
      4 => 0,
      5 => 0,
      6 => 50466,
      )]

      Stack trace:
      line 397 of /lib/dml/moodle_database.php: dml_write_exception thrown
      line 984 of /lib/dml/mysqli_native_moodle_database.php: call to moodle_database->query_end()
      line 1016 of /lib/dml/mysqli_native_moodle_database.php: call to mysqli_native_moodle_database->update_record_raw()
      line 92 of /question/type/multichoice/questiontype.php: call to mysqli_native_moodle_database->update_record()
      line 417 of /question/format.php: call to qtype_multichoice->save_question_options()
      line 121 of /question/import.php: call to qformat_default->importprocess()

      The problem seems to be that the functions that handle the Aiken format import passes a string with the text of the answer when the database import expects to get an array containing: format, text, and files.

        Gliffy Diagrams

          Activity

          Hide
          stronk7 Eloy Lafuente (stronk7) added a comment -

          Integrated, thanks!

          Show
          stronk7 Eloy Lafuente (stronk7) added a comment - Integrated, thanks!
          Hide
          rajeshtaneja Rajesh Taneja added a comment -

          Questions imported successfully
          Thanks for fixing this Tim.

          Show
          rajeshtaneja Rajesh Taneja added a comment - Questions imported successfully Thanks for fixing this Tim.
          Hide
          stronk7 Eloy Lafuente (stronk7) added a comment -

          Closing, this is now part of Moodle. Big thanks!

          Show
          stronk7 Eloy Lafuente (stronk7) added a comment - Closing, this is now part of Moodle. Big thanks!

            People

            • Votes:
              1 Vote for this issue
              Watchers:
              2 Start watching this issue

              Dates

              • Created:
                Updated:
                Resolved:
                Fix Release Date:
                10/Oct/11