Help me!

Help me!

by rongguang liu -
Number of replies: 7

I face the problem. There are two students who have the same name  in our class. I want to distinguish  them . I find that user table  of moodle database has ID field .It is only.So I want to add it to Participants in People block of moodle.But I don't know how to realize it. Can you help me ?Thanks a lot!

Average of ratings: -
In reply to rongguang liu

Re: Help me!

by John Isner -
I don't think using the ID is a good solution because everyone should recognize names in the Participants list. I would play with the first or last name in the profile, based on how people distinguish them verbally (for example "Tall John" and "Short John."
In reply to John Isner

回复: Re: Help me!

by rongguang liu -

At first thank you very much John.  I agree with you.

If I want to add ID field  to Participants in People block of moodle, How will I do? Can you help me?  Thanks!

In reply to rongguang liu

Re: 回复: Re: Help me!

by Anthony Borrow -
Picture of Core developers Picture of Plugin developers Picture of Testers
I did a similar hack for our production server where we use the studentid (a value we populate into the Moodle database). I would not recommend using the mdl_user id field and displaying it as such. Perhaps the username or idnumber field would work better for you (and give you more control over what data is placed in there). In any case, you will want to change the /user/index.php file and the /lib/weblib.php files. Which version of Moodle are you using? Just to give you an idea of a possible approach:replace or add to line ~464 in /user/index.php to something like (essentially adding the u.username or u.idnumber depending on which you choose to use (here I am showing using username):

$select = 'SELECT u.id, u.username, u.firstname, u.lastname, u.email, u.city, u.country, u.picture, u.lang, u.timezone, u.emailstop, u.maildisplay, s.timeaccess AS lastaccess ';

then go to weblib.php around 2815 where it starts to handle the output in the print_user function and change the line from something like:
echo '<div class="username">'.fullname($user, $isteacher).'</div>';
to:
echo '<div class="username">'.fullname($user, $isteacher).'('.$user->username.')'.'</div>';

One note of warning is that since this hack suggests you to change the weblib.php file any other places that call the print_user function will need to have whatever data you ask it to print. You may want to grep for print_user( to see where all it is used. Peace.

In reply to Anthony Borrow

回复: Re: 回复: Re: Help me!

by rongguang liu -

Anthony ,Thanks.

But  I am a teacher .I don't  understand php . So can you give me modified files which let userid  appear  at  Participants in People block of moodle?
our school  use moodle1.7 .  Language is chinese simple.

Thanks again!

In reply to rongguang liu

Re: 回复: Re: 回复: Re: Help me!

by Anthony Borrow -
Picture of Core developers Picture of Plugin developers Picture of Testers
Unfortunately, I managed to skip version 1.7 and I am not familiar with it. If you are not familiar with php, it may be safer for you to work with a consultant (i.e. a Moodle Partner) to implement the change. That way if there is a problem in other places they will be able to help you quickly resolve it. Best of luck.