How can I get the user name???

How can I get the user name???

av wendy solorzano -
Antal svar: 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 ??

Medeltalet av utvärderingarna: -
Som svar till wendy solorzano

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

av 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.
Medeltalet av utvärderingarna: -