Index: grade/edit/tree/category.php
=========================================================
--- grade/edit/tree/category.php	(revision 1.4.2.6)
+++ grade/edit/tree/category.php	Fri Jan 09 13:35:03 CET 2009
@@ -29,7 +29,8 @@
 require_once 'category_form.php';

 $courseid = required_param('courseid', PARAM_INT);
-$id       = optional_param('id', 0, PARAM_INT);
+$id       = optional_param('id', 0, PARAM_INT); // grade_category->id
+$grade_item_id       = optional_param('grade_item_id', 0, PARAM_INT); // grade_item->id

 if (!$course = get_record('course', 'id', $courseid)) {
     print_error('nocourseid');
@@ -54,11 +55,12 @@
     $category = $grade_category->get_record_data();
     // Get Category preferences
     $category->pref_aggregationview = grade_report::get_pref('aggregationview', $id);
-    // Load agg coef
-    $grade_item = $grade_category->load_grade_item();
-    $category->aggregationcoef = format_float($grade_item->aggregationcoef, 4);
     // set parent
     $category->parentcategory = $grade_category->parent;
+    $grade_item = $grade_category->load_grade_item();
+    foreach ($grade_item as $key => $value) {
+        $category->{"grade_item_$key"} = $value;
+    }

 } else {
     $grade_category = new grade_category(array('courseid'=>$courseid), false);
@@ -66,7 +68,6 @@
     $grade_category->apply_forced_settings();

     $category = $grade_category->get_record_data();
-    $category->aggregationcoef = format_float(0, 4);
 }

 $mform->set_data($category);
@@ -88,6 +89,7 @@
     }
     grade_category::set_properties($grade_category, $data);

+    /// CATEGORY
     if (empty($grade_category->id)) {
         $grade_category->insert();

@@ -95,6 +97,80 @@
         $grade_category->update();
     }

+    /// GRADE ITEM
+    // grade item data saved with prefix "grade_item_"
+    $itemdata = new stdClass();
+    foreach ($data as $k => $v) {
+        if (preg_match('/grade_item_(.*)/', $k, $matches)) {
+            $itemdata->{$matches[1]} = $v;
+        }
+    }
+
+    if (!isset($itemdata->aggregationcoef)) {
+        $itemdata->aggregationcoef = 0;
+    }
+
+    $hidden      = empty($itemdata->hidden) ? 0: $itemdata->hidden;
+    $hiddenuntil = empty($itemdata->hiddenuntil) ? 0: $itemdata->hiddenuntil;
+    unset($itemdata->hidden);
+    unset($itemdata->hiddenuntil);
+
+    $locked   = empty($itemdata->locked) ? 0: $itemdata->locked;
+    $locktime = empty($itemdata->locktime) ? 0: $itemdata->locktime;
+    unset($itemdata->locked);
+    unset($itemdata->locktime);
+
+    $convert = array('grademax', 'grademin', 'gradepass', 'multfactor', 'plusfactor', 'aggregationcoef');
+    foreach ($convert as $param) {
+        if (array_key_exists($param, $itemdata)) {
+            $itemdata->$param = unformat_float($itemdata->$param);
+        }
+    }
+
+    // When creating a new category, a number of grade item fields are filled out automatically, and are required.
+    // If the user leaves these fields empty during creation of a category, we let the default values take effect
+    // Otherwise, we let the user-entered grade item values take effect
+    $grade_item = $grade_category->load_grade_item();
+    $grade_item_id = $grade_item->id;
+    $grade_item_copy = fullclone($grade_item);
+    grade_item::set_properties($grade_item, $itemdata);
+
+    if (empty($grade_item->id)) {
+        $grade_item->id = $grade_item_copy->id;
+    }
+    if (empty($grade_item->grademax)) {
+        $grade_item->grademax = $grade_item_copy->grademax;
+    }
+    if (empty($grade_item->grademin)) {
+        $grade_item->grademin = $grade_item_copy->grademin;
+    }
+    if (empty($grade_item->gradepass)) {
+        $grade_item->gradepass = $grade_item_copy->gradepass;
+    }
+    if (empty($grade_item->aggregationcoef)) {
+        $grade_item->aggregationcoef = $grade_item_copy->aggregationcoef;
+    }
+
+    $grade_item->outcomeid = null;
+
+    // update hiding flag
+    if ($hiddenuntil) {
+        $grade_item->set_hidden($hiddenuntil, false);
+    } else {
+        $grade_item->set_hidden($hidden, false);
+    }
+
+    $grade_item->set_locktime($locktime); // locktime first - it might be removed when unlocking
+    $grade_item->set_locked($locked, false, true);
+
+
+    // Handle null decimals value
+    if (!array_key_exists('decimals', $itemdata) or $itemdata->decimals < 0) {
+        $grade_item->decimals = null;
+    }
+
+    $grade_item->update(); // We don't need to insert it, it's already created when the category is created
+
     // Handle user preferences
     if (isset($data->pref_aggregationview)) {
         if (!grade_report::set_pref('aggregationview', $data->pref_aggregationview, $grade_category->id)) {
Index: grade/edit/tree/category_form.php
=========================================================
--- grade/edit/tree/category_form.php	(revision 1.9.2.15)
+++ grade/edit/tree/category_form.php	Fri Jan 09 13:46:51 CET 2009
@@ -26,27 +26,28 @@
 require_once $CFG->libdir.'/formslib.php';

 class edit_category_form extends moodleform {
+    private $aggregation_options = array();

     function definition() {
         global $CFG, $COURSE;
         $mform =& $this->_form;

-        $options = array(GRADE_AGGREGATE_MEAN            =>get_string('aggregatemean', 'grades'),
+        $this->aggregation_options = array(GRADE_AGGREGATE_MEAN            =>get_string('aggregatemean', 'grades'),
-                         GRADE_AGGREGATE_WEIGHTED_MEAN   =>get_string('aggregateweightedmean', 'grades'),
-                         GRADE_AGGREGATE_WEIGHTED_MEAN2  =>get_string('aggregateweightedmean2', 'grades'),
-                         GRADE_AGGREGATE_EXTRACREDIT_MEAN=>get_string('aggregateextracreditmean', 'grades'),
-                         GRADE_AGGREGATE_MEDIAN          =>get_string('aggregatemedian', 'grades'),
-                         GRADE_AGGREGATE_MIN             =>get_string('aggregatemin', 'grades'),
-                         GRADE_AGGREGATE_MAX             =>get_string('aggregatemax', 'grades'),
-                         GRADE_AGGREGATE_MODE            =>get_string('aggregatemode', 'grades'),
-                         GRADE_AGGREGATE_SUM             =>get_string('aggregatesum', 'grades'));
+                                           GRADE_AGGREGATE_WEIGHTED_MEAN   =>get_string('aggregateweightedmean', 'grades'),
+                                           GRADE_AGGREGATE_WEIGHTED_MEAN2  =>get_string('aggregateweightedmean2', 'grades'),
+                                           GRADE_AGGREGATE_EXTRACREDIT_MEAN=>get_string('aggregateextracreditmean', 'grades'),
+                                           GRADE_AGGREGATE_MEDIAN          =>get_string('aggregatemedian', 'grades'),
+                                           GRADE_AGGREGATE_MIN             =>get_string('aggregatemin', 'grades'),
+                                           GRADE_AGGREGATE_MAX             =>get_string('aggregatemax', 'grades'),
+                                           GRADE_AGGREGATE_MODE            =>get_string('aggregatemode', 'grades'),
+                                           GRADE_AGGREGATE_SUM             =>get_string('aggregatesum', 'grades'));

         // visible elements
         $mform->addElement('header', 'headercategory', get_string('gradecategory', 'grades'));
         $mform->addElement('text', 'fullname', get_string('categoryname', 'grades'));
         $mform->addRule('fullname', null, 'required', null, 'client');

-        $mform->addElement('select', 'aggregation', get_string('aggregation', 'grades'), $options);
+        $mform->addElement('select', 'aggregation', get_string('aggregation', 'grades'), $this->aggregation_options);
         $mform->setHelpButton('aggregation', array('aggregation', get_string('aggregation', 'grades'), 'grade'));
         if ((int)$CFG->grade_aggregation_flag & 2) {
             $mform->setAdvanced('aggregation');
@@ -97,6 +98,115 @@
         $mform->disabledIf('keephigh', 'droplow', 'noteq', 0);
         $mform->disabledIf('droplow', 'keephigh', 'noteq', 0);

+        // Grade item settings
+        $mform->addElement('header', 'general', get_string('gradeitem', 'grades'));
+
+        $mform->addElement('text', 'grade_item_itemname', get_string('itemname', 'grades'));
+        $mform->addElement('text', 'grade_item_iteminfo', get_string('iteminfo', 'grades'));
+        $mform->setHelpButton('grade_item_iteminfo', array('iteminfo', get_string('iteminfo', 'grades'), 'grade'), true);
+
+        $mform->addElement('text', 'grade_item_idnumber', get_string('idnumbermod'));
+        $mform->setHelpButton('grade_item_idnumber', array('idnumber', get_string('idnumber', 'grades'), 'grade'), true);
+
+        $options = array(GRADE_TYPE_NONE=>get_string('typenone', 'grades'),
+                         GRADE_TYPE_VALUE=>get_string('typevalue', 'grades'),
+                         GRADE_TYPE_SCALE=>get_string('typescale', 'grades'),
+                         GRADE_TYPE_TEXT=>get_string('typetext', 'grades'));
+
+        $mform->addElement('select', 'grade_item_gradetype', get_string('gradetype', 'grades'), $options);
+        $mform->setHelpButton('grade_item_gradetype', array('gradetype', get_string('gradetype', 'grades'), 'grade'), true);
+        $mform->setDefault('grade_item_gradetype', GRADE_TYPE_VALUE);
+
+        //$mform->addElement('text', 'calculation', get_string('calculation', 'grades'));
+        //$mform->disabledIf('calculation', 'gradetype', 'eq', GRADE_TYPE_TEXT);
+        //$mform->disabledIf('calculation', 'gradetype', 'eq', GRADE_TYPE_NONE);
+
+        $options = array(0=>get_string('usenoscale', 'grades'));
+        if ($scales = get_records('scale')) {
+            foreach ($scales as $scale) {
+                $options[$scale->id] = format_string($scale->name);
+            }
+        }
+        $mform->addElement('select', 'grade_item_scaleid', get_string('scale'), $options);
+        $mform->setHelpButton('grade_item_scaleid', array('scaleid', get_string('scaleid', 'grades'), 'grade'), true);
+        $mform->disabledIf('grade_item_scaleid', 'grade_item_gradetype', 'noteq', GRADE_TYPE_SCALE);
+
+        $mform->addElement('text', 'grade_item_grademax', get_string('grademax', 'grades'));
+        $mform->setHelpButton('grade_item_grademax', array('grademax', get_string('grademax', 'grades'), 'grade'), true);
+        $mform->disabledIf('grade_item_grademax', 'grade_item_gradetype', 'noteq', GRADE_TYPE_VALUE);
+
+        $mform->addElement('text', 'grade_item_grademin', get_string('grademin', 'grades'));
+        $mform->setHelpButton('grade_item_grademin', array('grademin', get_string('grademin', 'grades'), 'grade'), true);
+        $mform->disabledIf('grade_item_grademin', 'grade_item_gradetype', 'noteq', GRADE_TYPE_VALUE);
+
+        $mform->addElement('text', 'grade_item_gradepass', get_string('gradepass', 'grades'));
+        $mform->setHelpButton('grade_item_gradepass', array('gradepass', get_string('gradepass', 'grades'), 'grade'), true);
+        $mform->disabledIf('grade_item_gradepass', 'grade_item_gradetype', 'eq', GRADE_TYPE_NONE);
+        $mform->disabledIf('grade_item_gradepass', 'grade_item_gradetype', 'eq', GRADE_TYPE_TEXT);
+
+        $mform->addElement('text', 'grade_item_multfactor', get_string('multfactor', 'grades'));
+        $mform->setHelpButton('grade_item_multfactor', array('multfactor', get_string('multfactor', 'grades'), 'grade'), true);
+        $mform->setAdvanced('grade_item_multfactor');
+        $mform->disabledIf('grade_item_multfactor', 'grade_item_gradetype', 'eq', GRADE_TYPE_NONE);
+        $mform->disabledIf('grade_item_multfactor', 'grade_item_gradetype', 'eq', GRADE_TYPE_TEXT);
+
+        $mform->addElement('text', 'grade_item_plusfactor', get_string('plusfactor', 'grades'));
+        $mform->setHelpButton('grade_item_plusfactor', array('plusfactor', get_string('plusfactor', 'grades'), 'grade'), true);
+        $mform->setAdvanced('grade_item_plusfactor');
+        $mform->disabledIf('grade_item_plusfactor', 'grade_item_gradetype', 'eq', GRADE_TYPE_NONE);
+        $mform->disabledIf('grade_item_plusfactor', 'grade_item_gradetype', 'eq', GRADE_TYPE_TEXT);
+
+        /// grade display prefs
+        $default_gradedisplaytype = grade_get_setting($COURSE->id, 'displaytype', $CFG->grade_displaytype);
+        $options = array(GRADE_DISPLAY_TYPE_DEFAULT            => get_string('default', 'grades'),
+                         GRADE_DISPLAY_TYPE_REAL               => get_string('real', 'grades'),
+                         GRADE_DISPLAY_TYPE_PERCENTAGE         => get_string('percentage', 'grades'),
+                         GRADE_DISPLAY_TYPE_LETTER             => get_string('letter', 'grades'),
+                         GRADE_DISPLAY_TYPE_REAL_PERCENTAGE    => get_string('realpercentage', 'grades'),
+                         GRADE_DISPLAY_TYPE_REAL_LETTER        => get_string('realletter', 'grades'),
+                         GRADE_DISPLAY_TYPE_LETTER_REAL        => get_string('letterreal', 'grades'),
+                         GRADE_DISPLAY_TYPE_LETTER_PERCENTAGE  => get_string('letterpercentage', 'grades'),
+                         GRADE_DISPLAY_TYPE_PERCENTAGE_LETTER  => get_string('percentageletter', 'grades'),
+                         GRADE_DISPLAY_TYPE_PERCENTAGE_REAL    => get_string('percentagereal', 'grades')
+                         );
+
+        asort($options);
+
+        foreach ($options as $key=>$option) {
+            if ($key == $default_gradedisplaytype) {
+                $options[GRADE_DISPLAY_TYPE_DEFAULT] = get_string('defaultprev', 'grades', $option);
+                break;
+            }
+        }
+        $mform->addElement('select', 'grade_item_display', get_string('gradedisplaytype', 'grades'), $options);
+        $mform->setHelpButton('grade_item_display', array('gradedisplaytype', get_string('gradedisplaytype', 'grades'), 'grade'), true);
+
+        $default_gradedecimals = grade_get_setting($COURSE->id, 'decimalpoints', $CFG->grade_decimalpoints);
+        $options = array(-1=>get_string('defaultprev', 'grades', $default_gradedecimals), 0=>0, 1=>1, 2=>2, 3=>3, 4=>4, 5=>5);
+        $mform->addElement('select', 'grade_item_decimals', get_string('decimalpoints', 'grades'), $options);
+        $mform->setHelpButton('grade_item_decimals', array('decimalpoints', get_string('decimalpoints', 'grades'), 'grade'), true);
+        $mform->setDefault('grade_item_decimals', -1);
+        $mform->disabledIf('grade_item_decimals', 'grade_item_display', 'eq', GRADE_DISPLAY_TYPE_LETTER);
+        if ($default_gradedisplaytype == GRADE_DISPLAY_TYPE_LETTER) {
+            $mform->disabledIf('grade_item_decimals', 'grade_item_display', "eq", GRADE_DISPLAY_TYPE_DEFAULT);
+        }
+
+        /// hiding
+        // advcheckbox is not compatible with disabledIf!
+        $mform->addElement('checkbox', 'grade_item_hidden', get_string('hidden', 'grades'));
+        $mform->setHelpButton('grade_item_hidden', array('hidden', get_string('hidden', 'grades'), 'grade'));
+        $mform->addElement('date_time_selector', 'grade_item_hiddenuntil', get_string('hiddenuntil', 'grades'), array('optional'=>true));
+        $mform->setHelpButton('grade_item_hiddenuntil', array('hiddenuntil', get_string('hiddenuntil', 'grades'), 'grade'));
+        $mform->disabledIf('grade_item_hidden', 'grade_item_hiddenuntil[off]', 'notchecked');
+
+        /// locking
+        $mform->addElement('advcheckbox', 'grade_item_locked', get_string('locked', 'grades'));
+        $mform->setHelpButton('grade_item_locked', array('locked', get_string('locked', 'grades'), 'grade'));
+
+        $mform->addElement('date_time_selector', 'grade_item_locktime', get_string('locktime', 'grades'), array('optional'=>true));
+        $mform->setHelpButton('grade_item_locktime', array('lockedafter', get_string('locktime', 'grades'), 'grade'));
+        $mform->disabledIf('grade_item_locktime', 'grade_item_gradetype', 'eq', GRADE_TYPE_NONE);
+
 /// parent category related settings
         $mform->addElement('header', 'headerparent', get_string('parentcategory', 'grades'));

@@ -121,16 +232,17 @@
                     $coefstring = 'aggregationcoef';
                 }
             } else {
-                $mform->disabledIf('aggregationcoef', 'parentcategory', 'eq', $cat->id);
+                $mform->disabledIf('grade_item_aggregationcoef', 'parentcategory', 'eq', $cat->id);
             }
         }
         if (count($categories) > 1) {
-            $mform->addElement('select', 'parentcategory', get_string('gradecategory', 'grades'), $options);
+            $mform->addElement('select', 'parentcategory', get_string('parentcategory', 'grades'), $options);
+            $mform->addElement('static', 'currentparentaggregation', get_string('currentparentaggregation', 'grades'));
         }

         if ($coefstring !== '') {
-            $mform->addElement('text', 'aggregationcoef', get_string($coefstring, 'grades'));
-            $mform->setHelpButton('aggregationcoef', array('aggregationcoefweight', get_string('aggregationcoef', 'grades'), 'grade'), true);
+            $mform->addElement('text', 'grade_item_aggregationcoef', get_string($coefstring, 'grades'));
+            $mform->setHelpButton('grade_item_aggregationcoef', array('aggregationcoefweight', get_string('aggregationcoef', 'grades'), 'grade'), true);
         }

 /// user preferences
@@ -148,7 +260,9 @@

         // hidden params
         $mform->addElement('hidden', 'id', 0);
+        $mform->addElement('hidden', 'grade_item_id', 0);
         $mform->setType('id', PARAM_INT);
+        $mform->setType('grade_item_id', PARAM_INT);

         $mform->addElement('hidden', 'courseid', 0);
         $mform->setType('courseid', PARAM_INT);
@@ -204,8 +318,8 @@
                 if ($mform->elementExists('parentcategory')) {
                     $mform->removeElement('parentcategory');
                 }
-                if ($mform->elementExists('aggregationcoef')) {
-                    $mform->removeElement('aggregationcoef');
+                if ($mform->elementExists('grade_item_aggregationcoef')) {
+                    $mform->removeElement('grade_item_aggregationcoef');
                 }

             } else {
@@ -213,29 +327,10 @@
                 if ($mform->elementExists('parentcategory')) {
                     $mform->hardFreeze('parentcategory');
                 }
-
-                $parent_category = $grade_category->get_parent_category();
-                $parent_category->apply_forced_settings();
-                if (!$parent_category->is_aggregationcoef_used()) {
-                    if ($mform->elementExists('aggregationcoef')) {
-                        $mform->removeElement('aggregationcoef');
-                    }
-                } else {
-                    //fix label if needed
-                    $agg_el =& $mform->getElement('aggregationcoef');
-                    $aggcoef = '';
-                    if ($parent_category->aggregation == GRADE_AGGREGATE_WEIGHTED_MEAN) {
-                        $aggcoef = 'aggregationcoefweight';
-                    } else if ($parent_category->aggregation == GRADE_AGGREGATE_EXTRACREDIT_MEAN) {
-                        $aggcoef = 'aggregationcoefextra';
-                    }
-                    if ($aggcoef !== '') {
-                        $agg_el->setLabel(get_string($aggcoef, 'grades'));
-                        $mform->setHelpButton('aggregationcoef', array('aggregationcoef', get_string('aggregationcoef', 'grades'), 'grade'), true);
-                    }
-                }
-
+            }
+
-            }
+            $parent_cat = $grade_category->get_parent_category();
+            $mform->setDefault('currentparentaggregation', $this->aggregation_options[$parent_cat->aggregation]);

             if ($grade_item->is_calculated()) {
                 // following elements are ignored when calculation formula used
@@ -277,7 +372,104 @@
             $mform->removeElement('headerparent');
         }

+/// GRADE ITEM
+        if ($id = $mform->getElementValue('grade_item_id')) {
+            $grade_item = grade_item::fetch(array('id'=>$id));
+
+            if (!$grade_item->is_raw_used()) {
+                $mform->removeElement('grade_item_plusfactor');
+                $mform->removeElement('grade_item_multfactor');
+            }
+
+            if ($grade_item->is_outcome_item()) {
+                // we have to prevent incompatible modifications of outcomes if outcomes disabled
+                $mform->removeElement('grade_item_grademax');
+                $mform->removeElement('grade_item_grademin');
+                $mform->removeElement('grade_item_gradetype');
+                $mform->removeElement('grade_item_display');
+                $mform->removeElement('grade_item_decimals');
+                $mform->hardFreeze('grade_item_scaleid');
+
+            } else {
+                if ($grade_item->is_external_item()) {
+                    // following items are set up from modules and should not be overrided by user
+                    $mform->hardFreeze('grade_item_itemname,grade_item_idnumber,grade_item_gradetype,grade_item_grademax,grade_item_grademin,grade_item_scaleid');
+                    //$mform->removeElement('calculation');
+                }
+            }
+
+            //remove the aggregation coef element if not needed
+            if ($grade_item->is_course_item()) {
+                if ($mform->elementExists('grade_item_parentcategory')) {
+                    $mform->removeElement('grade_item_parentcategory');
+                }
+                if ($mform->elementExists('grade_item_aggregationcoef')) {
+                    $mform->removeElement('grade_item_aggregationcoef');
+                }
+
+            } else {
+                // if we wanted to change parent of existing item - we would have to verify there are no circular references in parents!!!
+                if ($mform->elementExists('grade_item_parentcategory')) {
+                    $mform->hardFreeze('grade_item_parentcategory');
+                }
+
+                if ($grade_item->is_category_item()) {
+                    $category = $grade_item->get_item_category();
+                    $parent_category = $category->get_parent_category();
+                } else {
+                    $parent_category = $grade_item->get_parent_category();
+                }
+
+                $parent_category->apply_forced_settings();
+
+                if (!$parent_category->is_aggregationcoef_used()) {
+                    if ($mform->elementExists('grade_item_aggregationcoef')) {
+                        $mform->removeElement('grade_item_aggregationcoef');
+                    }
+                } else {
+                    //fix label if needed
+                    $agg_el =& $mform->getElement('grade_item_aggregationcoef');
+                    $aggcoef = '';
+                    if ($parent_category->aggregation == GRADE_AGGREGATE_WEIGHTED_MEAN) {
+                        $aggcoef = 'aggregationcoefweight';
+
+                    } else if ($parent_category->aggregation == GRADE_AGGREGATE_EXTRACREDIT_MEAN) {
+                        $aggcoef = 'aggregationcoefextra';
+
+                    } else if ($parent_category->aggregation == GRADE_AGGREGATE_SUM) {
+                        $aggcoef = 'aggregationcoefextrasum';
+                    }
+
+                    if ($aggcoef !== '') {
+                        $agg_el->setLabel(get_string($aggcoef, 'grades'));
+                        $mform->setHelpButton('grade_item_aggregationcoef', array($aggcoef, get_string($aggcoef, 'grades'), 'grade'), true);
+                    }
+                }
+            }
+
+            if ($category = $grade_item->get_item_category()) {
+                if ($category->aggregation == GRADE_AGGREGATE_SUM) {
+                    if ($mform->elementExists('grade_item_gradetype')) {
+                        $mform->hardFreeze('grade_item_gradetype');
+                    }
+                    if ($mform->elementExists('grade_item_grademin')) {
+                        $mform->hardFreeze('grade_item_grademin');
+                    }
+                    if ($mform->elementExists('grade_item_grademax')) {
+                        $mform->hardFreeze('grade_item_grademax');
+                    }
+                    if ($mform->elementExists('grade_item_scaleid')) {
+                        $mform->removeElement('grade_item_scaleid');
+                    }
+                }
+            }
+
+        } else {
+            // all new items are manual, children of course category
+            $mform->removeElement('grade_item_plusfactor');
+            $mform->removeElement('grade_item_multfactor');
+        }
-    }
+    }
 }

 ?>
Index: grade/lib.php
=========================================================
--- grade/lib.php	(revision 1.120.2.21)
+++ grade/lib.php	Fri Jan 09 13:55:52 CET 2009
@@ -1138,7 +1138,12 @@
         }

         // Init all icons
+        $edit_icon = '';
+
+        if ($element['type'] != 'categoryitem' && $element['type'] != 'courseitem') {
-        $edit_icon             = $this->gtree->get_edit_icon($element, $this->gpr);
+            $edit_icon             = $this->gtree->get_edit_icon($element, $this->gpr);
+        }
+
         $edit_calculation_icon = '';
         $show_hide_icon        = '';
         $lock_unlock_icon      = '';
Index: lang/en_utf8/grades.php
=========================================================
--- lang/en_utf8/grades.php	(revision 1.111.2.60)
+++ lang/en_utf8/grades.php	Fri Jan 09 13:47:17 CET 2009
@@ -122,6 +122,7 @@
 $string['createcategory'] = 'Create category';
 $string['createcategoryerror'] = 'Could not create a new category';
 $string['creatinggradebooksettings'] = 'Creating gradebook settings';
+$string['currentparentaggregation'] = 'Current parent aggregation';
 $string['csv'] = 'CSV';
 $string['curveto'] = 'Curve to';
 $string['decimalpoints'] = 'Overall decimal points';
