Is it possible to link directly to a networked course?

Is it possible to link directly to a networked course?

by Edward Hewlett -
Number of replies: 7
I have two networked Moodle instances and would like to create a link in the one instance that takes the user directly to a specific course in the other instance. Is this possible?
Average of ratings: -
In reply to Edward Hewlett

Re: Is it possible to link directly to a networked course?

by Dave Emsley -

Yes this is very easy. 

Go to the course you want to link TO.  Copy the URL.

Go to the FROM page and create a "Link to a Webpage" and use the URL as copied. It will look something like: http://www.whateversitename.com/moodle/course/view.php?id=411

...with a different id= number at the end for each course.

I hope this makes sense.

In reply to Dave Emsley

Re: Is it possible to link directly to a networked course?

by Edward Hewlett -
Thanks, Dave - though I knew this much already. The problem I am facing is a little more complex. Since I want to link from one Moodle instance (Moodle1) to a course in a second, networked Moodle instance (Moodle2), the above solution WILL take users directly to the course in question, but they will be stopped by the second Moodle instance's login page.

This is a problem because while users in Moodle1 can travel to Moodle2 via the Network Servers link (which takes them to Moodle2's course-list page and shows them as logged in as "USERNAME from Moodle1"), those Moodle1 users do not have a LOCAL user account in Moodle2. If they try to log in to Moodle2 with their Moodle1 account, they will get the error message "Invalid login, please try again
If you are a Moodle Network remote user and can confirm your email address here, you can be redirected to your login page."

What I want is a link that takes Moodle1 users seamlessly to a specific course in Moodle2 so that all the Moodle1 users have to do is click on the link and they will be taken directly to the course page in Moodle2 and show up as logged in as "USERNAME from Moodle1". Is this possible?

I noticed in mnet/land.php a variable called "wantsurl" can be passed, but I have not been able to find any documentation that I can understand which would show me how to use it - nor do I even know if that is what I'm looking for.

Hope that clarification of my question makes sense!
In reply to Edward Hewlett

Re: Is it possible to link directly to a networked course?

by Hubert Chathi -
As an add-on to Dave Emsley's post, this will only work if the user is already logged into the remote site. To have the user automatically logged in, you can create a link of the form:
[local_site]/auth/mnet/jump.php?hostid=[remote_host_id]&wantsurl=[remote_url]
where:
  • [local_site] is the wwwroot of your local site (obviously)
  • [remote_host_id] is the Moodle Network host id of the remote host (you can find it by going to Site Administration > Networking > Peers, clicking on the remote host, and looking at the "hostid" parameter in the URL
  • [remote_url] is the URL of the page you want to send users to, relative to the remote host's wwwroot, but including an initial slash. For example, if you want to link to http://www.whateversitename.com/moodle/course/view.php?id=411, then [remote_url] should be set to "/course/view.php%35id=411". Note that the URL needs to be url-encoded.
Average of ratings: Useful (3)
In reply to Hubert Chathi

Re: Is it possible to link directly to a networked course?

by Edward Hewlett -
THANK YOU!!! I was so close - but I couldn't make it work because I was mistakenly using the remote site to authorize instead of the local one. Thank you, thank you, thank you!
In reply to Hubert Chathi

Re: Is it possible to link directly to a networked course?

by Mark Aberdour -
Thanks Hubert, that was really useful smile
In reply to Hubert Chathi

Re: Is it possible to link directly to a networked course?

by Kathrin Bonfigt -
hi,

i think i did everything the way u described, but it still does not work. It directs always to the main page, not the wantsurl..

What did i miss..?

Cheers
Kathrin
In reply to Kathrin Bonfigt

Re: Is it possible to link directly to a networked course?

by Brian Turner -

Kathrin,

You did everything correctly.  I had the same problem.  It appears there was an error in the instructions. The instructions should have read:

This will only work if the user is already logged into the remote site. To have the user automatically logged in, you can create a link of the form:
[local_site]/auth/mnet/jump.php?hostid=[remote_host_id]&wantsurl=[remote_url]
where:

  • [local_site] is the wwwroot of your local site (obviously)
  • [remote_host_id] is the Moodle Network host id of the remote host (you can find it by going to Site Administration > Networking > Peers, clicking on the remote host, and looking at the "hostid" parameter in the URL
  • [remote_url] is the URL of the page you want to send users to, relative to the remote host's wwwroot, but including an initial slash. For example, if you want to link tohttp://www.whateversitename.com/moodle/course/view.php?id=411, then [remote_url] should be set to "/course/view.php%3Fid=411". Note that the URL needs to be url-encoded.

The encoding for a question mark is %3F (not %35).

Regards,

Brian