You are here

function theme_quiz_view_stats in Quiz 6.4

Same name and namespace in other branches
  1. 8.4 quiz.pages.inc \theme_quiz_view_stats()
  2. 7.6 quiz.pages.inc \theme_quiz_view_stats()
  3. 7 quiz.pages.inc \theme_quiz_view_stats()
  4. 7.4 quiz.pages.inc \theme_quiz_view_stats()
  5. 7.5 quiz.theme.inc \theme_quiz_view_stats()

Theme the stats on the views page

Parameters

$node: The quiz node

1 theme call to theme_quiz_view_stats()
quiz_view in ./quiz.module
Implementation of hook_view().

File

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

Code

function theme_quiz_view_stats($node) {

  // Fetch data
  $stats = array(
    array(
      'title' => t('Questions'),
      'data' => $node->number_of_questions,
    ),
  );
  if ($node->show_attempt_stats) {
    $takes = $node->takes == 0 ? t('Unlimited') : $node->takes;
    $stats[] = array(
      'title' => t('Attempts allowed'),
      'data' => $takes,
    );
  }
  if ($node->quiz_always) {
    $stats[] = array(
      'title' => t('Available'),
      'data' => t('Always'),
    );
  }
  else {
    $stats[] = array(
      'title' => t('Opens'),
      'data' => format_date($node->quiz_open, 'small'),
    );
    $stats[] = array(
      'title' => t('Closes'),
      'data' => format_date($node->quiz_close, 'small'),
    );
  }
  if (!empty($node->pass_rate)) {
    $stats[] = array(
      'title' => t('Pass rate'),
      'data' => $node->pass_rate . ' %',
    );
  }
  if (!empty($node->time_limit)) {
    $stats[] = array(
      'title' => t('Time limit'),
      'data' => _quiz_format_duration($node->time_limit),
    );
  }
  $stats[] = array(
    'title' => t('Backwards navigation'),
    'data' => $node->backwards_navigation ? t('Allowed') : t('Forbidden'),
  );

  // Format and output the data
  $out = '<table id="quiz-view-table">' . "\n";
  foreach ($stats as $stat) {
    $out .= '<tr><td class="quiz-view-table-title"><strong>' . $stat['title'] . ':</strong></td><td class="quiz-view-table-data"><em>' . $stat['data'] . '</em></td></tr>' . "\n";
  }
  $out .= '</table>' . "\n";
  return $out;
}