function theme_quiz_view in Quiz 5
Same name and namespace in other branches
- 5.2 quiz.module \theme_quiz_view()
- 6.6 quiz.pages.inc \theme_quiz_view()
- 6.2 quiz.pages.inc \theme_quiz_view()
- 6.3 quiz.pages.inc \theme_quiz_view()
- 6.5 quiz.pages.inc \theme_quiz_view()
Theme the node view for quizzes
File
- ./
quiz.module, line 486 - Quiz Module
Code
function theme_quiz_view($node, $teaser = FALSE, $page = FALSE) {
$output = '';
// Ouput quiz options
$output .= '<h3>' . t('@quiz Options', array(
'@quiz' => QUIZ_NAME,
)) . '</h3>';
$header = array(
t('# of Questions'),
t('Shuffle?'),
t('Number of takes'),
);
$shuffle = $node->shuffle == 1 ? t('Yes') : t('No');
$takes = $node->takes == 0 ? t('Unlimited') : check_plain($node->takes);
$rows = array();
$rows[] = array(
check_plain($node->number_of_questions),
$shuffle,
$takes,
);
$output .= theme('table', $header, $rows);
// Format Quiz Dates
$output .= '<h3>' . t('@quiz start/end', array(
'@quiz' => QUIZ_NAME,
)) . '</h3>';
if (!$node->quiz_always) {
// if we are previewing, make sure the dates are timestamps and not form arrays
if (is_array($node->quiz_open)) {
quiz_translate_form_date($node, 'quiz_open');
}
if (is_array($node->quiz_close)) {
quiz_translate_form_date($node, 'quiz_close');
}
// format the availability info
$output .= '<p>' . format_date($node->quiz_open) . ' — ' . format_date($node->quiz_close) . '</p>';
$output .= '<p><strong>' . t('Days @quiz live for: ', array(
'@quiz' => QUIZ_NAME,
)) . '</strong> ' . floor(($node->quiz_close - $node->quiz_open) / 60 / 60 / 24) . '</p>';
$remaining = floor(($node->quiz_close - time()) / 60 / 60 / 24);
$remaining = $remaining < 0 ? 'Expired' : $remaining;
$output .= '<p><strong>Days remaining:</strong> ' . $remaining . '</p>';
$elapsed = floor((time() - $node->quiz_open) / 60 / 60 / 24);
$elapsed = $elapsed < 0 ? -$elapsed . ' days to go' : $elapsed;
$output .= '<p><strong>Days since start:</strong> ' . $elapsed . '</p>';
}
else {
$output .= '<p>' . t('This Quiz is always available.') . '</p>' . "\n";
}
// Format taxonomy selection (if applicable)
if (function_exists(taxonomy_node_get_terms)) {
$output .= '<h3>' . t('Taxonomy selection') . '</h3>';
$terms = array();
foreach (taxonomy_node_get_terms($node->nid) as $term) {
$terms[] = check_plain($term->name);
}
if (!empty($terms)) {
$terms = implode(', ', $terms);
$output .= "<p>{$terms}</p>";
}
else {
$output .= '<p>' . t('No selected terms found') . '</p>';
}
}
// Format pass / fail and summary options
if ($node->pass_rate || $node->summary_default || $node->summary_pass) {
if ($node->pass_rate) {
$output .= '<h3>' . t('Pass / fail and summary options') . '</h3>' . "\n";
$output .= '<p><strong>' . t('Percentage needed to pass:') . '</strong> ' . check_plain($node->pass_rate) . '</p>' . "\n";
$output .= '<div><strong>' . t('Summary text if the user passed:') . '</strong> ';
$output .= $node->summary_pass ? check_markup($node->summary_pass) : t('No text defined.');
$output .= '</div>' . "\n";
}
$output .= '<div><strong>' . t('Default summary text:') . '</strong> ';
$output .= $node->summary_default ? check_markup($node->summary_default) : t('No text defined.');
$output .= '</div>' . "\n";
}
// Format quiz questions
if (is_numeric(arg(1))) {
$output .= '<h3>' . t('@quiz Questions', array(
'@quiz' => QUIZ_NAME,
)) . '</h3>';
$questions = _quiz_get_questions();
$output .= theme('quiz_question_table', $questions, $node->nid);
}
return $output;
}