You are here

function _qcollection_add_question_to_collection in Quiz 6.6

Add a question node to a qcollection

1 call to _qcollection_add_question_to_collection()
qcollection_add_question_action in includes/qcollection/qcollection.module
Callback function to copy a question node to one or more collections

File

includes/qcollection/qcollection.module, line 325
The main file for qcollection.

Code

function _qcollection_add_question_to_collection($question, $collections) {
  $weight = 0;

  // Now we add the question node to each collection
  // (Note that we are using a subselect to get the most recent vid of the qcollection.)
  $sql = "INSERT INTO {quiz_node_relationship} (parent_nid, parent_vid, child_nid, child_vid, question_status, weight)\n      VALUES (%d, (SELECT vid FROM {node} WHERE nid = %d), %d, %d, %d, %d)";
  foreach (array_filter($collections) as $collection_nid) {
    db_query($sql, $collection_nid, $collection_nid, $question->nid, $question->vid, QUESTION_ALWAYS, $weight);
  }
}