|
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.
Agreed.
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) 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)) { 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: to: 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} 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
According to MoodleDocs: Group FAQ, there's supposed to be a configuration option somewhere that allows you to affect the sort order of groups:
http://docs.moodle.org/en/Groups_FAQ Quoting: Tracker #734 also references this variable, and closes the ticket: I've dug around through 1.9, and can find anything that matches what they're describing. I suspect we lost this functionality in the jump from 1.6x to 1.7x, though if it existed under 1.6x, why was this tracker ticket spawned in the first place? Can we update this ticket to be a feature request for Moodle 2.0? (or does another ticket out there duplicate this one for 2.0?) With 18 votes, it seems like a pretty popular request. Kenneth - I think what you are looking for was moved to the Site Administration block -> Security -> Site policies -> Full Name Format. Although I think that casing of the string should probably be changed to Full name format to be consistent. Let me know if that is now what you are looking for. Peace - Anthony
That did the trick for me. Thanks (and sorry about not closing the loop back in December).
Ken - Thanks for the follow up. It has been a while since I have looked at this issue. From what I was reading it sounds like this issue may be able to be closed as fixed. I would want to give it a closer look but do not have time at the moment so I figured I would try to get folks opinion about whether more needs to be done with this. Hopefully those who have voted and are watching this issue will have some thoughts. If you can you may want to raise the question in the forums. Thanks for your help in looking at this issue. Peace - Anthony
Seems like this sorting issue is still happening in the latest 1.9.5+ codes (as of 10/16/2009)?
Wen - I want to focus the intent of this particular tracker issue. It is focused on the sorting of potential group members when assigning them to a group. Currently, it is sorted by lastname only which is the behavior you are finding problematic. This can easily be fixed by changing /group/lib.php around line 398 to:
function groups_get_users_not_in_group_by_role($courseid, $groupid, $searchtext='', $sort = 'u.lastname ASC, u.firstname ASC') { I think we need to decide, and perhaps you can encourage some discussion on this as to the behavior desired for sorting. I had initially created the issue because I wanted to display the student name as firstname lastname; however, I wanted an option to sort them by lastname firstname or possibly even username. When I created the issue username was more important to me than it is now. So I think we have a number of possible areas for improvement here. 1) simply add firstname to the sort list so that we get an accurate sorting (step 1) 2) have the sort order follow whatever is set by $CFG->fullnamedisplay (keeping in mind that there are four options and that if the firstname display name is chosen that we may want to sort by firstname lastname - I have mixed feelings about how to deal with the question of firstname only and would need to explore further what happens when using the language locale order). Currently, the sort is always lastname and this should probably be flexible. 3) Even with some flexibility by using $CFG->fullnamedisplay, I think that it would be helpful to have a separte variable for a default sorting order. Perhaps something like $CFG->usersortdefault which could be set to be fullname, lastname/firstname, firstname/lastname, user id, idnumber, etc. Then names could be displayed one way and sorted another and this would be configurable by the site admin. Let me know if this plan of attack makes sense and then we can move on to role assignments and other places were the sort order is not ideal. Peace - Anthony Martin - Given the number of votes on this and the relative ease of which at least step one could be taken, it might be good to get this in 1.9.6. Just say the word and I will happily add the firstname to the sort order so that it is lastname ASC, firstname ASC Peace - Anthony
Anthony Borrow made changes - 17/Oct/09 09:43 AM
Here is a patch file that implements what I referred to as step 2 which would use the $CFG->fullnamedisplay value to determine how the names are sorted. If displayed lastname, firstname then that is how they will be sorted. Peace - Anthony
Anthony Borrow made changes - 17/Oct/09 11:21 AM
The logic looks good, however, doing it inside the function like that means that the parameter is now completely ignored.
I would set the default $sort value for the parameter to "", and then only run your new logic if empty($sort). Finally, if $CFG->fullnamedisplay was something other than (lastname firstname) or (lastname firstname) then I would explicitly set $sort = 'u.lastname ASC, u.firstname ASC' at that point. That could squeeze into 1.9.6 Cheers and thanks!
Martin Dougiamas made changes - 19/Oct/09 02:41 PM
Martin Dougiamas made changes - 19/Oct/09 02:41 PM
MD - thanks for the catch on overriding $sort. Here is a revised patch setting default $sort to '' and checking if empty before beginning.
$CFG->fullnamedisplay can have four possible (valid) values: The fullnamedisplay language string should be either: I opted to make firstname ASC, lastname ASC the default to avoid some additional checks and thus lumping firstname lastname and firstname together. Then we only need to check if it is lastname. The down side to this is that if someone were to put in a bogus string then the function will default to firstname ASC, lastname ASC but that seems relatively trivial. I was not 100% clear on your last comment about "if $CFG->fullnamedisplay was something other than" but I think we have all the cases reasonably covered. Peace - Anthony
Anthony Borrow made changes - 19/Oct/09 03:10 PM
Testing revealed that I had not paid attention to how the language string is setup:
$string['fullnamedisplay'] = '$a->firstname $a->lastname'; so here is a revised patch that follows the logic used in /admin/user.php although I will admit it seems unnecessarily complex but perhaps there was some hope the string could be used in different ways but we can save evaluating that one for another day. Peace - Anthony
Anthony Borrow made changes - 19/Oct/09 03:33 PM
Busy!
Something like: if (empty($sort)) { // Determine a default from system settings $sort = 'u.firstname ASC, u.lastname ASC'; if (!empty($CFG->fullnamedisplay) ) { if ($CFG->fullnamedisplay == 'lastname firstname') { $sort = 'u.lastname ASC, u.firstname ASC'; } else if ($CFG->fullnamedisplay == 'language') { $override = new object(); $override->firstname = 'firstname'; $override->lastname = 'lastname'; $fullnamelanguage = get_string('fullnamedisplay', '', $override); if ($fullnamelanguage == 'lastname firstname' ) { $sort = 'u.lastname ASC, u.firstname ASC'; } } } } My only slight worry is: will this make sense in 1.9.6? a) It flips the current default sort in some cases. OK Regis, this is my final answer
If $sort and $CFG->fullnamedisplay are both empty then the default is lastname firstname; however, I fear this would be a challenging state to get in as someone would have to work at this by either deleting the value in the config database or setting it to blank in config. a) It flips the current default sort in some cases. Since the default fullnamedisplay (from Security->Site policies) is 'firstname lastname' the new default behavior would be to sort by firstname lastname which represents a change in 1.9 behavior. I would still consider it an improvement because with the patch the site admin has the option to control the desired behavior. As the code is now, the list is always sorted 'lastname firstname' unless specified by the code (with $sort) and thus effectively ignores the fullnamedisplay setting. My argument for including the patch in 1.9.6 is that this is the behavior specific in the documentation (http://docs.moodle.org/en/Groups_FAQ#How_can_I_change_the_sort_order_of_the_participants.3F b) Does it make sense to everyone to always sort by the first word first? (Just asking) Good question as that is essentially what initially prompted me to create the issue. I wanted the users sorted by lastname firstname but displayed firstname lastname. This would require a second variable like fullnamesort. In the process of looking at things, I noticed the difference in what was in Moodle Docs and what was actually happening. Let me know if you want a patch (2.0 and/or 1.9) for what I described above (comment dated 17/Oct/09 09:41 AM) as the third step toward improvement. This brings us back to the first step which may want to do for 1.9.6 is simply to add 'firstname ASC' to the default $sort so that it sorts first on lastname and secondarily on firstname displaying (but not sorting) as determined by $CFG->fullnamedisplay. Peace - Anthony
Anthony Borrow made changes - 19/Oct/09 10:56 PM
Martin Dougiamas made changes - 21/Oct/09 04:17 PM
|
||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
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.