function multichoice_calculate_result in Quiz 5.2
Same name and namespace in other branches
- 5 multichoice.module \multichoice_calculate_result()
- 6.6 question_types/multichoice/multichoice.module \multichoice_calculate_result()
- 6.2 multichoice.module \multichoice_calculate_result()
- 6.3 question_types/multichoice/multichoice.module \multichoice_calculate_result()
- 6.5 question_types/multichoice/multichoice.module \multichoice_calculate_result()
Check if the user selected all the correct answers for this question.
Parameters
$answers: Array of answers.
$tried: Array of answer id's the user selected.
Return value
TRUE if the user selected exactly all of the correct answers, otherwise FALSE.
1 call to multichoice_calculate_result()
- multichoice_evaluate_question in ./
multichoice.module - Evaluate whether a question is correct.
File
- ./
multichoice.module, line 648 - Multiple choice question type for the Quiz module.
Code
function multichoice_calculate_result($nid, $vid, $tried) {
$answers = db_query("SELECT answer_id FROM {quiz_multichoice_answers} " . "WHERE nid = %d AND vid = %d AND is_correct = 1", $nid, $vid);
while ($answer = db_fetch_array($answers)) {
$correct_answers[] = $answer['answer_id'];
}
return array_values($correct_answers) === array_values($tried);
}