You are here

function quiz_settings_form_validate in Quiz 6.5

Same name and namespace in other branches
  1. 5.2 quiz.module \quiz_settings_form_validate()
  2. 5 quiz.module \quiz_settings_form_validate()
  3. 6.6 quiz.admin.inc \quiz_settings_form_validate()
  4. 6.2 quiz.admin.inc \quiz_settings_form_validate()
  5. 6.3 quiz.admin.inc \quiz_settings_form_validate()
  6. 6.4 quiz.admin.inc \quiz_settings_form_validate()
  7. 7.6 quiz.admin.inc \quiz_settings_form_validate()
  8. 7 quiz.admin.inc \quiz_settings_form_validate()
  9. 7.4 quiz.admin.inc \quiz_settings_form_validate()
  10. 7.5 quiz.admin.inc \quiz_settings_form_validate()

Validation of the Form Settings form.

Checks the values for the form administration form for quiz settings.

File

./quiz.admin.inc, line 662
Administrator interface for Quiz module.

Code

function quiz_settings_form_validate($form, &$form_state) {
  if (!is_numeric($form_state['values']['number_of_random_questions']) || $form_state['values']['number_of_random_questions'] < 0) {
    form_set_error('number_of_random_questions', t('The number of random questions must be at least 0.'));
  }
  if (!is_numeric($form_state['values']['quiz_default_close']) || $form_state['values']['quiz_default_close'] <= 0) {
    form_set_error('quiz_default_close', t('The default number of days before a quiz is closed must be a number greater than 0.'));
  }
  if (!is_numeric($form_state['values']['quiz_default_pass_rate'])) {
    form_set_error('quiz_default_pass_rate', t('The pass rate value must be a number between 0% and 100%.'));
  }
  if ($form_state['values']['quiz_default_pass_rate'] > 100) {
    form_set_error('quiz_default_pass_rate', t('The pass rate value must not be more than 100%.'));
  }
  if ($form_state['values']['quiz_default_pass_rate'] < 0) {
    form_set_error('quiz_default_pass_rate', t('The pass rate value must not be less than 0%.'));
  }
}