+353 (0)1 602 4784
info@enovation.ie
  • Client Support
  • FR
  • UK
EnovationEnovationEnovationEnovation
+353 (0)1 602 4784
  • WHAT WE DO
    • OUR SERVICES
      • Consultancy
      • eLearning Content
      • Build & Design
      • Training
      • Moodle Educator Certification Program (MEC)
      • Hosting
      • Support & Maintenance
    • OUR SOLUTIONS
      • Aura Talent
      • Moodle
      • Moodle Workplace
      • Totara’s Talent Experience Platform
        • Totara Learn
        • Totara Engage
        • Totara Perform
      • Mahara
      • Go1 Premium Content
  • WHO WE ARE
    • About Enovation
    • Careers
  • CASE STUDIES
  • OUR PARTNERS
    • Microsoft Teams
    • IntelliBoard
    • BigBlueButton
  • INSIGHTS
  • CONTACT US

Moodle 2.0 File Storage

    Home Blog Moodle 2.0 File Storage

    Moodle 2.0 File Storage

    Stephen McGuinness | Blog, News | 3 January, 2011

    One of the major re-engineering efforts undertaken for Moodle 2.0 was a complete redesign of the Moodle file storage system. The release of Moodle 2.0 has delivered a database centric file handling model, replacing the OS file system centric model.

    Moodle <= 1.9 file storage

    Moodle stores files in a number of circumstances: student assignment submissions and teacher course resources being two examples. How would you store them? In Moodle 1.9 a directory structure was used to identify the files, using a combination of the course, module and user ID numbers. So, in your Moodle data directory you would see a number of folders corresponding to Moodle course ID numbers, in which you would find the course files (if any) and a ‘moddata’ folder.

    The ‘moddata’ folder contains sub folders corresponding to the Moodle module types, with further sub folders corresponding to the module instance ID numbers, and yet further sub folders corresponding to the user ID numbers which contain the user uploads to that instance of that module.

    Here is an example file and folder structure for a student with ID number 123 uploading an assignment submission to an assignment instance with ID number 456, in a course with ID number 789:

     {MOODLEDATA}/789/moddata/assignment/5/123/my_midterm_assignment.doc

    Corresponding database records are stored on a per module basis (if stored at all). Assignment submission details like submission date are stored in the database table ‘assignment_submissions’. Make sense? Perhaps, but it’s not ideal. This configuration makes backup and restoration more difficult for a start.  This method also means that the same file could be stored multiple times in different parts of the Moodle data – something which is likely to happen if you copy and re-use courses from year to year.

    Moodle 2.0 file storage

    Moodle 2 centralises the storage of files within a {MOODLEDATA}/filedir directory and a single ‘files’ database table. A new files API has been created to provide higher level of control. All files are referenced by a record in a files table and accessed via the files API.

    In the background, files uploaded into Moodle 2.0 are given an SHA1 hash value, and this hash value is used as the basis for storing the file in MOODLEDATA/filedir/HASH_PATH/HASH_FILE.

    In the example {MOODLEDATA}/filedir/5c/eb/b0/5cebb03d702827bb9e25b38b06910fa5 the hashed value for the file (5cebb03d702827bb9e25b38b06910fa5) is stored in a hash path created from the first three pairs of characters in the hash value: [5c][eb][b0]3d702827bb9e25b38b06910fa5. This method of storage means the same file uploaded multiple times will only be stored once, because the hash value will be the same. Using the hash value as a basis of creating the file storage directories creates a natural distribution of the files across multiple folders. This helps reduce the possibility that any one directory will contain an excessive number of files.

    There are other benefits to this file storage method; backup & restores are simplified, and all file access is through the file storage API giving better control. Additionally, the original file names are not recorded on disk which allows for full Unicode file name support, regardless of the Unicode support in the underlying operating system file system.

    One possible downside is that you will no longer be able to look at the Moodle data directory and immediately understand and modify the files with ease, but should anyone be doing this anyway?

    Next Previous
    Files API, Moodle2

    Related Post

    • Moodle development – IDs, coursemodules and contexts

      Tomek Muras | Blog, News | 18 May, 2012

      Introduction In this blog entry, I’d like to go through some basic concepts of the Moodle architecture. We will look at very common but sometimes confusing parts of Moodle: instance IDs, contexts and coursemodules. ToRead more

    • Generate random test data in Moodle 2

      Tomek Muras | Blog, News | 17 February, 2011

      Would you like to test Moodle 2 performance? Or maybe you are interested in checking Moodle’s scalability? Sure, it works fast with the few courses you have created – but how will it look whenRead more

    • Creating simple filter in Moodle 2

      Tomek Muras | Blog, News | 8 December, 2010

      Filters in Moodle are pluggable elements that can convert an output text to some other text. This is currently used for the functionality like: replacing text based emoticons with images (emoticon filter) generating images forRead more

    • Whats new in Moodle 2.0

      Mark Melia | Blog, News | 5 December, 2010

      Moodle 2.0, the long awaited next generation of Moodle was released on the 24th of November to much aclaim. In this blog post I am going to have a quick look at some of theRead more

    • Avatar
      Francisco February 25, 2011 at 10:34 pm

      The problem with this is that makes difficult to interoperate Moodle with other applications that share the files. For example, my students were uploading files via task that were processed by third part applications

    • Avatar
      tony March 15, 2011 at 9:32 pm

      Using 1.9… After marking assignments I move examples from the moddata folder to a ‘gallery’ folder in the parent directory that links to a ‘Projects Gallery’ in the course Moodle – students cannot access the moddata folder. Will there be an easier solution for creating a ‘Projects Gallery’ in Moodle 2.0?

      • Avatar
        smcguinness April 11, 2011 at 4:27 pm

        This wouldn’t be possible with Moodle 2. You would first have to look up the database to find the hash for the assignment, find the file, then move it to a new locate and create the correct references in the database.

        I think the process you would follow in Moodle 2 would be to add a ‘Folder’ resource to the course. You then add files to that folder using the file picker interface.

        The file picker is very nice, you can browse and add course files, upload files or add files from remote services (Flickr, Google docs, Picasa).

        Unfortunately I don’t think you can browse the student assignment submissions from the file picker, so you might have to download the assignments then upload them to the folder resource at this time.

    • Avatar
      Gabriel García Aguirre May 20, 2011 at 7:48 pm

      Hello,

      When I try to upload a file via the File Picker I get this error:

      Unknown exception related to local files (Invalid file path)

      I’ve read that it may be an SSH issue so I changed port 7022 to port 22 on my server but did not work.
      The moodledata folder and the filedir folder persmissions are set to 777
      I am using Moodle 2.0.3 under a CentOS server

      I have the same version of moodle running on a windows 7 computer under the xampp server and have no problems. I understand that Linux and Windows handle files and ports in a different way.

      I have had problems adding language packs (not able to write md5 file). I manually created the language pack folder in order to sort out that problem.

      I’m pretty sure that moodle has problems trying to connect either to the database or create folders under the moodledata/filedir folder.

      If any of you know how to solve this, please send me an email.

      Thank you

      • Avatar
        smcguinness October 3, 2011 at 9:24 am

        Hello Gabriel,

        In a Unix/Linux environment the directory tree starts with / , such as /home/gabriel/www

        The error you are seeing is thrown when Moodle detects that the file path does not begin with the ‘/’ character. This path is set as a field in the Moodle ‘files’ database table; I do not think it is something that is configurable. There may be a problem with your server or Moodle configuration.

        Firstly I would advise that you update your Moodle code to the latest version. Then I would verify that the Moodle and server configurations are correct.

        There is an open issue on the Moodle bug tracker which might be relevant – it relates to Redhat also, which might be a clue: http://tracker.moodle.org/browse/MDL-27651

        Stephen

    NextPrevious

    Latest Insights

    • Now you have an LMS, What's Next?
      26 January, 2021
      Comments Off on Now you have an LMS: What Next?

      Now you have an LMS: What Next?

    • 6 January, 2021
      Comments Off on Open-source: Spend Less, Gain More.

      Open-source: Spend Less, Gain More.

    • 16 December, 2020
      Comments Off on Our 2020 Highlights-It’s been quite a year!

      Our 2020 Highlights-It’s been quite a year!

    • Enovation: Microsoft Education Partner
      26 November, 2020
      Comments Off on Microsoft Teams: Add Teams Meeting Scheduling to Your Solution

      Microsoft Teams: Add Teams Meeting Scheduling to Your Solution

    Archives

    • January 2021
    • December 2020
    • November 2020
    • October 2020
    • September 2020
    • August 2020
    • July 2020
    • June 2020
    • May 2020
    • April 2020
    • March 2020
    • February 2020
    • January 2020
    • November 2019
    • October 2019
    • September 2019
    • August 2019
    • July 2019
    • June 2019
    • May 2019
    • March 2019
    • February 2019
    • January 2019
    • December 2018
    • November 2018
    • October 2018
    • September 2018
    • August 2018
    • July 2018
    • June 2018
    • May 2018
    • April 2018
    • March 2018
    • February 2018
    • January 2018
    • December 2017
    • November 2017
    • October 2017
    • September 2017
    • August 2017
    • July 2017
    • June 2017
    • May 2017
    • April 2017
    • March 2017
    • January 2017
    • November 2016
    • October 2016
    • June 2016
    • March 2016
    • February 2016
    • January 2016
    • December 2015
    • November 2015
    • October 2015
    • September 2015
    • July 2015
    • June 2015
    • May 2015
    • March 2015
    • February 2015
    • January 2015
    • December 2014
    • November 2014
    • September 2014
    • June 2014
    • May 2014
    • January 2014
    • August 2013
    • April 2013
    • March 2013
    • February 2013
    • January 2013
    • September 2012
    • July 2012
    • May 2012
    • April 2012
    • February 2012
    • December 2011
    • November 2011
    • June 2011
    • May 2011
    • April 2011
    • March 2011
    • February 2011
    • January 2011
    • December 2010

    Sign-up to get our insights direct to your inbox

      Enovation Square

      Enovation Solutions Ltd.,
      The Friary,
      Bow Street,
      Dublin, D07 X680,
      T: +353 (0) 1 602 4784

      Partners & Certifications

      images

      Moodle Partner Logo

      Latest Insights

      • Now you have an LMS, What's Next?

        Now you have an LMS: What Next?

        As Moodle and Totara Learn Partners we can tell you that acquiring

        26 January, 2021
      • Open-source: Spend Less, Gain More.

        We are Enovation, trusted Moodle & Totara Learn partners and all ’round

        6 January, 2021
      • Our 2020 Highlights-It’s been quite a year!

        2020 is a year that we will never forget. We have adapted

        16 December, 2020

      Latest Tweets

      Tweets by @EnovationIRE
      • Legal Information
      © 2021 Enovation Your eLearning Partner
      • WHAT WE DO
        • OUR SERVICES
          • Consultancy
          • eLearning Content
          • Build & Design
          • Training
          • Moodle Educator Certification Program (MEC)
          • Hosting
          • Support & Maintenance
        • OUR SOLUTIONS
          • Aura Talent
          • Moodle
          • Moodle Workplace
          • Totara’s Talent Experience Platform
            • Totara Learn
            • Totara Engage
            • Totara Perform
          • Mahara
          • Go1 Premium Content
      • WHO WE ARE
        • About Enovation
        • Careers
      • CASE STUDIES
      • OUR PARTNERS
        • Microsoft Teams
        • IntelliBoard
        • BigBlueButton
      • INSIGHTS
      • CONTACT US
      Enovation
      +353 (0)1 602 4784