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

    XMLWordPrintable

Details

    • Bug
    • Status: Closed
    • Minor
    • Resolution: Fixed
    • 2.3
    • 2.2.7, 2.3.4, 2.4.1
    • Questions
    • MOODLE_23_STABLE
    • MOODLE_22_STABLE, MOODLE_23_STABLE, MOODLE_24_STABLE
    • 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.

    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.

      Attachments

        Activity

          People

            timhunt Tim Hunt
            r.lobb Richard Lobb
            Sam Hemelryk Sam Hemelryk
            Adrian Greeve Adrian Greeve
            Safat Shahin, Tim Hunt, Ilya Tregubov, Kevin Percy, Mathew May, Mihail Geshoski, Shamim Rezaie
            Votes:
            0 Vote for this issue
            Watchers:
            0 Start watching this issue

            Dates

              Created:
              Updated:
              Resolved:
              14/Jan/13