Index: group/lib/courselib.php
===================================================================
RCS file: group/lib/courselib.php
diff -N group/lib/courselib.php
--- group/lib/courselib.php	7 Nov 2006 11:42:53 -0000	1.1
+++ /dev/null	1 Jan 1970 00:00:00 -0000
@@ -1,12 +0,0 @@
-<?php
-// @@@ TO DO 
-function groups_get_forced_grouping($courseid) {
-}
-
-function groups_set_forced_grouping($courseid, $groupingid) {
-}
-
-function groups_course_print_group_selector($userid, $courseid, $permissiontype) {
-}
-
-?>
Index: group/lib/automaticgroupinglib.php
===================================================================
RCS file: group/lib/automaticgroupinglib.php
diff -N group/lib/automaticgroupinglib.php
--- group/lib/automaticgroupinglib.php	23 Nov 2006 11:28:22 -0000	1.2
+++ /dev/null	1 Jan 1970 00:00:00 -0000
@@ -1,251 +0,0 @@
-<?PHP  
-
-/************************************
- * Automatic group generataion
- ************************************/
- 
- // @@@ TO DO - Some of this code could be simplified a lot I realised 
- // after I wrote it and got it working! 
- 
-/**
- * Seeds the random number generator used by groups_create_automatic_grouping. 
- * This must be called before using groups_create_automatic_grouping and should 
- * only be called once in each script even if you are calling 
- * groups_create_automatic_grouping more than once.
- */ 
-function groups_seed_random_number_generator() { 
-	$seed = (double)microtime()*1234567 ;
-	srand($seed);
-}
- 
-
-/**
- * Distributes students into groups randomly and creates a grouping with those 
- * groups.
- * 
- * You need to call groups_seed_random_number_generator() at some point in your 
- * script before calling this function. 
- * 
- * Note that this function does not distribute teachers into groups - this still 
- * needs to be done manually. 
- * 
- * @param int $courseid The id of the course that the grouping should belong to
- * @param int $nostudentspergroup The number of students to put in each group - 
- * this can be set to false if you prefer to specify the number of groups 
- * instead
- * @param int $nogroups The number of groups - this can be set to false if you 
- * prefer to specify the number of student in each group. If both are specified 
- * then $nostudentspergroup takes precedence. If neither is
- * specified then the function does nothing and returns false. 
- * @param boolean $distribevenly If $noofstudentspergroup is specified, then 
- * if this is set to true, any leftover students are distributed evenly among 
- * the groups, whereas if it is set to false then they are put in a separate 
- * group. 
- * @param object $groupsettings The default settings to give each group. 
- * This should contain prefix and defaultgroupdescription fields. The groups 
- * are named with the prefix followed by 1, 2, etc. and given the
- * default group description set. 
- * @param int $groupid If this is not set to false, then only students in the 
- * specified group are distributed into groups, not all the students enrolled on 
- * the course. 
- * @param boolean $alphabetical If this is set to true, then the students are 
- * not distributed randomly but in alphabetical order of last name. 
- * @return int The id of the grouping
- */
-function groups_create_automatic_grouping($courseid, $nostudentspergroup, 
-                                          $nogroups, $distribevenly, 
-                                          $groupingsettings, 
-                                          $groupid = false, 
-                                          $alphabetical = false) {
-	
-	if (!$nostudentspergroup and !$noteacherspergroup and !$nogroups) {
-		$groupingid = false;
-	} else {
-		// Set $userids to the list of students that we want to put into groups 
-		// in the grouping
-		if (!$groupid) {
-			$users = get_course_students($courseid);
-    		$userids = groups_users_to_userids($users); 
-		} else {
-			$userids = groups_get_members($groupid);
-		}
-		
-	   	// Distribute the users into sets according to the parameters specified    
-	    $userarrays = groups_distribute_in_random_sets($userids, 
-	            $nostudentspergroup, $nogroups, $distribevenly, !$alphabetical);  
-
-	    if (!$userarrays) {
-	    	$groupingid = false;
-	    } else { 
-	    	// Create the grouping that the groups we create will go into   
-	    	$groupingid = groups_create_grouping($courseid, $groupingsettings);
-	    	                                          
-	    	// Get the prefix for the names of each group and default group 
-	    	// description to give each group
-	    	if (!$groupingsettings->prefix) {
-	    		$prefix = get_string('defaultgroupprefix', 'groups');
-	    	} else {
-	    		$prefix = $groupingsettings->prefix;
-	    	}
-	    	
-	    	if (!$groupingsettings->defaultgroupdescription) {
-	    		$defaultgroupdescription = '';
-	    	} else {
-	    		$defaultgroupdescription = $groupingsettings->defaultgroupdescription;
-	    	}
-	    	
-	    	// Now create a group for each set of students, add the group to the 
-	    	// grouping and then add the students	
-	    	$i = 1;
-		    foreach ($userarrays as $userids) {
-		    	$groupsettings->name = $prefix.' '.$i;
-		    	$groupsettings->description = $defaultgroupdescription;
-		    	$i++;
-		    	$groupid = groups_create_group($courseid, $groupsettings);
-		    	$groupadded = groups_add_group_to_grouping($groupid, 
-		    	                                           $groupingid);
-		    	if (!$groupid or !$groupadded) {
-		    		$groupingid = false;
-		    	} else {
-					if ($userids) {
-						foreach($userids as $userid) {
-		    				$usersadded = groups_add_member($groupid, $userid);
-							// If unsuccessful just carry on I guess
-						}
-					}
-		    	}
-		    }
-	    }
-	}
-    return $groupingid;
-}
-
-
-/**
- * Takes an array and a set size, puts the elements of the array into an array 
- * of arrays of size $setsize randomly. 
- * @param array $array The array to distribute into random sets
- * @param int $setsize The size of each set - this can be set to false, if you 
- * would prefer to specify the number of sets.  
- * @param int $nosets The number of sets - this can be set to false if you would 
- * prefer to specify the setsize. 
- * If both $setsize and $nosets are set then $setsize takes precedence. If both 
- * are set to false then the function does nothing and returns false.  
- * @param $distribevenly boolean Determines how extra elements are distributed 
- * if $setsize doesn't divide exactly into the number of elements if $setsize is 
- * specified. If it is true then extra elements will be distributed evenly 
- * amongst the sets, whereas if it is set to false then the remaining elements 
- * will be put into a separate set. 
- * @param boolean $randomise If this is true then the elements of array will be 
- * put into the arrays in a random order, otherwise they will be put into the 
- * array in the same order as the original array. 
- * @return array The array of arrays of elements generated. 
- */
-function groups_distribute_in_random_sets($array, $setsize, $nosets, 
-                                          $distribevenly = true, 
-                                          $randomise = true) {
-    $noelements = count($array);    
-	
-	// Create a list of the numbers 1,..., $noelements, in either random order 
-	// or in numerical order depending on whether $randomise has been set.    
-    if ($randomise) {
-		$orderarray = groups_random_list($noelements);
-    } else {
-    	// Just create the array (1,2,3,....)
-    	$orderarray = array();
-    	for($i = 0; $i < $noelements; $i++) {
-    		array_push($orderarray, $i);
-    	}	
-    }
-    
-    // Now use the ordering in $orderarray to generate the new arrays
-    $arrayofrandomsets = array(); // 
-
-    for ($i = 0; $i < $noelements; $i++) {      
-    	$arrayofrandomsets[$arrayno][$i] = $array[$orderarray[$i]];
-        if (groups_last_element_in_set($noelements, $setsize, $nosets, 
-                                       $distribevenly, $i) 
-            and $i != $noelements - 1) {          	
-        	$arrayno++;
-            $arrayofrandomsets[$arrayno] = array(); 
-    	}
-        
-    }
-    
-    return  $arrayofrandomsets;
-}
-
-/**
- * Returns an array of the numbers 0,..,$size - 1 in random order 
- * @param int $size the number of numbers to return in a random order 
- * @return array The array of numbers in a random order
- */
-function groups_random_list($size) {
-	$orderarray = array();
-    $noelementsset = 0;
-    while($noelementsset != $size) {
-        $newelement = rand() % $size;
-        // If the array doesn't already contain the element, add it.
-        if (array_search($newelement, $orderarray) === false) {
-            array_push($orderarray, $newelement);
-            $noelementsset++;
-        }
-    }
-
-    return $orderarray;
-}
-
-/**
- * A helper function for groups_distribute_in_random_sets(). 
- * When distributing elements into sets, determines if a given element is the 
- * last element in the set. 
- * @param int $totalnoelements The total number of elements being distributed. 
- * @param int $setsize See groups_distribute_in_random_sets()
- * @param int $nosets See groups_distribute_in_random_sets()
- * @param boolean $distribevenly  See groups_distribute_in_random_sets()
- * @param int $elementno The element number that we are considering i.e. if this 
- * is the 15th element then this would be 15. 
- * @return boolean True if the element under consideration would be the last 
- * element in the set, fals otherwise. 
- */
-function groups_last_element_in_set($totalnoelements, $setsize, $nosets, 
-                                    $distribevenly, $elementno) {
-	$lastelement = false;
-	$elementno = $elementno + 1; // Counting from zero is just too confusing! 
-	
-	// If $nosets has been specified, make sure $setsize is set to the right 
-	// value, so that we can treat the two cases identically. Then work out how 
-	// many extra elements will be left over. 
-	if (!$setsize) {
-		$setsize = floor($totalnoelements / $nosets);
-		$noextra = $totalnoelements % $nosets;
-	} else {
-		$noextra = $totalnoelements % $setsize;
-	}
-	
-    if (!$distribevenly) {
-    	// If we're putting our extra elements in a set at the end, everything 
-    	// is easy!
-    	if ($elementno % $setsize == 0) {
-        	$lastelement = true;
-    	}
-    } else {
-    	// Work out the number of elements that will be in the bigger sets that 
-    	// have the leftover elements in 
-    	// them.
-    	$noinbiggersets = $noextra * ($setsize + 1);
-    	// Work out if this element is a last element in a set or not - we need 
-    	// to separate the case where the element is one of the ones that goes 
-    	// into the bigger sets at the beginning 
-    	// and the case where it's one of the elements in the normal sized sets. 
-    	if (($elementno <= $noinbiggersets and $elementno % ($setsize + 1) == 0) 
-    	    or ($elementno > $noinbiggersets  and 
-    	    ($elementno - $noinbiggersets ) % $setsize == 0) ) {
-        	$lastelement = true;
-    	}
-    }	
-
-    return $lastelement;
-}
-
-?>
\ No newline at end of file
Index: group/overview.txt
===================================================================
RCS file: group/overview.txt
diff -N group/overview.txt
--- group/overview.txt	7 Nov 2006 11:42:49 -0000	1.1
+++ /dev/null	1 Jan 1970 00:00:00 -0000
@@ -1,54 +0,0 @@
-Quick summary!
-
-See the wiki too - 
-
-http://docs.moodle.org/en/How_groups_work_in_Moodle
-http://docs.moodle.org/en/Groups_documentation_for_module_developers
-
-To install - run install.php. This create the appropriate database tables and 
-sets some default config for using an IMS Enterprise web service (in particular 
-the default setting is that such a web service is not called).
-
-The user interface for managing groups for a course is groupsui/index.php. 
-A grouping is just a set of groups - the idea is that you can have several 
-groupings for a course, and then choose different groupings for different 
-activities. 
-
-Note that installing this code does not enable you to actually use the groupings 
-with activity modules - this is coming :-)
-
-configui - This contains the user interface for changing the IMS Enterprise web 
-service config
-
-db - all the functions that access the database, only used internally. There are 
-basically six tables that this code deals with  groups_groups, 
-groups_courses_groups,groups_groups_users, groups_groupings  
-
-groupui - the user interface for managing the groups and groupings of a course. 
-This uses Ajax so most of the code for the user interface is in the javascript 
-files - the PHP files just send back an appropriate XML response to specific
-POST requests. You'll probably need to know the basics of how Ajax works to 
-understand the Javascript. 
-
-lib - The main libraries for the user interface and other moodle code to user. 
--- basicgrouplib.php contains the basic functions for  adding users to groups, 
-deleting groups etc.
--- groupinglib.php contains the basic function for groupings e.g. creating 
-groupings, adding groups to groupings
--- extendedgrouplib.php contains other functions that are useful and use the 
-basic group and grouping functions
--- lib.php is just there to let you include all the libraries more easily
--- utillib.php contains functions that are handy but don't use any of the group 
-or grouping library function e.g. 
-things like getting the names of users 
--- configlib.php - Contains wrapper functions for getting and setting config
-
-unittests - This directory needs a bit of sorting out, and I've just discovered 
-that I've broken one of the main 
-tests...
- 
-
-strings.php - This is stuff that will need to go in the language files - it's 
-here for convenience while I'm doing the
-development. 
-
Index: group/db/dbcleanup.php
===================================================================
RCS file: group/db/dbcleanup.php
diff -N group/db/dbcleanup.php
--- group/db/dbcleanup.php	7 Nov 2006 11:42:54 -0000	1.1
+++ /dev/null	1 Jan 1970 00:00:00 -0000
@@ -1,59 +0,0 @@
-<?php
-
-// @@@ TO DO Need to write these functions because they are needed by parts of
-// the current moodle code where courses are deleted etc. 
-
-/**
- * @param int $courseid If false, removes the user from all groups for all 
- * course
- */
-function groups_remove_user_from_all_groups($userid, $courseid) {
-	// @@@ TO DO 
-}
-
-function groups_remove_all_group_members($courseid, $showfeedback) {
-	// @@@ TO DO 
-}
-
-function groups_remove_all_groups($courseid, $removemembers, $showfeedback) {
-	// @@@ TO DO 
-}
-
-/**
- * Cleans up all the groups and groupings in a course (it does this best-effort 
- * i.e. if one deletion fails, it still attempts further deletions).
- * IMPORTANT: Note that if the groups and groupings are used by other courses 
- * somehow, they will still be deleted - it doesn't protect against this. 
- * @param int $courseid The id of the course
- * @return boolean True if the clean up was successful, false otherwise. 
- */
-function groups_cleanup_groups($courseid) {
-	$success = true;
-
-	// Delete all the groupings 
-	$groupings = groups_get_groupings($courseid);
-    if ($groupings != false) {
-        foreach($groupings as $groupingid) {
-            $groupingdeleted = groups_delete_grouping($groupingid);
-            if (!$groupingdeleted) {
-                $success = false;
-            }
-        }
-    }
-
-    // Delete all the groups
-    $groupids = groups_get_groups($courseid);
-    if ($groupids != false) {
-	    foreach($groupids as $groupid) {
-	        $groupdeleted = groups_delete_group($groupid);
-
-	        if (!$groupdeleted) {
-	            $success = false;
-	        }
-	    }
-    }
-
-	return $success;
-}
-
-?>
Index: group/db/vssver.scc
===================================================================
RCS file: group/db/vssver.scc
diff -N group/db/vssver.scc
Binary files /tmp/cvsTyjKR4 and /dev/null differ
Index: group/db/dbcourselib.php
===================================================================
RCS file: group/db/dbcourselib.php
diff -N group/db/dbcourselib.php
--- group/db/dbcourselib.php	7 Nov 2006 11:42:54 -0000	1.1
+++ /dev/null	1 Jan 1970 00:00:00 -0000
@@ -1,10 +0,0 @@
-<?php
-// @@@ TO DO 
-function groups_db_get_forced_grouping($courseid) {
-}
-
-function groups__db_set_forced_grouping($courseid, $groupingid) {
-}
-
-
-?>
Index: group/db/dbsetup.php
===================================================================
RCS file: group/db/dbsetup.php
diff -N group/db/dbsetup.php
--- group/db/dbsetup.php	12 Jan 2007 00:06:10 -0000	1.8
+++ /dev/null	1 Jan 1970 00:00:00 -0000
@@ -1,260 +0,0 @@
-<?php
-/**
- * Functions required for setting up the database to use the new groups.
- *
- * TODO: replace with, postrges7.sql, mysql.php, install.xml
- *
- * @copyright &copy; 2006 The Open University
- * @author J.White AT open.ac.uk
- * @author N.D.Freear AT open.ac.uk
- * @license http://www.gnu.org/copyleft/gpl.html GNU Public License
- * @package groups
- */
-require_once($CFG->libdir.'/datalib.php');
-
-
-// @@@ TO DO Needs lots of sorting out so proper install/upgrade and also 
-// so used new db stuff. In practice we probably don't actually want to rename 
-// the tables (the group_member table in particular as this is basically 
-// unchanged)that already exist on the whole if we can help it so this and the 
-// the other dblib files should really be sorted out to do this. 
-
-// Database changes
-// New tables - the SQL for creating the tables is below (though should be 
-// foreign keys!) - however it might be more sensible to modify the existing 
-// tables instead as much as we can so that we don't need to copy data over and 
-// that any existing code that does assume the existence of those tables
-// might still work.
-// Another caveat - the code below doesn't contain the new fields in the
-// groupings table - viewowngroup, viewallgroupsmemebers, viewallgroupsactivities,
-// teachersgroupmark, teachersgroupview, teachersoverride, teacherdeletetable.
-// Other changes:
-// * course currently contains groupmode and groupmodeforce - we need to change
-// this to groupingid which is either null or a forced groupingid - need to
-// copy over existing data sensibly. 
-// * course_modules needs groupingid (think it previously had groupmode)
-
-
-// Change database tables - course table need to remove two fields add groupingid field
-// Move everything over
-// Course module instance need to add groupingid field
-// Module table - add group support field. 
-// Add deletable by teacher field. 
-
-
-/**
- * Creates the database tables required
- */
-function groups_create_database_tables() {
-	global $CFG;
-
-    if ('mysql' == $CFG->dbfamily) {
-
-        $createcoursegrouptablesql = "CREATE TABLE IF NOT EXISTS `{$CFG->prefix}groups_courses_groups` (
-                            `id` int(10) unsigned NOT NULL auto_increment,
-                            `courseid` int(10) unsigned NOT NULL default '0',
-                            `groupid` int(11) NOT NULL,
-                            PRIMARY KEY  (`id`),
-                            UNIQUE KEY `id` (`id`),
-                            KEY `courseid` (`courseid`)
-                          ) ";
-
-        $creategroupstablesql = "CREATE TABLE IF NOT EXISTS `{$CFG->prefix}groups_groups` (
-                            `id` int(10) unsigned NOT NULL auto_increment,
-                            `name` varchar(254) collate latin1_general_ci NOT NULL default '',
-                            `description` text collate latin1_general_ci NOT NULL,
-                            `enrolmentkey` varchar(50) collate latin1_general_ci NOT NULL default '',
-                            `lang` varchar(10) collate latin1_general_ci NOT NULL default 'en',
-                            `theme` varchar(50) collate latin1_general_ci NOT NULL default '',
-                            `picture` int(10) unsigned NOT NULL default '0',
-                            `hidepicture` int(2) unsigned NOT NULL default '0',
-                            `timecreated` int(10) unsigned NOT NULL default '0',
-                            `timemodified` int(10) unsigned NOT NULL default '0',
-                            PRIMARY KEY  (`id`),
-                            UNIQUE KEY `id` (`id`)
-                          ) ";
-
-        $creategroupsuserstablesql = "CREATE TABLE IF NOT EXISTS `{$CFG->prefix}groups_groups_users` (
-                            `id` int(10) unsigned NOT NULL auto_increment,
-                            `groupid` int(10) unsigned NOT NULL default '0',
-                            `userid` int(10) unsigned NOT NULL default '0',
-                            `timeadded` int(10) unsigned NOT NULL default '0',
-                            PRIMARY KEY  (`id`),
-                            UNIQUE KEY `id` (`id`),
-                            KEY `groupid` (`groupid`),
-                            KEY `userid` (`userid`)
-                          ) ";
-    
-        $createcoursesgroupingtablesql = "CREATE TABLE IF NOT EXISTS `{$CFG->prefix}groups_courses_groupings` (
-                            `id` int(10) unsigned NOT NULL auto_increment,
-                            `courseid` int(10) unsigned NOT NULL default '0',
-                            `groupingid` mediumint(9) NOT NULL,
-                            PRIMARY KEY  (`id`),
-                            UNIQUE KEY `id` (`id`),
-                            KEY `courseid` (`courseid`)
-                          ) ";
-
-        $creategroupingstablesql = "CREATE TABLE `{$CFG->prefix}groups_groupings` (
-                            `id` int(10) unsigned NOT NULL auto_increment,
-                            `name` varchar(254) collate latin1_general_ci NOT NULL,
-                            `description` text collate latin1_general_ci NOT NULL default '',
-                            `timecreated` int(10) unsigned NOT NULL default 0,
-                            `viewowngroup` binary(1) NOT NULL default 1,
-                            `viewallgroupsmembers` binary(1) NOT NULL default 0,
-                            `viewallgroupsactivities` binary(1) NOT NULL default 0,
-                            `teachersgroupmark` binary(1) NOT NULL default 0,
-                            `teachersgroupview` binary(1) NOT NULL default 0,
-                            `teachersoverride` binary(1) NOT NULL default 0,
-                            PRIMARY KEY  (`id`),
-                            UNIQUE KEY `id` (`id`)
-                          ) ";
-
-        $creategroupingsgroupstablesql = "CREATE TABLE IF NOT EXISTS `{$CFG->prefix}groups_groupings_groups` (
-                            `id` int(10) unsigned NOT NULL auto_increment,
-                            `groupingid` int(10) unsigned default '0',
-                            `groupid` int(10) NOT NULL,
-                            `timeadded` int(10) unsigned NOT NULL default '0',
-                            PRIMARY KEY  (`id`),
-                            UNIQUE KEY `id` (`id`),
-                            KEY `courseid` (`groupingid`)
-                          ) ";
-
-    } else { //postgres7
-
-        $createcoursegrouptablesql = "CREATE TABLE {$CFG->prefix}groups_courses_groups (
-                            id SERIAL PRIMARY KEY,
-                            courseid integer NOT NULL default '0',
-                            groupid integer NOT NULL default '0'
-                          );
-                          CREATE INDEX {$CFG->prefix}groups_courses_groups_courseid_idx ON {$CFG->prefix}groups_courses_groups (courseid);
-                          ";
-                          //?? CONSTRAINT {$CFG->prefix}groups_courses_groups_id_courseid_uk UNIQUE (id, courseid)                                    
-
-        $creategroupstablesql = "CREATE TABLE {$CFG->prefix}groups_groups (
-                            id SERIAL PRIMARY KEY,
-                            name varchar(255) NOT NULL,
-                            description text NOT NULL default '',
-                            enrolmentkey varchar(50) NOT NULL default '',
-                            lang varchar(10) NOT NULL default 'en',
-                            theme varchar(50) NOT NULL default '',
-                            picture integer NOT NULL default '0',
-                            hidepicture integer NOT NULL default '0',
-                            timecreated integer NOT NULL default '0',
-                            timemodified integer NOT NULL default '0'
-                          ) ";
-
-        $creategroupsuserstablesql = "CREATE TABLE {$CFG->prefix}groups_groups_users (
-                            id SERIAL PRIMARY KEY,
-                            groupid integer NOT NULL default '0',
-                            userid integer NOT NULL default '0',
-                            timeadded integer NOT NULL default '0'
-                          );
-                          CREATE INDEX {$CFG->prefix}groups_groups_users_groupid_idx ON {$CFG->prefix}groups_groups_users (groupid);
-                          CREATE INDEX {$CFG->prefix}groups_groups_users_userid_idx ON {$CFG->prefix}groups_groups_users (userid);
-                          COMMENT ON TABLE {$CFG->prefix}groups_groups_users IS 'New groupings (OU).';
-                          ";
-    
-        $createcoursesgroupingtablesql = "CREATE TABLE {$CFG->prefix}groups_courses_groupings (
-                            id SERIAL PRIMARY KEY,
-                            courseid integer NOT NULL default '0',
-                            groupingid integer NOT NULL
-                          );
-                          CREATE INDEX {$CFG->prefix}groups_courses_groupings_courseid_idx ON {$CFG->prefix}groups_courses_groupings (courseid);
-                          COMMENT ON TABLE {$CFG->prefix}groups_courses_groupings IS 'New groupings (OU).';
-                          ";
-                                      
-        $creategroupingstablesql = "CREATE TABLE {$CFG->prefix}groups_groupings (
-                            id SERIAL PRIMARY KEY,
-                            name varchar(254) NOT NULL default,
-                            description text NOT NULL default '',
-                            timecreated integer NOT NULL default 0,
-                            viewowngroup integer NOT NULL default 1,
-                            viewallgroupsmembers integer NOT NULL default 0,
-                            viewallgroupsactivities integer NOT NULL default 0,
-                            teachersgroupmark integer NOT NULL default 0,
-                            teachersgroupview integer NOT NULL default 0,
-                            teachersoverride integer NOT NULL default 0
-                          ) ";
-
-        $creategroupingsgroupstablesql = "CREATE TABLE {$CFG->prefix}groups_groupings_groups (
-                            id SERIAL PRIMARY KEY,
-                            groupingid integer default '0',
-                            groupid integer NOT NULL,
-                            timeadded integer NOT NULL default '0'
-                          );
-                          CREATE INDEX {$CFG->prefix}groups_groupings_groups_groupingid_idx ON {$CFG->prefix}groups_groupings_groups (groupingid);
-                          ";
-    }
-
-    modify_database('', $createcoursegrouptablesql);
-    modify_database('', $creategroupstablesql);
-    modify_database('', $creategroupsuserstablesql);
-    modify_database('', $createcoursesgroupingtablesql);
-    modify_database('', $creategroupingstablesql);
-    modify_database('', $creategroupingsgroupstablesql);
-}
-
-
-/**
- * Copies any old style moodle group to a new style moodle group - we'll need this for any upgrade code
- * @param int $groupid The 'old moodle groups' id of the group to copy
- * @param int $courseid The course id 
- * @param boolean True if the operation was successful, false otherwise. 
- */
-function groups_db_copy_moodle_group_to_imsgroup($groupid, $courseid) {
-	
-	$success = true;
-	
-	$groupsettings = get_record('groups', 'id ', $groupid, '');
-	
-	// Only copy the group if the group exists. 
-	if ($groupsettings != false) {
-        $record = new Object();
-		$record->name = $groupsettings->name;
-		$record->description = $groupsettings->description;
-		$record->password = $groupsettings->password;
-		$record->lang = $groupsettings->lang;
-		$record->theme = $groupsettings->theme;
-		$record->picture = $groupsettings->picture;
-		$record->hidepicture = $groupsettings->hidepicture;
-		$record->timecreated = $groupsettings->timecreated;
-		$record->timemodified = $groupsettings->timemodified;
-
-		$newgroupid = insert_record('groups_groups', $record);
-	    if (!$newgroupid) {
-	    	$success = false;
-	    }
-
-        $courserecord = new Object();
-		$courserecord->courseid = $groupsettings->courseid;
-		$courserecord->groupid = $newgroupid;
-		
-		$added = insert_record('groups_courses_groups', $courserecord);
-
-	    if (!$added) {
-	        $success = false;
-	    }  
-
-	    // Copy over the group members
-		$groupmembers = get_records('groups_users', 'groupid', $groupid);
-		if ($groupmembers != false) {
-			foreach($groupmembers as $member) {
-                $record = new Object();
-                $record->groupid = $newgroupid;
-				$record->userid = $member->userid;
-				$useradded = insert_record('groups_groups_users', $record);
-				if (!$useradded) {
-					$success = false;
-				}
-			}
-		}
-	}
-
-	if (!$success) {
-		notify('Copy operations from Moodle groups to IMS Groups failed');
-	}
-
-    return $success;
-}
-
-?>
