### Eclipse Workspace Patch 1.0
#P 18stable
Index: grade/lib.php
===================================================================
RCS file: /cvsroot/moodle/moodle/grade/lib.php,v
retrieving revision 1.65.2.14
diff -u -r1.65.2.14 lib.php
--- grade/lib.php	23 Nov 2007 04:12:13 -0000	1.65.2.14
+++ grade/lib.php	27 Mar 2008 05:21:08 -0000
@@ -352,7 +352,7 @@
                             // points are set... see if the current category is using drop the x lowest and do so
                             // also drop exceptions first, so then this grades(s) won't be recoqnized as the x lowest
                 // Get exception scores and assign them in the array
-                            if ($main_category['stats']['drop'] != 0) {
+                            if ($main_category['stats']['drop'] != 0) { // I think the exceptions should be handled not only first but separtely from drops
                                 $exceptions = grade_get_exceptions_user($course->id, $student);
                                 if (isset($exceptions) && $exceptions) {
                                     foreach($exceptions as $exception) {
@@ -360,30 +360,30 @@
                                             if ($grades_by_student["$exception->userid"]["$exception->catname"]) {
                                                 $assgn = get_record($exception->modname, 'id', $exception->cminstance, 'course', $course->id);
                                                 $grade = $grades_by_student["$exception->userid"]["$exception->catname"]["$assgn->name"]['grade'];
-                        if (isset($grade)) {
-                            if (!isset($grades_by_student["$exception->userid"]["$exception->catname"]['stats']['exceptions'])) {
-                                                             $grades_by_student["$exception->userid"]["$exception->catname"]['stats']['exceptions'] = $grade;
+                                                if (isset($grade)) {
+                                                    if (!isset($grades_by_student["$exception->userid"]["$exception->catname"]['stats']['exceptions'])) {
+                                                        $grades_by_student["$exception->userid"]["$exception->catname"]['stats']['exceptions'] = $grade; //should probably include grade_against for total points deduction
                                                     }
                                                     elseif (isset($grades_by_student["$exception->userid"]["$exception->catname"]['stats']['exceptions'])) {
-                                                             $grades_by_student["$exception->userid"]["$exception->catname"]['stats']['exceptions'] .= ','. $grade;
-                            }
-                        }
+                                                        $grades_by_student["$exception->userid"]["$exception->catname"]['stats']['exceptions'] .= ','. $grade;
+                                                    }
+                                                }
                                             }
                                         }
                                     }
-                }
+                                }
                                 if (isset($grades_by_student["$student"]["$category"]['stats']['exceptions'])) {
                                     $grades_by_student["$student"]["$category"]['stats']['allgrades'] = grade_drop_exceptions($grades_by_student["$student"]["$category"]['stats']['allgrades'], $grades_by_student["$student"]["$category"]['stats']['exceptions']);
                                 }
                 
                                 $grades_by_student["$student"]["$category"]['stats']['allgrades'] = grade_drop_lowest($grades_by_student["$student"]["$category"]['stats']['allgrades'], $main_category['stats']['drop'], $main_category['stats']['grade_items']);
-                                if ($grades_by_student["$student"]["$category"]['stats']['points'] != '-') {
+                                if ($grades_by_student["$student"]["$category"]['stats']['points'] != '-') { //re-calculate category points
                                     $cat_points = 0;
                                     $count_grades = explode(',',$grades_by_student["$student"]["$category"]['stats']['allgrades']);
                                     foreach($count_grades as $grade) {
                                         $cat_points = $cat_points + $grade;
                                     }
-                                    $grades_by_student["$student"]["$category"]['stats']['points'] = $cat_points;
+                                    $grades_by_student["$student"]["$category"]['stats']['points'] = $cat_points; //what about category total points?
                                 }
                             }
                         }
@@ -640,7 +640,7 @@
     $ret_grades = Array(); 
     foreach ($grade_array as $key => $val) {
         $posb = array_search($val,$grade_exception_array);
-        if (is_integer($posb)) {
+        if (is_integer($posb)) { //this will not work if decimal grades are used
             unset($grade_exception_array[$posb]);
         } else {
         

