From: skodak Date: Thu, 4 Oct 2007 08:36:34 +0000 (+0000) Subject: MDL-11582 switch category item only if it is really there X-Git-Url: http://git.mjollnir.org/gw?a=commitdiff_plain;h=3e0e2436deba09b9b2cd269a4a16cfc9456533a5;p=moodle.git MDL-11582 switch category item only if it is really there --- diff --git a/grade/lib.php b/grade/lib.php index 8c09071634..9a5ad49dc8 100644 --- a/grade/lib.php +++ b/grade/lib.php @@ -941,10 +941,13 @@ class grade_tree { if (count($element['children']) < 2) { return; } - $category_item = reset($element['children']); - $order = key($element['children']); - unset($element['children'][$order]); - $element['children'][$order] =& $category_item; + $first_item = reset($element['children']); + if ($first_item['type'] == 'categoryitem') { + // the category item might have been already removed + $order = key($element['children']); + unset($element['children'][$order]); + $element['children'][$order] =& $first_item; + } foreach ($element['children'] as $sortorder => $child) { grade_tree::category_grade_last($element['children'][$sortorder]); }