You are here

function _multichoice_find_correct in Quiz 5.2

Same name and namespace in other branches
  1. 6.6 question_types/multichoice/multichoice.module \_multichoice_find_correct()
  2. 6.2 multichoice.module \_multichoice_find_correct()
  3. 6.3 question_types/multichoice/multichoice.module \_multichoice_find_correct()
  4. 6.5 question_types/multichoice/multichoice.module \_multichoice_find_correct()

Find the correct answers in an array of answers.

Parameters

$answers: An indexed array of answer choices.

Return value

The index of the first correct answer.

1 call to _multichoice_find_correct()
multichoice_form in ./multichoice.module
Implementation of hook_form().

File

./multichoice.module, line 264
Multiple choice question type for the Quiz module.

Code

function _multichoice_find_correct($answers) {
  if (is_array($answers)) {
    foreach ($answers as $id => $answer) {
      if ($answer['is_correct']) {
        return $id;
      }
    }
  }
  return 0;
}