You are here

function og_quiz_node_view in OG Quiz 7

Implements hook_node_view().

File

./og_quiz.module, line 39
Module hooks and custom logic.

Code

function og_quiz_node_view($node, $view_mode, $langcode) {
  if ($node->type == 'quiz') {
    if (empty($node->content['take'])) {
      $available = quiz_availability($node);
      if ($available) {
        if (og_quiz_ogs_access($node, 'access quiz')) {
          if ($view_mode == 'full') {
            $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,
            );
          }
        }
      }
    }
  }
}