function quiz_get_sub_questions in Quiz 8.5
Same name and namespace in other branches
- 8.6 quiz.module \quiz_get_sub_questions()
- 7.6 quiz.module \quiz_get_sub_questions()
- 7.5 quiz.module \quiz_get_sub_questions()
Get sub-questions.
1 call to quiz_get_sub_questions()
- Quiz::getQuestions in src/
Entity/ Quiz.php - Retrieve list of published questions assigned to quiz.
File
- ./
quiz.module, line 572 - Contains quiz.module
Code
function quiz_get_sub_questions($qqr_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',
'qqr_pid',
'child_nid',
'child_vid',
));
$query
->addField('n', 'vid', 'latest_vid');
$query
->innerJoin('node_revision', 'nr', 'n.nid = nr.nid');
$query
->innerJoin('quiz_question_relationship', 'qnr', 'nr.vid = qnr.child_vid');
$query
->condition('qqr_pid', $qqr_pid);
$query
->orderBy('weight');
$result = $query
->execute();
foreach ($result as $question) {
$questions[] = $question;
}
}