Add field of username or idnumber while taking attendance

Re: Add field of username or idnumber while taking attendance

by Amr Elmawardy -
Number of replies: 2

I was able to add "$user - > username" to the attendance table through this process :

- in renderer.php (moodle\mod\attendance\renderer.php) :

1- at line  approx 645:
change : return $fullnamehead;
to : return ' Username / '.$fullnamehead;

2-at line approx 950:
change : $row->cells[] = $this->user_picture($user);
to : $row->cells[] = '<p style="float:left;margin-top:10%;">'.$user->username.'&nbsp;</p>'.$this->user_picture($user);


3-at line approx 547:
add : $fullname = $user->username.' '.$fullname;
under : $fullname = $this->user_picture($user).$fullname;


this should add the column username in the session table & the report table.
tested on moodle v3.1.

hope it helps smile

In reply to Amr Elmawardy

Re: Add field of username or idnumber while taking attendance

by Hari Vege -

Thank you Amr Elmawardy. It really worked for me.

In reply to Amr Elmawardy

Re: Add field of username or idnumber while taking attendance

by Hari Vege -

Dear Mr. Elmawardy,


I just updated the renderer.php file with the code you provided. I get the attendance list with usernames which is exactly what I wanted. Thank you once again for the details.


I have a query based on this. I wish to sort the list of students based on the username which is not available with the code you mentioned. May I request you to guide me in this process. This will be truly very helpful for us if we can sort the list of students based on their username while marking attendance.


Kind Regards,

Hari Vege