function _quiz_get_answers in Quiz 7
Same name and namespace in other branches
- 8.4 quiz.module \_quiz_get_answers()
- 5.2 quiz.module \_quiz_get_answers()
- 5 quiz.module \_quiz_get_answers()
- 6.6 quiz.module \_quiz_get_answers()
- 6.2 quiz.module \_quiz_get_answers()
- 6.3 quiz.module \_quiz_get_answers()
- 6.4 quiz.module \_quiz_get_answers()
- 6.5 quiz.module \_quiz_get_answers()
- 7.6 quiz.module \_quiz_get_answers()
- 7.4 quiz.module \_quiz_get_answers()
- 7.5 quiz.module \_quiz_get_answers()
Get answer data for a specific result.
Parameters
$rid: Result id.
Return value
Array of answers.
3 calls to _quiz_get_answers()
- quiz_admin_results in ./
quiz.admin.inc - Quiz result report page for the quiz admin section
- quiz_take_quiz in ./
quiz.module - Handles quiz taking.
- quiz_user_results in ./
quiz.pages.inc - Show result page for a given result id
File
- ./
quiz.module, line 3559 - Quiz Module
Code
function _quiz_get_answers($quiz, $rid) {
$questions = array();
$ids = db_query("SELECT question_nid, question_vid, type, rs.max_score, qt.max_score as term_max_score\n FROM {quiz_node_results_answers} ra\n LEFT JOIN {node} n ON (ra.question_nid = n.nid)\n LEFT JOIN {quiz_node_results} r ON (ra.result_id = r.result_id)\n LEFT OUTER JOIN {quiz_node_relationship} rs ON (ra.question_vid = rs.child_vid) AND rs.parent_vid = r.vid\n LEFT OUTER JOIN {quiz_terms} qt ON (qt.vid = :vid AND qt.tid = ra.tid)\n WHERE ra.result_id = :rid\n ORDER BY ra.number, ra.answer_timestamp", array(
':vid' => $quiz->vid,
':rid' => $rid,
));
while ($line = $ids
->fetch()) {
// Questions picked from term id's won't be found in the quiz_node_relationship table
if ($line->max_score === NULL) {
if ($quiz->randomization == 2 && isset($quiz->tid) && $quiz->tid > 0) {
$line->max_score = $quiz->max_score_for_random;
}
elseif ($quiz->randomization == 3) {
$line->max_score = $line->term_max_score;
}
}
$module = quiz_question_module_for_type($line->type);
if (!$module) {
continue;
}
// Invoke hook_get_report().
$report = module_invoke($module, 'get_report', $line->question_nid, $line->question_vid, $rid);
if (!$report) {
continue;
}
$questions[$line->question_nid] = $report;
// Add max score info to the question.
if (!isset($questions[$line->question_nid]->score_weight)) {
if ($questions[$line->question_nid]->max_score == 0) {
$score_weight = 0;
}
else {
$score_weight = $line->max_score / $questions[$line->question_nid]->max_score;
}
$questions[$line->question_nid]->qnr_max_score = $line->max_score;
$questions[$line->question_nid]->score_weight = $score_weight;
}
}
return $questions;
}