You are here

function multichoice_calculate_result in Quiz 5

Same name and namespace in other branches
  1. 5.2 multichoice.module \multichoice_calculate_result()
  2. 6.6 question_types/multichoice/multichoice.module \multichoice_calculate_result()
  3. 6.2 multichoice.module \multichoice_calculate_result()
  4. 6.3 question_types/multichoice/multichoice.module \multichoice_calculate_result()
  5. 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

File

./multichoice.module, line 412
Multiple choice question type for quiz module

Code

function multichoice_calculate_result($answers, $tried) {
  if (empty($answers) || empty($tried)) {
    return FALSE;
  }
  foreach ($answers as $answer) {
    if ($answer['points'] == 1) {
      $correctanswers[] = $answer['aid'];
    }
  }
  return $correctanswers === $tried ? TRUE : FALSE;
}