You are here

function quiz_admin_settings in Quiz 7.5

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

This builds the main settings form for the quiz module.

1 string reference to 'quiz_admin_settings'
quiz_menu in ./quiz.module
Implements hook_menu().

File

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

Code

function quiz_admin_settings($form, &$form_state) {
  $form = array();
  $form['quiz_global_settings'] = array(
    '#type' => 'fieldset',
    '#title' => t('Global configuration'),
    '#collapsible' => TRUE,
    '#collapsed' => TRUE,
    '#description' => t("Control aspects of the Quiz module's display"),
  );
  $form['quiz_global_settings']['quiz_auto_revisioning'] = array(
    '#type' => 'checkbox',
    '#title' => t('Auto revisioning'),
    '#default_value' => variable_get('quiz_auto_revisioning', 1),
    '#description' => t('It is strongly recommended that auto revisioning is always on. It makes sure that when a question or quiz is changed a new revision is created if the current revision has been answered. If this feature is switched off result reports might be broken because a users saved answer might be connected to a wrong version of the quiz and/or question she was answering. All sorts of errors might appear.'),
  );
  $form['quiz_global_settings']['quiz_durod'] = array(
    '#type' => 'checkbox',
    '#title' => t('Delete results when a user is deleted'),
    '#default_value' => variable_get('quiz_durod', 0),
    '#description' => t('When a user is deleted delete any and all results for that user.'),
  );
  $form['quiz_global_settings']['quiz_index_questions'] = array(
    '#type' => 'checkbox',
    '#title' => t('Index questions'),
    '#default_value' => variable_get('quiz_index_questions', 1),
    '#description' => t('If you turn this off, questions will not show up in search results. Note that you will need to enable the "View quiz question outside of a quiz" permission for anonymous users, as search needs this to index the question.'),
  );
  $form['quiz_global_settings']['quiz_default_close'] = array(
    '#type' => 'textfield',
    '#title' => t('Default number of days before a @quiz is closed', array(
      '@quiz' => QUIZ_NAME,
    )),
    '#default_value' => variable_get('quiz_default_close', 30),
    '#size' => 4,
    '#maxlength' => 4,
    '#description' => t('Supply a number of days to calculate the default close date for new quizzes.'),
  );
  $form['quiz_global_settings']['quiz_use_passfail'] = array(
    '#type' => 'checkbox',
    '#title' => t('Allow quiz creators to set a pass/fail option when creating a @quiz.', array(
      '@quiz' => strtolower(QUIZ_NAME),
    )),
    '#default_value' => variable_get('quiz_use_passfail', 1),
    '#description' => t('Check this to display the pass/fail options in the @quiz form. If you want to prohibit other quiz creators from changing the default pass/fail percentage, uncheck this option.', array(
      '@quiz' => QUIZ_NAME,
    )),
  );
  $form['quiz_global_settings']['quiz_max_result_options'] = array(
    '#type' => 'textfield',
    '#title' => t('Maximum result options'),
    '#description' => t('Set the maximum number of result options (categorizations for scoring a quiz). Set to 0 to disable result options.'),
    '#default_value' => variable_get('quiz_max_result_options', 5),
    '#size' => 2,
    '#maxlength' => 2,
    '#required' => FALSE,
  );
  $form['quiz_global_settings']['quiz_remove_partial_quiz_record'] = array(
    '#title' => t('Remove incomplete quiz records (older than)'),
    '#description' => t('Number of days to keep incomplete quiz attempts.'),
    '#default_value' => variable_get('quiz_remove_partial_quiz_record', 0),
    '#type' => module_exists('timeperiod') ? 'timeperiod_select' : 'textfield',
    '#units' => array(
      '86400' => array(
        'max' => 30,
        'step size' => 1,
      ),
      '3600' => array(
        'max' => 24,
        'step size' => 1,
      ),
      '60' => array(
        'max' => 60,
        'step size' => 1,
      ),
    ),
  );
  $form['quiz_global_settings']['quiz_remove_invalid_quiz_record'] = array(
    '#title' => t('Remove invalid quiz records (older than)'),
    '#description' => t('Number of days to keep invalid quiz attempts.'),
    '#default_value' => variable_get('quiz_remove_invalid_quiz_record', 86400),
    '#type' => module_exists('timeperiod') ? 'timeperiod_select' : 'textfield',
    '#units' => array(
      '86400' => array(
        'max' => 30,
        'step size' => 1,
      ),
      '3600' => array(
        'max' => 24,
        'step size' => 1,
      ),
      '60' => array(
        'max' => 60,
        'step size' => 1,
      ),
    ),
  );
  $form['quiz_global_settings']['quiz_autotitle_length'] = array(
    '#type' => 'textfield',
    '#title' => t('Length of automatically set question titles'),
    '#size' => 3,
    '#maxlength' => 3,
    '#description' => t("Integer between 0 and 128. If the question creator doesn't set a question title the system will make a title automatically. Here you can decide how long the autotitle can be."),
    '#default_value' => variable_get('quiz_autotitle_length', 50),
  );
  $form['quiz_global_settings']['quiz_pager_start'] = array(
    '#type' => 'textfield',
    '#title' => t('Pager start'),
    '#size' => 3,
    '#maxlength' => 3,
    '#description' => t('If a quiz has this many questions, a pager will be displayed instead of a select box.'),
    '#default_value' => variable_get('quiz_pager_start', 100),
  );
  $form['quiz_global_settings']['quiz_pager_siblings'] = array(
    '#type' => 'textfield',
    '#title' => t('Pager siblings'),
    '#size' => 3,
    '#maxlength' => 3,
    '#description' => t('Number of siblings to show.'),
    '#default_value' => variable_get('quiz_pager_siblings', 5),
  );
  $form['quiz_global_settings']['quiz_time_limit_buffer'] = array(
    '#type' => 'textfield',
    '#title' => t('Time limit buffer'),
    '#size' => 3,
    '#maxlength' => 3,
    '#description' => t('How many seconds after the time limit runs out to allow answers.'),
    '#default_value' => variable_get('quiz_time_limit_buffer', 5),
    '#element_validate' => array(
      'element_validate_integer',
    ),
  );

  // Review options.
  $review_options = quiz_get_feedback_options();
  $form['quiz_global_settings']['quiz_admin_review_options']['#title'] = t('Administrator review options');
  $form['quiz_global_settings']['quiz_admin_review_options']['#type'] = 'fieldset';
  $form['quiz_global_settings']['quiz_admin_review_options']['#description'] = t('Control what feedback types quiz administrators will see when viewing results for other users.');
  foreach (quiz_get_feedback_times() as $key => $when) {
    $form['quiz_global_settings']['quiz_admin_review_options']["quiz_admin_review_options_{$key}"] = array(
      '#title' => $when['name'],
      '#type' => 'checkboxes',
      '#options' => $review_options,
      '#default_value' => variable_get("quiz_admin_review_options_{$key}", array()),
    );
  }
  $target = array(
    'attributes' => array(
      'target' => '_blank',
    ),
  );
  $links = array(
    '!jquery_countdown' => l(t('JQuery Countdown'), 'http://drupal.org/project/jquery_countdown', $target),
  );
  $form['quiz_addons'] = array(
    '#type' => 'fieldset',
    '#title' => t('Addons configuration'),
    '#description' => t('Quiz has built in integration with some other modules. Disabled checkboxes indicates that modules are not enabled.', $links),
    '#collapsible' => TRUE,
    '#collapsed' => TRUE,
  );
  $form['quiz_addons']['quiz_has_timer'] = array(
    '#type' => 'checkbox',
    '#title' => t('Display timer'),
    '#default_value' => variable_get('quiz_has_timer', 0),
    '#description' => t("!jquery_countdown is an <strong>optional</strong> module for Quiz. It is used to display a timer when taking a quiz. Without this timer, the user will not know how much time they have left to complete the Quiz", $links),
    '#disabled' => !function_exists('jquery_countdown_add'),
  );
  $form['quiz_look_feel'] = array(
    '#type' => 'fieldset',
    '#title' => t('Look and feel'),
    '#collapsible' => TRUE,
    '#collapsed' => TRUE,
    '#description' => t("Control aspects of the Quiz module's display"),
  );
  $form['quiz_look_feel']['quiz_name'] = array(
    '#type' => 'textfield',
    '#title' => t('Display name'),
    '#default_value' => QUIZ_NAME,
    '#description' => t('Change the name of the quiz type. Do you call it <em>test</em> or <em>assessment</em> instead? Change the display name of the module to something else. By default, it is called <em>Quiz</em>.'),
    '#required' => TRUE,
  );
  $form['#validate'][] = 'quiz_settings_form_validate';
  $form['#submit'][] = 'quiz_settings_form_submit';
  return system_settings_form($form);
}