You are here

function quiz_question_insert in Quiz 6.6

Same name and namespace in other branches
  1. 6.3 question_types/quiz_question/quiz_question.module \quiz_question_insert()
  2. 6.4 question_types/quiz_question/quiz_question.module \quiz_question_insert()
  3. 6.5 question_types/quiz_question/quiz_question.module \quiz_question_insert()
  4. 7 question_types/quiz_question/quiz_question.module \quiz_question_insert()

Implementation of hook_insert()

File

question_types/quiz_question/quiz_question.module, line 458
Quiz Question module. This module provides the basic facilities for adding quiz question types to a quiz. While you can create standard Quiz question types simply by implementing the appropriate hooks, this module provides a framework that makes…

Code

function quiz_question_insert($node) {
  _quiz_question_get_instance($node)
    ->save(TRUE);

  // If the form says this should be attached to a quiz, attach it.
  if (isset($node->quiz_id) && $node->quiz_id > 0) {
    $sql = 'INSERT INTO {quiz_node_relationship} (parent_nid, parent_vid, child_nid, child_vid, question_status)
        VALUES (%d, %d, %d, %d, %d)';
    db_query($sql, $node->quiz_id, $node->quiz_vid, $node->nid, $node->vid, QUESTION_ALWAYS);
  }
}