File management

Dealing with files in web-based applications is not always straightforward. While Moodle provides a user interface to perform this task, it is sometimes necessary that, as the administrator, you will have to bypass this mechanism and use other means. First though, let's look at the built-in file handling that is also the one used by students and teachers.

The Moodle file management interface

Moodle offers a basic file management interface, which lets you upload, move, delete, and rename files and directories. It is also possible to copy or link to files from third-party services such as Dropbox; on the same token, Moodle isn't a content management system.

We already talked about how Moodle stores files at system level—the ones we are not to touch! At application level, it arranges files according to Moodle's structure.

Note

In Moodle, a file is always connected to the particular bit of Moodle that uses it.

The Moodle file management interface

Files are organized in a tree-like structure, which has three types of main branches:

  • Categories, courses, activities, and resources
  • Users (private files and personal backups)
  • Front Page (Moodle's home page)

We will be dealing with all those concepts at later stages so, for now, let's just take them for granted. Courses are arranged in categories (and sub-categories) and consist of activities and resources. There are usually further subdirectories inside activities and resources.

There are multiple users on your system, each with a dedicated file area that can be accessed from anywhere in Moodle, but there is only a single Front Page. Remember, a file is always connected to the particular bit of Moodle content that uses it, which is reflected by the directory-like structure:

The Moodle file management interface

Uploading files

Uploading files usually takes place via drag and drop.

Tip

Drag and drop works in Firefox 25+, Chrome 30+, Safari 6+ and Internet Explorer 10+. Older versions of IE are not supported.

Adding single or multiple files via drag and drop is straightforward. Simply select the files in your Explorer (Windows) or Finder (Mac) and drag them onto the provided area inside the dotted lines:

Uploading files
Uploading files

When you click on a file once it has been uploaded, you have the option to Download or Delete the file. If multiple files are allowed (as is in the preceding example), you also have the option to set the selected document as the main file. If the selected file is a compressed archive, you have the Unzip option. This file will then appear on the view page. Additionally, meta information about the file (name, author, license, icon, last modified, created, and size) is displayed.

Uploading files

For some file operations, it is necessary to use the File picker, which is a tool that is utilized whenever files have to be added to a particular object in Moodle. A user can choose from multiple file sources, known as repositories (see the screenshot in the File system repository section further down). We will be dealing with them in Chapter 8, Moodle Plugins. The File picker can be accessed using the Add… button at the top-left on the files area.

Private files

Every user has an area where personal files can be stored and managed. These are only visible to the user the private files belong to. Any item stored in this protected area can be used throughout the site, that is, across courses. Private files can be accessed via the File picker, the Private files block, or directly via Home | My profile | My private files.

Private files

The handling of files and directories is identical to any other file areas. However, you might have spotted the Link icon in the PDF file in the preceding screenshot.

To link or to copy?

By default, files in Moodle are copied. That is, when you add a file from a source (for instance, your computer or your private files), it will be copied. This means that the source and the resulting file will be logically separated. For example, if you have stored an image in your private files and you use it in three different courses, there are three logical copies. If you change the source in your private files, the three images will not be affected.

Moodle also supports linking of files. Let us stick to the same example, but this time round, the three images are linked. If the source is changed, the three files in the courses will also have changed. Beware that there are some access restrictions with linked files, for example, instructor A might not be able to make a link with instructor B's file.

When you select a file from a source (repository) that supports linking, a Create an alias/shortcut to the file option is provided:

To link or to copy?

Moodle keeps track of linked files and guarantees that inconsistencies cannot occur:

  • When deleting a linked file, copies of the file will be created for each link
  • When a linked file is overwritten, all the links are updated
  • When a link is overwritten by a file, the files are separated

File types

Moodle itself does not restrict which types of files can be uploaded by users, for instance, an assignment in a course. For most popular file types, Moodle comes with predefined values in terms of the icon that is displayed as well as the program that will be opened, for example, PDF files or PowerPoint documents. However, you have the ability to add new file types and view, modify, and delete the existing file types by navigating to Site administration | Server | File types.

File types

When you add a new file type via the button at the bottom of the screen, you will need to provide the file Extension and its MIME type. Furthermore, you have the option to select a File icon, type groups (such as image or document), a description type, custom description (if description type is Custom description specified in this form), Alternative language string (if selected in description type), and Default icon for MIME type.

The upload limit

Your site has a file upload limit, which is set to 2 MB, by default. If you need to support files larger than the 2 MB threshold, you will have to increase the limit as follows:

  • In your php.ini file, modify the following two lines; <value> represents the maximum limit (multiple input formats are supported, for example, 20M or 20971520):
    upload_max_filesize = <value>
    post_max_size = <value>
  • If you don't have access to the php.ini file, create a .htaccess file in your main Moodle directory and add the following two lines:
    php_value upload_max_filesize = <value>
    php_value post_max_size = <value>

On some systems, you will also have to increase the LimitRequestBody parameter, which is usually found in the Apache configuration file, httpd.conf. You may also need to modify your database configuration, such as the max_allowed_packet size.

Once these changes have been applied, make sure Maximum upload file size in Security | Site policies is set to Site upload limit. Underneath this parameter, you can also change User quota for private files. When changing these two values, bear in mind that they potentially will have an impact on bandwidth and disk space, respectively.

Alternatively, you can use other file management operations, which we will cover next.

Web host file management

Most web hosts offer a web interface that provides a file management facility, for example, cPanel and Plesk. Unless your browser does not support drag and drop or you need to bypass the set upload limit, there is usually no need to use such a facility.

It has to be stressed again that you should only modify files in dirroot, for instance, to install third-party add-ons. Unless you know SHA1, do not change any files in moodledata. If you do, Moodle will not function correctly afterward.

For very large files, such as high-quality learning resources, it would be useful to be able to upload the content via (secure) FTP and then use the built-in unzip functionality in the File picker. However, it is not possible to upload files directly via FTP. Instead, you have to make use of the file system repository, which is discussed in the following section.

File management via the file system repository

The objective is to make the files appear in the File picker in a separate section; Moodle calls them repositories. To achieve this, we have to go to Plugins | Repositories | Manage repositories. Activate the File system plugin via Enabled and visible. Click on Settings and check the first box to allow access from courses before saving the settings (to grant access from users' personal files as well, check the second box).

File management via the file system repository

You might have spotted the repository directory when we looked at the data locations in the Moodle layer earlier. Any subdirectories in dataroot/repository can be read from within Moodle. First, create a subdirectory in that folder and copy or transfer (using FTP) some data into it.

Now go to a course where you wish to allow access to the folder, select the Repositories link in the Course administration section, and click on Create "File system" instance. Give the new repository a name and select a folder in case you have created more than one (we have created two). To support relative files (see the preceding screenshot), select the last option on the screen:

File management via the file system repository

From now on, any user with access to the File picker in that particular course has read-only access to the material. How cool is that! You can also grant access to directories at user level. Go to a user's profile settings where you will see the same Repositories link as in courses:

File management via the file system repository

We will be dealing with repositories in more detail in Chapter 8, Moodle Plugins, and have only focused on the files-related ones for now. For more detail on the file system repository, visit docs.moodle.org/en/File_system_repository_configuration.

..................Content has been hidden....................

You can't read the all page of ebook, please click here login for view all page.
Reset
18.220.124.177