# 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/admin/settings/grades.php --- moodle/admin/settings/grades.php Base (1.14.2.19) +++ moodle/admin/settings/grades.php Locally Modified (Based On 1.14.2.19) @@ -76,9 +76,18 @@ GRADE_AGGREGATE_MAX =>get_string('aggregatemax', 'grades'), GRADE_AGGREGATE_MODE =>get_string('aggregatemode', 'grades'), GRADE_AGGREGATE_SUM =>get_string('aggregatesum', 'grades')); + + $defaultvisible = array(GRADE_AGGREGATE_MEAN, GRADE_AGGREGATE_WEIGHTED_MEAN, GRADE_AGGREGATE_WEIGHTED_MEAN2, + GRADE_AGGREGATE_EXTRACREDIT_MEAN, GRADE_AGGREGATE_MEDIAN, GRADE_AGGREGATE_MIN, + GRADE_AGGREGATE_MAX, GRADE_AGGREGATE_MODE, GRADE_AGGREGATE_SUM); + $defaults = array('value'=>GRADE_AGGREGATE_WEIGHTED_MEAN2, 'forced'=>false, 'adv'=>false); $temp->add(new admin_setting_gradecat_combo('grade_aggregation', get_string('aggregation', 'grades'), get_string('aggregationhelp', 'grades'), $defaults, $options)); + $temp->add(new admin_setting_configmultiselect('grade_aggregations_visible', get_string('aggregationsvisible', 'grades'), + get_string('aggregationsvisiblehelp', 'grades'), $defaultvisible, $options)); + + $options = array(0 => get_string('no'), 1 => get_string('yes')); $defaults = array('value'=>1, 'forced'=>false, 'adv'=>true); Index: moodle/grade/edit/tree/category_form.php --- moodle/grade/edit/tree/category_form.php Base (1.9.2.15) +++ moodle/grade/edit/tree/category_form.php Locally Modified (Based On 1.9.2.15) @@ -26,7 +26,7 @@ require_once $CFG->libdir.'/formslib.php'; class edit_category_form extends moodleform { - + var $allaggoptions; function definition() { global $CFG, $COURSE; $mform =& $this->_form; @@ -40,7 +40,7 @@ GRADE_AGGREGATE_MAX =>get_string('aggregatemax', 'grades'), GRADE_AGGREGATE_MODE =>get_string('aggregatemode', 'grades'), GRADE_AGGREGATE_SUM =>get_string('aggregatesum', 'grades')); - + $this->allaggoptions = array_keys($options); // visible elements $mform->addElement('header', 'headercategory', get_string('gradecategory', 'grades')); $mform->addElement('text', 'fullname', get_string('categoryname', 'grades')); @@ -194,10 +194,13 @@ } } + $current_aggregation = null; + if ($id = $mform->getElementValue('id')) { $grade_category = grade_category::fetch(array('id'=>$id)); $grade_item = $grade_category->load_grade_item(); + $current_aggregation = $grade_category->aggregation; // remove agg coef if not used if ($grade_category->is_course_category()) { @@ -272,6 +275,22 @@ } } + // remove unwanted aggregation options + if ($mform->elementExists('aggregation')) { + $agg_el =& $mform->getElement('aggregation'); + $visible = explode(',', $CFG->grade_aggregations_visible); + if (!is_null($current_aggregation)) { + // current type is always visible + $visible[] = $current_aggregation; + } + foreach ($this->allaggoptions as $type) { + if (!in_array($type, $visible)) { + $agg_el->removeOption($type); + } + } + } + + // no parent header for course category if (!$mform->elementExists('aggregationcoef') and !$mform->elementExists('parentcategory')) { $mform->removeElement('headerparent'); Index: moodle/lang/en_utf8/grades.php --- moodle/lang/en_utf8/grades.php Base (1.111.2.60) +++ moodle/lang/en_utf8/grades.php Locally Modified (Based On 1.111.2.60) @@ -37,6 +37,8 @@ $string['aggregationcoefweighthelp'] = 'Weight applied to all grades in this grade item during aggregation with other grade items.'; $string['aggregationhelp'] = 'Strategy used to aggregate grades across all students in a course.'; $string['aggregationposition'] = 'Aggregation position'; +$string['aggregationsvisible'] = 'Selectable aggregation types'; +$string['aggregationsvisiblehelp'] = 'Select all aggragation types that should be available. Hint: use ctrl key when selecting.'; $string['aggregationview'] = 'Aggregation view'; $string['allgrades'] = 'All grades by category'; $string['allstudents'] = 'All students';