MDL-39167 quiz access rules: need to validate their settings.

We were missing the hook in the form validation method. We had them
everywhere else they were needed.
This commit is contained in:
Tim Hunt
2013-04-17 14:24:38 +01:00
parent b3661ab272
commit d823a63db0
3 changed files with 35 additions and 0 deletions
+18
View File
@@ -123,6 +123,24 @@ class quiz_access_manager {
return $options;
}
/**
* Validate the data from any form fields added using {@link add_settings_form_fields()}.
* @param array $errors the errors found so far.
* @param array $data the submitted form data.
* @param array $files information about any uploaded files.
* @param mod_quiz_mod_form $quizform the quiz form object.
* @return array $errors the updated $errors array.
*/
public static function validate_settings_form_fields(array $errors,
array $data, $files, mod_quiz_mod_form $this) {
foreach (self::get_rule_classes() as $rule) {
$errors = $rule::validate_settings_form_fields($errors, $data, $files, $this);
}
return $errors;
}
/**
* Save any submitted settings when the quiz settings form is submitted.
*
+14
View File
@@ -256,6 +256,20 @@ abstract class quiz_access_rule_base {
// By default do nothing.
}
/**
* Validate the data from any form fields added using {@link add_settings_form_fields()}.
* @param array $errors the errors found so far.
* @param array $data the submitted form data.
* @param array $files information about any uploaded files.
* @param mod_quiz_mod_form $quizform the quiz form object.
* @return array $errors the updated $errors array.
*/
public static function validate_settings_form_fields(array $errors,
array $data, $files, mod_quiz_mod_form $quizform) {
return $errors;
}
/**
* @return array key => lang string any choices to add to the quiz Browser
* security settings menu.
+3
View File
@@ -575,6 +575,9 @@ class mod_quiz_mod_form extends moodleform_mod {
}
}
// Any other rule plugins.
$errors = quiz_access_manager::validate_settings_form_fields($errors, $data, $files, $this);
return $errors;
}
}