Skip to content
Snippets Groups Projects
Commit 99855b2a authored by Elmar Ludwig's avatar Elmar Ludwig
Browse files

allow `]]` in cloze_exercise, fixes #138

parent e8ac0cda
No related branches found
No related tags found
No related merge requests found
......@@ -369,7 +369,7 @@ class cloze_exercise extends Exercise
foreach ($this->task['answers'][$blank] as $answer) {
$answer_text = $answer['text'];
if (preg_match('/^([":*~]|$|.*\|)/', $answer_text)) {
if (preg_match('/^$|^[":*~]|\||\]\]/', $answer_text)) {
$answer_text = '"' . $answer_text . '"';
}
......@@ -406,7 +406,7 @@ class cloze_exercise extends Exercise
$question = Studip\Markup::purifyHtml($question);
// $question_array contains text elements and blanks (surrounded by [[ and ]]).
$parts = preg_split('/(\[\[.*?\]\])/s', $question, -1, PREG_SPLIT_DELIM_CAPTURE);
$parts = preg_split('/(\[\[(?:".*?"|.)*?\]\])/s', $question, -1, PREG_SPLIT_DELIM_CAPTURE);
foreach ($parts as $part) {
if (preg_match('/^\[\[(.*)\]\]$/s', $part, $matches)) {
......@@ -424,7 +424,7 @@ class cloze_exercise extends Exercise
}
if ($part !== '') {
preg_match_all('/( *[*~]?".*?" *|[^|]*)\|/', $part . '|', $matches);
preg_match_all('/((?:".*?"|[^|])*)\|/', $part . '|', $matches);
foreach ($matches[1] as $answer) {
$answer = trim($answer);
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment