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.
Latest release:
280 sites
40 fans
Moodle 3.7, 3.8, 3.9, 3.10, 3.11

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.


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. 


Screenshot #0


Charles Fulton (Lead maintainer)
Please login to view contributors details and/or to contact them

Comments RSS

Show comments
  • Sat, Aug 1, 2020, 1:05 AM
    Hi Joanna, we've released a new vesrsion (3.6.2) that allows you to disable the caching behavior. That should clear up the problem that you're encountering.
  • Sat, Aug 8, 2020, 4:22 AM
    I believe there's a bug in the most recent version (3.6.2) of this plugin. We're on 3.8.2. I upgraded and it started running a "\local_course_template\task\cleanup_task" every second, filling up the task queue and maxing out our task runners so no other tasks could complete. I tried turning off the new caching option but the behavior persisted. The plugin would not allow me to downgrade to 3.4.1 so I had to uninstall it.
  • Sat, Aug 8, 2020, 4:54 AM
    Hi Eric, thanks for the report. That's unexpected; the task should run once at 3 AM server time. The caching behavior change shouldn't have affected that part of the plugin; we'll look into it right away.
  • Thu, Aug 13, 2020, 1:00 AM
    Hi Eric, we've identified the cause of that failure and released a new version (v3.6.3) that addreses it. Thanks again for the report.
  • Thu, Aug 13, 2020, 6:12 AM
    Glad to hear it! Thanks for your work on this plugin!
  • is it possible when a change is been made in main course, to be automatically to be added to the other courses?

  • Fri, Oct 2, 2020, 2:27 AM

    The plugin does not work with the external database course creation right??

    I actually try it, and seems only work with individual course creation and bulk csv course creation.
  • Fri, Oct 2, 2020, 2:54 AM
    I haven't tested it explicitly but it should work with external database course creation; that plugin calls create_course so the necessary events are triggered. IIRC external database has its own, separate course template functionality.
  • Fri, Oct 2, 2020, 3:02 AM
    We use external database enrollment and the plugin worked for new courses, though that was a couple versions ago now and I haven't tried with the latest. The external database template is much more limited—it gets applied to all new courses, whereas with this plugin you can use pattern matching on the idnumber to apply different templates to different courses.
  • Fri, Dec 4, 2020, 4:27 AM
    Clarification: the General restore defaults are fairly important to this plugin's functioning, correct? We had a suite of departmental templates we expected to be applied to new courses and it seemed like only content, and not course settings, were applied. It seems that we need "Restore defaults when restoring into another course deleting contents" > "Overwrite course configuration" (restore_replace_overwrite_conf) to be selected to have features like start date or course format carry over from templates.
  • Sat, Jan 16, 2021, 2:13 AM
    Do you know why the plugin is not working on moodle 3.10:
    I got the following configurations:


    Template Course

    New course based on Template
  • Tue, Apr 13, 2021, 12:19 AM
    We loaded courses for our summer term recently and while they received their templates, it seems like changes to course settings (course format, start date, etc.) weren't applied though template content (section names, activities) was. Any idea what might cause this? From my previous comment here I thought that the "restore_replace_overwrite_conf" setting had to be on but it is and the problem persists. When I manually backup and restore a template into a course I am able to overwrite course settings like start date & course format, it seems like only this plugin is unable to do so.
  • Tue, Apr 13, 2021, 6:56 AM
    So by reading the plugin's code I figured out you can have template's overwrite course configuration if you 1) select "Overwrite course configuration" (restore_replace_overwrite_conf) under "Restore defaults when restoring into another course deleting contents" and 2) lock that setting, forcing the plugin to respect it. Otherwise, it defaults to not overwriting anything in a course's settings.
  • Sat, Jun 5, 2021, 5:52 AM
    Hi Eric I do something like you do inside plugin code but I had an issue, the plugin overwrite the name and the course short name, for example the coursname change to something like "Base Course test copy 1" how do you solve that? Any idea?
  • Sat, Jun 5, 2021, 6:08 AM
    @Josue what are your settings for "Restore defaults when merging into another course"? We have "Overwrite course full name" (restore | restore_merge_course_fullname) and "Overwrite course short name" (restore | restore_merge_course_shortname) both unchecked. I suspect that is enough to make sure the names aren't overwritten, but you could also "lock" those settings to be extra careful.
1 2 3 4
Please login to post comments