You are here

function quiz_question_view in Quiz 6.4

Same name and namespace in other branches
  1. 6.6 question_types/quiz_question/quiz_question.module \quiz_question_view()
  2. 6.3 question_types/quiz_question/quiz_question.module \quiz_question_view()
  3. 6.5 question_types/quiz_question/quiz_question.module \quiz_question_view()
  4. 7.6 question_types/quiz_question/quiz_question.module \quiz_question_view()
  5. 7 question_types/quiz_question/quiz_question.module \quiz_question_view()
  6. 7.4 question_types/quiz_question/quiz_question.module \quiz_question_view()

Implementation of hook_view()

File

question_types/quiz_question/quiz_question.module, line 479
Quiz Question module. This module provides the basic facilities for adding quiz question types to a quiz.

Code

function quiz_question_view($node, $teaser = FALSE, $page = FALSE) {
  if ($node->build_mode == NODE_BUILD_SEARCH_INDEX && !variable_get('quiz_index_questions', 1)) {
    $node->body = '';
    $node->content = array();
    $node->title = '';
    $node->taxonomy = array();
    return $node;
  }
  $content = '';
  if ($teaser) {
    $content = _quiz_question_teaser_content($node);
  }
  elseif (_quiz_is_taking_context()) {

    /*
     * @todo: I see no reason why this should be a part of view anymore.
     * In quiz 5 we should stop using hook_view to view the answering form
     */
    $form_markup = drupal_get_form('quiz_question_answering_form', $node);
  }
  else {

    // normal node view
    $question = _quiz_question_get_instance($node, TRUE);
    $content = $question
      ->getNodeView();
  }

  // put it into the node->content
  if (!empty($content)) {
    if (isset($node->content)) {
      $node->content += $content;
    }
    else {
      $node->content = $content;
    }
  }
  if (!empty($form_markup)) {
    $node->content['body']['#value'] = $form_markup;
  }
  return $node;
}