You are here

function _cloze_get_question_chunks in Quiz 8.4

6 calls to _cloze_get_question_chunks()
ClozeQuestion::getAnsweringForm in question_types/cloze/lib/Drupal/cloze/ClozeQuestion.php
Implementation of getAnsweringForm
ClozeQuestion::getNodeView in question_types/cloze/lib/Drupal/cloze/ClozeQuestion.php
Implementation of getNodeView()
ClozeResponse::getReportForm in question_types/cloze/lib/Drupal/cloze/ClozeResponse.php
Implementation of getReportForm()
_cloze_get_correct_answer in question_types/cloze/cloze.module
_cloze_get_correct_answer_chunks in question_types/cloze/cloze.module

... See full list

File

question_types/cloze/cloze.module, line 85

Code

function _cloze_get_question_chunks($question) {
  $chunks = array();
  while (strlen($question) > 0) {
    $match = FALSE;
    $pos = strpos($question, '[');
    if ($pos) {
      $substring = substr($question, 0, $pos);
      $question = preg_replace('/' . preg_quote($substring) . '/', '', $question, 1);
      $chunks[] = $substring;
      $match = TRUE;
    }
    $pos = strpos($question, ']');
    if ($pos !== FALSE) {
      $substring = substr($question, 0, $pos + 1);
      $question = preg_replace('/' . preg_quote($substring) . '/', '', $question, 1);
      $chunks[] = $substring;
      $match = TRUE;
    }
    if (!$match) {
      $chunks[] = $question;
      $question = '';
    }
  }
  return $chunks;
}