MDL-47243 core_grades: Add weight settings to outcome edit page

This commit is contained in:
John Okely 2014-09-23 17:06:40 +08:00
parent cfa91962d1
commit c53708d9c0
2 changed files with 24 additions and 2 deletions

View file

@ -73,6 +73,14 @@ class edit_outcomeitem_form extends moodleform {
$mform->addHelpButton('cmid', 'linkedactivity', 'grades');
$mform->setDefault('cmid', 0);
$mform->addElement('advcheckbox', 'weightoverride', get_string('adjustedweight', 'grades'));
$mform->addHelpButton('weightoverride', 'weightoverride', 'grades');
$mform->addElement('text', 'aggregationcoef2', get_string('weight', 'grades'));
$mform->addHelpButton('aggregationcoef2', 'weight', 'grades');
$mform->setType('aggregationcoef2', PARAM_RAW);
$mform->disabledIf('aggregationcoef2', 'weightoverride');
/// hiding
/// advcheckbox is not compatible with disabledIf !!
$mform->addElement('checkbox', 'hidden', get_string('hidden', 'grades'));
@ -125,8 +133,9 @@ class edit_outcomeitem_form extends moodleform {
}
if ($coefstring !== '') {
if ($coefstring == 'aggregationcoefextrasum') {
if ($coefstring == 'aggregationcoefextrasum' || $coefstring == 'aggregationcoefextraweightsum') {
// advcheckbox is not compatible with disabledIf!
$coefstring = 'aggregationcoefextrasum';
$mform->addElement('checkbox', 'aggregationcoef', get_string($coefstring, 'grades'));
} else {
$mform->addElement('text', 'aggregationcoef', get_string($coefstring, 'grades'));
@ -219,6 +228,15 @@ class edit_outcomeitem_form extends moodleform {
$mform->addHelpButton('aggregationcoef', $aggcoef, 'grades');
}
}
// Remove fields used by natural weighting if the parent category is not using natural weighting.
if ($parent_category->aggregation != GRADE_AGGREGATE_SUM) {
if ($mform->elementExists('weightoverride')) {
$mform->removeElement('weightoverride');
}
if ($mform->elementExists('aggregationcoef2')) {
$mform->removeElement('aggregationcoef2');
}
}
}
}