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

XML import of questions can introduce an extra space at the start of each line

    Details

    • Type: Bug
    • Status: Closed
    • Priority: Minor
    • Resolution: Fixed
    • Affects Version/s: 2.3
    • Fix Version/s: 2.2.7, 2.3.4, 2.4.1
    • Component/s: Questions
    • Labels:
    • Testing Instructions:
      Hide

      1. Create a new question category.

      2. In that category, create a question containing some pre-formatted text that spans several lines.

      3. Export that question category as Moodle XML.

      4. Import that file into a new course.

      5. Make sure the question text, and other fields, have not had extra spaces added at the start of each line.

      Show
      1. Create a new question category. 2. In that category, create a question containing some pre-formatted text that spans several lines. 3. Export that question category as Moodle XML. 4. Import that file into a new course. 5. Make sure the question text, and other fields, have not had extra spaces added at the start of each line.
    • Affected Branches:
      MOODLE_23_STABLE
    • Fixed Branches:
      MOODLE_22_STABLE, MOODLE_23_STABLE, MOODLE_24_STABLE
    • Pull from Repository:
    • Pull Master Branch:

      Description

      When importing a question in Moodle XML format, where the question contains multiline (non-html) text fields, an extra space is inserted at the start of every line. For example, if the xml description of a question contains a tag like

      <text>line1
      line2
      line3
      </text>

      the imported value of that text field will be "line1\n line2\n line3\n " (note the extra spaces). The cause is the first line in the function readquestions in file question/format/xml/format.php: "$text = implode($lines, ' ');" which is intended to combine all the file lines into one big string, but does so with an extra space introduced at the start of each line.

        Gliffy Diagrams

          Attachments

            Activity

              People

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

                Dates

                • Created:
                  Updated:
                  Resolved:
                  Fix Release Date:
                  14/Jan/13