]> git.mjollnir.org Git - moodle.git/commitdiff
In Separate Group mode students now see only students in their own group.
authorrkingdon <rkingdon>
Sun, 8 Aug 2004 15:56:41 +0000 (15:56 +0000)
committerrkingdon <rkingdon>
Sun, 8 Aug 2004 15:56:41 +0000 (15:56 +0000)
mod/dialogue/locallib.php

index 5a632aa585a9001de43a12fa8598aea2550a3e06..764026d6f2a588c120f8257c66448970a2d269ae 100644 (file)
@@ -133,10 +133,14 @@ global $USER;
     if (! $course = get_record("course", "id", $dialogue->course)) {
         error("Course is misconfigured");
     }
+    if (! $cm = get_coursemodule_from_instance("dialogue", $dialogue->id, $course->id)) {
+        error("Course Module ID was incorrect");
+    }
+       
+    $groupid = get_current_group($course->id);
     // add current group before list of students if it's the teacher
     if (isteacher($course->id) and groupmode($course)) {
         // show teacher their current group
-        $groupid = get_current_group($course->id);
         if ($groupid) {
             if (!$group = get_record("groups", "id", $groupid)) {
                 error("Dialogue get available students: group not found");
@@ -152,13 +156,19 @@ global $USER;
                foreach ($users as $otheruser) {
                        // ...exclude self and...
                        if ($USER->id != $otheruser->id) {
-                // if teacher and groups then exclude students not in the current group
+                // ...if teacher and groups then exclude students not in the current group
                 if (isteacher($course->id) and groupmode($course) and $groupid) {
                     if (!ismember($groupid, $otheruser->id)) {
                         continue;
                     }
                 }
-                               // ...any already in any open conversations unless multiple conversations allowed
+                // ...if student and groupmode is SEPARATEGROUPS then exclude students not in student's group
+                if (isstudent($course->id) and (groupmode($course, $cm) == SEPARATEGROUPS)) {
+                    if (!ismember($groupid, $otheruser->id)) {
+                        continue;
+                    }
+                }
+                               // ... and any already in any open conversations unless multiple conversations allowed
                                if ($dialogue->multipleconversations or count_records_select("dialogue_conversations", 
                         "dialogueid = $dialogue->id AND 
                         ((userid = $USER->id AND recipientid = $otheruser->id) OR