]> git.mjollnir.org Git - moodle.git/commitdiff
Integration 3 - groups in core, modules, calendar... (Part of MDL-7380, new groups)
authornfreear <nfreear>
Thu, 21 Dec 2006 11:51:17 +0000 (11:51 +0000)
committernfreear <nfreear>
Thu, 21 Dec 2006 11:51:17 +0000 (11:51 +0000)
group/groupui/printgrouping.php

index 9e3dca384e2c524b1379851ca681dbe35b31ed79..04e9135031413b0eaddcdaf2885784e6761ab22d 100644 (file)
@@ -1,8 +1,16 @@
 <?php
+/**
+ * Print groups in groupings, and members of groups.
+ *
+ * @copyright &copy; 2006 The Open University
+ * @author J.White AT open.ac.uk 
+ * @license http://www.gnu.org/copyleft/gpl.html GNU Public License
+ * @package groups
+ */
 require_once('../../config.php');
-require_once('../lib/lib.php');
+require_once('../lib.php');
 
-$courseid     = required_param('courseid', PARAM_INT);
+$courseid   = required_param('courseid', PARAM_INT);
 $groupingid = required_param('groupingid', PARAM_INT);
 
 
@@ -10,7 +18,7 @@ require_login($courseid);
 
 // confirm_sesskey checks that this is a POST request  
 if (isteacheredit($courseid)) {
-       
+
        // Print the page and form
        $strgroups = get_string('groups');
        $strparticipants = get_string('participants');
@@ -19,28 +27,32 @@ if (isteacheredit($courseid)) {
                     "-> <a href=\"$CFG->wwwroot/user/index.php?id=$courseid\">$strparticipants</a> ".
                     "-> <a href=\"$CFG->wwwroot/group/groupui/index.php?id=$courseid\">$strgroups</a>".
                     "-> Display grouping", "", "", true, '', user_login_string($course, $USER));
-       
+
        $groupingsettings = groups_get_grouping_settings($groupingid);
-       
-       // Print the name of the grouping
-       $name = $groupingsettings->name;
-       print("<h1>$name</h1>");
-       
+
+    if (! isset($groupingsettings->name)) {
+        print_error('errorinvalidgrouping', 'group', groups_home_url($courseid));
+    } else {
+       // Print the name of the grouping
+          $name = $groupingsettings->name;
+          echo "<h1>$name</h1>\n";
+    }
+
        // Get the groups and group members for the grouping
        $groupids = groups_get_groups_in_grouping($groupingid);
-       
+
        if ($groupids != false) {
-               
+
                // Make sure the groups are in the right order 
                foreach($groupids as $groupid) {
                    $listgroups[$groupid] = groups_get_group_displayname($groupid);  
                }
-               
+
                natcasesort($listgroups);
-       
+
                // Go through each group in turn and print the group name and then the members  
                foreach($listgroups as $groupid=>$groupname) {
-                       print "<h2>$groupname</h2>";
+                       echo "<h2>$groupname</h2>\n";
                        $userids = groups_get_members($groupid);
                        if ($userids != false) {
                                // Make sure the users are in the right order
@@ -49,16 +61,17 @@ if (isteacheredit($courseid)) {
                                $listmembers[$userid] = groups_get_user_displayname($userid, $courseid);       
                                }
                                natcasesort($listmembers);
-                                       
+
+                echo "<ol>\n";
                                foreach($listmembers as $userid=>$name) {
-                                       print("$name<br>");
+                                   echo "<li>$name</li>\n";
                                }
+                echo "</ol>\n";
                        }
                }
        }
-       
-       print_footer($course);
-       
+
+    print_footer($course);
 }
 
 ?>
\ No newline at end of file