Brief about course formats in Moodle
A course format is a special type of plugin in Moodle, which is responsible for the course layout – what the course page looks like (/course/view.php) in both view and editing mode, which resources and activities must be displayed, how they are styled and in which order they are arranged, in which sections they are located etc. The basic and most popular Moodle course format is the Topics format. It is the most simple and that’s why it’s best to use it as a skeleton for the creation of a new course format.
An administrator can enable, disable or delete course formats for courses in Administration> Site administration > Plugins > Course formats > Manage course formats. The course format for the particular course can be selected in Administration > Course administration > Edit settings.
Create a new course format
To create a new course format that will fit all your needs, you must go through some steps. Let’s create a new course format ‘Devlion‘ (component name format_devlion)as an example. Use your own name instead of ‘devlion‘ everywhere in the new course format.
Copy all the files from /course/format/topics to the new folder with a unique name, for example, /course/format/
Update file version.php.Set the new component name for your new course format, plugin version and required Moodle version.
$plugin->version = 2018112000; // The current plugin version (Date: YYYYMMDDXX). $plugin->requires = 2018050800; // Requires this Moodle version. $plugin->component = 'format_devlion'; // Full name of the plugin (used for diagnostics).
Rename all the language files in course/format/
Rename callbacksand functions everywhere in the new course format.
In Moodle 2.3 and below: rename callback functions in lib.php. The names of the functions are formed as callback_FORMATNAME_CALLBACKNAME()
In Moodle 2.4 and above: Rename class name in lib.php to format_FORMATNAME. (we use format_devlion in our example)
Add your own modifications to the new course format.
After modifying the code, check it with the ‘Code checker’ – local_codechecker.