Changing the way names are displayed

Changing the way names are displayed

by Todd Moore -
Number of replies: 2

OK, I'm a newbie to Moodle, so bear with me.

I have a problem that I'm sure many have, especially in the K-12 environment in the United States.  We are not allowed to post a student's full name on the Internet in any way shape or form.  Most schools and districts now have policies similar to this. So we need to be able to differentiate the way names are displayed between student and teachers/admins.

I would stil like users to be able to see who's online, course participants and the like, so I have set Moodle up to display first names only.  That's great for the kids but not so good for instructors.

Is there a hack that will allow teacher names only to be displayed as "Mr. or Mrs. Surname" but still show just the student's first names?

Thanks in advance for any help.

Average of ratings: -
In reply to Todd Moore

Re: Changing the way names are displayed

by Jan Dierckx -

Not sure if this will work on all Moodle pages mixed but you can give it a try.

Make a copy of lib/moodlelib.php so you can always retore the situation as it was. Open lib/moodlelib.php and look for the function fullname (around line 2284 in my Moodle)

Change

} else if ($CFG->fullnamedisplay == 'firstname') {
    if ($override) {
        return get_string('fullnamedisplay', '', $user);
    } else {
        return $user->firstname;
    }
}

to

} else if ($CFG->fullnamedisplay == 'firstname') {
    if ($override or isteacherinanycourse($user->id)) {
        return get_string('fullnamedisplay', '', $user);
    } else {
        return $user->firstname;
    }
}

Now teachernames should always be displayed firstname (I reckon that would be Mr or Mrs in your installation) + lastname, while student names should follow the setting from the configuration screen: only first name in your case.

In reply to Todd Moore

Re: Changing the way names are displayed

by Reggie Ryan -
Todd,

I'm also in the US, and have had to deal with the 'name issue'. I've also set Moodle to display first names only for kids.

For teachers I've simply set their first names to be 'Mr. Name', or 'Mrs. Name' (example: Mr. Ryan).

For the last name I've set them all to be ':'. That way teacher names are set to be 'Mr. Ryan:'.

Seemed kind of nuts when I did it, but in Moodle, teacher names are displayed with a colon after them, which works well. Kind of....

Reggie