Moodle
  1. Moodle
  2. MDL-30760

Error, questionsummary too big, mod/quiz upgrade from 2.0.6 to 2.2+ (Build: 20111209)

    Details

    • Type: Bug Bug
    • Status: Closed
    • Priority: Major Major
    • Resolution: Fixed
    • Affects Version/s: 2.2
    • Fix Version/s: 2.1.4, 2.2.1
    • Component/s: Quiz
    • Labels:
      None
    • Environment:
      Linux server, Apache,
    • Database:
      MySQL
    • Testing Instructions:
      Hide

      This needs to be tested on MySQL. Ideally on all supported databases, but that is probably too much to ask.

      1. Import the question in the attached .xml file into a 2.0 site.
      2. Add that question to a quiz.
      3. Attempt the quiz as a student.
      4. Try upgrading the site to Moodle 2.1 or 2.2. Make sure there are no errors.

      5. Import the attached question to a 2.1 or 2.2 site.
      6. Try to preview the question. Make sure there are no errors.

      Show
      This needs to be tested on MySQL. Ideally on all supported databases, but that is probably too much to ask. 1. Import the question in the attached .xml file into a 2.0 site. 2. Add that question to a quiz. 3. Attempt the quiz as a student. 4. Try upgrading the site to Moodle 2.1 or 2.2. Make sure there are no errors. 5. Import the attached question to a 2.1 or 2.2 site. 6. Try to preview the question. Make sure there are no errors.
    • Workaround:
      Hide

      Updated question/engine/upgrade/upgradelib.php
      line 248 by adding

      if (isset($qa->questionsummary) && (strlen($qa->questionsummary) > 65535))

      { $qa->questionsummary = substr($qa->questionsummary, 0, 65534); }
      Show
      Updated question/engine/upgrade/upgradelib.php line 248 by adding if (isset($qa->questionsummary) && (strlen($qa->questionsummary) > 65535)) { $qa->questionsummary = substr($qa->questionsummary, 0, 65534); }
    • Affected Branches:
      MOODLE_22_STABLE
    • Fixed Branches:
      MOODLE_21_STABLE, MOODLE_22_STABLE
    • Pull from Repository:
    • Pull Master Branch:

      Description

      When I upgrade our Clone from 2.0.6 to 2.2+ (after a previous update from 1.9.10 to 2.0.6), I
      get the following error:
      ---------------------
      Debug info: Data too long for column 'questionsummary' at row 1
      INSERT INTO moquestion_attempts (questionid,variant,behaviour,questionsummary,rightanswer,maxmark,minfraction,flagged,responsesummary,timemodified,questionusageid,slot) VALUES(?,?,?,?,?,?,?,?,?,?,?,?)
      -------------------
      The complete output is attached. Apparently, the questionsummary created is too large.
      The upgrade script should check whether the string is to large and cut it to the maximum size
      of the questionsummary field (type text) when necessary.

        Gliffy Diagrams

          Issue Links

            Activity

            Hide
            Tim Hunt added a comment -

            Both question.questiontext and question_attempt.questionsummary are supposed to be of type TEXT(SMALL), so there should not really be a problem.

            The problem question is the one with id 11698. What sort of question is that? Can you export it from you Moodle 1.9 site in Moodle XML format, and attach it here? Thanks.

            Show
            Tim Hunt added a comment - Both question.questiontext and question_attempt.questionsummary are supposed to be of type TEXT(SMALL), so there should not really be a problem. The problem question is the one with id 11698. What sort of question is that? Can you export it from you Moodle 1.9 site in Moodle XML format, and attach it here? Thanks.
            Hide
            Juergen Zimmer added a comment -

            Dear Tim,

            I've attached the XML for the question as well.

            Cheers
            Juergen

            Show
            Juergen Zimmer added a comment - Dear Tim, I've attached the XML for the question as well. Cheers Juergen
            Hide
            Tim Hunt added a comment -

            Thanks. I will investigate.

            Show
            Tim Hunt added a comment - Thanks. I will investigate.
            Hide
            Tim Hunt added a comment -

            Well you certainly get a prize for the most complex Cloze question I have ever seen!

            Show
            Tim Hunt added a comment - Well you certainly get a prize for the most complex Cloze question I have ever seen!
            Hide
            Sam Hemelryk added a comment -

            Thanks Tim - integrated now

            Show
            Sam Hemelryk added a comment - Thanks Tim - integrated now
            Hide
            Rossiani Wijaya added a comment -

            Each time I try to import the .xml file in 2.0 or 2.1, it displays 'error writting to database'.

            Is there any alternative testing instructions for this issue?

            Show
            Rossiani Wijaya added a comment - Each time I try to import the .xml file in 2.0 or 2.1, it displays 'error writting to database'. Is there any alternative testing instructions for this issue?
            Hide
            Tim Hunt added a comment -

            Can you turn on debugging to get the full error message? It worked for me.

            Show
            Tim Hunt added a comment - Can you turn on debugging to get the full error message? It worked for me.
            Hide
            Rossiani Wijaya added a comment -

            This is the error message:

            Debug info: Data too long for column 'answers' at row 1
            UPDATE mdl_question_multichoice SET question = ?,correctfeedback = ?,partiallycorrectfeedback = ?,incorrectfeedback = ?,answers = ?,single = ?,layout = ?,answernumbering = ?,shuffleanswers = ?,correctfeedbackformat = ?,partiallycorrectfeedbackformat = ?,incorrectfeedbackformat = ?,shownumcorrect = ? WHERE id=?
            [array (
            0 => 154,
            1 => '',
            2 => '',
            3 => '',
            4 => '6063,6064,6065,6066,6067,6068,6069,6070,6071,6072,6073,6074,6075,6076,6077,6078,6079,6080,6081,6082,6083,6084,6085,6086,6087,6088,6089,6090,6091,6092,6093,6094,6095,6096,6097,6098,6099,6100,6101,6102,6103,6104,6105,6106,6107,6108,6109,6110,6111,6112,6113,6114,6115,6116,6117,6118,6119,6120,6121,6122,6123,6124,6125,6126,6127,6128,6129,6130,6131,6132,6133,6134,6135,6136,6137,6138,6139,6140,6141,6142,6143,6144,6145,6146,6147,6148,6149,6150,6151,6152,6153,6154,6155,6156,6157,6158,6159,6160,6161,6162,6163,6164,6165,6166,6167,6168,6169,6170,6171,6172,6173,6174,6175,6176,6177,6178,6179,6180,6181,6182,6183,6184,6185,6186,6187,6188',
            5 => 1,
            6 => 0,
            7 => 0,
            8 => 1,
            9 => '1',
            10 => '1',
            11 => '1',
            12 => 0,
            13 => 90,
            )]
            

            I manually update the length of varchar, and it is fine.

            I will report more on this.

            Show
            Rossiani Wijaya added a comment - This is the error message: Debug info: Data too long for column 'answers' at row 1 UPDATE mdl_question_multichoice SET question = ?,correctfeedback = ?,partiallycorrectfeedback = ?,incorrectfeedback = ?,answers = ?,single = ?,layout = ?,answernumbering = ?,shuffleanswers = ?,correctfeedbackformat = ?,partiallycorrectfeedbackformat = ?,incorrectfeedbackformat = ?,shownumcorrect = ? WHERE id=? [array ( 0 => 154, 1 => '', 2 => '', 3 => '', 4 => '6063,6064,6065,6066,6067,6068,6069,6070,6071,6072,6073,6074,6075,6076,6077,6078,6079,6080,6081,6082,6083,6084,6085,6086,6087,6088,6089,6090,6091,6092,6093,6094,6095,6096,6097,6098,6099,6100,6101,6102,6103,6104,6105,6106,6107,6108,6109,6110,6111,6112,6113,6114,6115,6116,6117,6118,6119,6120,6121,6122,6123,6124,6125,6126,6127,6128,6129,6130,6131,6132,6133,6134,6135,6136,6137,6138,6139,6140,6141,6142,6143,6144,6145,6146,6147,6148,6149,6150,6151,6152,6153,6154,6155,6156,6157,6158,6159,6160,6161,6162,6163,6164,6165,6166,6167,6168,6169,6170,6171,6172,6173,6174,6175,6176,6177,6178,6179,6180,6181,6182,6183,6184,6185,6186,6187,6188', 5 => 1, 6 => 0, 7 => 0, 8 => 1, 9 => '1', 10 => '1', 11 => '1', 12 => 0, 13 => 90, )] I manually update the length of varchar, and it is fine. I will report more on this.
            Hide
            Rossiani Wijaya added a comment -

            Also, upgrading from 2.0 to 2.1 produce the following error during upgrade

            Notice: Undefined property: question_engine_attempt_upgrader::$typo3cs in /home/git/testupgrade/lib/textlib.class.php on line 165
             
            Fatal error: Call to a member function parse_charset() on a non-object in /home/git/testupgrade/lib/textlib.class.php on line 165
            

            Show
            Rossiani Wijaya added a comment - Also, upgrading from 2.0 to 2.1 produce the following error during upgrade Notice: Undefined property: question_engine_attempt_upgrader::$typo3cs in /home/git/testupgrade/lib/textlib.class.php on line 165   Fatal error: Call to a member function parse_charset() on a non-object in /home/git/testupgrade/lib/textlib.class.php on line 165
            Hide
            Rossiani Wijaya added a comment -

            I asked Jason to test this issue and he had the same error message while trying to import the attached xml file.

            Note: Tested using integration repository.

            Show
            Rossiani Wijaya added a comment - I asked Jason to test this issue and he had the same error message while trying to import the attached xml file. Note: Tested using integration repository.
            Hide
            Tim Hunt added a comment -

            The multichoice.answers problem is already a known issue. No need to report it again. (It is a messy problem to solve, so the fix will be 2.3 only. It only affects questions with many answers.)

            As you worked out, the correct fix is to change the column length.

            The Undefined property error is a real problem. I will fix it shortly.

            Show
            Tim Hunt added a comment - The multichoice.answers problem is already a known issue. No need to report it again. (It is a messy problem to solve, so the fix will be 2.3 only. It only affects questions with many answers.) As you worked out, the correct fix is to change the column length. The Undefined property error is a real problem. I will fix it shortly.
            Hide
            Tim Hunt added a comment -

            Just moving to test failed state

            Show
            Tim Hunt added a comment - Just moving to test failed state
            Hide
            Tim Hunt added a comment -

            I see. it is broken in 2.1 only. You cannot just cherry-pick code using textlib from 2.2 to 2.1. Nasty gotcha.

            The required fix is

            https://github.com/timhunt/moodle/compare/MOODLE_21_STABLE...MDL-30760_fixup_21

            Fix required on 2.1 only.

            Show
            Tim Hunt added a comment - I see. it is broken in 2.1 only. You cannot just cherry-pick code using textlib from 2.2 to 2.1. Nasty gotcha. The required fix is https://github.com/timhunt/moodle/compare/MOODLE_21_STABLE...MDL-30760_fixup_21 Fix required on 2.1 only.
            Hide
            Eloy Lafuente (stronk7) added a comment -

            Re-integrated with the 21 fix applied, thanks!

            Show
            Eloy Lafuente (stronk7) added a comment - Re-integrated with the 21 fix applied, thanks!
            Hide
            Eloy Lafuente (stronk7) added a comment -

            Testing note: I imported the Q by changing the size of answers to 2000. I assume it is a separated issue (commented above).

            Side note: Yay, I scored: 1.85 / 100.00.

            Crap! Just tried the upgrade and got the same error, grrr, there are some more occurrences of 'textlib::xxxxxx' @ question/engine/upgrade/upgradelib.php

            Failing again, adding commit and retesting...

            Show
            Eloy Lafuente (stronk7) added a comment - Testing note: I imported the Q by changing the size of answers to 2000. I assume it is a separated issue (commented above). Side note: Yay, I scored: 1.85 / 100.00. Crap! Just tried the upgrade and got the same error, grrr, there are some more occurrences of 'textlib::xxxxxx' @ question/engine/upgrade/upgradelib.php Failing again, adding commit and retesting...
            Hide
            Eloy Lafuente (stronk7) added a comment -

            re-re-integrated, testing again...

            Show
            Eloy Lafuente (stronk7) added a comment - re-re-integrated, testing again...
            Hide
            Eloy Lafuente (stronk7) added a comment -

            Testing note: I imported the Q by changing the size of answers to 2000. I assume it is a separated issue (commented above).

            WTF! I continue getting the same error on questionsummary?

            Debug info: Data too long for column 'questionsummary' at row 1
            INSERT INTO mdl_question_attempts (questionid,variant,behaviour,questionsummary,rightanswer,maxmark,minfraction,flagged,responsesummary,timemodified,questionusageid,slot) VALUES(?,?,?,?,?,?,?,?,?,?,?,?)
            [array (
            0 => '8',
            1 => 1,
            2 => 'adaptive',
            3 => 'Wir verkaufen am 29.11.2007 einen .......
             
            Stack trace:
            line 397 of /lib/dml/moodle_database.php: dml_write_exception thrown
            line 893 of /lib/dml/mysqli_native_moodle_database.php: call to moodle_database->query_end()
            line 935 of /lib/dml/mysqli_native_moodle_database.php: call to mysqli_native_moodle_database->insert_record_raw()
            line 299 of /question/engine/upgrade/upgradelib.php: call to mysqli_native_moodle_database->insert_record()
            line 253 of /question/engine/upgrade/upgradelib.php: call to question_engine_attempt_upgrader->insert_record()
            line 221 of /question/engine/upgrade/upgradelib.php: call to question_engine_attempt_upgrader->save_usage()
            line 176 of /question/engine/upgrade/upgradelib.php: call to question_engine_attempt_upgrader->convert_quiz_attempt()
            line 131 of /question/engine/upgrade/upgradelib.php: call to question_engine_attempt_upgrader->update_all_attempts_at_quiz()
            line 1112 of /mod/quiz/db/upgrade.php: call to question_engine_attempt_upgrader->convert_all_quiz_attempts()
            line 541 of /lib/upgradelib.php: call to xmldb_quiz_upgrade()
            line 271 of /lib/upgradelib.php: call to upgrade_plugins_modules()
            line 1466 of /lib/upgradelib.php: call to upgrade_plugins()
            line 317 of /admin/index.php: call to upgrade_noncore()
            

            re-failing and re-investigating what has been changed here, grrrr.

            Show
            Eloy Lafuente (stronk7) added a comment - Testing note: I imported the Q by changing the size of answers to 2000. I assume it is a separated issue (commented above). WTF! I continue getting the same error on questionsummary? Debug info: Data too long for column 'questionsummary' at row 1 INSERT INTO mdl_question_attempts (questionid,variant,behaviour,questionsummary,rightanswer,maxmark,minfraction,flagged,responsesummary,timemodified,questionusageid,slot) VALUES(?,?,?,?,?,?,?,?,?,?,?,?) [array ( 0 => '8', 1 => 1, 2 => 'adaptive', 3 => 'Wir verkaufen am 29.11.2007 einen .......   Stack trace: line 397 of /lib/dml/moodle_database.php: dml_write_exception thrown line 893 of /lib/dml/mysqli_native_moodle_database.php: call to moodle_database->query_end() line 935 of /lib/dml/mysqli_native_moodle_database.php: call to mysqli_native_moodle_database->insert_record_raw() line 299 of /question/engine/upgrade/upgradelib.php: call to mysqli_native_moodle_database->insert_record() line 253 of /question/engine/upgrade/upgradelib.php: call to question_engine_attempt_upgrader->insert_record() line 221 of /question/engine/upgrade/upgradelib.php: call to question_engine_attempt_upgrader->save_usage() line 176 of /question/engine/upgrade/upgradelib.php: call to question_engine_attempt_upgrader->convert_quiz_attempt() line 131 of /question/engine/upgrade/upgradelib.php: call to question_engine_attempt_upgrader->update_all_attempts_at_quiz() line 1112 of /mod/quiz/db/upgrade.php: call to question_engine_attempt_upgrader->convert_all_quiz_attempts() line 541 of /lib/upgradelib.php: call to xmldb_quiz_upgrade() line 271 of /lib/upgradelib.php: call to upgrade_plugins_modules() line 1466 of /lib/upgradelib.php: call to upgrade_plugins() line 317 of /admin/index.php: call to upgrade_noncore() re-failing and re-investigating what has been changed here, grrrr.
            Hide
            Eloy Lafuente (stronk7) added a comment - - edited

            One commit has been added (master: 63637e9dd82b4d5befb417694c3a60d5a930a46f) in order to handle safely utf-8 contents (surely not all but 99% of them). Applied to 20, 21, master.

            Re-testing...

            Show
            Eloy Lafuente (stronk7) added a comment - - edited One commit has been added (master: 63637e9dd82b4d5befb417694c3a60d5a930a46f) in order to handle safely utf-8 contents (surely not all but 99% of them). Applied to 20, 21, master. Re-testing...
            Hide
            Eloy Lafuente (stronk7) added a comment -

            Testing note: I imported the Q by changing the size of answers to 2000. I assume it is a separated issue (commented above).

            Tested with target 21 and 22 stables... both upgrade and import of Q, ok.

            So... yes.... at last...

            Show
            Eloy Lafuente (stronk7) added a comment - Testing note: I imported the Q by changing the size of answers to 2000. I assume it is a separated issue (commented above). Tested with target 21 and 22 stables... both upgrade and import of Q, ok. So... yes.... at last...
            Hide
            Eloy Lafuente (stronk7) added a comment -

            Passed!

            Show
            Eloy Lafuente (stronk7) added a comment - Passed!
            Hide
            Tim Hunt added a comment -

            .answers thing is MDL-16464

            Show
            Tim Hunt added a comment - .answers thing is MDL-16464
            Hide
            Eloy Lafuente (stronk7) added a comment -

            Whoever decided one week was worth 14 days had really one bad idea. Anyway, the nightmare is over, so thanks for your, once again, amazing contributions. Many, many thanks!

            Now... disconnect, relax and enjoy the next days, yay!

            Closing...ciao

            Show
            Eloy Lafuente (stronk7) added a comment - Whoever decided one week was worth 14 days had really one bad idea. Anyway, the nightmare is over, so thanks for your, once again, amazing contributions. Many, many thanks! Now... disconnect, relax and enjoy the next days, yay! Closing...ciao
            Hide
            Juergen Zimmer added a comment -

            Thank you guys for fixing this!
            When will this be added to an official version of Moodle?

            Show
            Juergen Zimmer added a comment - Thank you guys for fixing this! When will this be added to an official version of Moodle?
            Hide
            Sam Hemelryk added a comment -

            Hi Juergen,
            This fix is already in our weekly releases.
            It will part of the 2.1.4, and 2.2.1 stable releases.

            Show
            Sam Hemelryk added a comment - Hi Juergen, This fix is already in our weekly releases. It will part of the 2.1.4, and 2.2.1 stable releases.

              People

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

                Dates

                • Created:
                  Updated:
                  Resolved: