You are here

function theme_quiz_feedback in Quiz 6.6

Same name and namespace in other branches
  1. 5.2 quiz.module \theme_quiz_feedback()
  2. 5 quiz.module \theme_quiz_feedback()
  3. 6.2 quiz.pages.inc \theme_quiz_feedback()
  4. 6.3 quiz.pages.inc \theme_quiz_feedback()
  5. 6.5 quiz.pages.inc \theme_quiz_feedback()

Theme the question feedback.

Parameters

$questions: Array of quiz questions objects as returned by _quiz_get_answers.

showpoints: Binary flag for whether to show the actual answers or not.

$showfeedback: Binary flag for whether to show question feedback.

Return value

Themed html.

3 theme calls to theme_quiz_feedback()
theme_quiz_admin_summary in ./quiz.admin.inc
Theme the summary page for admins.
theme_quiz_take_summary in ./quiz.pages.inc
Theme the summary page after the quiz has been completed.
theme_quiz_user_summary in ./quiz.pages.inc
Theme the summary page for user results.

File

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

Code

function theme_quiz_feedback($questions, $showpoints = TRUE, $showfeedback = FALSE) {
  $header = array(
    format_plural(count($questions), t('Question Result'), t('Question Results')),
  );
  $rows = array();

  // Go through each of the questions.
  foreach ($questions as $question) {
    $cols = array();

    // Ask each question to render a themed report of how the user did.
    $module = quiz_module_for_type($question->type);
    $report = theme($module . '_report', $question, $showpoints, $showfeedback);

    // Only include reports with actual data:
    if (!empty($report) && strlen($report) > 0) {
      $cols[] = array(
        'data' => $report,
        'class' => 'quiz_summary_qrow',
      );

      // Get the score result for each question only if it's a scored quiz.
      if ($showpoints) {
        $theme = $question->correct ? 'quiz_score_correct' : 'quiz_score_incorrect';
        $cols[] = array(
          'data' => theme($theme),
          'class' => 'quiz_summary_qcell',
        );
      }

      // Pack all of this into a table row.
      $rows[] = array(
        'data' => $cols,
        'class' => 'quiz_summary_qrow',
      );
    }
  }
  return theme('table', $header, $rows);
}