function theme_quiz_view_stats in Quiz 8.4
Same name and namespace in other branches
- 6.4 quiz.pages.inc \theme_quiz_view_stats()
- 7.6 quiz.pages.inc \theme_quiz_view_stats()
- 7 quiz.pages.inc \theme_quiz_view_stats()
- 7.4 quiz.pages.inc \theme_quiz_view_stats()
- 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_node_view in ./
quiz.module - Implements hook_node_view().
File
- ./
quiz.pages.inc, line 1216 - Page callback file for the quiz module.
Code
function theme_quiz_view_stats($variables) {
$node = $variables['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, 'short'),
);
$stats[] = array(
'title' => t('Closes'),
'data' => format_date($node->quiz_close, 'short'),
);
}
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;
}