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:
299 sites
296 downloads
50 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.

Usage

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. 

Screenshots

Screenshot #0

Contributors

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

Comments RSS

Comments

  • Charles Fulton
    Fri, 2 Oct 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.
  • Eric Phetteplace
    Fri, 2 Oct 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.
  • Eric Phetteplace
    Fri, 4 Dec 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.
  • Alexis Boza
    Sat, 16 Jan 2021, 2:13 AM
    Hi!!
    Do you know why the plugin is not working on moodle 3.10:
    I got the following configurations:

    Plugin
    https://ibb.co/bv9q84L

    Template Course
    https://ibb.co/1qNqBmm

    New course based on Template
    https://ibb.co/0DKRYGT
  • Eric Phetteplace
    Tue, 13 Apr 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.
  • Eric Phetteplace
    Tue, 13 Apr 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.
  • Josue Avendano Gutierrez
    Sat, 5 June 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?
  • Eric Phetteplace
    Sat, 5 June 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.
  • Bruce Wilbee
    Wed, 7 Dec 2022, 4:23 AM
    This plug in looks great. We are just wondering if we can use it without a term ID. For example we use a template course short name template-csw201a will it extract the alphanumeric csw201a if our regular expression is set to /[A-Za-z0-9\]
  • Charles Fulton
    Wed, 7 Dec 2022, 10:33 PM
    Hi Bruce, in theory any regular alphanumeric string will work, but your courses do need to have idnumbers. What do those look like>
  • Bruce Wilbee
    Thu, 8 Dec 2022, 12:24 AM
    We will likely have consecutive ID Numbers to identify individual courses. The short name will likely be concatenated name using: short name of template to be used (ie CSW2045), course start date and numerical courseID.
  • Bruce Wilbee
    Wed, 15 Feb 2023, 5:46 AM
    We need to reverse the convention and have a course id somewhat like COMP2021.12345678 Using the regex of ([A-Za-z0-9]+)\. it is not pulling the template Template-COMP2021....any suggestions?
  • Charles Fulton
    Wed, 15 Feb 2023, 5:54 AM
    Bruce, try using ([A-Za-z0-9]+)\.[0-9]+, which describes the full string? That said, I would have expected that to work.
  • Hugo Ribeiro
    Wed, 15 Feb 2023, 8:40 PM
    Does this work with the course request -> approval workflow?
  • Charles Fulton
    Wed, 15 Feb 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.
Please login to post comments