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:
331 sites
48 fans
Current versions available: 6

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
  • Charles Fulton
    Wed, Feb 15, 2023, 9:52 PM
    I've never tested it with the course request workflow, but if the idnumber matches, and the course request workflow fires the correct event, then it should.
  • Eric Phetteplace
    Wed, May 17, 2023, 7:39 AM
    We upgraded to Moodle 4.0 and are seeing a problem: grid format course templates do not carry over their section images when they used to. Any ideas? I tried editing backup.php to set "user_files => 1" but that did not work.
  • Charles Fulton
    Thu, May 18, 2023, 1:00 AM
    Eric, it sounds like something changed in the grid format plugin. I would follow up with that maintainer as well if you haven't already. Are the files in the backup and to being restored, or are they not in the backup at all?
  • Eric Phetteplace
    Thu, May 18, 2023, 7:40 AM
    If I backup the template & leave all the defaults, the images are there, I can find them in the .mbz file and also if I restore the course. It seems to be something about how this plugin creates / restores the grid format template course's backup. Any ideas of how to investigate? Where can I find the backup that the plugin uses so I can double check it to see if backup or restore is potentially the issue? We have caching enabled, if that matters.
  • Charles Fulton
    Thu, May 18, 2023, 9:34 PM
  • Blair F.
    Sat, Aug 19, 2023, 6:30 AM
    We've been using this plugin for a while now and, for the most part, it's working as we want. The one thing it's not doing is setting the start/end dates to match those of the template. I've read in forums that it should be using those dates. Instead, all our courses are given "today's date" as the start and empty end dates. If I could figure out a way to get this to work, it would be very helpful.
  • Charles Fulton
    Sat, Aug 19, 2023, 8:43 PM
    Blair, that's actually by design. In our environment, the course start and end dates are set by the import from our SIS, and then the plugin restores resources from the template course but doesn't override the dates. I can see how this could be a useful feature, and I'll track it in You should also take a look at the course dates plugin ( if you haven't already.
  • Blair F.
    Mon, Aug 21, 2023, 11:25 PM
    Thank you, Charles. I've looked at the course dates plugin, but our courses are not only created in bulk, but then continue to be added every 24 hours after initiated and in different categories. Once created, the instructor does have the ability to enter the exact dates (rather than generic term dates). So, I don't see how I could get this to work smoothly. I appreciate you tracking the issue.
  • Ricardo Caiado
    Fri, Sep 1, 2023, 10:12 PM
    Hi, Charles.

    I've tried several ways and I'm not getting it to work for "GRAD.2023-9".

    What would be the correct regular expression to set in "local_course_template | extracttermcode"?

  • Charles Fulton
    Sat, Sep 2, 2023, 2:57 AM
    Hi Ricardo, something like /[A-Z]+\.[0-9\-]+/ should work, assuming your idnumbers all follow that same format.
  • Ricardo Caiado
    Mon, Sep 11, 2023, 5:03 AM
    Hi, Charles.

    It worked!


  • Ricardo Caiado
    Mon, Sep 18, 2023, 12:48 AM
    Hi, Charles.

    My template course is set to use "Weekly Format", but all my courses are being created in "Topic Format".

    Is this the expected behavior?

    Note: The activities and resources present in the template are copied when creating new courses.

  • Charles Fulton
    Mon, Sep 18, 2023, 10:04 PM
    Hi Ricardo, that's expected behavior. New courses are still created according to the course creation defaults in site administration, which includes both the course format and the number of topics.
  • Ricardo Caiado
    Mon, Sep 18, 2023, 10:43 PM
    Hi, Charles,

    Thanks for the reply.

    Are the activities and resources created in the template all copied to the new course created? Or is there any restriction?

  • Charles Fulton
    Mon, Sep 18, 2023, 10:45 PM
    No restriction. If they're in the template course and they're backed up, they should be restored in the new course. The only thing the plugin does is make sure you don't have two copies of the Announcements forum.
1 2 3 4 5
Please login to post comments