function multichoice_get_report in Quiz 5.2
Same name and namespace in other branches
- 6.6 question_types/multichoice/multichoice.module \multichoice_get_report()
- 6.2 multichoice.module \multichoice_get_report()
- 6.3 question_types/multichoice/multichoice.module \multichoice_get_report()
- 6.5 question_types/multichoice/multichoice.module \multichoice_get_report()
Retrieve a full multichoice question with answers and user answers for reporting.
Parameters
$nid: The question node id.
$vid: The question node revision id.
$rid: The result id.
Return value
$question Question object with all available answers, and the user answers, and question properties.
File
- ./
multichoice.module, line 700 - Multiple choice question type for the Quiz module.
Code
function multichoice_get_report($nid, $vid, $rid) {
$result = db_query("SELECT *, " . "COALESCE((SELECT 1 FROM {quiz_multichoice_user_answers} ua WHERE question_nid = n.nid AND question_vid = n.vid AND result_id = %d AND ua.answer_id = ma.answer_id),0) as user_answer, " . "(SELECT is_correct FROM {quiz_node_results_answers} WHERE question_nid = n.nid AND question_vid = n.vid AND result_id = %d) as question_correct " . "FROM {node} n " . "LEFT JOIN {node_revisions} USING (nid, vid) " . "LEFT JOIN {quiz_multichoice_answers} ma USING (nid, vid) " . "WHERE n.nid = %d AND n.vid = %d", $rid, $rid, $nid, $vid);
if ($result) {
$question = new stdClass();
while ($next_row = db_fetch_array($result)) {
$row = $next_row;
$question->answers[$row['answer_id']] = $row;
}
$question->title = $row['title'];
$question->body = $row['body'];
$question->teaser = $row['teaser'];
$question->correct = $row['question_correct'];
$question->type = $row['type'];
}
return $question;
}