You are here

function _quiz_get_summary_text in Quiz 6.6

Same name and namespace in other branches
  1. 8.4 quiz.module \_quiz_get_summary_text()
  2. 5.2 quiz.module \_quiz_get_summary_text()
  3. 5 quiz.module \_quiz_get_summary_text()
  4. 6.2 quiz.module \_quiz_get_summary_text()
  5. 6.3 quiz.module \_quiz_get_summary_text()
  6. 6.4 quiz.module \_quiz_get_summary_text()
  7. 6.5 quiz.module \_quiz_get_summary_text()
  8. 7.6 quiz.module \_quiz_get_summary_text()
  9. 7 quiz.module \_quiz_get_summary_text()
  10. 7.4 quiz.module \_quiz_get_summary_text()
  11. 7.5 quiz.module \_quiz_get_summary_text()

Get the summary message for a completed quiz.

Summary is determined by whether we are using the pass / fail options, how the user did, and whether this is being called from admin/quiz/[quizid]/view.

TODO: Need better feedback for when a user is viewing their quiz results from the results list (and possibily when revisiting a quiz they can't take again).

Parameters

$quiz: The quiz node object.

$score: The score information as returned by quiz_calculate_score().

Return value

Filtered summary text or null if we are not displaying any summary.

3 calls to _quiz_get_summary_text()
quiz_admin_results in ./quiz.admin.inc
Quiz Results Admin.
quiz_take_quiz in ./quiz.module
Handles quiz taking.
quiz_user_results in ./quiz.pages.inc

File

./quiz.module, line 2196
Quiz Module

Code

function _quiz_get_summary_text($quiz, $score) {
  if (!empty($score['result_option'])) {

    // Unscored quiz, return the proper result option.
    return $score['result_option'];
  }
  $admin = arg(3) == 'view';
  if ($quiz->pass_rate > 0) {
    $score_result = _quiz_pick_result_option($quiz->nid, $quiz->vid, $score['percentage_score']);
  }
  $summary = '';

  // If we are using pass/fail, and they passed.
  if ($quiz->pass_rate > 0 && $score['percentage_score'] >= $quiz->pass_rate) {

    // If we are coming from the admin view page.
    if ($admin) {
      $summary = t('The user passed this quiz.');
    }
    elseif (trim($quiz->summary_pass) != '') {
      $summary = !empty($score_result) ? $score_result : check_markup($quiz->summary_pass, $quiz->format, FALSE);
    }
  }
  else {

    // If we are coming from the admin view page,
    // only show a summary if we are using pass/fail.
    if ($admin) {
      if ($quiz->pass_rate > 0) {
        $summary = t('The user failed this quiz.');
      }
      else {
        $summary = t('the user completed this quiz.');
      }
    }
    elseif (trim($quiz->summary_default) != '') {
      $summary = !empty($score_result) ? $score_result : check_markup($quiz->summary_default, $quiz->format, FALSE);
    }
  }
  return $summary;
}