The display of usernames.

The display of usernames.

by Timothy Takemoto -
Number of replies: 8

Does anyone know how to display the username (i.e. login name) of the students, and not just their name? This would be particularly useful in the screens where the lists of students are displayed such as the quiz, gradebook, and survey screens. The display of login names on student profiles, recent activity you be nice too.

Sometimes students log in via LDAP (Is that right? LMAP? or something) using their student number of something that is very easy to manage and the rolls (things that we do role calls with) are often in student number (i.e. login name) order.

Added to that, in the Japanese language there is often confusion about the order of the names, the characters they write their names in, and how to read student names in ideogram (hence, perhaps the use of numbers more often). The use of the login name would be a real plus.

If anyone knows the php variable then we may be able to hack something. For example might this work?
print ($$userid);

The ability to decided whether student usernames are displayed at a course level, immediately prior to all occurences of the users name (for ordering), would be a ideal.

On behalf (in Japanese) of taka kago and come to think of it myself. It would definately be a very useful function.

Thank you,

Tim
Takemoto

Average of ratings: -
In reply to Timothy Takemoto

Re: The display of usernames.

by Bernard Boucher -
Hi Timothy,
                   to have logging names aside of names one small change in one file:

moodle/lib/weblib.php

around line 1045

       $fullname = fullname($user, true);
add
       $fullname = fullname($user, true)."{".$user->username."}";


You may add elsewhere if you want and change { for what you want.

Not tested in japanesewink

Bye,

Bernard

In reply to Bernard Boucher

Re: The display of usernames.

by Martin Dougiamas -
Picture of Core developers Picture of Documentation writers Picture of Moodle HQ Picture of Particularly helpful Moodlers Picture of Plugin developers Picture of Testers
One could also just change the fullname() function itself.
In reply to Martin Dougiamas

Re: The display of usernames.

by Takahiro Kagoya -

Hi. This  is taka kago in Japan.

Some days before I asked about this problem in Japanese Forum.( Thank you Tim.)

I will explain about my request in detail.

I want to add moodle login account  for list of students. Because we are managing student's with number. You explained about the fullname() function. Maybe, if I modify this function I will be able to view student list with login id, but I want to sort this list with login id in any activitys, and I want to export a result of quiz and so on.  So please tell me how to modify the php source code .

In reply to Takahiro Kagoya

Re: The display of usernames.

by Martin Dougiamas -
Picture of Core developers Picture of Documentation writers Picture of Moodle HQ Picture of Particularly helpful Moodlers Picture of Plugin developers Picture of Testers
No guarantees here (I've not tested it), and it will probably not work absolutely everywhere, but find the fullname function in lib/moodlelib.php and change it to this:

function fullname($user, $override=false) {
    if (!empty($user->username)) {
        return $user->username;
    } else {
        return $user->lastname;
    }
}

In reply to Martin Dougiamas

Re: The display of usernames.

by Takahiro Kagoya -

Thank you very much for your commnet.

I understood your explanation. I will try it on next Tuesday.
(I'm home now. So I can't modify source code in server working on Windows IIS)

But in the future, I want to view both login id (ex: s001,s002...) and real name (in Japanese lastname+firstname).
And please add a optional settig for each course:
  "show username",  name order "username + last name + firstname"

sorry, my cheep English.

In reply to Martin Dougiamas

Re: The display of usernames.

by Big Faced Boy -
I've tried Bernard's suggestion above, but it doesn't seem to do anything, so I'll be changing it back. I found "function fullname" but it returned a parse error when I changed it - it appears to be for a much earlier version of moodle, maybe that's the problem, or maybe it's just because I know about as much about php as you know about my blood group. ;-P

function fullname($user, $override=false) {

global $CFG, $SESSION;

if (!isset($user->firstname) and !isset($user->lastname)) {
return '';
}

Is what I have currently in lib/moodlelib.php

Frankly, I find it hard to believe that this isn't a standard feature. Being able to list usernames against names is a basic requirement for me and, I'm sure, many other users.

I'd be most grateful if someone could edit moodlelib.php to add this function and post it so I can simply drop the file in to replace the old one.
In reply to Big Faced Boy

Re: The display of usernames.

by Karen Taylor -
Hi all,
Has anyone got this working? I am using 1.9.2..

Thanks
Karen