You are here

function quiz_report_form_validate in Quiz 8.4

Same name and namespace in other branches
  1. 6.4 quiz.pages.inc \quiz_report_form_validate()
  2. 7 quiz.pages.inc \quiz_report_form_validate()
  3. 7.4 quiz.pages.inc \quiz_report_form_validate()

Validate the report form

1 string reference to 'quiz_report_form_validate'
quiz_report_form in ./quiz.pages.inc
Form for showing feedback, and for editing the feedback if necessary...

File

./quiz.pages.inc, line 652
Page callback file for the quiz module.

Code

function quiz_report_form_validate($form, &$form_state) {

  /* We go through the form state values and validates all
   * questiontypes with validation functions declared.
   */
  foreach ($form_state['values'] as $key => $q_values) {

    // Questions has numeric keys in the report form
    if (!is_numeric($key)) {
      continue;
    }

    // Questions store the name of the validation function with the key 'validate'
    if (!isset($q_values['validate'])) {
      continue;
    }

    // The validation function must exist
    if (!function_exists($q_values['validate'])) {
      continue;
    }

    // We call the validation function provided by the question
    call_user_func($q_values['validate'], $q_values, $key);
  }
}