Add multichoice question to quiz node programmatically I'm using the latest version of drupal and quiz module. In my custom module, I have created a quiz by using below code 

 $quiz = new stdClass();
  $quiz-&gt;title = 'Testing Quiz';
  $quiz-&gt;type = 'quiz';
  $quiz-&gt;language = LANGUAGE_NONE;
  $quiz-&gt;uid = 1;
  $quiz-&gt;status = 1;
  node_object_prepare($quiz);
  $quiz = node_submit($quiz);
  node_save($quiz);


However, the quiz is created successfully. I have a list of multichoice question, which is imported using feeds module. Now what I want is assign those multichoice question to this custom quiz node. 

How can I do this?
Finally, I got the solution. The below code is used to add the multichoice question node to quiz node.

  $multichoice_node = node_load($nid); //load multichoice question nid  
  $multichoice_node-&gt;add_directly = array(
    'latest' =&gt; array(
      $quiz-&gt;nid. '-'. $quiz-&gt;vid =&gt; $quiz-&gt;nid. '-'. $quiz-&gt;vid
    )
  );
  node_save($multichoice_node);