You are here

function theme_quiz_jumper in Quiz 6.4

Same name and namespace in other branches
  1. 8.4 quiz.pages.inc \theme_quiz_jumper()
  2. 7 quiz.pages.inc \theme_quiz_jumper()
  3. 7.4 quiz.pages.inc \theme_quiz_jumper()
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 437
User pages.

Code

function theme_quiz_jumper($current, $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  ", 'inline');
  return $output;
}