Graphics when restoring a backup

Graphics when restoring a backup

by Marcus Green -
Number of replies: 7
Picture of Core developers Picture of Particularly helpful Moodlers Picture of Plugin developers Picture of Testers
I have been creating some html resources in moodle and inserting the URL of some graphics. When I do a backup and restore to another site I find that the URL of the graphics has change. To illustrate this here are the two URL's for comparison.

http://localhost/moodle/file.php?file=/4/key2.gif


As you can see the location of the file has changed, on my local machine it is in a directory called 4 and on the server it is at /5/. Anything I can do to align these so that the restore points to the same resource?

Marcus
Average of ratings: -
In reply to Marcus Green

Re: Graphics when restoring a backup

by Gustav W Delius -
The change in the URL is deliberate. The 4 was the id number of the course on the old server but on the new server you have restored to course 5. So also the course files, including the key2.gif file, will have been restored to this new folder, provided you chose to include the course files in the backup and restore.
In reply to Gustav W Delius

Re: Graphics when restoring a backup

by Marcus Green -
Picture of Core developers Picture of Particularly helpful Moodlers Picture of Plugin developers Picture of Testers
That figures. is there a way to embed a graphic resource so it will show up correctly even if the id of the course changes (or am I missing a more subtle point here)
Marcus
In reply to Marcus Green

Re: Graphics when restoring a backup

by Eloy Lafuente (stronk7) -
Picture of Core developers Picture of Documentation writers Picture of Moodle HQ Picture of Peer reviewers Picture of Plugin developers Picture of Testers
Hi Marcus,

I think that, independent of the type of resource (html text, uploaded file...) it's highly recommended that you use the "slasharguments" option in your URLs.

This implies modifying all your links from:

http://localhost/moodle/file.php?file=/4/key2.gif

to

http://localhost/moodle/file.php/4/key2.gif

You can set "slasharguments" under the "Administration/Configuration" page
(your server could need some adjustment, press over this "slasharguments" word for more info).

Then, working under a "slasharguments-server" you'll benefit of this:

- If you use uploaded resources, all your links in them can be specified relatively, so you won't need to use the "courseid" anymore. Your uploaded resources will be fully "movable".

- If you are using html resources, all your links in them will be absolute, but using the "slasharguments" syntax. If I'm not wrong, the backup and restore procedure (only in Moodle version >= 1.3) will modify that links "on the fly", making this html resources fully "movable" too.

Hope this helps, ciao smile
In reply to Eloy Lafuente (stronk7)

Re: Graphics when restoring a backup

by Marcus Green -
Picture of Core developers Picture of Particularly helpful Moodlers Picture of Plugin developers Picture of Testers

Many thanks for the suggestion Eloy, I'll give it a try.

Marcus

In reply to Eloy Lafuente (stronk7)

Re: Graphics when restoring a backup

by Marcus Green -
Picture of Core developers Picture of Particularly helpful Moodlers Picture of Plugin developers Picture of Testers

Wooo hooo, it works. I thought it was going to work but I would have to change the URL's in my source, but no it just works!. Who says open source software isn't supported eh? Thanks again for the replies.

In reply to Eloy Lafuente (stronk7)

Re: Graphics when restoring a backup

by PeterJaap de Bruin -

As teacher-user, not familiar with (or no privileged user),
how would I backup my complete course and restore it, using my teacher-interface, just to loose loginfo and keep everything else intact?

This way i can demonstrate a complete marvel to my collegues,
everything I ever build within moodle, is totally re-usable.
People can re-use questions from pools for their other quizes,
AND can re-use complete courses or other activities.

In reply to PeterJaap de Bruin

Re: how would I backup my complete course and restore it

by David Mudrák -
Picture of Core developers Picture of Documentation writers Picture of Moodle HQ Picture of Particularly helpful Moodlers Picture of Peer reviewers Picture of Plugin developers Picture of Plugins guardians Picture of Testers Picture of Translators
Hi Peter
Maybe I'm off topic but (and IMO):
  • you can backup your course using menu Administration-Backup... During creating backup you can choose what parts of course to include (eg ypu would include everything except logs). Your backup will be created in your course files as a ZIP file
  • if you want to restore your backup (ie template course in your case) into new course you must have at least CourseCreator (or Admin) privileges set by your Moodle admin