You are here

function theme_quiz_progress in Quiz 7.6

Same name and namespace in other branches
  1. 8.6 quiz.theme.inc \theme_quiz_progress()
  2. 8.4 quiz.pages.inc \theme_quiz_progress()
  3. 8.5 quiz.theme.inc \theme_quiz_progress()
  4. 5.2 quiz.module \theme_quiz_progress()
  5. 5 quiz.module \theme_quiz_progress()
  6. 6.6 quiz.pages.inc \theme_quiz_progress()
  7. 6.2 quiz.pages.inc \theme_quiz_progress()
  8. 6.3 quiz.pages.inc \theme_quiz_progress()
  9. 6.4 quiz.pages.inc \theme_quiz_progress()
  10. 6.5 quiz.pages.inc \theme_quiz_progress()
  11. 7 quiz.pages.inc \theme_quiz_progress()
  12. 7.4 quiz.pages.inc \theme_quiz_progress()
  13. 7.5 quiz.theme.inc \theme_quiz_progress()

Theme a progress indicator for use during a quiz.

Parameters

$question_number: The position of the current question in the sessions' array.

$num_of_question: The number of questions for this quiz as returned by quiz_get_number_of_questions().

Return value

Themed html.

1 theme call to theme_quiz_progress()
quiz_take_question in ./quiz.module
Take a quiz questions.

File

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

Code

function theme_quiz_progress($variables) {
  drupal_add_js(drupal_get_path('module', 'quiz') . '/js/quiz.jumper.js');
  $output = '';
  $output .= '<div id="quiz-progress">';
  $text = 'Page <span id="quiz-question-number">!x</span> of <span id="quiz-num-questions">@y</span>';
  if ($variables['allow_jumping']) {

    // Show jump form.
    if ($variables['pager']) {
      $output .= theme('quiz_pager', array(
        'siblings' => variable_get('quiz_pager_siblings', 5),
        'current' => $variables['current'],
        'total' => count($variables['questions']),
      ));
    }
    else {
      $selectbox = drupal_get_form('quiz_jumper_form', $variables['questions'], $variables['current']);
      $output .= t($text, array(
        '!x' => drupal_render($selectbox),
        '@y' => count($variables['questions']),
      ));
    }
  }
  else {

    // Just text.
    $output .= t($text, array(
      '!x' => $variables['current'],
      '@y' => count($variables['questions']),
    ));
  }
  $output .= '</div>' . "\n";

  // Add div to be used by jQuery countdown
  if ($variables['time_limit']) {
    $output .= '<div class="countdown"></div>';
  }
  return $output;
}