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

Question Import: <image_base64> decoding broken

    XMLWordPrintable

    Details

    • Type: Bug
    • Status: Closed
    • Priority: Major
    • Resolution: Fixed
    • Affects Version/s: 1.8
    • Fix Version/s: 1.8.1
    • Component/s: Backup, Questions
    • Labels:
      None
    • Environment:
      N/A
    • Database:
      Any
    • Affected Branches:
      MOODLE_18_STABLE
    • Fixed Branches:
      MOODLE_18_STABLE

      Description

      Questions imported using Moodle XML format are not being decoded properly, resulting in corrupted image file.

      A question gets imported properly and the corresponding image, extracted from <image_base64> tag, is created in the moodledata directory. However, the output image file is not being produced correctly and hence nothing is displayed when a user views the question. An interesting point to note is that the output file is always 8 bytes in size no matter what the supplied base64 encoding is.

      I have confirmed this bug by exporting a perfectly alight question out of Moodle and then importing it back. The output image file is always corrupted. Given below is a sample image data encapsulated inside the <image_base64> tag. The image files produced by moodle and by an external base64 decoder are both attached for analysis purposes.

      -------------------------------------------
      Sample MoodleXML Question:
      -------------------------------------------
      <?xml version="1.0" encoding="UTF-8"?>
      <quiz>

      <question type="multichoice">
      <name><text>selfmade</text>
      </name>
      <questiontext format="html">
      <text>Questiontext apart from the image</text>
      </questiontext>
      <image>moodle_image.png</image>
      <image_base64>
      iVBORw0KGgoAAAANSUhEUgAAAj8AAAA+CAIAAABLDe3sAAAABGdBTUEAAK/INwWK6QAAABl0RVh0U29mdHdhcmUAQWRvYmUgSW1hZ2VSZWFkeXHJZTwAAA65SURBVHjaYvz//z/DKBgFo2AUjIJRMKQAQAAxjQbBKBgFo2AUjIIhBwACaLT2GgWjYBSMglEw9ABAAI3WXqNgFIy

      CUTAKhh4ACKDR2msAQEhIyPDzVE9PD9BfVlZWW7duHY1iskF1dXUIGAxgMN64cQMYj5mZmUDHjMbIaAYftAAggBj+jwJqAGBQdnd3W1paElSZkZEBVDz8/AVR8+bNm+Dg4NH0gBmMVVVVwCBavnw5QZUDHoxAp27ZsgXumFEwjDP4kAYAAcQ4uuaQKoCRER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31C/nXL0Gr1RQC2AnBfOnDkDzyyQDj185BBrlkFONnA2sBcF0QUkgWxcKiHKvn79irw6dxSMghEFAAKIwO2UcnJywDz5+vXr1tbWo

      KAgYA+JYejfTjl6jd4ooBZAzi/GxsbAeguSWeCrMCAAV5bBBFlZWe/evQMmeCAJZONRJigoyM3NLS8vD7SU+KH1UTAKhg0ACKCReDvl6DV6o4C6CzfIvp1yFIyCUUA2AAigkXg75eg1eqOAioCS2ylHwSgYBWQDgAAaobdTjl6jNwqoCCi5nXIUjIJRQB4ACKDR02NHwSgYBaNg

      FAw9ABBAo/d7jYJRMApGwSgYegAggEZrr1EwCkbBKBgFQw8ABNBo7TUKRsEoGAWjYOgBgAAarb1GwSgYBaNgFAw9ABBAo7XXKBgFo2AUjIKhBwACaLT2GgWjYBSMglEw9ABAAI3WXqNgFIyCUTAKhh4ACKDR2msUjIJRMApGwdADAAEGAEqDzshqj8uQAAAAAElFTkSuQmCC
      </image_base64>
      <generalfeedback>
      <text>general feedback</text>
      </generalfeedback>
      <defaultgrade>1</defaultgrade>
      <penalty>0</penalty>
      <hidden>0</hidden>
      <shuffleanswers>0</shuffleanswers>
      <single>true</single>
      <shuffleanswers>false</shuffleanswers>
      <correctfeedback> <text>correct feedback</text>
      </correctfeedback>
      <partiallycorrectfeedback> <text>partially correct feedback</text>
      </partiallycorrectfeedback>
      <incorrectfeedback> <text>incorrect feedback</text>
      </incorrectfeedback>
      <answer fraction="0">
      <text>(a)</text>
      <feedback>
      <text></text>
      </feedback>
      </answer>
      <answer fraction="0">
      <text>(b)</text>
      <feedback>
      <text></text>
      </feedback>
      </answer>
      <answer fraction="100">
      <text>(c)</text>
      <feedback>
      <text></text>
      </feedback>
      </answer>
      <answer fraction="0">
      <text>(d)</text>
      <feedback>
      <text></text>
      </feedback>
      </answer>
      </question>
      </quiz>

        Attachments

        1. actual_image.png
          actual_image.png
          4 kB
        2. format.php
          40 kB
        3. moodle_image.png
          0.0 kB

          Activity

            People

            • Assignee:
              howardsmiller Howard Miller
              Reporter:
              akash Akash Kumar
              Tester:
              Nobody
              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:
              0 Vote for this issue
              Watchers:
              1 Start watching this issue

              Dates

              • Created:
                Updated:
                Resolved:
                Fix Release Date:
                11/Jun/07