You are here

function math_captcha_settings_form in CAPTCHA Pack 6

Same name and namespace in other branches
  1. 5 math_captcha/math_captcha.module \math_captcha_settings_form()
  2. 7 math_captcha/math_captcha.admin.inc \math_captcha_settings_form()

Math CAPTCHA settings form

1 string reference to 'math_captcha_settings_form'
math_captcha_menu in math_captcha/math_captcha.module
Implementation of hook_menu().

File

math_captcha/math_captcha.admin.inc, line 6

Code

function math_captcha_settings_form() {
  $form = array();
  $enabled_challenges = _math_captcha_enabled_challenges();
  $form['math_captcha_enabled_challenges'] = array(
    '#type' => 'checkboxes',
    '#title' => t('Enabled math challenges'),
    '#options' => array(
      'addition' => t('Addition: x + y = z'),
      'subtraction' => t('Subtraction: x - y = z'),
      'multiplication' => t('Multiplication: x * y = z'),
    ),
    '#default_value' => $enabled_challenges,
    '#description' => t('Select the math challenges you want to enable.'),
  );
  $form['math_captcha_textual_numbers'] = array(
    '#type' => 'checkbox',
    '#title' => t('Textual representation of numbers'),
    '#default_value' => variable_get('math_captcha_textual_numbers', TRUE),
    '#description' => t('When enabled, the numbers in the challenge will get a textual representation if available. E.g. "four" instead of "4".'),
  );
  $form['math_captcha_textual_operators'] = array(
    '#type' => 'checkbox',
    '#title' => t('Textual representation of operators'),
    '#default_value' => variable_get('math_captcha_textual_operators', FALSE),
    '#description' => t('When enabled, the operators in the challenge will get a textual representation if available. E.g. "plus" instead of "+".'),
  );

  // Addition challenge
  $form['math_captcha_addition'] = array(
    '#type' => 'fieldset',
    '#title' => t('Addition challenge: x + y = z'),
  );
  $form['math_captcha_addition']['math_captcha_addition_argmax'] = array(
    '#type' => 'textfield',
    '#title' => t('Maximum value for x and y'),
    '#default_value' => variable_get('math_captcha_addition_argmax', 10),
    '#maxlength' => 3,
    '#size' => 3,
  );
  $form['math_captcha_addition']['math_captcha_addition_allow_negative'] = array(
    '#type' => 'checkbox',
    '#title' => t('Allow negative values.'),
    '#default_value' => variable_get('math_captcha_addition_allow_negative', FALSE),
  );

  // subtraction challenge
  $form['math_captcha_subtraction'] = array(
    '#type' => 'fieldset',
    '#title' => t('Subtraction challenge: x - y = z'),
  );
  $form['math_captcha_subtraction']['math_captcha_subtraction_argmax'] = array(
    '#type' => 'textfield',
    '#title' => t('Maximum value for x and y'),
    '#default_value' => variable_get('math_captcha_subtraction_argmax', 10),
    '#maxlength' => 3,
    '#size' => 3,
  );
  $form['math_captcha_subtraction']['math_captcha_subtraction_allow_negative'] = array(
    '#type' => 'checkbox',
    '#title' => t('Allow negative values.'),
    '#default_value' => variable_get('math_captcha_subtraction_allow_negative', FALSE),
  );

  // multiplication challenge
  $form['math_captcha_multiplication'] = array(
    '#type' => 'fieldset',
    '#title' => t('Multiplication challenge: x * y = z'),
  );
  $form['math_captcha_multiplication']['math_captcha_multiplication_argmax'] = array(
    '#type' => 'textfield',
    '#title' => t('Maximum value for x and y'),
    '#default_value' => variable_get('math_captcha_multiplication_argmax', 5),
    '#maxlength' => 3,
    '#size' => 3,
  );
  $form['math_captcha_multiplication']['math_captcha_multiplication_allow_negative'] = array(
    '#type' => 'checkbox',
    '#title' => t('Allow negative values.'),
    '#default_value' => variable_get('math_captcha_multiplication_allow_negative', FALSE),
  );
  $form['#validate'] = array(
    'math_captcha_settings_form_validate',
  );

  // add buttons and return
  return system_settings_form($form);
}