How to change Course link?

How to change Course link?

by Enrico Marcosian -
Number of replies: 5
Hi,
I have set-up 9 teachers with all their courses. But, two of the teachers want to use their pre-existing web sites (not connected to our moodle).

How can I change their links such that when you click on their courses, you get sent directly to their outside-moodle web site? Is this something I change somewhere in Sql?

Thanks for any help!
Enrico


Average of ratings: -
In reply to Enrico Marcosian

Re: How to change Course link?

by Jan Dierckx -

Put a file called externservercourse.php inside the coursedirectory of your moodle installation.

Inside this /course/externservercourse.php place a function which returns the complete url for the outside moodle site, based on the course object passed to it. (You can use shortname or id if you like)

Name the function extern_server_course. (Why different names were given to the file and the function inside is a complete mystery to me?)

Example:

function extern_server_course($course) {
    if ($course->id == 23) {
        return 'http://www.mywebsite.be';
    }
}

However, every Moodle upgrade seems to make changes which breaks existing code. I am sure one of the upcoming versions of Moodle will alter this kind of functionality and then the redirects won't work anymore.

Maybe you should consider just putting a link to the outside website inside the Moodle course area.

In reply to Jan Dierckx

Re: How to change Course link?

by Jörg Schäfer -
Now I also use this method for create several entries in course list for the same course with moodle 1.8.2.

Thanks for the help!
In reply to Jörg Schäfer

Re: How to change Course link?

by Steve Power -

Jörg

Did you have to do anything other than add the file externservercourse.php to get this to work in Moodle 1.82?

I see the usual call to the function in course/view.php but when I try to use this to do an internal (or external) redirection I seel the contents of the function displayed at the top of the course page rather than the redirection happening.

Regards
Steve

In reply to Steve Power

Re: How to change Course link?

by Steve Power -
Oh dear I had simply forgotten to wrap the code inside externservercourse.php in <?php ?> tags blush