mirror of
https://github.com/moodle/moodle.git
synced 2025-04-14 13:02:07 +02:00
MDL-19429 Validating 0 values for grademin, grademax and gradepass for the edit category form. Also checking for grademax < grademin case. Merged from MOODLE_19_STABLE
This commit is contained in:
parent
9e4c51ee4c
commit
5939e44447
@ -126,6 +126,18 @@ if ($mform->is_cancelled()) {
|
||||
if (!isset($itemdata->aggregationcoef)) {
|
||||
$itemdata->aggregationcoef = 0;
|
||||
}
|
||||
|
||||
if (!isset($itemdata->gradepass) || $itemdata->gradepass == '') {
|
||||
$itemdata->gradepass = 0;
|
||||
}
|
||||
|
||||
if (!isset($itemdata->grademax) || $itemdata->grademax == '') {
|
||||
$itemdata->grademax = 0;
|
||||
}
|
||||
|
||||
if (!isset($itemdata->grademin) || $itemdata->grademin == '') {
|
||||
$itemdata->grademin = 0;
|
||||
}
|
||||
|
||||
$hidden = empty($itemdata->hidden) ? 0: $itemdata->hidden;
|
||||
$hiddenuntil = empty($itemdata->hiddenuntil) ? 0: $itemdata->hiddenuntil;
|
||||
@ -154,16 +166,16 @@ if ($mform->is_cancelled()) {
|
||||
if (empty($grade_item->id)) {
|
||||
$grade_item->id = $grade_item_copy->id;
|
||||
}
|
||||
if (empty($grade_item->grademax)) {
|
||||
if (empty($grade_item->grademax) && $grade_item->grademax != '0') {
|
||||
$grade_item->grademax = $grade_item_copy->grademax;
|
||||
}
|
||||
if (empty($grade_item->grademin)) {
|
||||
if (empty($grade_item->grademin) && $grade_item->grademin != '0') {
|
||||
$grade_item->grademin = $grade_item_copy->grademin;
|
||||
}
|
||||
if (empty($grade_item->gradepass)) {
|
||||
if (empty($grade_item->gradepass) && $grade_item->gradepass != '0') {
|
||||
$grade_item->gradepass = $grade_item_copy->gradepass;
|
||||
}
|
||||
if (empty($grade_item->aggregationcoef)) {
|
||||
if (empty($grade_item->aggregationcoef) && $grade_item->aggregationcoef != '0') {
|
||||
$grade_item->aggregationcoef = $grade_item_copy->aggregationcoef;
|
||||
}
|
||||
|
||||
|
@ -1,4 +1,3 @@
|
||||
<<<<<<< category_form.php
|
||||
<?php //$Id$
|
||||
|
||||
///////////////////////////////////////////////////////////////////////////
|
||||
@ -461,6 +460,14 @@ class edit_category_form extends moodleform {
|
||||
$errors['grade_item_scaleid'] = get_string('missingscale', 'grades');
|
||||
}
|
||||
}
|
||||
if (array_key_exists('grade_item_grademin', $data) and array_key_exists('grade_item_grademax', $data)) {
|
||||
if (($data['grade_item_grademax'] != 0 OR $data['grade_item_grademin'] != 0) AND
|
||||
($data['grade_item_grademax'] == $data['grade_item_grademin'] OR
|
||||
$data['grade_item_grademax'] < $data['grade_item_grademin'])) {
|
||||
$errors['grade_item_grademin'] = get_string('incorrectminmax', 'grades');
|
||||
$errors['grade_item_grademax'] = get_string('incorrectminmax', 'grades');
|
||||
}
|
||||
}
|
||||
|
||||
return $errors;
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user