public function MultichoiceResponse::__construct in Quiz 6.4
Same name and namespace in other branches
- 7.6 question_types/multichoice/multichoice.classes.inc \MultichoiceResponse::__construct()
- 7 question_types/multichoice/multichoice.classes.inc \MultichoiceResponse::__construct()
- 7.4 question_types/multichoice/multichoice.classes.inc \MultichoiceResponse::__construct()
- 7.5 question_types/multichoice/multichoice.classes.inc \MultichoiceResponse::__construct()
Constructor
Overrides QuizQuestionResponse::__construct
File
- question_types/
multichoice/ multichoice.classes.inc, line 703 - The main classes for the multichoice question type.
Class
- MultichoiceResponse
- Extension of QuizQuestionResponse
Code
public function __construct($result_id, stdClass $question_node, $tries = NULL) {
parent::__construct($result_id, $question_node, $tries);
$this->user_answer_ids = array();
// tries is the tries part of the post data
if (is_array($tries)) {
if (isset($tries['choice_order'])) {
$this->choice_order = $tries['choice_order'];
}
unset($tries['choice_order']);
if (is_array($tries['answer'])) {
foreach ($tries['answer'] as $answer_id) {
$this->user_answer_ids[] = $answer_id;
$this->answer = $this->user_answer_ids;
//@todo: Stop using user_answer_ids and only use answer instead...
}
}
elseif (isset($tries['answer'])) {
$this->user_answer_ids[] = $tries['answer'];
}
}
else {
$sql = 'SELECT answer_id
FROM {quiz_multichoice_user_answers} ua
LEFT OUTER JOIN {quiz_multichoice_user_answer_multi} uam ON(uam.user_answer_id = ua.id)
WHERE ua.result_id = %d AND ua.question_nid = %d AND ua.question_vid = %d';
$res = db_query($sql, $result_id, $this->question->nid, $this->question->vid);
while ($res_o = db_fetch_object($res)) {
$this->user_answer_ids[] = $res_o->answer_id;
}
}
}