You are here

function theme_quiz_jumper in Quiz 7

Same name and namespace in other branches
  1. 8.4 quiz.pages.inc \theme_quiz_jumper()
  2. 6.4 quiz.pages.inc \theme_quiz_jumper()
  3. 7.4 quiz.pages.inc \theme_quiz_jumper()

@todo Please document this function.

See also

http://drupal.org/node/1354

1 theme call to theme_quiz_jumper()
theme_quiz_progress in ./quiz.pages.inc
Theme a progress indicator for use during a quiz.

File

./quiz.pages.inc, line 476
User pages.

Code

function theme_quiz_jumper($variables) {
  $current = $variables['current'];
  $num_questions = $variables['num_questions'];
  $output = '<select name="quiz-jumper" class="form-select" id="quiz-jumper">';
  for ($i = 1; $i <= $num_questions; $i++) {
    $extra = $i == $current ? ' selected="selected"' : '';
    $output .= '<option value="' . $i . '"' . $extra . '>' . $i . '</option>';
  }
  $output .= '</select><span id="quiz-jumper-no-js">' . $current . '</span>';
  drupal_add_js("\n    Drupal.behaviors.quizJumper = function () {\n      \$('#quiz-jumper:not(.quizJumper-processed)').show().addClass('quizJumper-processed').change(function(){\n        \$('#edit-jump-to-question').val(\$(this).val());\n        \$('#edit-submit').trigger('click');\n      });\n      \$('#quiz-jumper-no-js:not(.quizJumper-processed)').hide().addClass('quizJumper-processed');\n    };\n  ", array(
    'type' => 'inline',
    'scope' => JS_DEFAULT,
  ));
  return $output;
}