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');
17 $courseid = required_param('courseid', PARAM_INT
);
18 $groupingid = required_param('groupingid', PARAM_INT
);
20 // Get the course information so we can print the header and
21 // check the course id is valid
22 $course = groups_get_course_info($courseid);
25 print_error('invalidcourse');
30 // Make sure that the user has permissions to manage groups.
31 require_login($courseid);
33 $context = get_context_instance(CONTEXT_COURSE
, $courseid);
34 if (! has_capability('moodle/course:managegroups', $context)) {
38 //( confirm_sesskey checks that this is a POST request.)
40 // Print the page and form
41 $strgroups = get_string('groups');
42 $strparticipants = get_string('participants');
43 print_header("$course->shortname: $strgroups", $course->fullname
,
44 "<a href=\"$CFG->wwwroot/course/view.php?id=$courseid\">$course->shortname</a> ".
45 "-> <a href=\"$CFG->wwwroot/user/index.php?id=$courseid\">$strparticipants</a> ".
46 "-> <a href=\"$CFG->wwwroot/group/index.php?id=$courseid\">$strgroups</a>".
47 "-> ".get_string('printerfriendly', 'group'), "", "", true, '', user_login_string($course, $USER));
49 $groupingname = groups_get_grouping_name($groupingid);
50 if (! $groupingname) {
51 print_error('errorinvalidgrouping', 'group', groups_home_url($courseid));
53 // Print the name of the grouping
54 if (!empty($CFG->enablegroupings
)) {
56 echo "<h1>$groupingname</h1>\n";
60 // Get the groups and group members for the grouping.
61 if (GROUP_NOT_IN_GROUPING
== $groupingid) {
62 $groupids = groups_get_groups_not_in_any_grouping($courseid);
64 $groupids = groups_get_groups_in_grouping($groupingid);
68 // Make sure the groups are in the right order
69 $group_names = groups_groupids_to_group_names($groupids);
71 // Go through each group in turn and print the group name and then the members
72 foreach ($group_names as $group) {
74 echo "<h2>{$group->name}</h2>\n";
75 $userids = groups_get_members($group->id
);
76 if ($userids != false) {
77 // Make sure the users are in the right order
78 $user_names = groups_userids_to_user_names($userids, $courseid);
81 foreach ($user_names as $user) {
83 echo "<li>{$user->name}</li>\n";
90 print_footer($course);