You are here

function _cloze_get_correct_answer_chunks in Cloze 6

Same name and namespace in other branches
  1. 7 cloze.module \_cloze_get_correct_answer_chunks()
3 calls to _cloze_get_correct_answer_chunks()
ClozeQuestion::evaluateAnswer in ./cloze.classes.inc
Evaluate the correctness of an answer based on the correct answer and evaluation method.
_cloze_get_correct_answer in ./cloze.module
_cloze_get_user_answer in ./cloze.module

File

./cloze.module, line 122

Code

function _cloze_get_correct_answer_chunks($question) {
  $correct_answer = array();
  $chunks = _cloze_get_question_chunks($question);
  foreach ($chunks as $key => $value) {
    if (strpos($value, '[') === FALSE) {
      continue;
    }
    else {
      $answer_chunk = str_replace(array(
        '[',
        ']',
      ), '', $value);
      $choice = explode(',', $answer_chunk);
      if (count($choice) == 1) {
        $correct_answer[$key] = $answer_chunk;
      }
      else {
        $correct_answer[$key] = $choice[0];
      }
    }
  }
  return $correct_answer;
}