You are here

function quiz_settings_form_validate in Quiz 6.6

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.2 quiz.admin.inc \quiz_settings_form_validate()
  4. 6.3 quiz.admin.inc \quiz_settings_form_validate()
  5. 6.4 quiz.admin.inc \quiz_settings_form_validate()
  6. 6.5 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.

1 string reference to 'quiz_settings_form_validate'
quiz_admin_settings in ./quiz.admin.inc
Implementation of hook_settings().

File

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

Code

function quiz_settings_form_validate($form, &$form_state) {
  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 (!is_numeric($form_state['values']['quiz_autotitle_length'])) {
    form_set_error('quiz_autotitle_length', t('The autotitle length value must be an integer between 0 and 128.'));
  }
  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%.'));
  }
  if ($form_state['values']['quiz_autotitle_length'] > 128) {
    form_set_error('quiz_autotitle_length', t('The autotitle length value must not be bigger than 128.'));
  }
  if ($form_state['values']['quiz_autotitle_length'] < 0) {
    form_set_error('quiz_autotitle_length', t('The autotitle length value must not be smaller than 0.'));
  }
}