Moodle
  1. Moodle
  2. MDL-32865

CLOZE Questions imported from another course end up with broken image links

    Details

    • Type: Bug Bug
    • Status: Closed
    • Priority: Minor Minor
    • Resolution: Fixed
    • Affects Version/s: 2.2.2, 2.2.5, 2.3.2
    • Fix Version/s: 2.2.7, 2.3.4
    • Component/s: Questions
    • Labels:
    • Environment:
      MS-SQL 2008 R2, IIS 7.5, Windows 2008
    • Database:
      Microsoft SQL
    • Testing Instructions:
      Hide

      Testing export + import of multianswer questions with images in text

      Create a few CLOZE type questions in a category of the question bank with some images in the question text. Warning: Don't put images in embedded multichoice subquestions answers as this is a separate issue (MDL-26511) not yet solved.
      Export this question's category using Moodle XML format.
      Import back the xml file into a new course, verify that questions display fine including the images both in preview and if you include them in a quiz.
      Open one of these questions for editing and verify the images are correctly displayed with a draft url.

      import of a file submitted by user

      import the quiz_sample_loco_moodle2.xml submitted 31/Oct/12 8:04 AM 125 kB attached to the present tracker issue by Paul Wray and verify you get 3 multianswer questions and that each one include an image both in preview and in editing (the image's name appear in bold above the image, this is not a bug).

      Show
      Testing export + import of multianswer questions with images in text Create a few CLOZE type questions in a category of the question bank with some images in the question text. Warning: Don't put images in embedded multichoice subquestions answers as this is a separate issue ( MDL-26511 ) not yet solved. Export this question's category using Moodle XML format. Import back the xml file into a new course, verify that questions display fine including the images both in preview and if you include them in a quiz. Open one of these questions for editing and verify the images are correctly displayed with a draft url. import of a file submitted by user import the quiz_sample_loco_moodle2.xml submitted 31/Oct/12 8:04 AM 125 kB attached to the present tracker issue by Paul Wray and verify you get 3 multianswer questions and that each one include an image both in preview and in editing (the image's name appear in bold above the image, this is not a bug).
    • Affected Branches:
      MOODLE_22_STABLE, MOODLE_23_STABLE
    • Fixed Branches:
      MOODLE_22_STABLE, MOODLE_23_STABLE
    • Pull Master Branch:
    • Rank:
      39928

      Description

      We have exported a question category which contains a few CLOZE type questions which contain images. When we import these questions into the new course, on the same server, the images appear as broken links. Images in other question types such as matching import correctly and work as expected. The only change in the URLs is the number after the word draft but this happens in both cases.

      CLOZE Question - give broken gif

      http://server/moodle/draftfile.php/10/user/draft/273773194/Bridge%20Rectifier%20Numbered%20With%20Ground%20Point.gif http://server/moodle/draftfile.php/10/user/draft/548034668/Bridge%20Rectifier%20Numbered%20With%20Ground%20Point.gif

      Matching Question - works correctly

      http://server/moodle/draftfile.php/10/user/draft/118530274/Figure%206.gif http://server/moodle/draftfile.php/10/user/draft/937713623/Figure%206.gif

        Issue Links

          Activity

          Hide
          Paul Wray added a comment - - edited

          I am seeing probably the same issue.
          In our case Moodle XML files with embedded base64-encoded images are generated by another application.
          Multichoice, matching, tf, and essay questions with images all import properly, but not cloze.

          Show
          Paul Wray added a comment - - edited I am seeing probably the same issue. In our case Moodle XML files with embedded base64-encoded images are generated by another application. Multichoice, matching, tf, and essay questions with images all import properly, but not cloze.
          Hide
          Jean-Michel Vedrine added a comment -

          To give this bug a chance to be looked at, I corrected the component (was other set to Question) and the Assignee (was moodle.com set to Tim Hunt).
          But I will have a try at understanding what is happening if I can.

          Show
          Jean-Michel Vedrine added a comment - To give this bug a chance to be looked at, I corrected the component (was other set to Question) and the Assignee (was moodle.com set to Tim Hunt). But I will have a try at understanding what is happening if I can.
          Hide
          Jean-Michel Vedrine added a comment -

          I can confirm the problem. And it is not only present in MOODLE_22_STABLE, all branchs including master are affected too.
          Paul said "In our case Moodle XML files with embedded base64-encoded images are generated by another application" but this is not the problem : in my tests even with files generated by Moodle XML export images are lost during import back.
          Looking at the XML files they appear to be corrects so the problem seems to be during XML import of multianswer questions with images.

          Show
          Jean-Michel Vedrine added a comment - I can confirm the problem. And it is not only present in MOODLE_22_STABLE, all branchs including master are affected too. Paul said "In our case Moodle XML files with embedded base64-encoded images are generated by another application" but this is not the problem : in my tests even with files generated by Moodle XML export images are lost during import back. Looking at the XML files they appear to be corrects so the problem seems to be during XML import of multianswer questions with images.
          Hide
          Jean-Michel Vedrine added a comment -

          Some more tests :

          Moodle XML export of multi answer questions with images

          The "questions-test-Test+Export-20120509-1343.xml" file attached to this issue 09/May/2012 contains a multianswer (cloze) question with all the images missing.
          I have been unable to reproduce this problem in all currently supported Moodle versions (master, MOODLE_22_STABLE, MOODLE_23_STABLE). If I create a multianswer question with images in questiontext general feedback, hints, ... and export it using Moodle XML format the resulting XML file does include all base64 encoded images so no problem during export for me. Maybe the original reporter (Fred Weiss ?) can provide further infos about how the attached file was produced ?

          Moodle XML import of multi answer questions with images

          As I said currently in all Moodle versions including master, if you import an xml files containing multianswer questions with images, all images in questiontext are lost during import.
          This problem is relatively easy to solve by just a one line change in the import_multianswer function in the question/format/xml/format.php
          line 443 change:
          $qo->questiontextfiles = array();
          to:
          $qo->questiontextfiles = $this->import_files($this->getpath($question,
          array('#', 'questiontext', 0, '#', 'file'), array(), false));

          But I don't know why it was decided to not use questiontextfiles to import images in questiontext of multianswer question, so maybe there are adverse effects of doing this change.
          So better to wait for Tim's comments.
          But I would be interested to hear if Paul Wray can test this change and tell if it solve his problem and permit import of the Moodle XML files with embedded base64-encoded images are generated by another application he uses.

          Show
          Jean-Michel Vedrine added a comment - Some more tests : Moodle XML export of multi answer questions with images The "questions-test-Test+Export-20120509-1343.xml" file attached to this issue 09/May/2012 contains a multianswer (cloze) question with all the images missing. I have been unable to reproduce this problem in all currently supported Moodle versions (master, MOODLE_22_STABLE, MOODLE_23_STABLE). If I create a multianswer question with images in questiontext general feedback, hints, ... and export it using Moodle XML format the resulting XML file does include all base64 encoded images so no problem during export for me. Maybe the original reporter (Fred Weiss ?) can provide further infos about how the attached file was produced ? Moodle XML import of multi answer questions with images As I said currently in all Moodle versions including master, if you import an xml files containing multianswer questions with images, all images in questiontext are lost during import. This problem is relatively easy to solve by just a one line change in the import_multianswer function in the question/format/xml/format.php line 443 change: $qo->questiontextfiles = array(); to: $qo->questiontextfiles = $this->import_files($this->getpath($question, array('#', 'questiontext', 0, '#', 'file'), array(), false)); But I don't know why it was decided to not use questiontextfiles to import images in questiontext of multianswer question, so maybe there are adverse effects of doing this change. So better to wait for Tim's comments. But I would be interested to hear if Paul Wray can test this change and tell if it solve his problem and permit import of the Moodle XML files with embedded base64-encoded images are generated by another application he uses.
          Hide
          Paul Wray added a comment - - edited

          Jean-Michel's suggested change works for me.
          Test file attached (quiz_sample_loco_moodle2.xml)

          Show
          Paul Wray added a comment - - edited Jean-Michel's suggested change works for me. Test file attached (quiz_sample_loco_moodle2.xml)
          Hide
          Tim Hunt added a comment -

          I don't know why the code was like that. I think it is just a bug. Thanks for finding it.

          Can you prepare branches for integration? Thanks.

          Show
          Tim Hunt added a comment - I don't know why the code was like that. I think it is just a bug. Thanks for finding it. Can you prepare branches for integration? Thanks.
          Hide
          Pierre Pichet added a comment -

          This is not a volontary bug but an incomplete updating from 1,9 to 2,0
          The images in the multianswer questiontext could be classic images in a questiontext but also images in other parts of the subquestions included in the questiontext.
          see the unfinished MDL-26511

          Show
          Pierre Pichet added a comment - This is not a volontary bug but an incomplete updating from 1,9 to 2,0 The images in the multianswer questiontext could be classic images in a questiontext but also images in other parts of the subquestions included in the questiontext. see the unfinished MDL-26511
          Hide
          Jean-Michel Vedrine added a comment -

          Pierre is right, the proposed fix will solve the issue for images in "main" questiontext but not for images in multichoice subquestion's answers so this issue should be linked with the one for subquestions' answers

          Show
          Jean-Michel Vedrine added a comment - Pierre is right, the proposed fix will solve the issue for images in "main" questiontext but not for images in multichoice subquestion's answers so this issue should be linked with the one for subquestions' answers
          Hide
          Jean-Michel Vedrine added a comment -

          Anyway I think there are a lot of cloze questions that only include images in main question text but not in subquestions' answers (the file attached by Paul is a good sample of that) so even if we are not able to fully solve MDL-26511 now, this one line fix is good to integrate in Moodle because it will helps some users. So I will prepare git branchs and add testing instructions.

          Show
          Jean-Michel Vedrine added a comment - Anyway I think there are a lot of cloze questions that only include images in main question text but not in subquestions' answers (the file attached by Paul is a good sample of that) so even if we are not able to fully solve MDL-26511 now, this one line fix is good to integrate in Moodle because it will helps some users. So I will prepare git branchs and add testing instructions.
          Hide
          Jean-Michel Vedrine added a comment -

          Fix for the master branch I did one more commit to add backwards compatibility to deal with the old image tag when people import multianswer questions created with Moodle 1.9. I think it could be usefull to some Moodle users so worth adding it but of course I can revert to only the first commit if you prefer.

          Show
          Jean-Michel Vedrine added a comment - Fix for the master branch I did one more commit to add backwards compatibility to deal with the old image tag when people import multianswer questions created with Moodle 1.9. I think it could be usefull to some Moodle users so worth adding it but of course I can revert to only the first commit if you prefer.
          Hide
          Tim Hunt added a comment -

          Submitting for integration.

          Show
          Tim Hunt added a comment - Submitting for integration.
          Hide
          Jean-Michel Vedrine added a comment -

          Git branches created and testing instructions updated.
          Thanks Pierre for pointing me to MDL-26511 there is interesting code there. I still need to read and understand all the tracker issue's comments unfortunately I am not so familiar with the multianswer code than Tim and you !

          Show
          Jean-Michel Vedrine added a comment - Git branches created and testing instructions updated. Thanks Pierre for pointing me to MDL-26511 there is interesting code there. I still need to read and understand all the tracker issue's comments unfortunately I am not so familiar with the multianswer code than Tim and you !
          Hide
          Pierre Pichet added a comment -

          I should have some time to work on MDL-26511 next week.
          Among the reasons to stop on this bug was that the code for file handling even in the restore process, was not completely fixed at this time.

          Show
          Pierre Pichet added a comment - I should have some time to work on MDL-26511 next week. Among the reasons to stop on this bug was that the code for file handling even in the restore process, was not completely fixed at this time.
          Hide
          Jean-Michel Vedrine added a comment -

          rebased all branchs

          Show
          Jean-Michel Vedrine added a comment - rebased all branchs
          Hide
          Dan Poltawski added a comment -

          I've integrated this now. Thanks Jean-Michel

          Show
          Dan Poltawski added a comment - I've integrated this now. Thanks Jean-Michel
          Hide
          Rajesh Taneja added a comment -

          Works Great,

          Thanks for fixing this Jean-Michel.

          Show
          Rajesh Taneja added a comment - Works Great, Thanks for fixing this Jean-Michel.
          Hide
          Jean-Michel Vedrine added a comment -

          Thanks Dan and Rajesh

          Show
          Jean-Michel Vedrine added a comment - Thanks Dan and Rajesh
          Hide
          Dan Poltawski added a comment -

          Congratulations! Another bug solved.. only another 7330 to go, thanks for contributing to contributing to 0.8% of all bugs being fixed this week!

          ciao
          Dan

          Show
          Dan Poltawski added a comment - Congratulations! Another bug solved.. only another 7330 to go, thanks for contributing to contributing to 0.8% of all bugs being fixed this week! ciao Dan
          Hide
          Paul Wray added a comment -

          I think this issue has returned, affecting Moodle 2.3 and 2.4.

          Show
          Paul Wray added a comment - I think this issue has returned, affecting Moodle 2.3 and 2.4.
          Hide
          Tim Hunt added a comment -

          Paul, if that is really true, then you need to:

          1. Find a way to reproduce the problem you are seeing, perhaps on http://demo.moodle.net.
          2. Create a new bug giving the exact steps to reproduce.

          Show
          Tim Hunt added a comment - Paul, if that is really true, then you need to: 1. Find a way to reproduce the problem you are seeing, perhaps on http://demo.moodle.net . 2. Create a new bug giving the exact steps to reproduce.

            People

            • Votes:
              1 Vote for this issue
              Watchers:
              4 Start watching this issue

              Dates

              • Created:
                Updated:
                Resolved: