You are here

function quiz_view in Quiz 7.6

Same name and namespace in other branches
  1. 5.2 quiz.module \quiz_view()
  2. 5 quiz.module \quiz_view()
  3. 6.6 quiz.module \quiz_view()
  4. 6.2 quiz.module \quiz_view()
  5. 6.3 quiz.module \quiz_view()
  6. 6.4 quiz.module \quiz_view()
  7. 6.5 quiz.module \quiz_view()
  8. 7 quiz.module \quiz_view()
  9. 7.4 quiz.module \quiz_view()
  10. 7.5 quiz.module \quiz_view()

Implements hook_view().

File

./quiz.module, line 919
quiz.module Main file for the Quiz module.

Code

function quiz_view($node) {

  // 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.
      $node->content['take'] = array(
        '#markup' => l(t('Start @quiz', array(
          '@quiz' => QUIZ_NAME,
        )), 'node/' . $node->nid . '/take', array(
          'attributes' => array(
            'class' => array(
              'quiz-start-link',
            ),
          ),
        )),
        '#weight' => 2,
      );
    }
  }
  else {
    $node->content['take'] = array(
      '#markup' => '<div class="quiz-not-available">' . $available . '</div>',
      '#weight' => 2,
    );
  }
  return $node;
}