Moodle – Create a new Course format, based on Topics

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.

Step 1

Copy all the files from /course/format/topics to the new folder with a unique name, for example, /course/format/devlion (course format names cannot exceed 21 characters).

Step 2

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).

Step 3

Rename all the language files in course/format/devlion/lang/ for all languages you use in Moodle. Also, change $string[‘pluginname’] in all language files course/format/devlion/lang/en/format_devlion.php to the new name.

Step 4

Rename callbacks and 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)

Search and replace other occurrences of the old format name (topics and/or format_topics), for example in renderer, capabilities names, settings, javascript libraries, etc. to the new one (devlion and/or format_devlion). Don’t forget to update the names of variables and constants, if you need.

Step 5

Add your own modifications to the new course format.

Step 6

After modifying the code, check it with the ‘Code checker’ – local_codechecker.

Additional resources

Leave a Reply

Your email address will not be published. Required fields are marked *

This site uses Akismet to reduce spam. Learn how your comment data is processed.

Moodle – יצירת קורס פורמת חדש

מבוא 

הקורס פורמט הוא סוג תוסף מיוחד במוודל שאחראי על פריסת מידע של הקורס במערכת moodle. דף הקורס (/course/view.php) יכול להיות במצב תצוגה ועריכה, קורס פורמט של moodle מציג פרקים, משאבים ופעילויות בצורה מוגדרת בהגדרות הקורס במערכת moodle. מנהל מערכת יכול להפעיל, לבטל או למחוק תבניות לקורסים. 

(more…)

Leave a Reply

Your email address will not be published. Required fields are marked *

This site uses Akismet to reduce spam. Learn how your comment data is processed.