Use template on course creation

General plugins (Local) ::: local_course_template
Maintained by Charles Fulton, Andrew Zito
This local plugin allows site administrators to create "template" courses which will be restored into new courses on course creation.

Use template on course creation v0.3.0

Moodle 3.1, 3.2, 3.3, 3.4
Released: Friday, August 25, 2017, 8:57 PM

Moodle Course Template

Build Status

This local plugin allows site administrators to create "template" courses which will be restored into new courses on course creation. The intended use case is defining common blocks and activities for a given academic term.

This is considered BETA code; please report any issues to GitHub.


  • Moodle 3.1 (build 2016052300 or later)


Copy the course_template folder into your /local directory and visit your Admin Notification page to complete the installation.


The administrator will need to create a "template" course which contains the desired blocks and resources. This course will need a specially-named short name. By default the plugin will search for a course with the short name Template-[TERMCODE], where [TERMCODE] is the matching value for YYYYYY. For example, if a course had the termcode 201610, the module would search for a course with the short name Template-201610.

The administrator will need to define a regular expression for extracting the term code from the course idnumber. This will be used to identify which course template (if any) should be used on creation. For example, if your courses have idnumbers in the format XXXXXX.YYYYYY, where YYYYYY is the termcode, then the regular expression /[0-9]+\.([0-9]+)/ will return YYYYYY.

The plugin listens on the \core\event\course_created event and fires immediately on course creation. Once you've given a course the necessary short name you don't need to do anything further. The plugin will create a backup of the template course and import it into the new course.

You should consider overriding Moodle's default block settings in config.php: $CFG->defaultblocks_override = '';. Otherwise you will get two sets of blocks on course creation. Manually configure the blocks in the template course instead.

Sample regular expressions

The basic use case above, /[0-9]+\.([0-9]+)/, would return YYYYYY from the following idnumbers:

  • 9999.201610
  • 3781.201730

A more complicated example, /[A-Za-z0-9\.]+([0-9]{6})/, would capture the following:

  • 4422.201610
  • 7866a.201730
  • XLSB7201610


This plugin was inspired by the course enrollment/templating plugin in use at Wesleyan University. The restoration controller settings are derived from LSU's Simplified Restore block.


Charles Fulton (

Version information

Version build number
Version release name
Can be updated from
v0.1.0 (2017030300), v0.2.0 (2017050900)
Can be updated to
v3.4.0 (2018051300), v3.3.0 (2017082401), v3.4.1 (2018051301)
MD5 Sum
Supported software
Moodle 3.1, Moodle 3.2, Moodle 3.3, Moodle 3.4

Version control information

Version control system (VCS)
VCS repository URL
VCS branch
VCS tag

Default installation instructions for plugins of the type General plugins (Local)

  1. Make sure you have all the required versions.
  2. Download and unpack the module.
  3. Place the folder in the "local" subdirectory.
  4. Visit to finish the installation.