Variable for Course Link

Re: Variable for Course Link

by Stephen Mc Guinness -
Number of replies: 0

Hi Alan,

The language string for the course welcome email (in 1.9) is:

$string['welcometocoursetext'] = 'Welcome to $a->coursename!

If you have not done so already, you should edit your profile page so that we can learn more about you:

$a->profileurl';

I that case $a is an object that is being passed as a parameter to the get_string call which is retrieving the welcometocoursetext language string.

You need to locate the get_string call and add your course link to the object which is passed as a parameter to that call.

In Moodle 1.9 the call to get_string is around lines 4711 - 4718 in lib/moodlelib.php

4711     if (!empty($course->welcomemessage)) {
4712         $message = $course->welcomemessage;
4713     } else {
4714         $a = new Object();
4715         $a->coursename = $course->fullname;
4716         $a->profileurl = "$CFG->wwwroot/user/view.php?id=$user->id&course=$course->id";
4717         $message = get_string("welcometocoursetext", "", $a);
4718     }

You need to modify that code to add your course link:

4711     if (!empty($course->welcomemessage)) {
4712         $message = $course->welcomemessage;
4713     } else {
4714         $a = new Object();
4715         $a->coursename = $course->fullname;
//Add the course link to $a so it can be used in the language string
$a->courselink = "{$CFG->wwwroot}/course/view.php?id={$course->id}";

4716         $a->profileurl = "$CFG->wwwroot/user/view.php?id=$user->id&course=$course->id";
4717         $message = get_string("welcometocoursetext", "", $a);
4718     }

$a->courselink would then be available in the language file for you to use in your modification of the course welcome email

Stephen Mc Guinness
Enovation Solutions