示例#1
0
/**
 * Gets the number of groups in a specified grouping
 * @param int $groupingid The grouping specified
 * @param int $courseid The related course.
 * @return int The number of groups in the grouping
 */
function groups_count_groups_in_grouping($groupingid, $courseid)
{
    if (GROUP_NOT_IN_GROUPING == $groupingid) {
        $groupids = groups_get_groups_not_in_any_grouping($courseid);
        if ($groupids === false) {
            return false;
        }
        return count($groupids);
    } elseif (GROUP_ANY_GROUPING == $groupingid) {
        return count_records('groups_courses_groups', 'courseid', $courseid);
    } else {
        return count_records('groups_groupings_groups', 'groupingid ', $groupingid);
    }
}
示例#2
0
 $strgroups = get_string('groups');
 $strparticipants = get_string('participants');
 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) {