public function MultichoiceQuestion::getNodeProperties in Quiz 7.5
Same name and namespace in other branches
- 6.4 question_types/multichoice/multichoice.classes.inc \MultichoiceQuestion::getNodeProperties()
- 7.6 question_types/multichoice/multichoice.classes.inc \MultichoiceQuestion::getNodeProperties()
- 7 question_types/multichoice/multichoice.classes.inc \MultichoiceQuestion::getNodeProperties()
- 7.4 question_types/multichoice/multichoice.classes.inc \MultichoiceQuestion::getNodeProperties()
Implementation of getNodeProperties().
Overrides QuizQuestion::getNodeProperties
See also
QuizQuestion::getNodeProperties()
File
- question_types/
multichoice/ multichoice.classes.inc, line 332 - Multichoice classes.
Class
- MultichoiceQuestion
- Extension of QuizQuestion.
Code
public function getNodeProperties() {
if (isset($this->nodeProperties) && !empty($this->nodeProperties)) {
return $this->nodeProperties;
}
$props = parent::getNodeProperties();
$res_a = db_query('SELECT choice_multi, choice_random, choice_boolean FROM {quiz_multichoice_properties}
WHERE nid = :nid AND vid = :vid', array(
':nid' => $this->node->nid,
':vid' => $this->node->vid,
))
->fetchAssoc();
if (is_array($res_a)) {
$props = array_merge($props, $res_a);
}
// Load the answers.
$res = db_query('SELECT id, answer, answer_format, feedback_if_chosen, feedback_if_chosen_format,
feedback_if_not_chosen, feedback_if_not_chosen_format, score_if_chosen, score_if_not_chosen, weight
FROM {quiz_multichoice_answers}
WHERE question_nid = :question_nid AND question_vid = :question_vid
ORDER BY weight', array(
':question_nid' => $this->node->nid,
':question_vid' => $this->node->vid,
));
// Init array so it can be iterated even if empty.
$props['alternatives'] = array();
while ($res_arr = $res
->fetchAssoc()) {
$props['alternatives'][] = array(
'id' => $res_arr['id'],
'answer' => array(
'value' => $res_arr['answer'],
'format' => $res_arr['answer_format'],
),
'feedback_if_chosen' => array(
'value' => $res_arr['feedback_if_chosen'],
'format' => $res_arr['feedback_if_chosen_format'],
),
'feedback_if_not_chosen' => array(
'value' => $res_arr['feedback_if_not_chosen'],
'format' => $res_arr['feedback_if_not_chosen_format'],
),
'score_if_chosen' => $res_arr['score_if_chosen'],
'score_if_not_chosen' => $res_arr['score_if_not_chosen'],
'weight' => $res_arr['weight'],
);
}
$this->nodeProperties = $props;
return $props;
}