mirror of
https://github.com/moodle/moodle.git
synced 2025-08-06 01:16:44 +02:00
MDL-47243 core_grades: Add weight settings to outcome edit page
This commit is contained in:
parent
cfa91962d1
commit
c53708d9c0
2 changed files with 24 additions and 2 deletions
|
@ -104,6 +104,7 @@ if (empty($parent_category)) {
|
||||||
$item->aggregationcoef = 0;
|
$item->aggregationcoef = 0;
|
||||||
} else if ($parent_category->aggregation == GRADE_AGGREGATE_SUM) {
|
} else if ($parent_category->aggregation == GRADE_AGGREGATE_SUM) {
|
||||||
$item->aggregationcoef = $item->aggregationcoef > 0 ? 1 : 0;
|
$item->aggregationcoef = $item->aggregationcoef > 0 ? 1 : 0;
|
||||||
|
$item->aggregationcoef2 = format_float($item->aggregationcoef2 * 100.0);
|
||||||
} else {
|
} else {
|
||||||
$item->aggregationcoef = format_float($item->aggregationcoef, 4);
|
$item->aggregationcoef = format_float($item->aggregationcoef, 4);
|
||||||
}
|
}
|
||||||
|
@ -131,12 +132,15 @@ if ($data = $mform->get_data()) {
|
||||||
unset($data->locked);
|
unset($data->locked);
|
||||||
unset($data->locktime);
|
unset($data->locktime);
|
||||||
|
|
||||||
$convert = array('gradepass', 'aggregationcoef');
|
$convert = array('gradepass', 'aggregationcoef', 'aggregationcoef2');
|
||||||
foreach ($convert as $param) {
|
foreach ($convert as $param) {
|
||||||
if (property_exists($data, $param)) {
|
if (property_exists($data, $param)) {
|
||||||
$data->$param = unformat_float($data->$param);
|
$data->$param = unformat_float($data->$param);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
if (isset($data->aggregationcoef2) && $parent_category->aggregation == GRADE_AGGREGATE_SUM) {
|
||||||
|
$data->aggregationcoef2 = $data->aggregationcoef2 / 100.0;
|
||||||
|
}
|
||||||
|
|
||||||
$grade_item = new grade_item(array('id'=>$id, 'courseid'=>$courseid));
|
$grade_item = new grade_item(array('id'=>$id, 'courseid'=>$courseid));
|
||||||
grade_item::set_properties($grade_item, $data);
|
grade_item::set_properties($grade_item, $data);
|
||||||
|
|
|
@ -73,6 +73,14 @@ class edit_outcomeitem_form extends moodleform {
|
||||||
$mform->addHelpButton('cmid', 'linkedactivity', 'grades');
|
$mform->addHelpButton('cmid', 'linkedactivity', 'grades');
|
||||||
$mform->setDefault('cmid', 0);
|
$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
|
/// hiding
|
||||||
/// advcheckbox is not compatible with disabledIf !!
|
/// advcheckbox is not compatible with disabledIf !!
|
||||||
$mform->addElement('checkbox', 'hidden', get_string('hidden', 'grades'));
|
$mform->addElement('checkbox', 'hidden', get_string('hidden', 'grades'));
|
||||||
|
@ -125,8 +133,9 @@ class edit_outcomeitem_form extends moodleform {
|
||||||
}
|
}
|
||||||
|
|
||||||
if ($coefstring !== '') {
|
if ($coefstring !== '') {
|
||||||
if ($coefstring == 'aggregationcoefextrasum') {
|
if ($coefstring == 'aggregationcoefextrasum' || $coefstring == 'aggregationcoefextraweightsum') {
|
||||||
// advcheckbox is not compatible with disabledIf!
|
// advcheckbox is not compatible with disabledIf!
|
||||||
|
$coefstring = 'aggregationcoefextrasum';
|
||||||
$mform->addElement('checkbox', 'aggregationcoef', get_string($coefstring, 'grades'));
|
$mform->addElement('checkbox', 'aggregationcoef', get_string($coefstring, 'grades'));
|
||||||
} else {
|
} else {
|
||||||
$mform->addElement('text', 'aggregationcoef', get_string($coefstring, 'grades'));
|
$mform->addElement('text', 'aggregationcoef', get_string($coefstring, 'grades'));
|
||||||
|
@ -219,6 +228,15 @@ class edit_outcomeitem_form extends moodleform {
|
||||||
$mform->addHelpButton('aggregationcoef', $aggcoef, 'grades');
|
$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');
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue