Uploaded image for project: 'Moodle'
  1. Moodle
  2. MDL-37917

Firstname AND Lastname order in user list

    • MOODLE_19_STABLE, MOODLE_21_STABLE, MOODLE_22_STABLE, MOODLE_23_STABLE, MOODLE_24_STABLE, MOODLE_30_STABLE, MOODLE_401_STABLE, MOODLE_402_STABLE, MOODLE_403_STABLE, MOODLE_404_STABLE
    • MOODLE_main_MDL-37917
    • Hide
      • Log in as admin
      • Create a course
      • Create some users with different first and last names and enrol them in the course
      • Go to the Grade report
      • Make sure they are sorted by lastname
      • Go to Site administration / Users / Accounts / User default preferences and set the "Default user sort order" option to "Order by firstname, lastname"
      • Go back to the Grade report and make sure the students are sorted by firstname AND lastname
      Show
      Log in as admin Create a course Create some users with different first and last names and enrol them in the course Go to the Grade report Make sure they are sorted by lastname Go to Site administration / Users / Accounts / User default preferences and set the "Default user sort order" option to "Order by firstname, lastname" Go back to the Grade report and make sure the students are sorted by firstname AND lastname
    • Hide

      Fails against automated checks.

      Checked MDL-37917 using repository: https://github.com/danielneis/moodle.git

      Should these errors be fixed?

      Built on: Fri Jan 31 10:05:41 PM UTC 2025

      Show
      Fails against automated checks. Checked MDL-37917 using repository: https://github.com/danielneis/moodle.git main [branch: MOODLE_main_MDL-37917 | CI Job ] Error: The MOODLE_main_ MDL-37917 branch at https://github.com/danielneis/moodle.git is very old (>60 days ago). Please rebase against current main. Should these errors be fixed? Built on: Fri Jan 31 10:05:41 PM UTC 2025

      In big Moodle sites, usually there are several users with the same firstname or lastname.
      When we click in the column header "firstname", users appears ordered by firstname, but it would be better if they appear ordered by firstname AND lastname to get a correct order for users with the same firstname.

      As the function get_users_listing() (lib/datalib.php) permits it, it is only necessary to do a small hack in admin/user.php just before the get_users_listing() call:

       
          if ($sort == "lastname") {
              $sort = "lastname, firstname";
          }
       
          if ($sort == "firstname") {
              $sort = "firstname, lastname";
          }
      

      In the same file, another small improvement could be to change the default order. Instead of:

       
              $fullnamedisplay = "$firstname / $lastname";
              if ($sort == "name") { // If sort has already been set to something else then ignore.
                  $sort = "firstname";
              }
          } else { // ($CFG->fullnamedisplay == 'language' and $fullnamelanguage == 'lastname firstname').
              $fullnamedisplay = "$lastname / $firstname";
              if ($sort == "name") { // This should give the desired sorting based on fullnamedisplay.
                  $sort = "lastname";
              }
      
      

      it would be better:

       
              $fullnamedisplay = "$firstname / $lastname";
              if ($sort == "name") { // If sort has already been set to something else then ignore.
                  $sort = "firstname, lastname";
              }
          } else { // ($CFG->fullnamedisplay == 'language' and $fullnamelanguage == 'lastname firstname').
              $fullnamedisplay = "$lastname / $firstname";
              if ($sort == "name") { // This should give the desired sorting based on fullnamedisplay.
                  $sort = "lastname, firstname";
              }
      

      Thanks.

            Votes:
            25 Vote for this issue
            Watchers:
            23 Start watching this issue

              Created:
              Updated:

                Estimated:
                Original Estimate - 0 minutes
                0m
                Remaining:
                Remaining Estimate - 0 minutes
                0m
                Logged:
                Time Spent - 1 hour, 26 minutes
                1h 26m

                  Error rendering 'clockify-timesheets-time-tracking-reports:timer-sidebar'. Please contact your Jira administrators.