Restored course doesn't show images

Restored course doesn't show images

by Josep M. Fontana -
Number of replies: 12
I installed a Moodle course via restore and most of the images and links have been lost. Is there any quick way to fix this? I imagine it has to do with 'relative paths' not being correct. When I check the HTML code of the links that fail I see things like:
<a href="/course/view.php?id=3#moodlelinks">Moodle Links</a>

The number assigned by Moodle to this particular course is 4 rather than 3 but replacing the 4 by a 3 doesn't fix the problem either.

Josep M.



Average of ratings: -
In reply to Josep M. Fontana

Re: Restored course doesn't show images

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 Josep,

and how was that URL in origin? Perhaps it was exactly the same?

As I know, all the URLs using file.php plus inter-module full URLs (pointing to discussions, posts, activities...) are properly converted but URLs to courses aren't!

It could be a nice addition for 1.5.4 (post a bug), but a condition should be satisfied and it's that the FULL URL must be present. And your example above don't follow the rule. It's ABSOLUTE but not FULL!

Ciao smile
In reply to Eloy Lafuente (stronk7)

Re: Restored course doesn't show images

by Josep M. Fontana -
Hi Eloy,

I don't really understand what you mean by "how was that URL in origin"?
The backup course I'm having problems with is a course about Moodle originally created by Morag Munro that I downloaded I think from moodle.org.

After downloading this course, I restored it in a Moodle installation I have. I then modified it by adding several resources to it. After that, I did a backup and restored it in a different course which is in a different Moodle installation (different database and everything).

What's funny is that I checked the other course in the other installation and it doesn't have 3 as a course id either. It has also a 4. I don't know where the 3 comes from.

Many of the links that are not working are to the main page.

So the link I see is:

 href="/course/view.php?id=3#createcourse

When I click on it it takes me to:

http://parles.upf.es/course/view.php?id=3#createcourse

which of course returns a "Not found"

If I replace the id=3 by id=4, it takes me to:

http://parles.upf.es/course/view.php?id=3#createcourse

which also returns a "Not found". If everything worked fine, it should have taken me to:

http://parles.upf.es/mellange/course/view.php?id=4#createcourse

So, can you infer what is going on with this information?

Please, let me know whether you need any more information. I'm using the latest version: 1.5.3 (Moodle 1.5.3+ (2005060230)) and the backup was made under Moodle 1.5.2 + (2005060223). I'm hesitant to post this as a bug without digging a little bit more into the possible causes. Unless you tell me this really does look like a bug, of course.

Josep M.
In reply to Josep M. Fontana

Re: Restored course doesn't show images

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 Josep,

what I'm trying to ask is how was that piece of code in your backup file. If it was:

href="/course/view.php?id=3#createcourse"

I call it ABSOLUTE url but not FULL url. One full URL should be:

href="http://myhost/mypath/course/view.php?id=3#createcourse"

And your example isn't being processed at all! Why?

Because, in the destination course, only FULL (processed by backup and restore) and RELATIVE (because they don't need any transformation) urls will work once restored but never ABSOLUTE urls (because the absolute part can be completely different: "/course" in origin, and "/mellange/course" in your destination server and backup doesn't know about it).

More yet, not every FULL url will work. For now all the FULL urls to modules are supported but FULL urls to other places (course, sections...) aren't. sad

What I was trying to tell you is that, if urls in your backup file were FULL (so they had to be FULL in your original course), it would be relatively easy to add new FULL transformations to the backup/restore code to keep them working.

I don't know if I've explained my thoughts well...have I? shy

Ciao smile
In reply to Eloy Lafuente (stronk7)

Re: Restored course doesn't show images

by Josep M. Fontana -
Hola Eloy,

Yes, I think you have explained your thoughts very well. I guess the URLs that I have in this backup course are absolute addresses, since they have the form:

<a href="/course/view.php?id=3#createcourse">

What I don't understand is how they turned out this way. As I said, this was a course prepared by somebody else which I downloaded and modified and then uploaded into a different Moodle installation. I know I didn't touch any of these links and I don't know how the original creator created these links. But this means something in the Moodle backup system is not working properly, doesn't it? Or is there a proper way of backing up a course which would prevent this from happening? Somebody in a different forum suggested using the "resource auto-link" filter would solve these problems but I don't understand very well how it would do so.

Anyway, my question now is: is there anyway to fix this without having to change every single URL manually. It occurs to me that perhaps it would be possible to fix this by backing up the course again and then doing a search and replace within the moodle.xml file that changed all the strings of the form '/course/view.php?id=3#' into strings of the form '/mellange/course/view.php?id=4#'. Once this is done, we restore the course again. Does this look like something that could work?

This kind of substitution seems to solve the problem of the links that I modify manually. 


Josep M.

In reply to Josep M. Fontana

Re: Restored course doesn't show images

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 Josep,

that's exactly the trick (the search and replace that you propose above). No other solution is available for now. sad

About the "resource-names" or "activity-names" filter, it has nothing to do with restore, so enabling or disabling it hasn't any effect in URLs. I suppose that such suggestion was pointing to the good habit if use such filters instead of hardcode the URLs to activities in your texts. Using the filters, you only have to write the activity name and Moodle will link it for you. And you won't have any problem with absolute or full urls.

But there isn't any filter providing auto-links to course and sections, perhaps it would be interesting to have one...providing custom links...or something similar.

Ciao smile
In reply to Eloy Lafuente (stronk7)

Re: Restored course doesn't show images

by Josep M. Fontana -
Thanks Eloy. The search and replace looks like a simple enough solution. The question I have now is, would it be better to replace the existing strings in the way I suggested? -->

i.e. replace strings of the form '<a href="/course/view.php?id=3#">' by strings of the form '<a href="/mellange/course/view.php?id=4#">'

The doubt I'm having is that, if I understood you correctly, this would be replacing an absolute URL with another absolute URL. The problem would be then that I wouldn't be able to restore this backup in another course because then I would have exactly the same situation I have now. Wouldn't it be better to replace the existing strings with FULL or RELATIVE URLs instead?

At this point, though, it's not totally clear to me what a relative URL looks like. Up to know, I would have thought that a string like href="/course/view.php?id=3#createcourse" WAS a relative URL, but as you say, this is rather an absolute URL. What would the relative URL look like in this case?

Thanks a lot for everything. Do you ever sleep? smile
In reply to Josep M. Fontana

Re: Restored course doesn't show images

by Karl Peltomaa -
Joseph,
I have the same problem when restoring the "Using Moodle" course. How is a link like href="/course/view.php?id=3#createcourse" an Absolute URL? I thought that such links were relative, and that an absolute link would be for instance "http://www.example.com/moodle/course/view/view.php?id=3#createcourse" ?

In the interest of the whole Moodle community this ought to be fixed in the original, if that's possible. The "Using Moodle" course is a too valuable resource for instructor training to be left with this major problem. For such a collaborative community of brainy Moodlers it would be "dumb" if everyone have to do the manual work of re-writing the links. Imagine the savings in time and work effort if this would be solved once at the source!

In reply to Karl Peltomaa

Re: Restored course doesn't show images

by Steve James -
Hi,

I came here to find out if there is a way changing the absolute links which teachers have within their course web pages.

I have not used Moodle so all this was new to me.

My problem is this:

I copied the directories moodle and moodle data from httpdocs to httpsdocs.

I then made changes to config.php to reflect this, all was well until a teacher noticed that all web pages she had created would not display images.

I tried adding redirect rules to the hosts.conf of apache which worked fine in FireFox and Opera, but in IE everytime the images are requested it asks the user to authorise loading of non secure content. Immpossible situation.

So I understand that I should do a search & replace but I dont know where to do that.

Is it a table in the database?

You reccomend exporting table, performing search and replace and restoring table?

Thanks

Steve

In reply to Steve James

Re: Restored course doesn't show images

by David Field -
Having recently suffered with this problem, do this

Open phpmyadmin
Export the whole moodle database into an uncompressed SQL File
Might be a good idea to put the drop tables bit in there as well


That SQL file is a text file,

Open it in a TEXT editor (one that will save the file as ONLY text)

I used gedit on my Linux PC

Right now do a find and replace for the http://<oldservername>

Replace it with a space....

Bingo...

Save this new file

Upload this editied SQL file

You will find that your images are there

In reply to David Field

Re: Restored course doesn't show images

by Steve James -
Thanks,

Will follow that method.

Regards
Steve
In reply to Steve James

Re: Restored course doesn't show images

by Ahmed Metwally -

Yhaa, it's a very good shortcut solution to change the server name  in all absolute links in moodle, but there is another mega problem I have experienced which is the course ID. Always the restored course has a different ID from the original one. So, is there a solution for such a problem?

Thanks