Show username column next to Full Name column

Show username column next to Full Name column

by Brian Jones -
Number of replies: 3
I've just made a change to Moodle 1.6's /mod/assignment/lib.php 'display_submissions' function so that professors can sort the grading interface by username instead of just first name or last name. Can I request that this feature be added?

Here's my 'cvs diff' output for lib.php. Other functions in other parts of Moodle could also use this change. I'm sure I'll be making and posting them later as they are demanded by my users.

Again - this is moodle 1.6.

Index: lib.php
===================================================================
RCS file: /cvs/CSMOODLE/mod/assignment/lib.php,v
retrieving revision 1.3
diff -r1.3 lib.php
818c818
< $select = 'SELECT u.id, u.id, u.firstname, u.lastname, u.picture,'.
---
> $select = 'SELECT u.id, u.id, u.username, u.firstname, u.lastname, u.picture,'.
1011,1012c1011,1012
< $tablecolumns = array('picture', 'fullname', 'grade', 'comment', 'timemodified', 'timemarked', 'status');
< $tableheaders = array('', get_string('fullname'), get_string('grade'), get_string('comment', 'assignment'), get_string('lastmodified').' ('.$course->student.')', get_string('lastmodified').' ('.$course->teacher.')', get_string('status'));
---
> $tablecolumns = array('picture', 'fullname', 'username', 'grade', 'comment', 'timemodified', 'timemarked', 'status');
> $tableheaders = array('', get_string('fullname'), get_string('username'), get_string('grade'), get_string('comment', 'assignment'), get_string('lastmodified').' ('.$course->student.')', get_string('lastmodified').' ('.$course->teacher.')', get_string('status'));
1026a1027
> $table->column_suppress('username');
1029a1031
> $table->column_class('username', 'username');
1072c1074
< $select = 'SELECT u.id, u.id, u.firstname, u.lastname, u.picture, s.id AS submissionid, s.grade, s.comment, s.timemodified, s.timemarked, ((s.timemarked > 0) AND (s.timemarked >= s.timemodified)) AS status ';
---
> $select = 'SELECT u.id, u.id, u.username, u.firstname, u.lastname, u.picture, s.id AS submissionid, s.grade, s.comment, s.timemodified, s.timemarked, ((s.timemarked > 0) AND (s.timemarked >= s.timemodified)) AS status ';
1166c1168
< $row = array($picture, fullname($auser), $grade, $comment, $studentmodified, $teachermodified, $status);
---
> $row = array($picture, fullname($auser), $auser->username, $grade, $comment, $studentmodified, $teachermodified, $status);
Average of ratings: -
In reply to Brian Jones

Re: Show username column next to Full Name column

by Brian Jones -
PS - not sure why "u.id" is selected twice in the SELECT query above. Is that a bug?
In reply to Brian Jones

Re: Show username column next to Full Name column

by Tim Hunt -
Picture of Core developers Picture of Documentation writers Picture of Particularly helpful Moodlers Picture of Peer reviewers Picture of Plugin developers
Displaying usernames has security implications, so your changes won't be wanted in the official moodle codebase.

The double select of id is for historical reasons to do with how get_records used to work, and can be safely removed.
In reply to Tim Hunt

Re: Show username column next to Full Name column

by Brian Jones -
Well, I guess my request is more "can moodle please allow me to make choices like this for my site?". I understand the security implications, but for my site, the usernames are going to map to email names, and nobody is hiding their email address, and I'm not inclined to force them to hide their email. I *do* require a login to see a profile, though.

In reality, displaying first and last names has security implications as well. With a first and last name, one can search campus directories for more information. Eventually, with a first and last name, you'll find an email, which is quite likely a username with '@domain.edu' attached. Go find the users facebook profile, ~user home page on campus... whatever. It's not hard to get information for those that want it. You're not really protecting anything by *not* showing usernames. At best it's security by obscurity, which several commercial proprietary applications (indeed, entire operating systems) have proven is near useless.

Like I say, though, I could certainly understand that for online learning sites (ones where there *is* no campus - just an online presence), you don't want to show usernames to the other users, but on those sites you probably don't want to show other *users* to anyone *at all* in a lot of cases. Besides, in this instance, we're only talking about the grading interface, which can only ever be seen by teachers, who can see all of this stuff if they want to anyway.