Quiz Module persistance implementation details In which part of the code is a new quiz stored in the database? What are the functions responsible for storing a new quiz in the database upon the submission of the form for creating a new quiz?

I'm trying to accomplish two things:


Timer per question 
Dynamic question selection strategy


Quiz Module Version: 7.x-5.3
You need to be familiar with Drupal concepts like Nodes and Entities because they are used to model a Quiz.

The logic to keep the pieces synchronized is implemented via Hooks, like _hook_insert_ and _hook_update_, located on the quiz.module file.

Quiz 2.0 Architecture Information


  A Quiz is a Drupal node, and thus the node table contains a row for
  each Quiz. Similarly, a Question is also a Drupal node, so it too has
  an entry in the node table. Additional properties for Quizzes can be
  found in the rows of the quiz_node_properties table. Similarly, all
  question-types have a table called quiz_node_question_properties to
  store additional data. Each question-type also makes it's own set of
  tables to hold answers and user feedback. That means the
  multichoice.module question-type gets a quiz_multichoice_answers and a
  quiz_multichoice_user_answers.



From Community Documentation: Chapter 3 ~ Under The Hood


hook_insert

/**
 * Implements hook_insert().
 */
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-&gt;is_new &amp;&amp; isset($node-&gt;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-&gt;is_new &amp;&amp; isset($node-&gt;clone_from_original_nid)) {
    $old_quiz = node_load($node-&gt;clone_from_original_nid);

    $max_score = $old_quiz-&gt;max_score;

    $questions = quiz_get_questions($old_quiz-&gt;nid, $old_quiz-&gt;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);
}


hook_update

/**
 * Implements hook_update().
 */
function quiz_update($node) {
  // Quiz node vid (revision) was updated.
  if (isset($node-&gt;revision) &amp;&amp; $node-&gt;revision) {
    // Create new quiz-question relation entries in the quiz_node_relationship
    // table.
    quiz_update_quiz_question_relationship($node-&gt;old_vid, $node-&gt;vid, $node-&gt;nid);
    drupal_set_message(t('Some of the updated settings may not apply to quiz being taken already. To see all changes in action you need to start again.'), 'warning');
  }

  // Update an existing row in the quiz_node_properties table.
  _quiz_common_presave_actions($node);

  quiz_update_defaults($node);
  _quiz_update_resultoptions($node);

  _quiz_check_num_random($node);
  _quiz_check_num_always($node);
  quiz_update_max_score_properties(array($node-&gt;vid));
}