function _quiz_get_unused_questions in Quiz 6.5
Same name and namespace in other branches
- 5.2 quiz.module \_quiz_get_unused_questions()
- 6.6 quiz.module \_quiz_get_unused_questions()
- 6.2 quiz.module \_quiz_get_unused_questions()
- 6.3 quiz.module \_quiz_get_unused_questions()
Retrieve list of published questions not assigned to quiz.
@access public
Parameters
integer $quiz_nid:
Return value
array Array of questions objects.
File
- ./
quiz.module, line 2450 - Quiz Module
Code
function _quiz_get_unused_questions($quiz_vid = NULL, $nid_keys = FALSE) {
$quiz = menu_get_object();
$types = array_keys(_quiz_get_question_types());
$where_sql = '';
$questions = array();
if (count($types) > 0) {
$where_sql = "AND question.type IN ('" . implode("','", $types) . "')";
}
$result = db_query('SELECT DISTINCT question.nid, question.vid, question.type, nr.body, nr.format
FROM {node} question
LEFT JOIN {node_revisions} nr ON (question.nid = nr.nid)
WHERE question.status = 1
AND (question.vid NOT IN
(SELECT DISTINCT qnr.child_vid
FROM {quiz_node_relationship} qnr
WHERE qnr.parent_vid = %d
AND qnr.question_status != ' . QUESTION_NEVER . '))
' . $where_sql, $quiz_vid);
// Create questions array.
if ($nid_keys === FALSE) {
while ($node = db_fetch_object($result)) {
$questions[] = quiz_node_map($node);
}
}
else {
while ($node = db_fetch_object($result)) {
$n = quiz_node_map($node);
$questions[$n->nid] = $n;
}
}
return $questions;
}