gradebook MDL-23543 made gradebook not display items with gradetype of no grade
authorAndrew Davis <andrew@affinitysoftware.net>
Tue, 3 Aug 2010 07:22:27 +0000 (07:22 +0000)
committerAndrew Davis <andrew@affinitysoftware.net>
Tue, 3 Aug 2010 07:22:27 +0000 (07:22 +0000)
grade/report/grader/lib.php
lib/grade/grade_category.php
mod/lesson/lib.php

index d794347..b029f18 100644 (file)
@@ -688,8 +688,6 @@ class grade_report_grader extends grade_report {
                 $object = $element['object'];
                 $type   = $element['type'];
                 $categorystate = @$element['categorystate'];
-                $itemmodule = null;
-                $iteminstance = null;
 
                 if (!empty($element['colspan'])) {
                     $colspan = $element['colspan'];
@@ -732,8 +730,8 @@ class grade_report_grader extends grade_report {
                 }
 // Element is a grade_item
                 else {
-                    $itemmodule = $element['object']->itemmodule;
-                    $iteminstance = $element['object']->iteminstance;
+                    //$itemmodule = $element['object']->itemmodule;
+                    //$iteminstance = $element['object']->iteminstance;
 
                     if ($element['object']->id == $this->sortitemid) {
                         if ($this->sortorder == 'ASC') {
index 1b2baac..e8d0755 100644 (file)
@@ -1038,6 +1038,10 @@ class grade_category extends grade_object {
             $category_array['object']->set_sortorder($sortorder);
         }
 
+        if (isset($category_array['object']->gradetype) && $category_array['object']->gradetype==GRADE_TYPE_NONE) {
+            return null;
+        }
+
         // store the grade_item or grade_category instance with extra info
         $result = array('object'=>$category_array['object'], 'type'=>$category_array['type'], 'depth'=>$category_array['depth']);
 
@@ -1050,19 +1054,25 @@ class grade_category extends grade_object {
         if (!empty($category_array['children'])) {
             $result['children'] = array();
             //process the category item first
-            $cat_item_id = null;
+            $child = null;
 
             foreach ($category_array['children'] as $oldorder=>$child_array) {
 
                 if ($child_array['type'] == 'courseitem' or $child_array['type'] == 'categoryitem') {
-                    $result['children'][$sortorder] = grade_category::_fetch_course_tree_recursion($child_array, $sortorder);
+                    $child = grade_category::_fetch_course_tree_recursion($child_array, $sortorder);
+                    if (!empty($child)) {
+                        $result['children'][$sortorder] = $child;
+                    }
                 }
             }
 
             foreach ($category_array['children'] as $oldorder=>$child_array) {
 
                 if ($child_array['type'] != 'courseitem' and $child_array['type'] != 'categoryitem') {
-                    $result['children'][++$sortorder] = grade_category::_fetch_course_tree_recursion($child_array, $sortorder);
+                    $child = grade_category::_fetch_course_tree_recursion($child_array, $sortorder);
+                    if (!empty($child)) {
+                        $result['children'][++$sortorder] = $child;
+                    }
                 }
             }
         }
index 172748c..bca698a 100644 (file)
@@ -468,7 +468,6 @@ function lesson_grade_item_update($lesson, $grades=NULL) {
         $params['gradetype']  = GRADE_TYPE_VALUE;
         $params['grademax']   = $lesson->grade;
         $params['grademin']   = 0;
-
     } else {
         $params['gradetype']  = GRADE_TYPE_NONE;
     }