Skip to content
Browse files

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.
  • Loading branch information...
1 parent b3661ab commit d823a63db089e6607c4b708b2b8ef278ab1e99d2 @timhunt timhunt committed Apr 17, 2013
Showing with 35 additions and 0 deletions.
  1. +18 −0 mod/quiz/accessmanager.php
  2. +14 −0 mod/quiz/accessrule/accessrulebase.php
  3. +3 −0 mod/quiz/mod_form.php
View
18 mod/quiz/accessmanager.php
@@ -124,6 +124,24 @@ public static function get_browser_security_choices() {
}
/**
+ * 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.
*
* Note that the standard plugins do not use this mechanism, becuase all their
View
14 mod/quiz/accessrule/accessrulebase.php
@@ -257,6 +257,20 @@ public static function add_settings_form_fields(
}
/**
+ * 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.
*/
View
3 mod/quiz/mod_form.php
@@ -575,6 +575,9 @@ public function validation($data, $files) {
}
}
+ // Any other rule plugins.
+ $errors = quiz_access_manager::validate_settings_form_fields($errors, $data, $files, $this);
+
return $errors;
}
}

0 comments on commit d823a63

Please sign in to comment.
Something went wrong with that request. Please try again.