3 * Print groups in groupings, and members of groups.
5 * @copyright © 2006 The Open University
6 * @author J.White AT open.ac.uk
7 * @license http://www.gnu.org/copyleft/gpl.html GNU Public License
10 require_once('../config.php');
11 require_once('lib.php');
15 $courseid = required_param('courseid', PARAM_INT
);
16 $groupingid = required_param('groupingid', PARAM_INT
);
18 // Get the course information so we can print the header and
19 // check the course id is valid
20 $course = groups_get_course_info($courseid);
23 print_error('invalidcourse');
28 // Make sure that the user has permissions to manage groups.
29 require_login($courseid);
31 $context = get_context_instance(CONTEXT_COURSE
, $courseid);
32 if (! has_capability('moodle/course:managegroups', $context)) {
36 //( confirm_sesskey checks that this is a POST request.)
38 // Print the page and form
39 $strgroups = get_string('groups');
40 $strparticipants = get_string('participants');
41 print_header("$course->shortname: $strgroups", $course->fullname
,
42 "<a href=\"$CFG->wwwroot/course/view.php?id=$courseid\">$course->shortname</a> ".
43 "-> <a href=\"$CFG->wwwroot/user/index.php?id=$courseid\">$strparticipants</a> ".
44 "-> <a href=\"$CFG->wwwroot/group/index.php?id=$courseid\">$strgroups</a>".
45 "-> ".get_string('printerfriendly', 'group'), "", "", true, '', user_login_string($course, $USER));
47 $groupingname = groups_get_grouping_name($groupingid);
48 if (! $groupingname) {
49 print_error('errorinvalidgrouping', 'group', groups_home_url($courseid));
51 // Print the name of the grouping
52 if (!empty($CFG->enablegroupings
)) {
54 echo "<h1>$groupingname</h1>\n";
58 // Get the groups and group members for the grouping.
59 if (GROUP_NOT_IN_GROUPING
== $groupingid) {
60 $groupids = groups_get_groups_not_in_any_grouping($courseid);
62 $groupids = groups_get_groups_in_grouping($groupingid);
66 // Make sure the groups are in the right order
67 $group_names = groups_groupids_to_group_names($groupids);
69 // Go through each group in turn and print the group name and then the members
70 foreach ($group_names as $group) {
72 echo "<h2>{$group->name}</h2>\n";
73 $userids = groups_get_members($group->id
);
74 if ($userids != false) {
75 // Make sure the users are in the right order
76 $user_names = groups_userids_to_user_names($userids, $courseid);
79 foreach ($user_names as $user) {
81 echo "<li>{$user->name}</li>\n";
88 print_footer($course);