private function MultichoiceResponse::orderAlternatives in Quiz 6.4
Same name and namespace in other branches
- 7.6 question_types/multichoice/multichoice.classes.inc \MultichoiceResponse::orderAlternatives()
- 7 question_types/multichoice/multichoice.classes.inc \MultichoiceResponse::orderAlternatives()
- 7.4 question_types/multichoice/multichoice.classes.inc \MultichoiceResponse::orderAlternatives()
- 7.5 question_types/multichoice/multichoice.classes.inc \MultichoiceResponse::orderAlternatives()
Order the alternatives according to the choice order stored in the database
Parameters
array $alternatives: The alternatives to be ordered
1 call to MultichoiceResponse::orderAlternatives()
- MultichoiceResponse::getReportFormResponse in question_types/
multichoice/ multichoice.classes.inc - Implementation of getReportFormResponse
File
- question_types/
multichoice/ multichoice.classes.inc, line 918 - The main classes for the multichoice question type.
Class
- MultichoiceResponse
- Extension of QuizQuestionResponse
Code
private function orderAlternatives(array &$alternatives) {
if (!$this->question->choice_random) {
return;
}
$sql = "SELECT choice_order\n FROM {quiz_multichoice_user_answers}\n WHERE result_id = %d AND question_nid = %d AND question_vid = %d";
$result = db_result(db_query($sql, $this->rid, $this->question->nid, $this->question->vid));
if (!$result) {
return;
}
$order = explode(',', $result);
$newAlternatives = array();
foreach ($order as $value) {
foreach ($alternatives as $alternative) {
if ($alternative['id'] == $value) {
$newAlternatives[] = $alternative;
break;
}
}
}
$alternatives = $newAlternatives;
}