Attendant URL not working for student

Attendant URL not working for student

by Sebastien Jaffredo -
Number of replies: 4

Regarding the confirmation e-mail sent to the student.

The URL of the teacher : <a href="{$a->attendant_url}">{$a->attendant}</a> doesn't work : when the user clicks on the link, he has the following message : "The details of this user are not available to you".

Even if the user is supposed to see the teachers's profile.

What happens is that the resulting link is :

http://siteurl/user/profile.php?id=X

While the right URL to correctly display the teacher's profile should be :

http://siteurl/user/profile.php?id=X&course=Y

How can I have this work ? I can think of 3 logical possibilities :

  1. There is a setting somewhere in Moodle enabling a user to display the profile even if the context course id isn't declared in the url (not sure whether such a setting exists)
  2. Change the definition of the "attendant_url" variable to include the contexted course id
  3. Create a new variable such as  "attendant_course_url" that would generate a link like "http://siteurl/user/profile.php?id=X&course=Y"

Having no notions of PHP I cannot fathom how to do this, but I'd be glad to learn for the occasion if someone can think of a simple patch to the plugin to enable it.

 

Thanks,

 

Sébastien

Average of ratings: -
In reply to Sebastien Jaffredo

Re: Attendant URL not working for student

by Sebastien Jaffredo -

I tried to hack the code myself, being aware I didn't really know what I was doing.

I changed line 775 in locallib.php from :

 $vars['ATTENDANT_URL'] = $CFG->wwwroot.'/user/view.php?id='.$attendant->id;

to

  $vars['ATTENDANT_URL'] = $CFG->wwwroot.'/user/view.php?id='.$attendant->id.'&course='.$course->id;

 

Now I'm getting the error message :

Notice: Undefined variable: course in /home4/jaffredo/public_html/etudier/mod/scheduler/locallib.php on line 775

I suppose it boils down to defining the $course variable. Where and how to do this ?

In reply to Sebastien Jaffredo

Re: Attendant URL not working for student

by Scott Krajewski -

That's a great try!  The problem is the function scheduler_get_mail_variables does not know anything about the course.  It only knows what it's been told through the variables passed to it.

Unless you pass the $course to the function we'll have to figure out the course id from the $scheduler id.  Try this (I have not tested this!), I think it should work.  Working in scheduler_get_mail_variables,

change global $CFG; to global $CFG, $DB;

In the if($scheduler) section add in

$courseid = $DB->get_field('scheduler', 'course', array('id' => $scheduler->id));

That gets the course id from the scheduler id.  Now use $courseid in your code addition.

Average of ratings: Useful (1)
In reply to Scott Krajewski

Re: Attendant URL not working for student

by Sebastien Jaffredo -

Thanks Scott, I followed your advice, and the error message doesn't show anymore. I feel a little bit cleverer thanks to you.

Still, I didn't have the occasion to check the result because for some reason Moodle doesn't seem to send the confirmation mail to the student, only the teacher. I'm not sure what to do about this.

Besides, when I erase a time slot that has a reservation on it, it doesn't erase it in the calendar and I get this error message :

Notice: Undefined property: stdClass::$schedulerid in /home4/jaffredo/public_html/etudier/mod/scheduler/locallib.php on line 595

That line of locallib.php I dodn't change. Not sure if it's related to the hack.

In reply to Sebastien Jaffredo

Re: Attendant URL not working for student

by Henning Bostelmann -
Picture of Core developers Picture of Plugin developers

Hello Sebastien,

thanks for mentioning this bug; I have now (if late) fixed it in the master and 2.3 branches (fix version not yet released, but available on github).

Henning