function short_answer_get_answer in Quiz 6.4
Same name and namespace in other branches
- 8.4 question_types/short_answer/short_answer.module \short_answer_get_answer()
- 6.6 question_types/short_answer/short_answer.module \short_answer_get_answer()
- 6.3 question_types/short_answer/short_answer.module \short_answer_get_answer()
- 6.5 question_types/short_answer/short_answer.module \short_answer_get_answer()
- 7.6 question_types/short_answer/short_answer.module \short_answer_get_answer()
- 7 question_types/short_answer/short_answer.module \short_answer_get_answer()
- 7.4 question_types/short_answer/short_answer.module \short_answer_get_answer()
Get the answer for a question.
This stores a score for a short answer question and marks that question as having been evaluated.
Parameters
$question_nid: Node ID of question.
$question_vid: Version ID of question.
$result_id: Result ID for the quiz results.
Return value
Assoc array An array if successful, or FALSE if no result could be found. The array contains the following properties: <code> answer_id; // The answer ID answer; // The full text of the answer is_evaluated; // 0 if the question has not been evaluated, 1 if it has score; // The score the evaluator gave the user; this should be 0 if is_evaluated is 0. question_vid question_nid result_id </code>
1 call to short_answer_get_answer()
- short_answer_edit_score in question_types/
short_answer/ short_answer.admin.inc - Page handler for displaying a scoring form. This function is called directly from the menu router. It generates a form for scoring a quiz.
File
- question_types/
short_answer/ short_answer.module, line 216 - The main file for short_answer.
Code
function short_answer_get_answer($question_nid, $question_vid, $result_id) {
$sql = "SELECT sa.answer_id, sa.answer, sa.is_evaluated, sa.score, sa.question_vid, sa.question_nid, sa.result_id, sa.answer_feedback, rel.max_score AS rel_max_score, qt.max_score AS term_max_score, qnra.tid\n FROM {quiz_short_answer_user_answers} sa\n JOIN {quiz_node_results} qnr ON (sa.result_id = qnr.result_id)\n JOIN {quiz_node_results_answers} qnra ON (qnr.result_id = qnra.result_id AND sa.question_nid = qnra.question_nid AND sa.question_vid = qnra.question_vid)\n LEFT OUTER JOIN {quiz_node_relationship} rel ON (qnr.vid = rel.parent_vid AND rel.child_vid = sa.question_vid)\n LEFT OUTER JOIN {quiz_terms} qt ON qnr.nid = qt.nid AND qnr.vid = qt.vid AND qnra.tid = qt.tid\n WHERE sa.question_nid = %d AND sa.question_vid = %d AND sa.result_id = %d";
$results = db_query($sql, $question_nid, $question_vid, $result_id);
if (!$results) {
return FALSE;
}
$answer = db_fetch_object($results);
if ($answer->rel_max_score === NULL) {
$answer->rel_max_score = $answer->term_max_score;
}
return $answer;
}