Moodle

Import of Quiz breaks links to image and audio files

Details

  • Type: Bug Bug
  • Status: Closed Closed
  • Priority: Major Major
  • Resolution: Cannot Reproduce
  • Affects Version/s: 1.7.2
  • Fix Version/s: None
  • Component/s: Backup
  • Labels:
    None
  • Database:
    MySQL
  • Affected Branches:
    MOODLE_17_STABLE

Description

When importing a quiz from one course into another on the same site, the links to image files and audio files are broken. The image files and and audio files are properly copied and moved to the new course, but the links to the files are not updated.

This is not a problem for the teacher or admin, because they have site-wide permissions to view files. However, students do not have permissions to view files outside of their own courses. Therefore students cannot hear the recordings and cannot see the images in the questions.

Workaround: Manually update the HTML code for each quiz question and each link.

  • identify the course ID numbers of the source course and the destination course
  • open up the imported quiz, open up each quiz question item with an audio, video or image file link
  • delete the old course number in the link, and replace it with the new course number in the same place
  • then students are able to view and play the files in the quiz question

Issue Links

Activity

Hide
Eloy Lafuente (stronk7) added a comment -

This goes to Tim...

Show
Eloy Lafuente (stronk7) added a comment - This goes to Tim...
Hide
Tim Hunt added a comment -

Please could you attach a backup file showing the problem. That will help me determine whether the problem is at the backup or restore end. Thanks.

Show
Tim Hunt added a comment - Please could you attach a backup file showing the problem. That will help me determine whether the problem is at the backup or restore end. Thanks.
Hide
Tim Hunt added a comment -

I'm pretty sure the bug I linked as a duplicate is the same issue as this, and I fixed it some time ago.

Show
Tim Hunt added a comment - I'm pretty sure the bug I linked as a duplicate is the same issue as this, and I fixed it some time ago.
Hide
Nicholas McJetters added a comment -

This course includes a quiz that has an audio file/mp3 attached to a quiz question. When this course is restored, the MP3 file will not play even while the file is included in the course files. It will not play because when restored the MP3 is hard-linked back to the original course ID (14) from which the question was created from. You can verify this from view source when you render the quiz page in your browser.

Show
Nicholas McJetters added a comment - This course includes a quiz that has an audio file/mp3 attached to a quiz question. When this course is restored, the MP3 file will not play even while the file is included in the course files. It will not play because when restored the MP3 is hard-linked back to the original course ID (14) from which the question was created from. You can verify this from view source when you render the quiz page in your browser.
Hide
Nicholas McJetters added a comment -

It's my new working theory the reason why this problem occurs is that even when a course backup includes quiz questions and audio/mp3/images, if you are restoring to a Moodle that already has these questions saved in the question bank, the restore of quiz questions is automatically skipped during restore.

Because the restore process is not creating new questions, but recycling questions pre-existing in the database for the newly restored course, the links never get republished, and the original course ID keeps manifesting itself into new courses. Since it is unlikely for the future student to have access to course files from the original course ID, the files will not play. I'm not sure if this issue can be reopened or addressed. Thanks.

Show
Nicholas McJetters added a comment - It's my new working theory the reason why this problem occurs is that even when a course backup includes quiz questions and audio/mp3/images, if you are restoring to a Moodle that already has these questions saved in the question bank, the restore of quiz questions is automatically skipped during restore. Because the restore process is not creating new questions, but recycling questions pre-existing in the database for the newly restored course, the links never get republished, and the original course ID keeps manifesting itself into new courses. Since it is unlikely for the future student to have access to course files from the original course ID, the files will not play. I'm not sure if this issue can be reopened or addressed. Thanks.
Hide
Tim Hunt added a comment -

Than sounds plausible.

Show
Tim Hunt added a comment - Than sounds plausible.
Hide
Joseph Perret added a comment -

This is a serious issue for me. A typical chapter question set will have 20 or so questions with figures. And I have 18 or so chapters. This takes forever to update.

Please work on this one soon!

Show
Joseph Perret added a comment - This is a serious issue for me. A typical chapter question set will have 20 or so questions with figures. And I have 18 or so chapters. This takes forever to update. Please work on this one soon!
Hide
Tim Hunt added a comment -

I have just been reading the code of question/restorelib.php, and I think the situation is this: (Admittedly, I am sitting in a bar in a San Francisco hotel drinking beer and seeing if anyone else is going to turn up before the MoodleMoot, but I think I am still sober enough to know what I am taking about

OK, so in Moodle 1.9+ the situation is fine. Jamie Pratt thought about this situation when he was re-working the question bank.

In 1.8, Nicholas's analysis is right, but only if the category being backed up is 'published'. (If your questions use images or other media files, then publishing them is a bad idea, because they will not work in other courses. That was one fo the fundamental flaws that lead to Jamie re-writing the question bank.)

So, it should be the case that if you ensure that all your question categories are not published, then do the backup, then do the restore, then you should get a copy of the questions, and the copies should have the links to the course files rewritten correctly.

It would be great if someone could test this and confirm it. Thanks.

Show
Tim Hunt added a comment - I have just been reading the code of question/restorelib.php, and I think the situation is this: (Admittedly, I am sitting in a bar in a San Francisco hotel drinking beer and seeing if anyone else is going to turn up before the MoodleMoot, but I think I am still sober enough to know what I am taking about OK, so in Moodle 1.9+ the situation is fine. Jamie Pratt thought about this situation when he was re-working the question bank. In 1.8, Nicholas's analysis is right, but only if the category being backed up is 'published'. (If your questions use images or other media files, then publishing them is a bad idea, because they will not work in other courses. That was one fo the fundamental flaws that lead to Jamie re-writing the question bank.) So, it should be the case that if you ensure that all your question categories are not published, then do the backup, then do the restore, then you should get a copy of the questions, and the copies should have the links to the course files rewritten correctly. It would be great if someone could test this and confirm it. Thanks.
Hide
Roger Kenner added a comment -

This problem still exists in 1.9. The workaround is not realistic for an instructor who might have hundreds of such links in their question bank. It ALSO affects internal links to files in Assignment descriptions.

Show
Roger Kenner added a comment - This problem still exists in 1.9. The workaround is not realistic for an instructor who might have hundreds of such links in their question bank. It ALSO affects internal links to files in Assignment descriptions.
Hide
Tim Hunt added a comment -

When you say 'this problem still exists in 1.9' what exact steps are you performing? and how does the actual outcome differ from the outcome you expect.

Show
Tim Hunt added a comment - When you say 'this problem still exists in 1.9' what exact steps are you performing? and how does the actual outcome differ from the outcome you expect.
Hide
Don Hinkelman added a comment -

After seeing Roger's report, we retested the the import of a single quiz from one course to another course in Moodle 1.9.2+ (October 1). We found the links were not broken. The sound and image media files were moved to the new course and the links were updated to the new courseID number. The question bank category was set at Course Default for all questions. So for our setup, my conclusion is that this bug has been fixed. Thanks!

For Roger, I suggest you list step-by-step what caused your bug, the exact version/date of Moodle you are working with, the location of your media files, and the question bank categories that the questions are set to.

Show
Don Hinkelman added a comment - After seeing Roger's report, we retested the the import of a single quiz from one course to another course in Moodle 1.9.2+ (October 1). We found the links were not broken. The sound and image media files were moved to the new course and the links were updated to the new courseID number. The question bank category was set at Course Default for all questions. So for our setup, my conclusion is that this bug has been fixed. Thanks! For Roger, I suggest you list step-by-step what caused your bug, the exact version/date of Moodle you are working with, the location of your media files, and the question bank categories that the questions are set to.
Hide
Andrew Yong added a comment -

I believe the problem was fixed previously but has come back to haunt us as it was reported last year and we subsequently patched it up to the stable version on 4-Aug-2008. That fixed our issue but it looks as though the problem has returned.

We are running Moodle 1.9.4+ (Build: 20090405) and did not experience the problem last semester but we are now experiencing it.

We backup from the course from a previous semester - which then creates a zip file
We then restore it (with the create new course option) for the new semester.

The image link within the quizzes are not updated and still points to the previous year's course which the current students do not have access to.

We have hundreds of courses that will need to be fixed and withing each course, there are up to 12 quizes. So it is impractical for us to go through all quizes, in all courses, within all faculties. We really do need a utility to run the fix against existing courses and to have the restorelib.php fixed for future restores.

Show
Andrew Yong added a comment - I believe the problem was fixed previously but has come back to haunt us as it was reported last year and we subsequently patched it up to the stable version on 4-Aug-2008. That fixed our issue but it looks as though the problem has returned. We are running Moodle 1.9.4+ (Build: 20090405) and did not experience the problem last semester but we are now experiencing it. We backup from the course from a previous semester - which then creates a zip file We then restore it (with the create new course option) for the new semester. The image link within the quizzes are not updated and still points to the previous year's course which the current students do not have access to. We have hundreds of courses that will need to be fixed and withing each course, there are up to 12 quizes. So it is impractical for us to go through all quizes, in all courses, within all faculties. We really do need a utility to run the fix against existing courses and to have the restorelib.php fixed for future restores.
Hide
Kam Vento added a comment -

When creating a new class based on an old class. Moodle ver: 1.92 20080711

Quizzes and image folder with images embedded in questions are imported. However, the image has the filename only in the question.
kv

Show
Kam Vento added a comment - When creating a new class based on an old class. Moodle ver: 1.92 20080711 Quizzes and image folder with images embedded in questions are imported. However, the image has the filename only in the question. kv
Hide
Kam Vento added a comment -

Aha (A good clue for the bug) Moodle 1.92 20080711

The problem is: The image link embedded in the question retains the location from the source class instead of applying the new folder numbered location. In my case the number after the Source:....File.php was 43 the old class, when I update the link it changes to 56.

kv

Show
Kam Vento added a comment - Aha (A good clue for the bug) Moodle 1.92 20080711 The problem is: The image link embedded in the question retains the location from the source class instead of applying the new folder numbered location. In my case the number after the Source:....File.php was 43 the old class, when I update the link it changes to 56. kv
Hide
Tim Hunt added a comment -

I still need more information to be able to reproduce and fix this bug.

Exactly what steps are you performing?

That is what question types are there in the quiz? What options do you choose when you do the backup? After the restore, which bit of text has the wrong link? Please can you copy and paste the HTML from the old course, and the new course after the restore.

Show
Tim Hunt added a comment - I still need more information to be able to reproduce and fix this bug. Exactly what steps are you performing? That is what question types are there in the quiz? What options do you choose when you do the backup? After the restore, which bit of text has the wrong link? Please can you copy and paste the HTML from the old course, and the new course after the restore.
Hide
Amy Groshek added a comment -

Hi, I have this issue for every <img> tag in backed up courses, regardless of module. My absolute URLs end up like this: src="http://campus.extension.org/file.php/227$@SLASH@$image$@SLASH@$couple.png"

Can supply backup files if needed. But they are large.

Show
Amy Groshek added a comment - Hi, I have this issue for every <img> tag in backed up courses, regardless of module. My absolute URLs end up like this: src="http://campus.extension.org/file.php/227$@SLASH@$image$@SLASH@$couple.png" Can supply backup files if needed. But they are large.
Hide
Amy Groshek added a comment -

Attaching moodle.xml. Note how forward slashes are not correct in the backup file. src="http://campus.extension.org/file.php/227$@SLASH@$image$@SLASH@$couple.png"

These image URLs are not broken when I restore locally, but are broken when I restore on another site.

Also see the last post in this forum: http://moodle.org/mod/forum/discuss.php?d=123571#p541640

Running LAMP, Moodle 1.9.5+

Show
Amy Groshek added a comment - Attaching moodle.xml. Note how forward slashes are not correct in the backup file. src="http://campus.extension.org/file.php/227$@SLASH@$image$@SLASH@$couple.png" These image URLs are not broken when I restore locally, but are broken when I restore on another site. Also see the last post in this forum: http://moodle.org/mod/forum/discuss.php?d=123571#p541640 Running LAMP, Moodle 1.9.5+
Hide
Tim Hunt added a comment - - edited

Please tell me which bit of text in which question type is getting messed up. (For example, a choice or a feedback in a multiple choice question, or whatever.)

Show
Tim Hunt added a comment - - edited Please tell me which bit of text in which question type is getting messed up. (For example, a choice or a feedback in a multiple choice question, or whatever.)
Hide
ray cantwell added a comment -

Would this issue also pertain to links located in courses not updating properly?

Show
ray cantwell added a comment - Would this issue also pertain to links located in courses not updating properly?
Hide
Tim Hunt added a comment -

The file changes in Moodle 2.0 resolved this sort of problem once-and-for-all. We are not now going to try to fix this sort of thing in Moodle 1.9, so closing this issue.

Show
Tim Hunt added a comment - The file changes in Moodle 2.0 resolved this sort of problem once-and-for-all. We are not now going to try to fix this sort of thing in Moodle 1.9, so closing this issue.

Dates

  • Created:
    Updated:
    Resolved: