You are here

function ClozeQuestion::_answerJs in Cloze 7

1 call to ClozeQuestion::_answerJs()
ClozeQuestion::getAnsweringForm in ./cloze.classes.inc
Implementation of getAnsweringForm

File

./cloze.classes.inc, line 128
The main classes for the cloze question type. These inherit or implement code found in quiz_question.classes.inc.

Class

ClozeQuestion
Extension of QuizQuestion.

Code

function _answerJs($question) {
  $answers = array();
  $chunks = _cloze_get_correct_answer_chunks($question);
  foreach ($chunks as $key => $chunk) {
    $id = 'answer-' . $key;
    $answers[$id] = $chunk;
  }
  foreach ($chunks as $key => $chunk) {
    $key = $key - 1;
    $id = 'answer-' . $key;
    $answers_alt[$id] = $chunk;
  }
  $answers = array_merge($answers, $answers_alt);
  drupal_add_js(array(
    'answer' => $answers,
  ), 'setting');
}