function _cloze_get_question_chunks in Cloze 7
Same name and namespace in other branches
- 6 cloze.module \_cloze_get_question_chunks()
6 calls to _cloze_get_question_chunks()
- ClozeQuestion::getAnsweringForm in ./
cloze.classes.inc - Implementation of getAnsweringForm
- ClozeQuestion::getNodeView in ./
cloze.classes.inc - Implementation of getNodeView()
- ClozeResponse::getReportForm in ./
cloze.classes.inc - Implementation of getReportForm()
- _cloze_get_correct_answer in ./
cloze.module - _cloze_get_correct_answer_chunks in ./
cloze.module
File
- ./
cloze.module, line 99
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;
}