Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

Merge branch 'MDL-36412-m23' of git://github.com/sammarshallou/moodle…

… into MOODLE_23_STABLE
  • Loading branch information...
commit 50dcac01eb119fe7a70de128d6db37eebcc8d289 2 parents 1962821 + f84e58d
@danpoltawski danpoltawski authored
Showing with 33 additions and 2 deletions.
  1. +32 −1 course/editsection_form.php
  2. +1 −1  course/moodleform_mod.php
View
33 course/editsection_form.php
@@ -180,10 +180,41 @@ public function validation($data, $files) {
// 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;
}
}
View
2  course/moodleform_mod.php
@@ -332,7 +332,7 @@ function validation($data, $files) {
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;
}
Please sign in to comment.
Something went wrong with that request. Please try again.