private function ChoiceResponse::orderAlternatives in Quiz 6.6
1 call to ChoiceResponse::orderAlternatives()
- ChoiceResponse::formatReport in question_types/
choice/ choice.classes.inc - Implementation of format report.
File
- question_types/
choice/ choice.classes.inc, line 740 - The main classes for the choice question type.
Class
- ChoiceResponse
- The short answer question response class.
Code
private function orderAlternatives(&$alternatives) {
if (!$this->question->choice_random) {
return;
}
$sql = "SELECT choice_order\n FROM {quiz_choice_user_answers}\n WHERE result_id = %d AND nid = %d AND vid = %d";
$res = db_query($sql, $this->rid, $this->question->nid, $this->question->vid);
$order = explode(',', db_result($res));
$newAlternatives = array();
foreach ($order as $value) {
foreach ($alternatives as $alternative) {
if ($alternative['id'] == $value) {
$newAlternatives[] = $alternative;
break;
}
}
}
$alternatives = $newAlternatives;
}