function test_add_group_to_grouping() { $this->assertTrue(groups_add_group_to_grouping($this->groupid, $this->groupingid)); $this->assertTrue(groups_belongs_to_grouping($this->groupid, $this->groupingid)); $this->assertTrue($groupings = groups_get_groupings_for_group($this->groupid)); //array... $this->assertTrue($groups = groups_get_groups_in_grouping($this->groupingid)); //... }
/** * Gets the groups for the module instance. In general, you should use * groups_m_get_groups_for_user, however this function is provided for * circumstances where this function isn't sufficient for some reason. * @param int $cmid The id of the module instance. * @return array An array of the ids of the groups for the module instance */ function groups_m_get_groups($cmid) { $groupingid = groups_db_get_groupingid($cmid); $groupids = groups_get_groups_in_grouping($groupingid); return $groupids; }
print_header("{$course->shortname}: {$strgroups}", $course->fullname, "<a href=\"{$CFG->wwwroot}/course/view.php?id={$courseid}\">{$course->shortname}</a> " . "-> <a href=\"{$CFG->wwwroot}/user/index.php?id={$courseid}\">{$strparticipants}</a> " . "-> <a href=\"{$CFG->wwwroot}/group/index.php?id={$courseid}\">{$strgroups}</a>" . "-> " . get_string('printerfriendly', 'group'), "", "", true, '', user_login_string($course, $USER)); $groupingname = groups_get_grouping_name($groupingid); if (!$groupingname) { print_error('errorinvalidgrouping', 'group', groups_home_url($courseid)); } else { // Print the name of the grouping if (!empty($CFG->enablegroupings)) { // NO GROUPINGS YET! echo "<h1>{$groupingname}</h1>\n"; } } // Get the groups and group members for the grouping. if (GROUP_NOT_IN_GROUPING == $groupingid) { $groupids = groups_get_groups_not_in_any_grouping($courseid); } else { $groupids = groups_get_groups_in_grouping($groupingid); } if ($groupids) { // Make sure the groups are in the right order $group_names = groups_groupids_to_group_names($groupids); // Go through each group in turn and print the group name and then the members foreach ($group_names as $group) { echo "<h2>{$group->name}</h2>\n"; $userids = groups_get_members($group->id); if ($userids != false) { // Make sure the users are in the right order $user_names = groups_userids_to_user_names($userids, $courseid); echo "<ol>\n"; foreach ($user_names as $user) { echo "<li>{$user->name}</li>\n"; }