Sharing courses

Sharing courses

by Peter Honan -
Number of replies: 9

I know this has been raised before, but I am wondering if there is any way around a problem I am having with explicit URL's used within moodle courses and html content like forums and html resources. Even if I use relative URL's and edit the html directly Moodle still stores the content as a fully qualified URL.

Every time a course is moved from one moodle server to another either for sharing of the course between sites or during a migration, numerous links end up broken. Our staff have also expressed a desire to have Moodle on their laptops for 'ofline' development of courses, again the transfer causes problems.

Possibly the server and path info could be stored as a php tag ??

I love the idea of being able to share content and courses but this issue makes it a messy proposition......

Average of ratings: -
In reply to Peter Honan

Absolute vs Relative links

by Martin Dougiamas -
Picture of Core developers Picture of Documentation writers Picture of Moodle HQ Picture of Particularly helpful Moodlers Picture of Plugin developers Picture of Testers
It's a messy issue in general that does need to be dealt with, but it's not easy.

One problem is that links (including images) which get sent out via email do need to be absolute.

Another is that relative links may mean different things within different contexts - for example, a relative image in the editor is relative TO THE EDITOR PAGE, not it's final location, so to get the correct final result people would need to put up with broken images in the editor.

One solution is to continually parse all incoming text looking for absolute URLs within the Moodle-space and convert them to relative links for storage, while always parsing outgoing texts and converting relative links to absolute ones.

Alternatively, we can use absolute references all the time and only do this conversion during backup and restore ...
In reply to Martin Dougiamas

Re: Absolute vs Relative links

by Gustav W Delius -

... or we can make all links point to a new script link.php and pass a MRL (Moodle Resource Locator) as an argument. All link.php will do is look up the URL from the MRL in a table and forward to the URL. This table would have to be dealt with appropriately by backup and restore.

One nice thing about his proposal is that it can be phased in gradually without breaking anything. All that is required is that someone writes the lookup-and-redirect script and updates the backup module. We can then slowly start using MRL's in more and more places in Moodle.

In reply to Gustav W Delius

Re: Absolute vs Relative links

by Peter Honan -

I think both proposals would work well....but Martins is probably the more efficient one. The conversion would only need to be done when doing a backup/restore, leaving the current code intact and not imposing any additional processing for standard pages.

How??

P.S. The smilies seem to be broken....

In reply to Gustav W Delius

Re: Absolute vs Relative links

by Martin Dougiamas -
Picture of Core developers Picture of Documentation writers Picture of Moodle HQ Picture of Particularly helpful Moodlers Picture of Plugin developers Picture of Testers
This MRL is pretty much what /file.php and /user/pix.php does now ... and the issue of absolute/relative still applies to the links going to these (or a link.php).

The more I think about it the more I think this is something backup/restore should handle ...

thoughtful ( Smileys working OK for me... )
In reply to Martin Dougiamas

Re: Absolute vs Relative links

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

it would be perfect (and laborious!!) to handle it from backup/restore but some ideas in natural language could help me to understand the exact steps to implement.

Please, illustrate me !!

big grin (laughter working too!!)

Ciao, smile
In reply to Eloy Lafuente (stronk7)

Re: Absolute vs Relative links

by Martin Dougiamas -
Picture of Core developers Picture of Documentation writers Picture of Moodle HQ Picture of Particularly helpful Moodlers Picture of Plugin developers Picture of Testers
I'll have a quick stab at this ... it undoubtedly needs more thought...

backup process:
   search each text for the $CFG->wwwroot string
   replace with a special string like XSITEX
  
restore process:
   search each text for XSITEX
   replace with $CFG->wwwroot

The "search each text" might be possible just from within backup, otherwise it would have to be implemented in each module's backuplib.php and restorelib.php.
In reply to Martin Dougiamas

Re: Absolute vs Relative links

by Gustav W Delius -

What you propose would indeed be required. But, as you pointed out to me in a different thread, it is not enough because also all resource ID's change during restore and thus all links to resources need to be changed accordingly.

In reply to Gustav W Delius

Re: Absolute vs Relative links

by Martin Dougiamas -
Picture of Core developers Picture of Documentation writers Picture of Moodle HQ Picture of Particularly helpful Moodlers Picture of Plugin developers Picture of Testers
Indeed - I wasn't even thinking about those yet! wide eyes

OK, so, each backuplib/restorelib could also search/replace things like:

http://moodle.org/mod/forum/discuss.php?d=3506 ==> FORUM:DISCUSSION=3506
http://moodle.org/mod/forum/discuss.php?d=3506#15720 ==> FORUM:DISCUSSION=3506,POST=15720
http://moodle.org/mod/resource/view.php?id=1033 ==> RESOURCE:1033

The numbers in the backup version will be internal numbers which get renumbered during restore.

Good points:

One thing I'm liking about this general approach (although it does put a very large responsibility/load on backup/restore - sorry Eloy smile) is that people don't need to use special codes or a special GUI ... they can cut and paste normal URLs and it will all "just work" (hopefully).  This is a huge advantage.

It can also be implemented gradually, starting with the common types of links ... as the default case will be to pass through the URLs untouched.

Bad points:

I can see a lot of logic work in the backup stage ... for example, if the discussion/resource/activity being pointed to is NOT in the current course backup, then the URL shouldn't be converted (ie internal links only).

Also, since links to resources could occur within any module, each text will have to be passed through all the module filters. This stuff will really slow backups down ... perhaps it would be an option at backup time.
In reply to Martin Dougiamas

Re: Absolute vs Relative links

by Williams Castillo -
This discussion bring to my mind one I was having with Eloy when talking about the bookmark hack...

We were talking about how to deal with bookmarks when the user made a backup/restore...

The last words/thoughts we had was that all modules within moodle MUST had a common set of parameters in order to make it scalable, mantainable... which could be a pain in the neck when dealing with complex modules, like quiz.

It is already done already, partially at least... all modules use id for the $cm->id...

Uhmm... I'm just thinking about other possibility... There could be a common function in every module that returns an array with all parameters it uses among the module, and its right translation (mode => GLOSSARY_VIEW, hook => GLOSSARY_AUX_ID, etc)...

Will