MDL-11582 switch category item only if it is really there

This commit is contained in:
skodak 2007-10-04 08:36:34 +00:00
parent fb72e817d9
commit 3e0e2436de

View File

@ -941,10 +941,13 @@ class grade_tree {
if (count($element['children']) < 2) { if (count($element['children']) < 2) {
return; return;
} }
$category_item = reset($element['children']); $first_item = reset($element['children']);
$order = key($element['children']); if ($first_item['type'] == 'categoryitem') {
unset($element['children'][$order]); // the category item might have been already removed
$element['children'][$order] =& $category_item; $order = key($element['children']);
unset($element['children'][$order]);
$element['children'][$order] =& $first_item;
}
foreach ($element['children'] as $sortorder => $child) { foreach ($element['children'] as $sortorder => $child) {
grade_tree::category_grade_last($element['children'][$sortorder]); grade_tree::category_grade_last($element['children'][$sortorder]);
} }