mirror of
https://github.com/moodle/moodle.git
synced 2025-01-19 06:18:28 +01:00
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.
This commit is contained in:
parent
20751863e3
commit
26efb4888f
@ -522,11 +522,16 @@ class mod_quiz_mod_form extends moodleform_mod {
|
||||
$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);
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user