You are here

function theme_quiz_view_stats in Quiz 7.5

Same name and namespace in other branches
  1. 8.4 quiz.pages.inc \theme_quiz_view_stats()
  2. 6.4 quiz.pages.inc \theme_quiz_view_stats()
  3. 7.6 quiz.pages.inc \theme_quiz_view_stats()
  4. 7 quiz.pages.inc \theme_quiz_view_stats()
  5. 7.4 quiz.pages.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
Implements hook_view().

File

./quiz.theme.inc, line 123
quiz.theme.inc Quiz theme functions.

Code

function theme_quiz_view_stats($variables) {
  $node = $variables['node'];

  // Fetch data.
  $stats = array(
    array(
      array(
        'header' => TRUE,
        'width' => '25%',
        'data' => t('Questions'),
      ),
      $node->number_of_questions,
    ),
  );
  if ($node->show_attempt_stats) {
    $takes = $node->takes == 0 ? t('Unlimited') : $node->takes;
    $stats[] = array(
      array(
        'header' => TRUE,
        'data' => t('Attempts allowed'),
      ),
      $takes,
    );
  }
  if ($node->quiz_always) {
    $stats[] = array(
      array(
        'header' => TRUE,
        'data' => t('Available'),
      ),
      t('Always'),
    );
  }
  else {
    $stats[] = array(
      array(
        'header' => TRUE,
        'data' => t('Opens'),
      ),
      format_date($node->quiz_open, 'short'),
    );
    $stats[] = array(
      array(
        'header' => TRUE,
        'data' => t('Closes'),
      ),
      format_date($node->quiz_close, 'short'),
    );
  }
  if (!empty($node->pass_rate)) {
    $stats[] = array(
      array(
        'header' => TRUE,
        'data' => t('Pass rate'),
      ),
      $node->pass_rate . ' %',
    );
  }
  if (!empty($node->time_limit)) {
    $stats[] = array(
      array(
        'header' => TRUE,
        'data' => t('Time limit'),
      ),
      _quiz_format_duration($node->time_limit),
    );
  }
  $stats[] = array(
    array(
      'header' => TRUE,
      'data' => t('Backwards navigation'),
    ),
    $node->backwards_navigation ? t('Allowed') : t('Forbidden'),
  );
  return theme('table', array(
    'attributes' => array(
      'id' => 'quiz-view-table',
    ),
    'rows' => $stats,
  ));
}