You are here

function theme_quiz_user_summary in Quiz 8.4

Same name and namespace in other branches
  1. 5.2 quiz.module \theme_quiz_user_summary()
  2. 5 quiz.module \theme_quiz_user_summary()
  3. 6.6 quiz.pages.inc \theme_quiz_user_summary()
  4. 6.2 quiz.pages.inc \theme_quiz_user_summary()
  5. 6.3 quiz.pages.inc \theme_quiz_user_summary()
  6. 6.4 quiz.pages.inc \theme_quiz_user_summary()
  7. 6.5 quiz.pages.inc \theme_quiz_user_summary()
  8. 7 quiz.pages.inc \theme_quiz_user_summary()
  9. 7.4 quiz.pages.inc \theme_quiz_user_summary()

Theme the summary page for user results.

Parameters

$quiz: The quiz node object.

$questions: The questions array as defined by _quiz_get_answers.

$score: Array of score information as returned by quiz_calculate_score().

$summary: Filtered text of the summary.

Return value

Themed html.

1 theme call to theme_quiz_user_summary()
quiz_user_results in ./quiz.pages.inc
Show result page for a given result id

File

./quiz.pages.inc, line 1144
Page callback file for the quiz module.

Code

function theme_quiz_user_summary($variables) {
  $quiz = $variables['quiz'];
  $questions = $variables['questions'];
  $score = $variables['score'];
  $summary = $variables['summary'];
  $rid = $variables['rid'];

  // Set the title here so themers can adjust.
  drupal_set_title($quiz
    ->getTitle());
  if (!$score['is_evaluated']) {
    if (user_access('score taken quiz answer')) {
      $msg = t('Parts of this @quiz have not been evaluated yet. The score below is not final. <a class="self-score" href="!result_url">Click here</a> to give scores on your own.', array(
        '@quiz' => QUIZ_NAME,
        '!result_url' => url('node/' . $quiz
          ->id() . '/results/' . $rid),
      ));
    }
    else {
      $msg = t('Parts of this @quiz have not been evaluated yet. The score below is not final.', array(
        '@quiz' => QUIZ_NAME,
      ));
    }
  }

  // Display overall result.
  $output = '';
  $output .= '<div id="quiz_score_possible">' . t('You got %num_correct of %question_count possible points.', array(
    '%num_correct' => $score['numeric_score'],
    '%question_count' => $score['possible_score'],
  )) . '</div>';
  $output .= '<div id="quiz_score_percent">' . t('Your score was: @score %', array(
    '@score' => $score['percentage_score'],
  )) . '</div>';
  if (isset($summary['passfail'])) {
    $output .= '<div id="quiz_summary">' . $summary['passfail'] . '</div>' . "\n";
  }
  if (isset($summary['result'])) {
    $output .= '<div id="quiz_summary">' . $summary['result'] . '</div>' . "\n";
  }

  // Get the feedback for all questions.
  $form = drupal_get_form('quiz_report_form', $questions, FALSE, TRUE);
  $output .= drupal_render($form);
  return $output;
}