You are here

function theme_quiz_categorized_form in Quiz 6.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. 7.6 quiz.admin.inc \theme_quiz_categorized_form()
  5. 7 quiz.admin.inc \theme_quiz_categorized_form()
  6. 7.4 quiz.admin.inc \theme_quiz_categorized_form()
  7. 7.5 quiz.theme.inc \theme_quiz_categorized_form()

File

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

Code

function theme_quiz_categorized_form($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' => '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', $header, $rows, array(
      'id' => 'existing-terms',
    ));
  }
  $output .= drupal_render($form);
  drupal_add_js("\n    Drupal.behaviors.quiz_categorized = function() {\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    };", 'inline');
  return $output;
}