]> git.mjollnir.org Git - moodle.git/commitdiff
Groups support for choice module
authormoodler <moodler>
Sun, 15 Feb 2004 08:17:45 +0000 (08:17 +0000)
committermoodler <moodler>
Sun, 15 Feb 2004 08:17:45 +0000 (08:17 +0000)
mod/choice/report.php
mod/choice/view.php

index 0910010720f94766aa9164e9bcc668ad4108c0bc..9c89c715d73fe29b20676621edfc3797c9d7d876 100644 (file)
                   <a href=\"index.php?id=$course->id\">$strchoices</a> ->
                   <a href=\"view.php?id=$cm->id\">$choice->name</a> -> $strresponses", "");
 
+/// Check to see if groups are being used in this choice
+    if ($groupmode = groupmode($course, $cm)) {   // Groups are being used
+        $currentgroup = setup_and_print_groups($course, $groupmode, "report.php?id=$cm->id");
+    } else {
+        $currentgroup = false;
+    }
+
+    if ($currentgroup) {
+        $users = get_users_in_group($currentgroup, "u.firstname ASC");
+    } else {
+        $users = get_course_users($course->id, "u.firstname ASC");
+    }
 
-    if (! $users = get_course_users($course->id, "u.firstname ASC")) {
-        error("No users found (very strange)");
+    if (!$users) {
+        print_heading(get_string("nousersyet"));
+        print_footer($course);
+        exit;
     }
 
     if ( $allanswers = get_records("choice_answers", "choice", $choice->id)) {
index d6ec67249e8560c647c49fb0751ab13d8c596c28..7eb2a8ffd45e73cf05c6d28bd27eb777b20b0a79 100644 (file)
                  "$navigation <A HREF=index.php?id=$course->id>$strchoices</A> -> $choice->name", "", "", true,
                   update_module_button($cm->id, $course->id, $strchoice), navmenu($course, $cm));
 
+/// Check to see if groups are being used in this choice
+    if ($groupmode = groupmode($course, $cm)) {   // Groups are being used
+        $currentgroup = setup_and_print_groups($course, $groupmode, "view.php?id=$cm->id");
+    } else {
+        $currentgroup = false;
+    }
+
     if (isteacher($course->id)) {
         if ( $allanswers = get_records("choice_answers", "choice", $choice->id)) {
             $responsecount = count($allanswers);
 
         print_heading(get_string("responses", "choice"));
 
-        if (! $users = get_course_users($course->id, "u.firstname ASC")) {
-            error("No users found (very strange)");
+        if ($currentgroup) {
+            $users = get_users_in_group($currentgroup, "u.firstname ASC");
+        } else {
+            $users = get_course_users($course->id, "u.firstname ASC");
+        }
+
+        if (!$users) {
+            print_heading(get_string("nousersyet"));
+            print_footer($course);
+            exit;
         }
 
         if ( $allanswers = get_records("choice_answers", "choice", $choice->id)) {