commit b00366e942bd2673d0050a5afcc9c1db27e679ba Author: cmoore Date: Tue Jun 28 13:04:16 2011 -0700 CLAMP-333: Auto-create grouping when a group is created. diff --git a/group/autocreategrouping.php b/group/autocreategrouping.php new file mode 100644 index 0000000..bebd549 --- /dev/null +++ b/group/autocreategrouping.php @@ -0,0 +1,31 @@ +courseid = $course->id; +$autodata->name = $data->name; +$autodata->timecreated = time(); +$autodata->descriptionformat=1; // HTML format + + +if ($groupingid = groups_create_grouping($autodata)) + echo "Grouping $groupingid created.
"; +else echo "I can't create that grouping, Bob."; + + +// assign group to grouping + +$groupid = $data->id; + +if (groups_assign_grouping($groupingid, $groupid)) + echo "Group $groupid assigned to grouping $groupingid.
"; +else echo "Couldn't assign group $groupid to grouping $groupingid.
"; + + + + +?> diff --git a/group/lib.php b/group/lib.php index 6c9e52c..5f2f084 100644 --- a/group/lib.php +++ b/group/lib.php @@ -134,6 +134,9 @@ function groups_create_group($data, $editform = false, $editoroptions = false) { $data->id = $DB->insert_record('groups', $data); +include('autocreategrouping.php'); // #CLAMP-333 cmoore & bobpuffer + + if ($editform and $editoroptions) { // Update description from editor with fixed files $data = file_postupdate_standard_editor($data, 'description', $editoroptions, $context, 'group', 'description', $data->id);