mirror of
https://github.com/moodle/moodle.git
synced 2025-08-05 00:46:50 +02:00
Merge branch 'MDL-36412-m23' of git://github.com/sammarshallou/moodle into MOODLE_23_STABLE
This commit is contained in:
commit
50dcac01eb
2 changed files with 33 additions and 2 deletions
|
@ -180,10 +180,41 @@ class editsection_form extends moodleform {
|
|||
// Conditions: Don't let them set dates which make no sense
|
||||
if (array_key_exists('availablefrom', $data) &&
|
||||
$data['availablefrom'] && $data['availableuntil'] &&
|
||||
$data['availablefrom'] > $data['availableuntil']) {
|
||||
$data['availablefrom'] >= $data['availableuntil']) {
|
||||
$errors['availablefrom'] = get_string('badavailabledates', 'condition');
|
||||
}
|
||||
|
||||
// Conditions: Verify that the grade conditions are numbers, and make sense.
|
||||
if (array_key_exists('conditiongradegroup', $data)) {
|
||||
foreach ($data['conditiongradegroup'] as $i => $gradedata) {
|
||||
if ($gradedata['conditiongrademin'] !== '' &&
|
||||
!is_numeric(unformat_float($gradedata['conditiongrademin']))) {
|
||||
$errors["conditiongradegroup[{$i}]"] = get_string('gradesmustbenumeric', 'condition');
|
||||
continue;
|
||||
}
|
||||
if ($gradedata['conditiongrademax'] !== '' &&
|
||||
!is_numeric(unformat_float($gradedata['conditiongrademax']))) {
|
||||
$errors["conditiongradegroup[{$i}]"] = get_string('gradesmustbenumeric', 'condition');
|
||||
continue;
|
||||
}
|
||||
if ($gradedata['conditiongrademin'] !== '' && $gradedata['conditiongrademax'] !== '' &&
|
||||
unformat_float($gradedata['conditiongrademax']) <= unformat_float($gradedata['conditiongrademin'])) {
|
||||
$errors["conditiongradegroup[{$i}]"] = get_string('badgradelimits', 'condition');
|
||||
continue;
|
||||
}
|
||||
if ($gradedata['conditiongrademin'] === '' && $gradedata['conditiongrademax'] === '' &&
|
||||
$gradedata['conditiongradeitemid']) {
|
||||
$errors["conditiongradegroup[{$i}]"] = get_string('gradeitembutnolimits', 'condition');
|
||||
continue;
|
||||
}
|
||||
if (($gradedata['conditiongrademin'] !== '' || $gradedata['conditiongrademax'] !== '') &&
|
||||
!$gradedata['conditiongradeitemid']) {
|
||||
$errors["conditiongradegroup[{$i}]"] = get_string('gradelimitsbutnoitem', 'condition');
|
||||
continue;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return $errors;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -332,7 +332,7 @@ abstract class moodleform_mod extends moodleform {
|
|||
continue;
|
||||
}
|
||||
if ($gradedata['conditiongrademin'] !== '' && $gradedata['conditiongrademax'] !== '' &&
|
||||
unformat_float($gradedata['conditiongrademax']) < unformat_float($gradedata['conditiongrademin'])) {
|
||||
unformat_float($gradedata['conditiongrademax']) <= unformat_float($gradedata['conditiongrademin'])) {
|
||||
$errors["conditiongradegroup[{$i}]"] = get_string('badgradelimits', 'condition');
|
||||
continue;
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue