Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

MDL-37114 quiz form validation: feedback boundaries.

The feedback boundaries must either be a number or a percentage.
We were not correctly validating the non-percentage case.
  • Loading branch information...
commit 29c1067b683ab76756fbb59005992ee284b011cc 1 parent 041a234
Joseph Rezeau authored timhunt committed
Showing with 10 additions and 5 deletions.
  1. +10 −5 mod/quiz/mod_form.php
View
15 mod/quiz/mod_form.php
@@ -470,11 +470,16 @@ public function validation($data, $files) {
$i = 0;
while (!empty($data['feedbackboundaries'][$i] )) {
$boundary = trim($data['feedbackboundaries'][$i]);
- if (strlen($boundary) > 0 && $boundary[strlen($boundary) - 1] == '%') {
- $boundary = trim(substr($boundary, 0, -1));
- if (is_numeric($boundary)) {
- $boundary = $boundary * $data['grade'] / 100.0;
- } else {
+ if (strlen($boundary) > 0) {
+ if ($boundary[strlen($boundary) - 1] == '%') {
+ $boundary = trim(substr($boundary, 0, -1));
+ if (is_numeric($boundary)) {
+ $boundary = $boundary * $data['grade'] / 100.0;
+ } else {
+ $errors["feedbackboundaries[$i]"] =
+ get_string('feedbackerrorboundaryformat', 'quiz', $i + 1);
+ }
+ } else if (!is_numeric($boundary)) {
$errors["feedbackboundaries[$i]"] =
get_string('feedbackerrorboundaryformat', 'quiz', $i + 1);
}
Please sign in to comment.
Something went wrong with that request. Please try again.