MDL-34985 gradebook Fixing issue where default parent in Full View Add Category could...
authorEric Merrill <merrill@oakland.edu>
Mon, 20 Aug 2012 21:09:40 +0000 (17:09 -0400)
committerEric Merrill <merrill@oakland.edu>
Mon, 20 Aug 2012 21:09:40 +0000 (17:09 -0400)
Turns out the correct default was already computed, but was not being applied to the setting.

grade/edit/tree/category_form.php

index 5a1d8f7..c155565 100644 (file)
@@ -225,7 +225,7 @@ class edit_category_form extends moodleform {
         $mform->addElement('header', 'headerparent', get_string('parentcategory', 'grades'));
 
         $options = array();
-        $default = '';
+        $default = -1;
         $categories = grade_category::fetch_all(array('courseid'=>$COURSE->id));
 
         foreach ($categories as $cat) {
@@ -238,6 +238,7 @@ class edit_category_form extends moodleform {
 
         if (count($categories) > 1) {
             $mform->addElement('select', 'parentcategory', get_string('parentcategory', 'grades'), $options);
+            $mform->setDefault('parentcategory', $default);
             $mform->addElement('static', 'currentparentaggregation', get_string('currentparentaggregation', 'grades'));
         }