Teacher name doesn't show in course list

Teacher name doesn't show in course list

by Arara CD -
Number of replies: 3

I'm using Moodle 1.7 and i've recently stumbled across the following problem:

Some of my teachers are in more than one course (something completely normal). But in the course list, their name will only appear below one of the courses and not the others that get added later. This worked fine on 1.6 so i'm thinking this must be a role-related problem. If i check the roles the teacher is there but it's name just won't show in the list. Maybe it's an easy fix but i just can't get it sorted.

Thank in advance to anyone who can help me.

Average of ratings: -
In reply to Arara CD

Re: Teacher name doesn't show in course list

by C Lopez -
As tar as I can tell, this is caused by the fact that the main page only shows teacher role assignments if the teacher has accessed the course since the role was assigned. I've gone through the docs and forums and it seems like this is "not a bug" but I can't see why it should be this way. Maybe the get_users_by_capability function has to behave this way but it seems like in that case we need a new or different function.
In reply to C Lopez

Re: Teacher name doesn't show in course list

by C Lopez -
Okay, I downloaded the latest 1.7 release, and it appears that this bug is fixed. If you look in the lib/accesslib.php file and the get_users_by_capability function has lines that look like

/// Construct the main SQL
$select = " SELECT $fields";
$from = " FROM {$CFG->prefix}user u
INNER JOIN {$CFG->prefix}role_assignments ra ON ra.userid = u.id INNER JOIN {$CFG->prefix}role r ON r.id = ra.roleid
LEFT OUTER JOIN {$CFG->prefix}user_lastaccess ul ON ul.userid = u.id
$groupjoin";
$where = " WHERE ra.contextid ".get_related_contexts_string($context)."
AND u.deleted = 0
AND ra.roleid in $roleids
$exceptionsql
$coursesql
$groupsql";


instead of

/// Construct the main SQL
$select = " SELECT $fields";
$from = " FROM {$CFG->prefix}user u
INNER JOIN {$CFG->prefix}role_assignments ra ON ra.userid = u.id INNER JOIN {$CFG->prefix}role r ON r.id = ra.roleid
LEFT OUTER JOIN {$CFG->prefix}user_lastaccess ul ON (ul.userid = u.id $coursesql1)
$groupjoin";
$where = " WHERE ra.contextid ".get_related_contexts_string($context)."
AND u.deleted = 0
AND ra.roleid in $roleids
$exceptionsql
$groupsql";

Then you need to upgrade.
In reply to C Lopez

Re: Teacher name doesn't show in course list

by Arara CD -

Thank you! You've got it, that was exactly the problem.