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

Error writing to the database when creating certain cloze question

    Details

    • Type: Bug
    • Status: Closed
    • Priority: Critical
    • 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. Create a multianswer (Embedded answer) question. There is an example question text that tests all the options in this comment: http://tracker.moodle.org/browse/MDL-28241?focusedCommentId=121358&page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel#comment-121358

      2. Check that the 'Decode and verify question text' button on the form works without errors.

      3. Check that saving the question works without errors, both when creating a new question and editing an existing one.

      4. Then preview the newly created question and verify it works properly.

      Show
      1. Create a multianswer (Embedded answer) question. There is an example question text that tests all the options in this comment: http://tracker.moodle.org/browse/MDL-28241?focusedCommentId=121358&page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel#comment-121358 2. Check that the 'Decode and verify question text' button on the form works without errors. 3. Check that saving the question works without errors, both when creating a new question and editing an existing one. 4. Then preview the newly created question and verify it works properly.
    • Affected Branches:
      MOODLE_21_STABLE, MOODLE_22_STABLE
    • Fixed Branches:
      MOODLE_21_STABLE
    • Pull from Repository:
    • Pull Master Branch:

      Description

      To reproduce:

      Create a new cloze question with this simple HTML code:

      <p>Sub-question 1:

      {2:NUMERICAL:=5E-3:1E-4}

      </p>
      <p>Sub-question 2:

      {1:MULTICHOICE:%100%Yes~%0%No}

      </p>

      Then save it. This leads to the error shown in the image attached. As you can see, Moodle code tries to store a character 'Y' in the 'answerformat' field.

      This character is obviously the first one of the word 'Yes' in the multichoice sub-question (if you change the word
      'Yes' to 'Si' then Moodle tries to store an 'S'), so it seems clearly a problem related to parsing code.

      Note that this bug may pass unnoticed if you upgrade from 1.9 or 2.0 to 2.1 because upgrade works fine. Only when you edit/import the question or add new ones (i.e., when parsing HTML code) this bug appears.

        Gliffy Diagrams

          Attachments

            Issue Links

              Activity

                People

                • Votes:
                  19 Vote for this issue
                  Watchers:
                  22 Start watching this issue

                  Dates

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