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

Files in subdirs not exported correctly by question XML format

    XMLWordPrintable

Details

    • Bug
    • Resolution: Fixed
    • Major
    • 2.5.5, 2.6.2
    • 2.4.6, 2.5.2
    • Questions
    • MOODLE_24_STABLE, MOODLE_25_STABLE
    • MOODLE_25_STABLE, MOODLE_26_STABLE
    • Hide

      Create some questions with images in subfolders.
      An easy way to do that in recent Moodle versions is to use Marina's managefiles TinyMCE plugin.
      Export this question bank category using Moodle XML format.
      Import them back in another course.
      Verify no image is missing.
      Verify that the same XML file can be imported in a Moodle version before this patch and that apart broken images (to be expected) there is no other problem.
      Note: As I said in comments, I don't really know how people get images in subdirs (I don't suppose they use Marina's plugin ) but I can testify it happen most probably by restoring courses from an old Moodle version ?

      Show
      Create some questions with images in subfolders. An easy way to do that in recent Moodle versions is to use Marina's managefiles TinyMCE plugin. Export this question bank category using Moodle XML format. Import them back in another course. Verify no image is missing. Verify that the same XML file can be imported in a Moodle version before this patch and that apart broken images (to be expected) there is no other problem. Note: As I said in comments, I don't really know how people get images in subdirs (I don't suppose they use Marina's plugin ) but I can testify it happen most probably by restoring courses from an old Moodle version ?

    Description

      If a question contains some embedded file with a non empty path(tested on non legacy files but I will test for legacy files later), the resulting Moodle XML file is broken because the path is included in the text for instance

      <img src="@@PLUGINFILE@@/images/mcq3.jpg" />

      but not in the file tag

      <file name="mcq3.jpg" encoding="base64">/9j/4AAQ...
      

      So if you import this file back, you get missing images in questions.
      I think the problem is caused by this line : http://git.moodle.org/gw?p=moodle.git;a=blob;f=question/format/xml/format.php;h=1c2edafdd2e62ebb53bf397cc41ea26b741a2d12;hb=HEAD#l1091 but I am at work so I will submit a fix later.
      I am quite sure master branch is affected but is it not the only one because the website where I discovered the problem is running Moodle 2.4.5. I am not sure when these non legacy images with subdirs were created (this website started as Moodle 1.3 and was upgraded since) but obviously if it happen on one of my websites it can happen elsewhere so I think we must make a fix for all supported stable branches.

      Attachments

        Activity

          People

            jmvedrine Jean-Michel Vedrine
            jmvedrine Jean-Michel Vedrine
            Tim Hunt Tim Hunt
            Dan Poltawski Dan Poltawski
            Andrew Lyons Andrew Lyons
            Votes:
            0 Vote for this issue
            Watchers:
            2 Start watching this issue

            Dates

              Created:
              Updated:
              Resolved:
              10/Mar/14