PHPackages                             lafayettecollege/moodle-local\_course\_template - PHPackages - PHPackages  [Skip to content](#main-content)[PHPackages](/)[Directory](/)[Categories](/categories)[Trending](/trending)[Leaderboard](/leaderboard)[Changelog](/changelog)[Analyze](/analyze)[Collections](/collections)[Log in](/login)[Sign up](/register)

1. [Directory](/)
2. /
3. lafayettecollege/moodle-local\_course\_template

ActiveMoodle-local

lafayettecollege/moodle-local\_course\_template
===============================================

This local plugin allows site administrators to create "templat" courses in Moodle which will be restored into new courses on course creation.

v4.1.0(1mo ago)525↓75%8[6 issues](https://github.com/LafColITS/moodle-local_course_template/issues)[2 PRs](https://github.com/LafColITS/moodle-local_course_template/pulls)GPL-3.0-or-laterPHPCI passing

Since Jul 15Pushed 1mo ago6 watchersCompare

[ Source](https://github.com/LafColITS/moodle-local_course_template)[ Packagist](https://packagist.org/packages/lafayettecollege/moodle-local_course_template)[ RSS](/packages/lafayettecollege-moodle-local-course-template/feed)WikiDiscussions main Synced 1w ago

READMEChangelogDependencies (1)Versions (2)Used By (0)

Use template on course creation
===============================

[](#use-template-on-course-creation)

[![Moodle Plugin CI](https://github.com/LafColITS/moodle-local_course_template/workflows/Moodle%20Plugin%20CI/badge.svg)](https://github.com/LafColITS/moodle-local_course_template/workflows/Moodle%20Plugin%20CI/badge.svg)

This local plugin allows site administrators to create "template" courses in Moodle 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.

Requirements
------------

[](#requirements)

- Moodle 4.1 (build 2022112800 or later)

Installation
------------

[](#installation)

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

Usage
-----

[](#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.

### Default template

[](#default-template)

You may specify a default template course in the "Default template course shortname" setting. If there is a course with that shortname, it will be used as the template for any course which matches the termcode regex but does *not* match with a specific template.

Let's say you have termcode regex `/[A-Za-z0-9\.\-]+-([A-Z]+)-\d+/`, where the extracted substring is a department code. Then let's say you have the following template courses (shortnames):

- Template-BIO
- Template-HIS
- Template-MTH

These template courses will be used for Biology (BIO), History (HIS), and Math (MTH) courses respectively. Let's say you don't have specific templates for the other departments (POL, SCI, ENG, EPI, etc.), but you do want them to be based on a generalized template. You can create a fourth template course, and give it a shortname that matches the "Default template course shortname" setting value (eg `default-template`). Then, any course which matches the regex -- that is, any course from which a termcode is successfully extracted -- will be based on the default template course if it does not match a specific template.

So, the course with idnumber `intro-BIO-201910` will still use `Template-BIO`, but the course with idnumber `shakespeare-sem-ENG-201920` will use `default-template`. A course with idnumber `study-abroad-201950` will not use any template.

### Sample regular expressions

[](#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`

### Event / Observers

[](#event--observers)

There is a custom event `local_course_template\event\template_copied`, which is triggered after template copying is complete. This also adds a system-level log entry which specifies the template course ID and the target course ID.

### Caching

[](#caching)

When a new course is created the plugin looks for the template course, then creates a backup of that template course. Both results are cached. The template course id is cached indefinitely; the course backup cache is cleared by the same job that removes the backup itself. By default this occurs every day at 3 AM. You may disable the caching behavior by unchecking "Enable caching" in the plugin settings.

### Compatibilty with course copying

[](#compatibilty-with-course-copying)

Moodle's [course copy](https://docs.moodle.org/39/en/Course_copy) feature (introduced in Moodle 3.9) does not trigger a course created event so copying a course from the interface will *not* trigger this plugin.

### Start and end dates

[](#start-and-end-dates)

By default, the new course will retain its existing start and end dates. You may choose to override these with the template course's values by checking "Copy start and end dates" in the plugin settings.

Acknowledgements
----------------

[](#acknowledgements)

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](https://github.com/lsuits/simple_restore).

Author
------

[](#author)

Charles Fulton ()

###  Health Score

35

—

LowBetter than 77% of packages

Maintenance70

Regular maintenance activity

Popularity17

Limited adoption so far

Community15

Small or concentrated contributor base

Maturity33

Early-stage or recently created project

 Bus Factor1

Top contributor holds 97.6% of commits — single point of failure

How is this calculated?**Maintenance (25%)** — Last commit recency, latest release date, and issue-to-star ratio. Uses a 2-year decay window.

**Popularity (30%)** — Total and monthly downloads, GitHub stars, and forks. Logarithmic scaling prevents top-heavy scores.

**Community (15%)** — Contributors, dependents, forks, watchers, and maintainers. Measures real ecosystem engagement.

**Maturity (30%)** — Project age, version count, PHP version support, and release stability.

###  Release Activity

Cadence

Unknown

Total

1

Last Release

46d ago

### Community

Maintainers

![](https://www.gravatar.com/avatar/3ef434bc036124ba911b2fdea03980e1867faaddd675e86184cdc2b18d210a66?d=identicon)[lafayettecollege](/maintainers/lafayettecollege)

---

Top Contributors

[![mackensen](https://avatars.githubusercontent.com/u/553370?v=4)](https://github.com/mackensen "mackensen (83 commits)")[![kiklop74](https://avatars.githubusercontent.com/u/216822?v=4)](https://github.com/kiklop74 "kiklop74 (2 commits)")

### Embed Badge

![Health badge](/badges/lafayettecollege-moodle-local-course-template/health.svg)

```
[![Health](https://phpackages.com/badges/lafayettecollege-moodle-local-course-template/health.svg)](https://phpackages.com/packages/lafayettecollege-moodle-local-course-template)
```

###  Alternatives

[helsingborg-stad/municipio

A bootstrap theme for creating municipality sites.

4028.8k10](/packages/helsingborg-stad-municipio)[wp-media/wp-rocket

Performance optimization plugin for WordPress

7691.4M4](/packages/wp-media-wp-rocket)[october/rain

October Rain Library

1611.7M109](/packages/october-rain)[drupal/recommended-project

Project template for Drupal projects with a relocated document root

1623.0M1](/packages/drupal-recommended-project)[pressbooks/pressbooks

Pressbooks is an open source book publishing tool built on a WordPress multisite platform. Pressbooks outputs books in multiple formats, including PDF, EPUB, web, and a variety of XML flavours, using a theming/templating system, driven by CSS.

45945.2k1](/packages/pressbooks-pressbooks)[mediawiki/maps

Adds various mapping features to MediaWiki

84157.7k3](/packages/mediawiki-maps)

PHPackages © 2026

[Directory](/)[Categories](/categories)[Trending](/trending)[Changelog](/changelog)[Analyze](/analyze)
