function multichoice_calculate_results in Quiz 6.2
Same name and namespace in other branches
- 5.2 multichoice.module \multichoice_calculate_results()
- 5 multichoice.module \multichoice_calculate_results()
- 6.6 question_types/multichoice/multichoice.module \multichoice_calculate_results()
- 6.3 question_types/multichoice/multichoice.module \multichoice_calculate_results()
- 6.5 question_types/multichoice/multichoice.module \multichoice_calculate_results()
File
- ./
multichoice.module, line 794 - Multiple choice question type for the Quiz module.
Code
function multichoice_calculate_results($answers, $tried, $showpoints = FALSE, $showfeedback = FALSE) {
// Create results table.
$rows = array();
$correctanswers = array();
while (list($key, $answer) = each($answers)) {
$cols = array();
$cols[] = check_markup($answer['answer']);
if ($showpoints) {
$cols[] = $answer['is_correct'] == 0 ? theme_multichoice_unselected() : theme_multichoice_selected();
}
$selected = array_search($answer['answer_id'], $tried) !== FALSE;
$cols[] = $selected ? theme_multichoice_selected() : theme_multichoice_unselected();
if ($showfeedback) {
$cols[] = $selected ? '<div class="quiz_answer_feedback">' . check_markup($answer['feedback']) . '</div>' : '';
}
$rows[] = $cols;
if ($answer['is_correct'] > 0) {
$correctanswers[] = $answer['answer_id'];
}
}
if ($correctanswers === $tried) {
$score = 1;
}
else {
$score = 0;
}
return array(
'score' => $score,
'resultstable' => $rows,
);
}