public function MultichoiceQuestion::getNodeProperties in Quiz 6.4
Same name and namespace in other branches
- 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()
- 7.5 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 292 - The main classes for the multichoice question type.
Class
- MultichoiceQuestion
- Extension of QuizQuestion.
Code
public function getNodeProperties() {
if (isset($this->nodeProperties)) {
return $this->nodeProperties;
}
$props = parent::getNodeProperties();
// Load the properties
$sql = 'SELECT choice_multi, choice_random, choice_boolean
FROM {quiz_multichoice_properties}
WHERE nid = %d AND vid = %d';
$res = db_query($sql, $this->node->nid, $this->node->vid);
$res_a = db_fetch_array($res);
if (is_array($res_a)) {
$props = array_merge($props, $res_a);
}
// Load the answers
$sql = '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
FROM {quiz_multichoice_answers}
WHERE question_nid = %d AND question_vid = %d
ORDER BY id';
$res = db_query($sql, $this->node->nid, $this->node->vid);
$props['alternatives'] = array();
// init array so it can be iterated even if empty
while ($res_arr = db_fetch_array($res)) {
$props['alternatives'][] = $res_arr;
}
$this->nodeProperties = $props;
return $props;
}