You are here

function quiz_update in Quiz 6.3

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

Implementation of hook_update().

File

./quiz.module, line 415
Quiz Module

Code

function quiz_update($node) {

  // Quiz node vid (revision) was updated.
  if ($node->revision) {

    // Insert a new row in the quiz_node_properties table.
    quiz_insert($node);

    // Create new quiz-question relation entries in the quiz_node_relationship table.
    quiz_update_quiz_question_relationship($node->old_vid, $node->vid, $node->nid);
  }
  else {

    // Update an existing row in the quiz_node_properties table.
    quiz_translate_form_date($node, 'quiz_open');
    quiz_translate_form_date($node, 'quiz_close');
    $sql = "UPDATE {quiz_node_properties}\n      SET vid = %d,\n        aid='%s',\n        shuffle = %d,\n        backwards_navigation = %d,\n        quiz_open = %d,\n        quiz_close = %d,\n        takes = %d,\n        time_limit = '%d',\n        pass_rate = %d,\n        summary_pass = '%s',\n        summary_default = '%s',\n        quiz_always = %d,\n        feedback_time = %d,\n        number_of_random_questions = %d,\n        has_userpoints = %d\n      WHERE vid = %d\n        AND nid = %d";
    $resource = db_query($sql, $node->vid, $node->aid, $node->shuffle, $node->backwards_navigation, $node->quiz_open, $node->quiz_close, $node->takes, $node->time_limit, $node->pass_rate, $node->summary_pass, $node->summary_default, $node->quiz_always, $node->feedback_time, $node->number_of_random_questions, $node->has_userpoints, $node->vid, $node->nid);

    // if (db_affected_rows($resource) == 0) {
    //       drupal_set_message('No quiz was found that could be modified.', 'status');
    //     }
  }
  _quiz_update_resultoptions($node);
}