Skip to end of metadata
Go to start of metadata

Task: To improve our Moodle Course management
Tools: Moodle Plugin "local_course_templates", Moosh, and config.php


  1. We currently use Moosh ( to create  accounts, courses, and course enrollments. 

  2. Information from our Campus Solution Software gets sent over to one of our Moodle Web servers which has a moodlecron running to run user adds, user/course enrolls, and course creations. 

    1. Our course creation bash script  is run by moodlecron every 15 minutes. The contents of the file follows the pattern below.
      1.  (  /usr/local/moosh/moosh.php -n --verbose -p /var/www/html course-create -c $categoryID -F 'topcoll' -i 'UNIV10001_F18' -f '$CourseFullName (UNIV10001_F18)' -v 'n' 'UNIV10001_F18'  )


  1. When moodle receives the "Create Course" trigger from our moosh process it looks to config.php first to see if there is any "default block overrides". We currently have our's set to ($CFG->defaultblocks_override = '';) because we do not want duplicate blocks added to new courses.

Local_Course_Templates Plugin

  1. Install the local_course_templates plugin. Instructions are found here (
  2. In the "Administration" block go to "Site Administration -> Plugins -> Local plugins -> Use template on course creation"
    1. In the "Term Code" field please enter in your own Regex.
      1. We name our courses based off Course-Short-Name, Section, Semester, and Year. (i.e. UNIV10001_F18)
      2. So our Term Code is "/[A-Za-z0-9]+\_([A-Z]+[0-9]+)/" and our "Template shortname format" is "Template-[TERMCODE]"
  3. Create a new category called "Semester Templates"
  4. Add a new course named "Template-Semester/Year" (i.e. Template-F18)
  5. Modify the course template to your liking. This includes blocks, activities, course formats, etc.
  6. Once the course template is ready you will need to clear moodle's cache ("Site Administration → Development → Purge All Caches")
  7. The next time a course is created and it has your custom Regex (i.e. UNIV10001_F18) it should apply the "Template-F18" template to your course.