Use template on course creation

General plugins (Local) ::: local_course_template
Maintained by Picture of Charles FultonCharles Fulton, Picture of Andrew ZitoAndrew Zito
This local plugin allows site administrators to create "template" courses which will be restored into new courses on course creation.
Latest release:
248 sites
209 downloads
36 fans
Moodle 3.6, 3.7, 3.8, 3.9, 3.10

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

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

Comments RSS

Show comments
  • Picture of Andrew Zito
    Mon, Jul 27, 2020, 11:39 PM
    Hi Joanna, we've discussed this internally and determined that what you're seeing is the caching behavior. For now, you'll have to clear the cache in between each change. We recognize that this is less than ideal, so we're going to look at making the caching behavior more intelligent.
  • Picture of Charles Fulton
    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.
  • Picture of Charles Fulton
    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.
  • Picture of Eric Phetteplace
    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.
  • Picture of Charles Fulton
    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.
  • Picture of Charles Fulton
    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.
  • Picture of Eric Phetteplace
    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?

    Thanks
  • Picture of Alexis Boza
    Fri, Oct 2, 2020, 2:27 AM
    Hi!!!

    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.
  • Picture of Charles Fulton
    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.
  • Picture of Eric Phetteplace
    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.
  • Picture of Eric Phetteplace
    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.
  • Picture of Alexis Boza
    Sat, Jan 16, 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
  • Picture of Eric Phetteplace
    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.
  • Picture of Eric Phetteplace
    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.
1 2 3
Please login to post comments