You are here

function quiz_insert in Quiz 6.4

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

Implementation of hook_insert().

1 call to quiz_insert()
quiz_update in ./quiz.module
Implementation of hook_update().

File

./quiz.module, line 591
Quiz Module

Code

function quiz_insert($node) {
  _quiz_save_user_settings($node);

  // Copy all the questions belonging to the quiz if this is a new translation.
  if ($node->is_new && isset($node->translation_source)) {
    quiz_copy_questions($node);
  }
  _quiz_common_presave_actions($node);
  $tid = isset($node->tid) ? $node->tid : 0;
  if (!isset($node->has_userpoints)) {
    $node->has_userpoints = 0;
  }
  $sql = "INSERT INTO {quiz_node_properties}\n    (vid, nid, aid, number_of_random_questions, randomization,\n    backwards_navigation, repeat_until_correct, quiz_open, quiz_close, takes,\n    show_attempt_stats, keep_results, time_limit, pass_rate, summary_pass,\n    summary_default, quiz_always, feedback_time, display_feedback, tid,\n    has_userpoints, allow_skipping, allow_resume, allow_jumping)\n    VALUES(%d, %d, '%s', %d, %d,\n    %d, %d, %d, %d, %d,\n    %d, %d, %d, %d, '%s',\n    '%s', %d, %d, %d, %d,\n    %d, %d, %d, %d)";

  // If the quiz is saved as not randomized we have to make sure that questions belonging to the quiz are saved as not random
  _quiz_check_num_random($node);
  _quiz_check_num_always($node);
  db_query($sql, $node->vid, $node->nid, $node->aid, $node->number_of_random_questions, $node->randomization, $node->backwards_navigation, $node->repeat_until_correct, $node->quiz_open, $node->quiz_close, $node->takes, $node->show_attempt_stats, $node->keep_results, $node->time_limit, $node->pass_rate, $node->summary_pass, $node->summary_default, $node->quiz_always, $node->feedback_time, $node->display_feedback, $tid, isset($node->has_userpoints) ? $node->has_userpoints : 0, $node->allow_skipping, $node->allow_resume, $node->allow_jumping);
  _quiz_insert_resultoptions($node);
  if (!isset($node->auto_created) && $node->revision == 0) {
    drupal_set_message(t('You just created a new quiz. Now you have to add questions to it. This page is for adding and managing questions. Here you can create new questions or add some of your already created questions. If you want to change the quiz settings, you can use the "edit" tab.'));
    $_REQUEST['destination'] = url("node/{$node->nid}/questions");
  }

  // If the quiz don't have any questions and have been created manually jump to
  // the manage questions tab.
  if (!isset($node->auto_created)) {
    _quiz_redirect_if_empty($node);
  }
}