### Eclipse Workspace Patch 1.0
#P GBPv2_18STABLE
Index: exceptions.php
===================================================================
RCS file: /cvsroot/moodle/contrib/patches/gradebookplus_v2_1.7/exceptions.php,v
retrieving revision 1.1.8.2
diff -u -r1.1.8.2 exceptions.php
--- exceptions.php	5 Oct 2007 03:39:10 -0000	1.1.8.2
+++ exceptions.php	14 Nov 2007 22:31:21 -0000
@@ -82,30 +82,31 @@
     $grade_items = array();
     $grade_items = get_records('grade_item', 'courseid', $course->id);
     $grade_itemcount = count($grade_items);
-    
+
+    // get current group of students and assign that to be the working list of students
+    if (groupmode($course) !=0) {
+    if ($currentgroup = get_current_group($course->id)) {//groupmode is either separate or visible and there is a group 
+        $students = get_group_users($group);
+        } else {//groupmode is either separate or visible and the current group is all participants
+         $students = grade_get_course_students($course->id);
+        }} 
+        else {
+            $students = grade_get_course_students($course->id); //groupmode is not set (all participants)
+        }
+
     // we need to create a multidimensional array keyed by grade_itemid with all_students at each level
     if (isset($grade_items)) {
         foreach($grade_items as $grade_item) {
             $nonmembers[$grade_item->id] = array();
-			//*BP* Make the groups work in the exceptions tab!
-			if (get_group_users($group)) 
-				{
-				($students = get_group_users($group));
-				}
-			else 
-				{
-				($students = get_course_students($course->id));
-				}
-			if ($students) {
-                foreach ($students as $student) {
-                    $nonmembers[$grade_item->id][$student->id] = fullname($student, true);
-                }
-                unset($students);
-            }//*BP* End of my changes
+         
+           if ($students) {
+            foreach ($students as $student) {
+                $nonmembers[$grade_item->id][$student->id] = fullname($student, true);
+            }
+           }
         }
     }
 
-    
     if ($grade_items) {
         foreach ($grade_items as $grade_item) {
             if ($grade_item->modid != 0) {
@@ -121,9 +122,11 @@
             $listmembers[$grade_item->id] = array();
             if ($grade_itemexceptions = grade_get_grade_item_exceptions($grade_item->id)) {
                 foreach ($grade_itemexceptions as $grade_itemexception) {
-                    $listmembers[$grade_item->id][$grade_itemexception->userid] = $nonmembers[$grade_item->id][$grade_itemexception->userid];
-                    unset($nonmembers[$grade_item->id][$grade_itemexception->userid]);
+                      if (isset($nonmembers[$grade_item->id][$grade_itemexception->userid])) { //if the excepted user is part of the current group of users then list them
+                            $listmembers[$grade_item->id][$grade_itemexception->userid] = $nonmembers[$grade_item->id][$grade_itemexception->userid];
+                            unset($nonmembers[$grade_item->id][$grade_itemexception->userid]);
                     $countusers++;
+                    }
                 }
             }
             $listgrade_items[$grade_item->id] = strip_tags(format_string($grade_item->name,true))." ($countusers)";
