mirror of
https://github.com/moodle/moodle.git
synced 2025-05-01 22:18:03 +02:00
MDL-47006 core_grades: Change category and item forms back to using
aggregationcoef and aggregationcoef2 Part of MDL-46576.
This commit is contained in:
parent
61e521bb09
commit
d6447690bd
@ -75,15 +75,12 @@ if ($id) {
|
||||
$category->grade_item_gradepass = format_float($category->grade_item_gradepass, $decimalpoints);
|
||||
$category->grade_item_multfactor = format_float($category->grade_item_multfactor, 4);
|
||||
$category->grade_item_plusfactor = format_float($category->grade_item_plusfactor, 4);
|
||||
$category->grade_item_aggregationcoef2 = format_float($category->grade_item_aggregationcoef2 * 100.0, 4);
|
||||
|
||||
if (!$parent_category) {
|
||||
// keep as is
|
||||
} else if ($parent_category->aggregation == GRADE_AGGREGATE_SUM or $parent_category->aggregation == GRADE_AGGREGATE_WEIGHTED_MEAN2) {
|
||||
$category->grade_item_aggregationcoef = $category->grade_item_aggregationcoef == 0 ? 0 : 1;
|
||||
if ($parent_category->aggregation == GRADE_AGGREGATE_SUM) {
|
||||
$category->grade_item_weight = format_float($category->grade_item_aggregationcoef2 * 100, 4);
|
||||
}
|
||||
unset($category->grade_item_aggregationcoef2);
|
||||
} else {
|
||||
$category->grade_item_aggregationcoef = format_float($category->grade_item_aggregationcoef, 4);
|
||||
}
|
||||
@ -164,15 +161,14 @@ if ($mform->is_cancelled()) {
|
||||
unset($itemdata->locked);
|
||||
unset($itemdata->locktime);
|
||||
|
||||
$convert = array('grademax', 'grademin', 'gradepass', 'multfactor', 'plusfactor', 'aggregationcoef', 'weight');
|
||||
$convert = array('grademax', 'grademin', 'gradepass', 'multfactor', 'plusfactor', 'aggregationcoef', 'aggregationcoef2');
|
||||
foreach ($convert as $param) {
|
||||
if (property_exists($itemdata, $param)) {
|
||||
$itemdata->$param = unformat_float($itemdata->$param);
|
||||
}
|
||||
}
|
||||
if (isset($itemdata->weight)) {
|
||||
$temdata->aggregationcoef2 = $itemdata->weight / 100.0;
|
||||
unset($itemdata->weight);
|
||||
if (isset($itemdata->aggregationcoef2)) {
|
||||
$itemdata->aggregationcoef2 = $itemdata->aggregationcoef2 / 100.0;
|
||||
}
|
||||
|
||||
// When creating a new category, a number of grade item fields are filled out automatically, and are required.
|
||||
|
@ -164,10 +164,10 @@ class edit_category_form extends moodleform {
|
||||
$mform->addElement('advcheckbox', 'grade_item_weightoverride', get_string('adjustedweight', 'grades'));
|
||||
$mform->addHelpButton('grade_item_weightoverride', 'weightoverride', 'grades');
|
||||
|
||||
$mform->addElement('text', 'grade_item_weight', get_string('weight', 'grades'));
|
||||
$mform->addHelpButton('grade_item_weight', 'weight', 'grades');
|
||||
$mform->setType('grade_item_weight', PARAM_RAW);
|
||||
$mform->disabledIf('grade_item_weight', 'grade_item_weightoverride');
|
||||
$mform->addElement('text', 'grade_item_aggregationcoef2', get_string('weight', 'grades'));
|
||||
$mform->addHelpButton('grade_item_aggregationcoef2', 'weight', 'grades');
|
||||
$mform->setType('grade_item_aggregationcoef2', PARAM_RAW);
|
||||
$mform->disabledIf('grade_item_aggregationcoef2', 'grade_item_weightoverride');
|
||||
|
||||
$mform->addElement('text', 'grade_item_gradepass', get_string('gradepass', 'grades'));
|
||||
$mform->setType('grade_item_gradepass', PARAM_RAW);
|
||||
@ -444,8 +444,8 @@ class edit_category_form extends moodleform {
|
||||
if ($mform->elementExists('grade_item_weightoverride')) {
|
||||
$mform->removeElement('grade_item_weightoverride');
|
||||
}
|
||||
if ($mform->elementExists('grade_item_weight')) {
|
||||
$mform->removeElement('grade_item_weight');
|
||||
if ($mform->elementExists('grade_item_aggregationcoef2')) {
|
||||
$mform->removeElement('grade_item_aggregationcoef2');
|
||||
}
|
||||
} else {
|
||||
if ($grade_item->is_category_item()) {
|
||||
@ -481,8 +481,8 @@ class edit_category_form extends moodleform {
|
||||
if ($mform->elementExists('grade_item_weightoverride')) {
|
||||
$mform->removeElement('grade_item_weightoverride');
|
||||
}
|
||||
if ($mform->elementExists('grade_item_weight')) {
|
||||
$mform->removeElement('grade_item_weight');
|
||||
if ($mform->elementExists('grade_item_aggregationcoef2')) {
|
||||
$mform->removeElement('grade_item_aggregationcoef2');
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -98,9 +98,7 @@ if ($parent_category->aggregation == GRADE_AGGREGATE_SUM or $parent_category->ag
|
||||
$item->aggregationcoef = format_float($item->aggregationcoef, 4);
|
||||
}
|
||||
if ($parent_category->aggregation == GRADE_AGGREGATE_SUM) {
|
||||
$item->weight = format_float($item->aggregationcoef2 * 100.0);
|
||||
} else if ($parent_category->aggregation == GRADE_AGGREGATE_WEIGHTED_MEAN) {
|
||||
$item->weight = format_float($item->aggregationcoef);
|
||||
$item->aggregationcoef2 = format_float($item->aggregationcoef2 * 100.0);
|
||||
}
|
||||
$item->cancontrolvisibility = $grade_item->can_control_visibility();
|
||||
|
||||
@ -137,19 +135,14 @@ if ($mform->is_cancelled()) {
|
||||
unset($data->locked);
|
||||
unset($data->locktime);
|
||||
|
||||
$convert = array('grademax', 'grademin', 'gradepass', 'multfactor', 'plusfactor', 'weight');
|
||||
$convert = array('grademax', 'grademin', 'gradepass', 'multfactor', 'plusfactor', 'aggregationcoef', 'aggregationcoef2');
|
||||
foreach ($convert as $param) {
|
||||
if (property_exists($data, $param)) {
|
||||
$data->$param = unformat_float($data->$param);
|
||||
}
|
||||
}
|
||||
if (isset($data->weight)) {
|
||||
if ($parent_category->aggregation == GRADE_AGGREGATE_SUM) {
|
||||
$data->aggregationcoef2 = $data->weight / 100.0;
|
||||
} else if ($parent_category->aggregation == GRADE_AGGREGATE_WEIGHTED_MEAN) {
|
||||
$data->aggregationcoef = $data->weight;
|
||||
}
|
||||
unset($data->weight);
|
||||
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));
|
||||
|
@ -100,10 +100,10 @@ class edit_item_form extends moodleform {
|
||||
$mform->addElement('advcheckbox', 'weightoverride', get_string('adjustedweight', 'grades'));
|
||||
$mform->addHelpButton('weightoverride', 'weightoverride', 'grades');
|
||||
|
||||
$mform->addElement('text', 'weight', get_string('weight', 'grades'));
|
||||
$mform->addHelpButton('weight', 'weight', 'grades');
|
||||
$mform->setType('weight', PARAM_RAW);
|
||||
$mform->disabledIf('weight', 'weightoverride');
|
||||
$mform->addElement('text', 'aggregationcoef2', get_string('weight', 'grades'));
|
||||
$mform->addHelpButton('aggregationcoef2', 'weight', 'grades');
|
||||
$mform->setType('aggregationcoef2', PARAM_RAW);
|
||||
$mform->disabledIf('aggregationcoef2', 'weightoverride');
|
||||
|
||||
$mform->addElement('text', 'gradepass', get_string('gradepass', 'grades'));
|
||||
$mform->addHelpButton('gradepass', 'gradepass', 'grades');
|
||||
@ -291,17 +291,17 @@ class edit_item_form extends moodleform {
|
||||
$coefstring = 'aggregationcoefextrasum';
|
||||
$element =& $mform->createElement('checkbox', 'aggregationcoef', get_string($coefstring, 'grades'));
|
||||
} else {
|
||||
$element =& $mform->createElement('text', 'weight', get_string($coefstring, 'grades'));
|
||||
$element =& $mform->createElement('text', 'aggregationcoef', get_string($coefstring, 'grades'));
|
||||
}
|
||||
if ($mform->elementExists('parentcategory')) {
|
||||
$mform->insertElementBefore($element, 'parentcategory');
|
||||
} else {
|
||||
$mform->insertElementBefore($element, 'id');
|
||||
}
|
||||
$mform->addHelpButton('weight', $coefstring, 'grades');
|
||||
$mform->addHelpButton('aggregationcoef', $coefstring, 'grades');
|
||||
}
|
||||
|
||||
$mform->disabledIf('weight', 'parentcategory', 'eq', $parent_category->id);
|
||||
$mform->disabledIf('aggregationcoef', 'parentcategory', 'eq', $parent_category->id);
|
||||
}
|
||||
|
||||
// Remove fields used by natural weighting if the parent category is not using natural weighting.
|
||||
@ -309,8 +309,8 @@ class edit_item_form extends moodleform {
|
||||
if ($mform->elementExists('weightoverride')) {
|
||||
$mform->removeElement('weightoverride');
|
||||
}
|
||||
if ($mform->elementExists('weight')) {
|
||||
$mform->removeElement('weight');
|
||||
if ($mform->elementExists('aggregationcoef2')) {
|
||||
$mform->removeElement('aggregationcoef2');
|
||||
}
|
||||
}
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user