You are here

function _questions_in_quiz in Quiz 6.5

Same name and namespace in other branches
  1. 6.6 includes/questions_export/questions_export.admin.inc \_questions_in_quiz()
2 calls to _questions_in_quiz()
questions_export_submit_drupal in includes/questions_export/questions_export.admin.inc
questions_export_submit_moodle in includes/questions_export/questions_export.admin.inc
Exports questions to a GIFT file.

File

includes/questions_export/questions_export.admin.inc, line 154

Code

function _questions_in_quiz($quiz_nid) {
  $questions = array();
  $quiz_vid = db_result(db_query("SELECT vid FROM {node} WHERE nid = %d", $quiz_nid));

  // Get all the questions (ignore `question_status`)
  $sql = "SELECT child_nid as nid, child_vid as vid\n    FROM {quiz_node_relationship}\n    WHERE parent_vid = %d\n      AND parent_nid = %d\n    ORDER BY weight";
  $result = db_query($sql, $quiz_vid, $quiz_nid);
  while ($question_node_ids = db_fetch_array($result)) {

    // nid, vid
    $question_nodes[] = node_load($question_node_ids['vid']);

    // TODO do we need the version?
  }

  // OMG FIXME this loop is #bad if someone has a quiz with lot questions
  return $question_nodes;
}