public function ShortAnswerResponse::__construct in Quiz 7.6
Same name and namespace in other branches
- 6.6 question_types/short_answer/short_answer.classes.inc \ShortAnswerResponse::__construct()
- 6.3 question_types/short_answer/short_answer.classes.inc \ShortAnswerResponse::__construct()
- 6.4 question_types/short_answer/short_answer.classes.inc \ShortAnswerResponse::__construct()
- 6.5 question_types/short_answer/short_answer.classes.inc \ShortAnswerResponse::__construct()
- 7 question_types/short_answer/short_answer.classes.inc \ShortAnswerResponse::__construct()
- 7.4 question_types/short_answer/short_answer.classes.inc \ShortAnswerResponse::__construct()
- 7.5 question_types/short_answer/short_answer.classes.inc \ShortAnswerResponse::__construct()
Constructor
Overrides QuizQuestionResponse::__construct
File
- question_types/
short_answer/ short_answer.classes.inc, line 344 - The main classes for the short answer question type.
Class
- ShortAnswerResponse
- Extension of QuizQuestionResponse
Code
public function __construct($result_id, stdClass $question_node, $answer = NULL) {
parent::__construct($result_id, $question_node, $answer);
if (!isset($answer)) {
$r = db_query('SELECT answer_id, answer, is_evaluated, score, question_vid, question_nid, result_id, answer_feedback, answer_feedback_format
FROM {quiz_short_answer_user_answers}
WHERE question_nid = :qnid AND question_vid = :qvid AND result_id = :rid', array(
':qnid' => $question_node->nid,
':qvid' => $question_node->vid,
':rid' => $result_id,
))
->fetch();
if (!empty($r)) {
$this->answer = $r->answer;
$this->score = $r->score;
$this->evaluated = $r->is_evaluated;
$this->answer_id = $r->answer_id;
$this->answer_feedback = $r->answer_feedback;
$this->answer_feedback_format = $r->answer_feedback_format;
}
}
else {
if (is_array($answer)) {
$this->answer = $answer['answer'];
}
else {
$this->answer = $answer;
$this->evaluated = $this->question->correct_answer_evaluation != ShortAnswerQuestion::ANSWER_MANUAL;
}
}
}