From bfe0c0ddcfb076db36a40de9e471c2dd03e5b4f1 Mon Sep 17 00:00:00 2001 From: skodak Date: Sat, 20 Oct 2007 19:12:33 +0000 Subject: [PATCH] MDL-11835 proper labels for aggregation coef - weight and extra credit --- grade/edit/tree/item_form.php | 43 +++++++++++++++++++------- grade/edit/tree/outcomeitem_form.php | 45 ++++++++++++++++++++-------- lang/en_utf8/grades.php | 5 +++- 3 files changed, 69 insertions(+), 24 deletions(-) diff --git a/grade/edit/tree/item_form.php b/grade/edit/tree/item_form.php index d0298f2eff..9251cfd9a1 100644 --- a/grade/edit/tree/item_form.php +++ b/grade/edit/tree/item_form.php @@ -101,8 +101,6 @@ class edit_item_form extends moodleform { $mform->disabledIf('plusfactor', 'gradetype', 'eq', GRADE_TYPE_TEXT); $mform->addElement('text', 'aggregationcoef', get_string('aggregationcoef', 'grades')); - $mform->setHelpButton('aggregationcoef', array(false, get_string('aggregationcoef', 'grades'), - false, true, false, get_string('aggregationcoefhelp', 'grades'))); /// grade display prefs @@ -203,17 +201,29 @@ class edit_item_form extends moodleform { if ($grade_item->is_course_item()) { $mform->removeElement('aggregationcoef'); - } else if ($grade_item->is_category_item()) { - $category = $grade_item->get_item_category(); - $parent_category = $category->get_parent_category(); - if (!$parent_category->is_aggregationcoef_used()) { - $mform->removeElement('aggregationcoef'); + } else { + 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(); } - } else { - $parent_category = $grade_item->get_parent_category(); + $parent_category->apply_forced_settings(); + if (!$parent_category->is_aggregationcoef_used()) { $mform->removeElement('aggregationcoef'); + } else { + $agg_el =& $mform->getElement('aggregationcoef'); + if ($parent_category->aggregation == GRADE_AGGREGATE_WEIGHTED_MEAN) { + $agg_el->setLabel(get_string('aggregationcoefweight', 'grades')); + $mform->setHelpButton('aggregationcoef', array(false, get_string('aggregationcoefweight', 'grades'), + false, true, false, get_string('aggregationcoefweighthelp', 'grades'))); + } else if ($parent_category->aggregation == GRADE_AGGREGATE_EXTRACREDIT_MEAN) { + $agg_el->setLabel(get_string('aggregationcoefextra', 'grades')); + $mform->setHelpButton('aggregationcoef', array(false, get_string('aggregationcoefextra', 'grades'), + false, true, false, get_string('aggregationcoefextrahelp', 'grades'))); + } } } @@ -222,9 +232,20 @@ class edit_item_form extends moodleform { $mform->removeElement('plusfactor'); $mform->removeElement('multfactor'); - $course_category = grade_category::fetch_course_category($COURSE->id); - if (!$course_category->is_aggregationcoef_used()) { + $parent_category = grade_category::fetch_course_category($COURSE->id); + if (!$parent_category->is_aggregationcoef_used()) { $mform->removeElement('aggregationcoef'); + } else { + $agg_el =& $mform->getElement('aggregationcoef'); + if ($parent_category->aggregation == GRADE_AGGREGATE_WEIGHTED_MEAN) { + $agg_el->setLabel(get_string('aggregationcoefweight', 'grades')); + $mform->setHelpButton('aggregationcoef', array(false, get_string('aggregationcoefweight', 'grades'), + false, true, false, get_string('aggregationcoefweighthelp', 'grades'))); + } else if ($parent_category->aggregation == GRADE_AGGREGATE_EXTRACREDIT_MEAN) { + $agg_el->setLabel(get_string('aggregationcoefextra', 'grades')); + $mform->setHelpButton('aggregationcoef', array(false, get_string('aggregationcoefextra', 'grades'), + false, true, false, get_string('aggregationcoefextrahelp', 'grades'))); + } } } } diff --git a/grade/edit/tree/outcomeitem_form.php b/grade/edit/tree/outcomeitem_form.php index e03893969d..3f1623c484 100644 --- a/grade/edit/tree/outcomeitem_form.php +++ b/grade/edit/tree/outcomeitem_form.php @@ -76,8 +76,6 @@ class edit_outcomeitem_form extends moodleform { false, true, false, get_string('gradepasshelp', 'grades')));*/ $mform->addElement('text', 'aggregationcoef', get_string('aggregationcoef', 'grades')); - $mform->setHelpButton('aggregationcoef', array(false, get_string('aggregationcoef', 'grades'), - false, true, false, get_string('aggregationcoefhelp', 'grades'))); /// hiding /// advcheckbox is not compatible with disabledIf !! @@ -123,24 +121,47 @@ class edit_outcomeitem_form extends moodleform { if ($grade_item->is_course_item()) { $mform->removeElement('aggregationcoef'); - } else if ($grade_item->is_category_item()) { - $category = $grade_item->get_item_category(); - $parent_category = $category->get_parent_category(); - if (!$parent_category->is_aggregationcoef_used()) { - $mform->removeElement('aggregationcoef'); + } else { + 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(); } - } else { - $parent_category = $grade_item->get_parent_category(); - if (!$parent_category->is_aggregationcoef_used()) { + $parent_category->apply_forced_settings(); + + if (!$parent_category->is_aggregationcoef_used() or !$parent_category->aggregateoutcomes) { $mform->removeElement('aggregationcoef'); + } else { + $agg_el =& $mform->getElement('aggregationcoef'); + if ($parent_category->aggregation == GRADE_AGGREGATE_WEIGHTED_MEAN) { + $agg_el->setLabel(get_string('aggregationcoefweight', 'grades')); + $mform->setHelpButton('aggregationcoef', array(false, get_string('aggregationcoefweight', 'grades'), + false, true, false, get_string('aggregationcoefweighthelp', 'grades'))); + } else if ($parent_category->aggregation == GRADE_AGGREGATE_EXTRACREDIT_MEAN) { + $agg_el->setLabel(get_string('aggregationcoefextra', 'grades')); + $mform->setHelpButton('aggregationcoef', array(false, get_string('aggregationcoefextra', 'grades'), + false, true, false, get_string('aggregationcoefextrahelp', 'grades'))); + } } } } else { - $course_category = grade_category::fetch_course_category($COURSE->id); - if (!$course_category->is_aggregationcoef_used()) { + $parent_category = grade_category::fetch_course_category($COURSE->id); + if (!$parent_category->is_aggregationcoef_used() or !$parent_category->aggregateoutcomes) { $mform->removeElement('aggregationcoef'); + } else { + $agg_el =& $mform->getElement('aggregationcoef'); + if ($parent_category->aggregation == GRADE_AGGREGATE_WEIGHTED_MEAN) { + $agg_el->setLabel(get_string('aggregationcoefweight', 'grades')); + $mform->setHelpButton('aggregationcoef', array(false, get_string('aggregationcoefweight', 'grades'), + false, true, false, get_string('aggregationcoefweighthelp', 'grades'))); + } else if ($parent_category->aggregation == GRADE_AGGREGATE_EXTRACREDIT_MEAN) { + $agg_el->setLabel(get_string('aggregationcoefextra', 'grades')); + $mform->setHelpButton('aggregationcoef', array(false, get_string('aggregationcoefextra', 'grades'), + false, true, false, get_string('aggregationcoefextrahelp', 'grades'))); + } } } } diff --git a/lang/en_utf8/grades.php b/lang/en_utf8/grades.php index 6d7cefe680..8217f91cbc 100644 --- a/lang/en_utf8/grades.php +++ b/lang/en_utf8/grades.php @@ -27,7 +27,10 @@ $string['aggregatesonly'] = 'Aggregates only'; $string['aggregateweightedmean'] = 'Weighted mean of grades'; $string['aggregation'] = 'Aggregation'; $string['aggregationcoef'] = 'Aggregation coefficient'; -$string['aggregationcoefhelp'] = 'Weight applied to all grades in this grade item during aggregation with other grade items.'; +$string['aggregationcoefextra'] = 'Extra credit'; +$string['aggregationcoefextrahelp'] = 'Extra credit for this grade item during aggregation.'; +$string['aggregationcoefweight'] = 'Item weight'; +$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['aggregationview'] = 'Aggregation view'; -- 2.39.5