You are here

function theme_quiz_categorized_form in Quiz 7.4

Same name and namespace in other branches
  1. 8.6 quiz.theme.inc \theme_quiz_categorized_form()
  2. 8.4 quiz.admin.inc \theme_quiz_categorized_form()
  3. 8.5 quiz.theme.inc \theme_quiz_categorized_form()
  4. 6.4 quiz.admin.inc \theme_quiz_categorized_form()
  5. 7.6 quiz.admin.inc \theme_quiz_categorized_form()
  6. 7 quiz.admin.inc \theme_quiz_categorized_form()
  7. 7.5 quiz.theme.inc \theme_quiz_categorized_form()

Themes a categorized quiz form

File

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

Code

function theme_quiz_categorized_form($variables) {
  $form = $variables['form'];
  $output = '';
  $rows = array();
  foreach ($form as $key => &$existing) {
    if (!is_numeric($key)) {
      continue;
    }
    $cols = array();
    $cols[] = drupal_render($existing['name']);
    $cols[] = drupal_render($existing['number']);
    $cols[] = drupal_render($existing['max_score']);
    $cols[] = drupal_render($existing['remove']);
    $cols[] = drupal_render($existing['weight']);
    $rows[] = array(
      'data' => $cols,
      'class' => array(
        'draggable',
      ),
    );
  }
  if (!empty($rows)) {
    $header = array(
      t('Category'),
      t('Number of questions'),
      t('Max score per question'),
      t('Remove'),
      t('Weight'),
    );
    drupal_add_tabledrag('existing-terms', 'order', 'sibling', 'term-weight', NULL, NULL, TRUE);
    $output .= theme('table', array(
      'header' => $header,
      'rows' => $rows,
      'attributes' => array(
        'id' => 'existing-terms',
      ),
    ));
  }
  $output .= drupal_render_children($form);
  drupal_add_js("(function (\$) {\n     Drupal.behaviors.quiz_categorized = {\n     attach: function(context) {\n      \$('#browse-for-term:not(.quiz-processed)').click(function(event) {\n        event.preventDefault();\n        \$('#edit-term').focus().val('*').trigger('keyup');\n      }).addClass('quiz-processed');\n      \$('#edit-term').click(function(){\n        if (\$(this).val() == '*') {\n          \$(this).val('');\n        }\n      });\n    }};}(jQuery));", array(
    'type' => 'inline',
    'group' => JS_DEFAULT,
  ));
  return $output;
}