Moodle
  1. Moodle
  2. MDL-7163

Allow sorting of people in course by lastname, firstname when assigning groups

    Details

    • Type: Improvement Improvement
    • Status: Open
    • Priority: Critical Critical
    • Resolution: Unresolved
    • Affects Version/s: 1.6.3, 1.9.5, 2.1
    • Fix Version/s: STABLE backlog
    • Component/s: Course
    • Labels:
    • Environment:
      n/a
    • URL:
      /course/groups.php
    • Affected Branches:
      MOODLE_16_STABLE, MOODLE_19_STABLE, MOODLE_21_STABLE
    • Rank:
      1041

      Description

      Currently sorting of students (people in course) is by fullname which I find somewhat awkward as most users prefer to see firstname + lastname; however, most lists from the school (such as school rosters) are sorted by lastname. While it makes sense to me to sort by lastname, I think ideally it is best to give the users (i.e. teachers) the option to sort either by lastname, firstname, or username. This could be implemented either at the site or course level (my preference would be the course level so that each teacher can control how the names are sorted; however, AT Wyatt suggested the site level. As I envision it, the field could be added in with the group mode dropdown boxes in /course/edit.php as group members sorted by: with options of - Firstname, Lastname, Username.

      I am requesting this because adding group members to the sections was a tedious process for me and my teachers because the list we had been given from the school was the student's official firstname; however, when I had pulled in the enrollment data I used the student's preferred name which means that what was on the teacher's roster as William Jones was in the group listing of people in course as Billy Jones. It was difficult to find Jones and required visually scanning the whole list. Hence, it would have been really helpful to be able to sort by lastname.

      Thanks for your consideration of this improvement and let me know if there is anything I can do to support its introduction into Moodle.

      Peace - Anthony

      1. MDL-7163.patch
        2 kB
        Anthony Borrow
      2. MDL-7163.patch
        2 kB
        Anthony Borrow
      3. MDL-7163.patch
        1 kB
        Anthony Borrow
      4. MDL-7163.patch
        1 kB
        Anthony Borrow
      1. groupselect.jpg
        19 kB

        Activity

        Hide
        Anthony Borrow added a comment -

        I looked at the code in course/groups.php (revision 1.24) earlier and at least in 1.6.3 the sort is performed on line 211 with:

        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.

        Show
        Anthony Borrow added a comment - I looked at the code in course/groups.php (revision 1.24) earlier and at least in 1.6.3 the sort is performed on line 211 with: 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.
        Hide
        Ray Lawrence added a comment -

        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?

        Show
        Ray Lawrence added a comment - 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?
        Hide
        Anthony Borrow added a comment -

        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.

        Show
        Anthony Borrow added a comment - 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.
        Hide
        Ray Lawrence added a comment -

        Agreed. Best wishes with this request.

        Show
        Ray Lawrence added a comment - Agreed. Best wishes with this request.
        Hide
        Matt Tate added a comment -

        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

        Show
        Matt Tate added a comment - 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
        Hide
        Anthony Borrow added a comment -

        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);

        Show
        Anthony Borrow added a comment - 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);
        Hide
        Matt Tate added a comment -

        Thank you - works spot on.

        I have now got an easy way for teachers to add pupils to their groups.

        Thanks

        Matt

        Show
        Matt Tate added a comment - Thank you - works spot on. I have now got an easy way for teachers to add pupils to their groups. Thanks Matt
        Hide
        Matt Tate added a comment -

        This is slightly off topic. I want to achieve the same thing in /admin/roles/assign.php but the format seems very different...

        -wish i knew more about PHP

        Show
        Matt Tate added a comment - This is slightly off topic. I want to achieve the same thing in /admin/roles/assign.php but the format seems very different... -wish i knew more about PHP
        Hide
        Anthony Borrow added a comment -

        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

        Show
        Anthony Borrow added a comment - 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
        Hide
        Matt Tate added a comment -

        Apologies - thought it was worth thinking about in terms of the additional functionality of sorting by firstname/surname etc in other parts of moodle.

        Show
        Matt Tate added a comment - Apologies - thought it was worth thinking about in terms of the additional functionality of sorting by firstname/surname etc in other parts of moodle.
        Hide
        Anthony Borrow added a comment -

        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.

        Show
        Anthony Borrow added a comment - 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.
        Hide
        Anthony Borrow added a comment -

        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.

        Show
        Anthony Borrow added a comment - 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.
        Hide
        Anthony Borrow added a comment -
        Show
        Anthony Borrow added a comment - See discussion at http://moodle.org/mod/forum/discuss.php?d=66210
        Hide
        Anthony Borrow added a comment -

        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.

        Show
        Anthony Borrow added a comment - 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.
        Hide
        A. T. Wyatt added a comment -
        Show
        A. T. Wyatt added a comment - Related issue filed here: http://tracker.moodle.org/browse/MDL-7591
        Hide
        Brian Pool added a comment -

        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.

        Show
        Brian Pool added a comment - 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.
        Hide
        Anthony Borrow added a comment -

        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

        Show
        Anthony Borrow added a comment - 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
        Hide
        Kenneth Newquist added a comment -

        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:
        ---------------------------
        How can I change the sort order of the participants?
        The admin can change the "fullnamedisplay" which will affect the sort order of participants.
        Have your admin go to:
        Administration >> Configuration >> Variables
        Then under "User," see "fullnamedisplay."
        (Tested using Moodle 1.6.3.)
        ---------------------------

        Tracker #734 also references this variable, and closes the ticket:
        http://tracker.moodle.org/browse/MDL-734

        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.

        Show
        Kenneth Newquist added a comment - 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: --------------------------- How can I change the sort order of the participants? The admin can change the "fullnamedisplay" which will affect the sort order of participants. Have your admin go to: Administration >> Configuration >> Variables Then under "User," see "fullnamedisplay." (Tested using Moodle 1.6.3.) --------------------------- Tracker #734 also references this variable, and closes the ticket: http://tracker.moodle.org/browse/MDL-734 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.
        Hide
        Anthony Borrow added a comment -

        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

        Show
        Anthony Borrow added a comment - 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
        Hide
        Anthony Borrow added a comment -

        self bump

        Show
        Anthony Borrow added a comment - self bump
        Hide
        Kenneth Newquist added a comment -

        That did the trick for me. Thanks (and sorry about not closing the loop back in December).

        Show
        Kenneth Newquist added a comment - That did the trick for me. Thanks (and sorry about not closing the loop back in December).
        Hide
        Anthony Borrow added a comment -

        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

        Show
        Anthony Borrow added a comment - 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
        Hide
        Wen Hao Chuang added a comment - - edited

        Seems like this sorting issue is still happening in the latest 1.9.5+ codes (as of 10/16/2009)?

        Show
        Wen Hao Chuang added a comment - - edited Seems like this sorting issue is still happening in the latest 1.9.5+ codes (as of 10/16/2009)?
        Hide
        Anthony Borrow added a comment -

        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

        Show
        Anthony Borrow added a comment - 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
        Hide
        Anthony Borrow added a comment -

        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

        Show
        Anthony Borrow added a comment - 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
        Hide
        Anthony Borrow added a comment -

        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

        Show
        Anthony Borrow added a comment - 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
        Hide
        Martin Dougiamas added a comment -

        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!

        Show
        Martin Dougiamas added a comment - 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!
        Hide
        Anthony Borrow added a comment -

        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:
        firstname lastname
        lastname firstname
        firstname
        language

        The fullnamedisplay language string should be either:
        firstname lastname
        lastname firstname
        firstname

        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

        Show
        Anthony Borrow added a comment - 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: firstname lastname lastname firstname firstname language The fullnamedisplay language string should be either: firstname lastname lastname firstname firstname 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
        Hide
        Anthony Borrow added a comment -

        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

        Show
        Anthony Borrow added a comment - 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
        Hide
        Martin Dougiamas added a comment - - edited

        Busy! The last thing was just for this case: If $sort starts out empty and $CFG->fullnamedisplay is empty then $sort needs to get a value.

        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.
        b) Does it make sense to everyone to always sort by the first word first? (Just asking)

        Show
        Martin Dougiamas added a comment - - edited Busy! The last thing was just for this case: If $sort starts out empty and $CFG->fullnamedisplay is empty then $sort needs to get a value. 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. b) Does it make sense to everyone to always sort by the first word first? (Just asking)
        Hide
        Anthony Borrow added a comment -

        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) which I assume is what folks expect to happen. That said, I do not like to see the behavior changed in a stable release. What we may want to do is simply leave the patch here for those who want it for 1.9, apply the patch to HEAD, and update Moodle Docs such that for 1.9 there is a reference to the patch and an explanation about the change of (improved) behavior in 2.0.

        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

        Show
        Anthony Borrow added a comment - 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 ) which I assume is what folks expect to happen. That said, I do not like to see the behavior changed in a stable release. What we may want to do is simply leave the patch here for those who want it for 1.9, apply the patch to HEAD, and update Moodle Docs such that for 1.9 there is a reference to the patch and an explanation about the change of (improved) behavior in 2.0. 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
        Hide
        Michael Skwara added a comment -

        The option for this type of sorting behavior would be terrific!

        I'm having a little trouble following the discussion- Would this patch allow lastname, firstname sorting on sitewide, or just the groups module? That behavior would be great to have all over, especially in the asignment module during grading, so faculty who have class lists in that format can easily assign grades to thier students in order. If this is just groups module specific, I'll open up a second ticket for the assignmnet module.

        Thanks,

        Michael

        Show
        Michael Skwara added a comment - The option for this type of sorting behavior would be terrific! I'm having a little trouble following the discussion- Would this patch allow lastname, firstname sorting on sitewide, or just the groups module? That behavior would be great to have all over, especially in the asignment module during grading, so faculty who have class lists in that format can easily assign grades to thier students in order. If this is just groups module specific, I'll open up a second ticket for the assignmnet module. Thanks, Michael
        Hide
        Anthony Borrow added a comment -

        Michael - This issue is focused on setting up groups. It's been too long since I've looked at this, but Martin raises a good question about always sorting on the first word. Go ahead and check if a ticket exists for assignment but it is good to have separate tickets for separate issues. Peace - Anthony

        Show
        Anthony Borrow added a comment - Michael - This issue is focused on setting up groups. It's been too long since I've looked at this, but Martin raises a good question about always sorting on the first word. Go ahead and check if a ticket exists for assignment but it is good to have separate tickets for separate issues. Peace - Anthony
        Hide
        Anthony Borrow added a comment -

        Since the username is considered more private, I am removing that from the description of this issue. The patch focuses on only lastname/firstname. Peace - Anthony

        Show
        Anthony Borrow added a comment - Since the username is considered more private, I am removing that from the description of this issue. The patch focuses on only lastname/firstname. Peace - Anthony
        Hide
        Ray Lawrence added a comment -

        Absolutely! Usernames shouldn't be exposed apart from in the profile and appropriate system user management tools.

        Also, if one thinks about it. I don't know another user's username. How would this search option have been useful for me?

        Show
        Ray Lawrence added a comment - Absolutely! Usernames shouldn't be exposed apart from in the profile and appropriate system user management tools. Also, if one thinks about it. I don't know another user's username. How would this search option have been useful for me?
        Hide
        Tim Hunt added a comment -

        I think this has been done in Moodle 2.0+. Can anyone verify and then close this issue?

        Show
        Tim Hunt added a comment - I think this has been done in Moodle 2.0+. Can anyone verify and then close this issue?
        Hide
        Anthony Borrow added a comment -

        Tim - I looked at 2.2 (http://qa.moodle.net/group/index.php?id=8) and it seems like there is no functionality to sort users although they can be searched for. If I recall, it allowed the search to be AJAXy so that it would not require a page refresh to load the users. Perhaps we could use search options to add an optional search ordering but I suspect that it is using the default based on how the full name is (lastname, firstname or firstname lastname). Peace - Anthony

        Show
        Anthony Borrow added a comment - Tim - I looked at 2.2 ( http://qa.moodle.net/group/index.php?id=8 ) and it seems like there is no functionality to sort users although they can be searched for. If I recall, it allowed the search to be AJAXy so that it would not require a page refresh to load the users. Perhaps we could use search options to add an optional search ordering but I suspect that it is using the default based on how the full name is (lastname, firstname or firstname lastname). Peace - Anthony
        Hide
        Anthony Borrow added a comment -

        Here's a screenshot of the group select from within a course. Perhaps we could use the search options to provide an option for searching. Peace - Anthony

        Show
        Anthony Borrow added a comment - Here's a screenshot of the group select from within a course. Perhaps we could use the search options to provide an option for searching. Peace - Anthony
        Hide
        Michael de Raadt added a comment -

        Bumping this issue.

        Show
        Michael de Raadt added a comment - Bumping this issue.

          People

          • Votes:
            33 Vote for this issue
            Watchers:
            13 Start watching this issue

            Dates

            • Created:
              Updated: