MDL-54802 mod_quiz: Add validation to require passing grade greater than 0

This commit adds a form validation to prevent the creation of quizzes
using zero or null grade to pass when using require passing grade.
This commit is contained in:
Simey Lameze 2016-09-21 16:09:25 +08:00
parent 1f2744851f
commit 981356b23d
4 changed files with 34 additions and 1 deletions

View file

@ -533,6 +533,13 @@ class mod_quiz_mod_form extends moodleform_mod {
}
}
if (array_key_exists('completion', $data) && $data['completion'] == COMPLETION_TRACKING_AUTOMATIC) {
// Show an error if require passing grade was selected and the grade to pass was setted to 0.
if ($data['completionpass'] == 1 && (empty($data['gradepass']) || grade_floatval($data['gradepass']) == 0)) {
$errors['gradepass'] = get_string('gradetopassnotset', 'quiz');
}
}
// Check the boundary value is a number or a percentage, and in range.
$i = 0;
while (!empty($data['feedbackboundaries'][$i] )) {