You are here

function quiz_get_sub_questions in Quiz 7.6

Same name and namespace in other branches
  1. 8.6 quiz.module \quiz_get_sub_questions()
  2. 8.5 quiz.module \quiz_get_sub_questions()
  3. 7.5 quiz.module \quiz_get_sub_questions()

Get sub-questions.

1 call to quiz_get_sub_questions()
quiz_get_questions in ./quiz.module
Retrieve list of published questions assigned to quiz.

File

./quiz.module, line 3081
quiz.module Main file for the Quiz module.

Code

function quiz_get_sub_questions($qnr_pid, &$questions) {
  $query = db_select('node', 'n');
  $query
    ->fields('n', array(
    'nid',
    'type',
  ));
  $query
    ->fields('nr', array(
    'vid',
    'title',
  ));
  $query
    ->fields('qnr', array(
    'question_status',
    'weight',
    'max_score',
    'auto_update_max_score',
    'qnr_id',
    'qnr_pid',
  ));
  $query
    ->addField('n', 'vid', 'latest_vid');
  $query
    ->innerJoin('node_revision', 'nr', 'n.nid = nr.nid');
  $query
    ->innerJoin('quiz_node_relationship', 'qnr', 'nr.vid = qnr.child_vid');
  $query
    ->condition('qnr_pid', $qnr_pid);
  $query
    ->orderBy('weight');
  $result = $query
    ->execute();
  foreach ($result as $question) {
    $questions[] = $question;
  }
}