Moodle
  1. Moodle
  2. MDL-34748

Filesystem repository does not sort filenames in file picker

    Details

    • Testing Instructions:
      Hide

      1. Enable and configure FileSystem repository, add several files (both images and non-images) and create several directories there.
      2. Create a folder resource
      3. Open filepicker to add files to filearea, select filesystem repository and make sure files are sorted alphabetically by default
      4. Open filepicker to insert image in the description textarea and make sure that only images and directories are displayed and they are sorted by name as well

      extra testing possible : language variation, adding numbers to file names

      Show
      1. Enable and configure FileSystem repository, add several files (both images and non-images) and create several directories there. 2. Create a folder resource 3. Open filepicker to add files to filearea, select filesystem repository and make sure files are sorted alphabetically by default 4. Open filepicker to insert image in the description textarea and make sure that only images and directories are displayed and they are sorted by name as well extra testing possible : language variation, adding numbers to file names
    • Affected Branches:
      MOODLE_22_STABLE, MOODLE_23_STABLE, MOODLE_24_STABLE
    • Fixed Branches:
      MOODLE_22_STABLE, MOODLE_23_STABLE
    • Pull Master Branch:
      wip-MDL-34748-master

      Description

      Whether viewing as icons or a list, the files in a filesystem repository appear in what seems to be a random order when listed in the File Picker. This would be much more useful if the entries were alphabetized.

        Gliffy Diagrams

        1. MDL-43748.patch
          0.9 kB
          Brad
        2. MDL-43748-01.patch
          1 kB
          Brad

          Activity

          Hide
          Brad added a comment -

          Patch that fixes the problem (alphabetizes by title) in 2.2.1

          Show
          Brad added a comment - Patch that fixes the problem (alphabetizes by title) in 2.2.1
          Hide
          Marina Glancy added a comment -

          hi Brad,
          Thanks for mentioning it and submitting a patch.

          Can you make a small change to the patch please so that function sort_by_title is inside the class and we don't declare a global function in the plugin.
          See example 3 in http://au2.php.net/manual/en/function.usort.php

          Marina

          Show
          Marina Glancy added a comment - hi Brad, Thanks for mentioning it and submitting a patch. Can you make a small change to the patch please so that function sort_by_title is inside the class and we don't declare a global function in the plugin. See example 3 in http://au2.php.net/manual/en/function.usort.php Marina
          Hide
          Brad added a comment -

          Updated patch per Marina Glancy's request (thanks for the quick response!)

          Show
          Brad added a comment - Updated patch per Marina Glancy's request (thanks for the quick response!)
          Hide
          Marina Glancy added a comment - - edited

          that's great. Thanks. I changed it a little so that subfolders are listed first.

          Show
          Marina Glancy added a comment - - edited that's great. Thanks. I changed it a little so that subfolders are listed first.
          Hide
          Eloy Lafuente (stronk7) added a comment -

          The main moodle.git repository has just been updated with latest weekly modifications. You may wish to rebase your PULL branches to simplify history and avoid any possible merge conflicts. This would also make integrator's life easier next week.

          TIA and ciao

          Show
          Eloy Lafuente (stronk7) added a comment - The main moodle.git repository has just been updated with latest weekly modifications. You may wish to rebase your PULL branches to simplify history and avoid any possible merge conflicts. This would also make integrator's life easier next week. TIA and ciao
          Hide
          Petr Skoda added a comment -

          strcmp() and strtolower() breaks for utf8 strings, please use our textlib library instead...

          Show
          Petr Skoda added a comment - strcmp() and strtolower() breaks for utf8 strings, please use our textlib library instead...
          Hide
          Marina Glancy added a comment -

          Hi Dan, I want to re-submit it considering Petr's comment. Can you return it to work in progress please?

          Show
          Marina Glancy added a comment - Hi Dan, I want to re-submit it considering Petr's comment. Can you return it to work in progress please?
          Hide
          Aparup Banerjee added a comment -

          Hi Marina,

          perhaps (Petr means) at https://github.com/marinaglancy/moodle/compare/master...wip-MDL-34748-master#L0R142 we could do :-
          collatorlib::ksort($list['list'], collatorlib::SORT_NATURAL);

          Show
          Aparup Banerjee added a comment - Hi Marina, perhaps (Petr means) at https://github.com/marinaglancy/moodle/compare/master...wip-MDL-34748-master#L0R142 we could do :- collatorlib::ksort($list ['list'] , collatorlib::SORT_NATURAL);
          Hide
          Aparup Banerjee added a comment -

          reopening for Marina.

          Show
          Aparup Banerjee added a comment - reopening for Marina.
          Hide
          Marina Glancy added a comment -

          there is no function in textlib or collatorlib to sort an array of arrays by property or to compare strings.

          So I had to retrieve list of dirs and files first, then sort it and then fill the $list['list']

          Show
          Marina Glancy added a comment - there is no function in textlib or collatorlib to sort an array of arrays by property or to compare strings. So I had to retrieve list of dirs and files first, then sort it and then fill the $list ['list']
          Hide
          Aparup Banerjee added a comment -

          Thanks for asorting that out Marina! :-D

          that's been integrated into 22,23 and master.

          Show
          Aparup Banerjee added a comment - Thanks for asorting that out Marina! :-D that's been integrated into 22,23 and master.
          Hide
          Frédéric Massart added a comment -

          Works like a charm on 2.2, 2.3 and master! \o/

          Show
          Frédéric Massart added a comment - Works like a charm on 2.2, 2.3 and master! \o/
          Hide
          Eloy Lafuente (stronk7) added a comment -

          For the good and the bad... this is now part of Moodle and people around the world will start using it immediately, what a responsibility!

          Many thanks for your collaboration, yay!

          Closing, ciao

          Show
          Eloy Lafuente (stronk7) added a comment - For the good and the bad... this is now part of Moodle and people around the world will start using it immediately, what a responsibility! Many thanks for your collaboration, yay! Closing, ciao

            People

            • Votes:
              0 Vote for this issue
              Watchers:
              1 Start watching this issue

              Dates

              • Created:
                Updated:
                Resolved: