# This patch file was generated by NetBeans IDE
# This patch can be applied using context Tools: Apply Diff Patch action on respective folder.
# It uses platform neutral UTF-8 encoding.
# Above lines and this line are ignored by the patching process.
Index: moodle/lib/grade/grade_category.php
--- moodle/lib/grade/grade_category.php Base (1.96.2.30)
+++ moodle/lib/grade/grade_category.php Locally Modified (Based On 1.96.2.30)
@@ -1374,7 +1374,19 @@
                 }
             }
         }
+
+        //if marking category visible make sure parent category is visible MDL-21367
+        if( !$hidden ) {
+            $category_array = grade_category::fetch_all(array('id'=>$this->parent));
+            if ($category_array && array_key_exists($this->parent, $category_array)) {
+                $category = $category_array[$this->parent];
+                //call set_hidden on the category regardless of whether it is hidden as its parent might be hidden
+                //if($category->is_hidden()) {
+                    $category->set_hidden($hidden, false);
+                //}
     }
+        }
+    }
 
     /**
      * Applies default settings on this category
Index: moodle/lib/grade/grade_item.php
--- moodle/lib/grade/grade_item.php Base (1.130.2.34)
+++ moodle/lib/grade/grade_item.php Locally Modified (Based On 1.130.2.34)
@@ -600,7 +600,19 @@
                 }
             }
         }
+
+        //if marking item visible make sure category is visible MDL-21367
+        if( !$hidden ) {
+            $category_array = grade_category::fetch_all(array('id'=>$this->categoryid));
+            if ($category_array && array_key_exists($this->categoryid, $category_array)) {
+                $category = $category_array[$this->categoryid];
+                //call set_hidden on the category regardless of whether it is hidden as its parent might be hidden
+                //if($category->is_hidden()) {
+                    $category->set_hidden($hidden, false);
+                //}
     }
+        }
+    }
 
     /**
      * Returns the number of grades that are hidden.
