How can I get the user name???

How can I get the user name???

per wendy solorzano,
Number of replies: 2

excuse me if I made a mistake, but i know a little english. but i will try

I try to do a report to print in the screem after the quiz, I need print user's name, quiz's date, user's grade, i try to modify the moodle's code in quiz module, but i can't to print the user name, i only can print the user Id , can someone help me and tell me what code i must use.

the code I use is:

 echo get_string("nombre") . ': <strong>' .  $USER->id . '</strong><br />';

how can I get the user name , if i have the id user ??

Average of ratings: -
In reply to wendy solorzano

Re: How can I get the user name???

per Tariq Adel Al Ammadi,
$USER->firstname and $USER->lastname; also, you can use fullname($USER, true), see below for the definition.
* @uses $CFG
* @uses $SESSION
* @param object $user A {@link $USER} object to get full name of
* @param bool $override If true then the name will be first name
* followed by last name rather than adhering to fullnamedisplay setting.
*/
function fullname($user, $override=false) {
... 
Put var_dump($USER) in your code to see exactly what is going on inside $USER.
In reply to Tariq Adel Al Ammadi

Re: How can I get the user name???

per wendy solorzano,
thaks  for answer me, i taste this, I will write you  and tell you what happend with this.