function quiz_insert in Quiz 7.5
Same name and namespace in other branches
- 5.2 quiz.module \quiz_insert()
- 5 quiz.module \quiz_insert()
- 6.6 quiz.module \quiz_insert()
- 6.2 quiz.module \quiz_insert()
- 6.3 quiz.module \quiz_insert()
- 6.4 quiz.module \quiz_insert()
- 6.5 quiz.module \quiz_insert()
- 7.6 quiz.module \quiz_insert()
- 7 quiz.module \quiz_insert()
- 7.4 quiz.module \quiz_insert()
Implements hook_insert().
File
- ./
quiz.module, line 672 - quiz.module Main file for the Quiz module.
Code
function quiz_insert($node) {
// Need to set max_score if this is a cloned node.
$max_score = 0;
// 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);
}
// Add references to all the questions belonging to the quiz if this is a
// cloned quiz (node_clone compatibility).
if ($node->is_new && isset($node->clone_from_original_nid)) {
$old_quiz = node_load($node->clone_from_original_nid);
$max_score = $old_quiz->max_score;
$questions = quiz_get_questions($old_quiz->nid, $old_quiz->vid);
quiz_set_questions($node, $questions);
}
_quiz_common_presave_actions($node);
// 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);
quiz_update_defaults($node);
_quiz_insert_resultoptions($node);
}