示例#1
0
/**
 * Adds a specified group to a specified grouping.
 * @param int $groupid The id of the group
 * @param int $groupingid The id of the grouping
 * @return boolean True if the group was added successfully or the group already 
 * belonged to the grouping, false otherwise. Also returns false if the group 
 * doesn't belong to the same course as the grouping. 
 */
function groups_add_group_to_grouping($groupid, $groupingid)
{
    if (GROUP_NOT_IN_GROUPING == $groupingid) {
        return true;
    }
    $belongstogrouping = groups_belongs_to_grouping($groupid, $groupingid);
    if (!groups_grouping_exists($groupingid)) {
        $groupadded = false;
    } elseif (!$belongstogrouping) {
        $groupadded = groups_db_add_group_to_grouping($groupid, $groupingid);
    } else {
        $groupadded = true;
    }
    return $groupadded;
}
 function test_delete_grouping()
 {
     $this->assertTrue(groups_delete_grouping($this->groupingid));
     $this->assertFalse(groups_grouping_exists($this->groupingid));
 }