Old modules and plugins

Note: This database has been replaced by the Moodle Plugins Directory.

Small Hack: Group Template (Site-wide Groups)

Type: Small Hack
Requires: Moodle 1.9
Status: Contributed
Maintainer(s): Dakota Duff

Our organization uses groups to share courses among multiple sites. However, we wanted an easy way to create and maintain identical groups in multiple classes, so this script was created.

In our setup we wanted group names and settings, as well as group members (the teachers) to be identical in all courses where we were using groups. Our students enroll in courses and are assigned to the appropriate group by using the group password.

The script is a cron addition that first looks for courses with Group Mode set to "Separate Groups" or "Visible Groups" and modifies these courses to have the same group settings as the Template Course (including removing any groups not found in the Template Course).

The script does NOT remove any users from existing groups, but does add them. This prevents our students from being removed from groups, since they're actually entered into groups on a course-by-course basis, rather than a site-wide basis.

Because the script can delete groups, please backup before running.

Please read the documentation in the comments of the script for information on installation and configuration.

I wrote this for Moodle 1.9 and haven't tested it in anything prior. If you have any questions, please email me.


v 1.5 2009-01-27

  • Finally got delete_nontemplate_groups and reassign_template_users working well

v 1.4 2008-10-13

  • Changed symbolic linking to file copying to minimize exposure to errors

v 1.3 2008-09-26

  • Corrected insert group members query - no longer adds NULL member if no members exist
  • Moved non-tempate deletion query outside of loop
  • Added more options to non-template deletion to help it comply with other features
  • Added reassign_template_users flag and queries

v 1.2 2008-08-12

  • Changed query_sql function to an unbuffered query
  • Complete rewrite of image copying
    • Symbolic links now point to image files instead of group directories
    • Reduced number of queries by having single query fetch all clone IDs
    • Reduced server load by eliminating need to scan directories to find differences

v 1.1 2008-07-16

  • Added Version History
  • fixed bug where some {$CFG->prefix} were hardcoded as "mdl_"
  • forced $srcid to equal an integer before proceeding
  • "Roped off" user variables
  • Added $do_not_include_ids for Course IDs user does not want processed
  • Now looks for all courses with Group Mode not set to "No Groups"
  • Now creates symbolic links to template's group picture
  • Now also deletes groups_members if group was deleted
  • Added option to not remove destination course groups not in template
  • Updated and improved documentation

v 1.0 2008-03-25

Record added by Dakota Duff - Thursday, 27 March 2008, 12:30 AM
Last modified - Thursday, 5 February 2009, 6:10 AM