I don't know if this is a Moodle bug or something bad happened or is set at our site. When My courses are listed (default setting for main page for logged users at our site), original role names of teachers are shown instead of the new ones set on the course level.
After clicking on All courses and a category, I can see the right renamed roles. Looking at a user profile at course level, I can also see the new names.
Any idea?
Moodle 1.9.2+ (20080903)
O.Š.
In reply to Otakar Šprdlík
Re: Role renaming does not work on the My courses page
by Otakar Šprdlík -
I hope this is right, seems work.
Edit function print_course() in course/lib.php. Add replacing of rolenames by aliasnames in the same way as on lines 1885-1909
// $Id: lib.php,v 1.538.2.51 2008/07/26 11:35:23 skodak Exp $
--- www/moodle19/course/lib.php 2008-09-17 19:44:02.000000000 +0200
***************
*** 1919,1926 ****
--- 1919,1932 ----
true, '', 'r.sortorder ASC, u.lastname ASC', $canseehidden);
if (is_array($rusers) && count($rusers)) {
$canviewfullnames = has_capability('moodle/site:viewfullnames', $context);
+ if (isset($context)) {
+ $aliasnames = get_records('role_names', 'contextid', $context->id,'','roleid,contextid,name');
+ }
foreach ($rusers as $teacher) {
$fullname = fullname($teacher, $canviewfullnames);
+ if (isset($aliasnames[$teacher->roleid])) {
+ $teacher->rolename = $aliasnames[$teacher->roleid]->name;
+ }
$namesarray[] = format_string($teacher->rolename)
. ': <a href="'.$CFG->wwwroot.'/user/view.php?id='.$teacher->id.'&course='.SITEID.'">'
. $fullname . '</a>';
Edit function print_course() in course/lib.php. Add replacing of rolenames by aliasnames in the same way as on lines 1885-1909
// $Id: lib.php,v 1.538.2.51 2008/07/26 11:35:23 skodak Exp $
--- www/moodle19/course/lib.php 2008-09-17 19:44:02.000000000 +0200
***************
*** 1919,1926 ****
--- 1919,1932 ----
true, '', 'r.sortorder ASC, u.lastname ASC', $canseehidden);
if (is_array($rusers) && count($rusers)) {
$canviewfullnames = has_capability('moodle/site:viewfullnames', $context);
+ if (isset($context)) {
+ $aliasnames = get_records('role_names', 'contextid', $context->id,'','roleid,contextid,name');
+ }
foreach ($rusers as $teacher) {
$fullname = fullname($teacher, $canviewfullnames);
+ if (isset($aliasnames[$teacher->roleid])) {
+ $teacher->rolename = $aliasnames[$teacher->roleid]->name;
+ }
$namesarray[] = format_string($teacher->rolename)
. ': <a href="'.$CFG->wwwroot.'/user/view.php?id='.$teacher->id.'&course='.SITEID.'">'
. $fullname . '</a>';
In reply to Otakar Šprdlík
Re: Role renaming does not work on the My courses page
Hi Otakar,
that has been tracked as MDL-16569 . Your patch is perfect .
Has been fixed in 19_STABLE and HEAD. Thanks!
Ciao
that has been tracked as MDL-16569 . Your patch is perfect .
Has been fixed in 19_STABLE and HEAD. Thanks!
Ciao
In reply to Eloy Lafuente (stronk7)
Απάντηση: Re: Role renaming does not work on the My courses page
by Deleted user -
Hi,
i have the same problem and i am happy thay Otakar find a solution.
Unfortunately i do not know the way to fix ii. Can you help me giving some steps to do it.
Thanks
George
i have the same problem and i am happy thay Otakar find a solution.
Unfortunately i do not know the way to fix ii. Can you help me giving some steps to do it.
Thanks
George
In reply to Deleted user
Re: Απάντηση: Re: Role renaming does not work on the My courses page
by Steven A -
Does this help?
Here is the file version: $Id: lib.php,v 1.538.2.51 2008/07/26 11:35:23 skodak Exp $
The line numbers before the hack are: 1919-1926
The new line numbers after the hack are: 1919-1932
There are six new lines of code, each preceded by a red plus sign (+). Erase the plus signs (and nothing more!) when you cut and paste the hack into your file. Also please be careful that you're not altering any other bits of code.
true, '', 'r.sortorder ASC, u.lastname ASC', $canseehidden);
if (is_array($rusers) && count($rusers)) {
$canviewfullnames = has_capability('moodle/site:viewfullnames', $context);
+ if (isset($context)) {
+ $aliasnames = get_records('role_names', 'contextid', $context->id,'','roleid,contextid,name');
+ }
foreach ($rusers as $teacher) {
$fullname = fullname($teacher, $canviewfullnames);
+ if (isset($aliasnames[$teacher->roleid])) {
+ $teacher->rolename = $aliasnames[$teacher->roleid]->name;
+ }
$namesarray[] = format_string($teacher->rolename)
. ': <a href="'.$CFG->wwwroot.'/user/view.php?id='.$teacher->id.'&course='.SITEID.'">'
. $fullname . '</a>';
Here is the file version: $Id: lib.php,v 1.538.2.51 2008/07/26 11:35:23 skodak Exp $
The line numbers before the hack are: 1919-1926
The new line numbers after the hack are: 1919-1932
There are six new lines of code, each preceded by a red plus sign (+). Erase the plus signs (and nothing more!) when you cut and paste the hack into your file. Also please be careful that you're not altering any other bits of code.
true, '', 'r.sortorder ASC, u.lastname ASC', $canseehidden);
if (is_array($rusers) && count($rusers)) {
$canviewfullnames = has_capability('moodle/site:viewfullnames', $context);
+ if (isset($context)) {
+ $aliasnames = get_records('role_names', 'contextid', $context->id,'','roleid,contextid,name');
+ }
foreach ($rusers as $teacher) {
$fullname = fullname($teacher, $canviewfullnames);
+ if (isset($aliasnames[$teacher->roleid])) {
+ $teacher->rolename = $aliasnames[$teacher->roleid]->name;
+ }
$namesarray[] = format_string($teacher->rolename)
. ': <a href="'.$CFG->wwwroot.'/user/view.php?id='.$teacher->id.'&course='.SITEID.'">'
. $fullname . '</a>';