Display Username instead of "First name / Surname"

Display Username instead of "First name / Surname"

Yaoting Ke -
Atsakymų skaičius: 15
I asked this question in May and Mr Hunt advisedI should search the report.php in mod/quiz/report/overview/report.php and replace firstname and lastname with username.

I found this line at 303 - 305

$select = 'SELECT '.sql_concat('u.id', '\'#\'',$db->IfNull('qa.attempt', '0')).' AS uniqueid, '.
'qa.uniqueid as attemptuniqueid, qa.id AS attempt, u.id AS userid, u.firstname, u.lastname, u.picture, '.
'qa.sumgrades, qa.timefinish, qa.timestart, qa.timefinish - qa.timestart AS duration ';

But after I replace 'u.firstname, u.lastname' with u.username, the output became Empty.

Can anyone help? I needed the username because it cannot be changed (student id)

Priedas screenshot.png
Įvertinimų vidurkis: -
Atsakymas į Yaoting Ke

Re: Display Username instead of "First name / Surname"

Tim Hunt -
Core developers paveikslėlis Documentation writers paveikslėlis Particularly helpful Moodlers paveikslėlis Peer reviewers paveikslėlis Plugin developers paveikslėlis
That's close. What you actually neeed to do is add u.username after u.firstname and u.lastname.

Then, lower down, replace fullname($attempt) with $attempt->username. You need to do this in three places.
Atsakymas į Tim Hunt

Re: Display Username instead of "First name / Surname"

Yaoting Ke -
Thank you Mr Hunt, it is working perfectly besišypsantis.
Atsakymas į Tim Hunt

Re: Display Username instead of "First name / Surname"

jeremy kerr -
This didn't work for me ..

is there a refresh time that might cause a delay on the server?

i logged out and back in, but i didn't see any change ..

btw, are we talking about the display when you go to:

Home -> Users -> Accounts -> Browse List of New Users

?

If so, I would really like to see user name there, instead of first/last ..

any ideas?

moodle 1.8.2

thanks!

-jeremy
Atsakymas į jeremy kerr

תשובה ל: Re: Display Username instead of "First name / Surname"

Miki Alliel -
Translators paveikslėlis

Hello

I do need to ask about this topic something although it is still similar but I need an answer:

 I was surprised that there is no way to set any or other column in the results table in a quiz. We see there are only Private name, Family Name and other quiz data but we do need for example idnumber otherwise how can you distinguish between two users with the same name and family name. it's really weird.

So in this topic there was an explanation to replace a exist column with another but we need to add a new column the idnumber (of astudent) to the quiz results table. when we will see it, it will help us to export to xls file.and we can work with this file with other  applications that we have for example the grading applications of our collage and so on..

hope there is a code explanation where and how to do it.

really appreciate that.

thanks

Atsakymas į Tim Hunt

Re: Display Username instead of "First name / Surname"

Anandkumar Subramani -

I am using "MoodleWindowsInstaller-latest-19"

I need help in configuring Quiz-->Results-->Overview

I need to display "username" instead of "Firstname / Surname" and while i download in csv format that too must contain "Username" in addition to "Firstname / Surname. Please help me,,,

Atsakymas į Anandkumar Subramani

Re: Display Username instead of "First name / Surname"

Tim Hunt -
Core developers paveikslėlis Documentation writers paveikslėlis Particularly helpful Moodlers paveikslėlis Peer reviewers paveikslėlis Plugin developers paveikslėlis

There is no easy way to do that. Basically you have to customise the code, but that is a relatively easy customisation to make.

You need to change three places:

  1. The database query that loads the data to be displayed. Include the username field.
  2. The place where the table columns are set up. Change the fullname column to username.
  3. Where the contents of that column are printed.

All this is in mod/quiz/report/overview/report.php.

Atsakymas į Tim Hunt

Re: Display Username instead of "First name / Surname"

Daniel Tan -

Hi Tim,

I am new to php. I think there are 8 instances of fullname in report.php. IF I were to replace them with username. Will it worked?

Atsakymas į Daniel Tan

Re: Display Username instead of "First name / Surname"

Tim Hunt -
Core developers paveikslėlis Documentation writers paveikslėlis Particularly helpful Moodlers paveikslėlis Peer reviewers paveikslėlis Plugin developers paveikslėlis

You say you are new to PHP, but are you completely new to any sort of programming, or have you programmed in other languages before? If you have done other languages, you should be able to make some sense of what the Moodle PHP code is doing.

Sorry, it is a bit harder than that (but not very much). Also search for 'firstname' and 'lastname'. But then I think you actually need to spend some time reading the code and working out what it does, rather than just doing a simple search-and-replace.

Actually, fullname is not the easiest column to use as a starting point, because the fullname that is displayed is build up from the two bits firstname and lastname. With a username column, you don't have that complexity.

Atsakymas į Tim Hunt

Re: Display Username instead of "First name / Surname"

Anandkumar Subramani -

Can you hep me with that modiefied report.php file

Atsakymas į Anandkumar Subramani

Re: Display Username instead of "First name / Surname"

RJ Kunde -

Hello,

Maybe one of you can help me with this.  I am experiencing the same results as Jeremy Kerr.  I made the changes to the report.php file located at

moodle/mod/quiz/report/overview

 

My question is this:  When I go to the "Grades" section of a given course, it displays firstname/surname.

We have thousands of students and need all reports, grades etc to just have the unique identifier of userid.

Please assist?

 

Atsakymas į RJ Kunde

Re: Display Username instead of "First name / Surname"

Sriprasad TG -

Such a great LMS Moodle is! Why no one has given any plugin to extend Username, City, Institution..& so on in Quiz report.

I have so many people with same first name & last name..it's a mess!

I'm just stuck here, is there a way out? Can any one tell me is there any plugin/ download to extend this feature in Moodle 1.9?

Atsakymas į RJ Kunde

Re: Display Username instead of "First name / Surname"

Sriprasad TG -

I resolved relatively acceptable way. My purpose is met.

I have 6 vendors, and I had to publish quiz report by vendors..I had challenge with the report, as there were over 80 people had same first name & last name, not unique.

What I did, is, using Bulk upload user, I updated uses data..in this way:

1. I merged Firstname & Surname into Firstname itself.

2. The I copied Username as Surname, so for all my users Surname is Username itsel.

3. Now in my report, I can see employee full name & username (Username is anyways unique)

4. Once, I export quiz report, I use VLOOKUP in excel to get rest of details of the Username.

5. Publish report by Vendors, Language, Institution, designation...now made possible.

Cheers

Atsakymas į Sriprasad TG

Re: Display Username instead of "First name / Surname"

Tim Hunt -
Core developers paveikslėlis Documentation writers paveikslėlis Particularly helpful Moodlers paveikslėlis Peer reviewers paveikslėlis Plugin developers paveikslėlis

Well done for solving that challange.

Another (similar) way you could do it would be to copy the username to the idnumber field in the user profile. Then turn on the Site administration > Grades > Report settings > Grader report > Show user ID numbers admin setting (which also affects the quiz reports). That would avoid altering the firstname/lastname.

You may also wish to vote for this feature request: MDL-26647

Atsakymas į Sriprasad TG

Re: Display Username instead of "First name / Surname"

Anthony Borrow -
Core developers paveikslėlis Plugin developers paveikslėlis Testers paveikslėlis

Just a quick note that some would consider displaying the username to be a potential security vulnerability since that provides half of what is needed to authenticate as a user. I can appreciate in practice how using the username could be useful especially for administrators. I would recommend using some type of user id number that is different from the username. That said, most user names are predictable so the practical advantage of keeping it secret is somewhat mitigated but it is worth keeping in mind. Peace - Anthony