|
|
|
Just a quick comment on this request.
Unless I'm missing something obvious (highly likely as I've only had a quick think about this) to see a student's username a teacher would need to log in as a student (for each student) to find their username. So would the ability to be able to sort by username be useful in practice? We use the students school id as their username and have some lists that come sorted by it. It is admittedly not as important as being able to sort by lastname then firstname (which currently can be done if you switch the fullname to be surname+firstname; however, in practice most folks (at least here in the U.S.) prefer firstname+lastname) for display purposes but lastname, firstname for sorting purposes. I think having the ability to choose is the key point of this request. Whether or not username is part of that is not as important - it was just another option that I thought might be useful to some.
This fix does not seem to work with 1.7.1.
I have commented out the equivalent line ie ( // $nonmembers[$contextuser->id] = fullname($contextuser, true);) and altered the suggested code to match the changes: $nonmembers[$contextuser->id] = $contextuser->firstname.', '.$contextuser->lastname; Doing this I can alter the order of the display but it STILL sorts by lastname ... (ps I want to sort by firstname) Any idea what I am missing? Thanks Matt - I took a quick look at the 1.7 /course/groups.php code and I did not see the previous natcasesort($nonmembers); line that was in 1.6 around 211. I added this in to sort the list after we populate it and I think it will give you the desired functionality that you are looking for.
if ($contextusers = get_role_users($roleid, $context)) { foreach ($contextusers as $contextuser) { # $nonmembers[$contextuser->id] = fullname($contextuser, true); $nonmembers[$contextuser->id] = $contextuser->firstname.', '.$contextuser->lastname; } } natcasesort($nonmembers); unset($contextusers); Matt - in order to avoid having non-related material on the tracker issue which IMHO only creates unnecessary reading for the developers - let's keep these types of inquires in the forums. Thanks - Anthony
Matt - not a problem, I just know how swamped the developers are and was being a little protective. As 1.8 gets ready for release I am hoping that this bug might get some attention.
I am a little confused about how this is being implemented in 1.8. If I use the link for groups on the course page I am now taken to /group/index.php; however /course/groups.php still exists (without an obvious link to it) and without any interface for groupings. There seems to be an inconsistency here and perhaps the priority of this bug should be raised so that this question about groupings and groups and how the UI is going to be handled in 1.8 can be worked out.
See discussion at http://moodle.org/mod/forum/discuss.php?d=66210
To change the order of the list of members in the group members box I changed line 63 of /group/lib/utillib.php
from: $fullname = fullname($user, true); to: $fullname = $user->lastname.', '.$user->firstname; this is significantly simpler in 1.8 which makes make think that giving the user a choice would be fairly easy if {some condition like $sortbyfullname=true} then $fullname = fullname($user, true); else $fullname = $user->lastname.', '.$user->firstname; I'm sure there are 100 better ways to implement this but it should be fairly simple and I could see it giving greater flexibility in terms of how names are sorted and shown. Related issue filed here:
http://tracker.moodle.org/browse/MDL-7591 I have made the code change to make users list by lastname, firstname and was suprised this option was not in version 1.8. I actually like groups less now than in 1.7. 1.7 interface was simple and let you know how many groups a person was in (ie if you already had him.)
I actually think in would be useful to be able to only list users not already in a group so as you add members the list keeps getting smaller to wade through. We are now using Moodle as our K-12 online gradebook and our "Groups" are being used as our course sections, so students are only members of a single group for a particular course. I has hoped to drop the 1.7 code in 1.8 but the structure changed enough that it wasn't possible. Brian - Keep in mind that the group list used to get smaller as members were added to a group; however, that assumed that members were only in one group. Now members can be in multiple groups. While it may be a little more complex and/or time consuming to set them up the goal is ultimately to make the use of groups more flexible for teachers. Peace - Anthony
|
|||||||||||||||||||||||||||||||||||||||||||||||||||
natcasesort($nonmembers);
I can produce the desired behavior by modifying /course/groups.php file
If I comment out line 174 (the original)
// $nonmembers[$student->id] = fullname($student, true);
and insert a modified version of the line:
$nonmembers[$student->id] = $student->lastname.', '.$student->firstname;
I am able to get the behavior that I want. Similarly, if someone want to sort by username they could instead use:
$nonmembers[$student->id] = $student->username.' ('.$student->lastname.', '.$student->firstname.')';
For consistency the same procedure should be applied to the teacher array on line 185
commenting out line 185
// $nonmembers[$teacher->id] = $prefix.fullname($teacher, true);
and replacing it with either (to sort by lastname)
$nonmembers[$teacher->id] = $prefix.$teacher->lastname.', '.$teacher->firstname;
or (to sort by username)
// $nonmembers[$teacher->id] = $prefix.$teacher->username.' ('.$teacher->lastname.', '.$teacher->firstname.')';
It is just a matter of setting up a course variable (for example, $course->groupsortby) and adding some if statements or a case statement to it and then modifying the course edit.php file to include a dropdown box with the options for fullname, lastname, firstname or username.