You are here

function theme_quiz_progress in Quiz 7

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.6 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_quiz in ./quiz.module
Handles quiz taking.

File

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

Code

function theme_quiz_progress($variables) {
  $question_number = $variables['question_number'];
  $num_of_question = $variables['num_questions'];

  // TODO Number of parameters in this theme funcion does not match number of parameters found in hook_theme.
  // Determine the percentage finished (not used, but left here for other implementations).

  //$progress = ($question_number*100)/$num_of_question;

  // Get the current question # by adding one.
  $current_question = $question_number + 1;
  if ($variables['allow_jumping']) {
    $current_question = theme('quiz_jumper', array(
      'current' => $current_question,
      'num_questions' => $num_of_question,
    ));
  }
  $output = '';
  $output .= '<div id="quiz_progress">';
  $output .= t('Question <span id="quiz-question-number">!x</span> of <span id="quiz-num-questions">@y</span>', array(
    '!x' => $current_question,
    '@y' => $num_of_question,
  ));
  $output .= '</div>' . "\n";

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