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

add escape syntax for cloze_exercise, fix white space in layout, fixes #136

parent 86ce32b3
No related branches found
No related tags found
No related merge requests found
......@@ -313,6 +313,7 @@ button.vips_file_upload:hover {
min-height: 36px;
min-width: 80px;
vertical-align: middle;
white-space: normal;
}
.cloze_drop.hover {
......
......@@ -370,15 +370,13 @@ class cloze_exercise extends Exercise
$answers[] = '*' . $answer['text'];
} else if ($answer['score'] == 0.5) {
$answers[] = '~' . $answer['text'];
} else if (preg_match('/^([":*~]|$)/', $answer['text'])) {
$answers[] = '"' . $answer['text'] . '"';
} else {
$answers[] = $answer['text'];
}
}
if (count($answers) === 1 && $answers[0] === '') {
$answers = [' '];
}
$blank = '[[' . $select . implode('|', $answers) . ']]';
if ($is_html) {
......@@ -435,6 +433,10 @@ class cloze_exercise extends Exercise
}
}
if (preg_match('/^"(.*)"$/', $answer, $matches)) {
$answer = $matches[1];
}
$answers[] = ['text' => $answer, 'score' => $points];
}
}
......
......@@ -5,20 +5,20 @@
<? if (isset($exercise->task['answers'][$blank])) : ?>
<? if ($solution->id): ?>
<? if ($results[$blank]['points'] == 1): ?>
--><span class="correct_item"><?= htmlReady($response[$blank]) ?>
<?= Icon::create('accept', 'status-green', ['class' => 'correction_inline', 'title' => _vips('richtig')]) ?><!--
--><span class="correct_item"><?= htmlReady($response[$blank]) ?><!--
--><?= Icon::create('accept', 'status-green', ['class' => 'correction_inline', 'title' => _vips('richtig')]) ?><!--
--></span><!--
<? elseif ($results[$blank]['points'] == 0.5): ?>
--><span class="fuzzy_item"><?= htmlReady($response[$blank]) ?>
<?= Icon::create('decline', 'status-yellow', ['class' => 'correction_inline', 'title' => _vips('fast richtig')]) ?><!--
--><span class="fuzzy_item"><?= htmlReady($response[$blank]) ?><!--
--><?= Icon::create('decline', 'status-yellow', ['class' => 'correction_inline', 'title' => _vips('fast richtig')]) ?><!--
--></span><!--
<? elseif (!$edit_solution || $results[$blank]['safe']): ?>
--><span class="wrong_item"><?= htmlReady($response[$blank]) ?>
<?= Icon::create('decline', 'status-red', ['class' => 'correction_inline', 'title' => _vips('falsch')]) ?><!--
--><span class="wrong_item"><?= htmlReady($response[$blank]) ?><!--
--><?= Icon::create('decline', 'status-red', ['class' => 'correction_inline', 'title' => _vips('falsch')]) ?><!--
--></span><!--
<? else: ?>
--><span class="wrong_item"><?= htmlReady($response[$blank]) ?>
<?= Icon::create('question', 'status-red', ['class' => 'correction_inline', 'title' => _vips('unbekannte Antwort')]) ?><!--
--><span class="wrong_item"><?= htmlReady($response[$blank]) ?><!--
--><?= Icon::create('question', 'status-red', ['class' => 'correction_inline', 'title' => _vips('unbekannte Antwort')]) ?><!--
--></span><!--
<? endif ?>
<? endif ?>
......
......@@ -16,9 +16,9 @@
<? endif ?>
<? elseif ($exercise->isSelect($blank)): ?>
<? foreach ($exercise->task['answers'][$blank] as $index => $option) : ?>
--><?= $index ? ' | ' : '' ?>
<?= Assets::img(vips_image_url('choice_unchecked.svg'), ['style' => 'vertical-align: text-bottom;']) ?>
<span style="border-bottom: 1px dotted black;"><?= htmlReady($option['text']) ?></span><!--
--><?= $index ? ' | ' : '' ?><!--
--><?= Assets::img(vips_image_url('choice_unchecked.svg'), ['style' => 'vertical-align: text-bottom;']) ?> <!--
--><span style="border-bottom: 1px dotted black;"><?= htmlReady($option['text']) ?></span><!--
<? endforeach ?>
<? else: ?>
--><?= str_repeat('__', $exercise->getInputWidth($blank)) ?><!--
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment