function quiz_view in Quiz 7.4
Same name and namespace in other branches
- 5.2 quiz.module \quiz_view()
- 5 quiz.module \quiz_view()
- 6.6 quiz.module \quiz_view()
- 6.2 quiz.module \quiz_view()
- 6.3 quiz.module \quiz_view()
- 6.4 quiz.module \quiz_view()
- 6.5 quiz.module \quiz_view()
- 7.6 quiz.module \quiz_view()
- 7 quiz.module \quiz_view()
- 7.5 quiz.module \quiz_view()
File
- ./
quiz.module, line 1078 - Quiz Module
Code
function quiz_view($node, $view_mode) {
drupal_alter('quiz_view', $node, $view_mode);
node_invoke($node, 'prepare');
// Number of questions is needed on the statistics page.
$node->number_of_questions = $node->number_of_random_questions + _quiz_get_num_always_questions($node->vid);
$node->content['stats'] = array(
'#markup' => theme('quiz_view_stats', array(
'node' => $node,
)),
'#weight' => -1,
);
$available = quiz_availability($node);
if ($available === TRUE) {
// Check the permission before displaying start button.
if (user_access('access quiz')) {
// Add a link to the take tab as a button if this isn't a teaser view.
if ($view_mode !== 'teaser') {
$quiz_form = drupal_get_form('quiz_start_quiz_button_form', $node);
$node->content['take'] = array(
'#markup' => drupal_render($quiz_form),
'#weight' => 2,
);
}
else {
$node->content['take'] = array(
'#markup' => l(t('Start quiz'), 'node/' . $node->nid . '/take'),
'#weight' => 2,
);
}
}
}
else {
$node->content['take'] = array(
'#markup' => '<div class="quiz-not-available">' . $available . '</div>',
'#weight' => 2,
);
}
return $node;
}