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

force integer comparison for mc_exercise, fixes #259

parent 04aaf944
No related branches found
No related tags found
No related merge requests found
......@@ -108,10 +108,10 @@ class mc_exercise extends Exercise
$response = $solution->response;
foreach ($this->task['answers'] as $i => $answer) {
if ($response[$i] == '-1') {
if (!isset($response[$i])) {
$points = null;
} else {
$points = $response[$i] == $answer['score'] ? 1 : 0;
$points = (int) $response[$i] == $answer['score'] ? 1 : 0;
}
$result[] = ['points' => $points, 'safe' => true];
......
......@@ -9,8 +9,8 @@
<?= formatReady($entry['text']) ?>
<? if ($solution->id): ?>
<? if ($response[$key] == $entry['score']): ?>
<? if (isset($response[$key])): ?>
<? if ((int) $response[$key] == $entry['score']): ?>
<?= Icon::create('accept', 'status-green', ['class' => 'correction_marker', 'title' => _vips('richtig')]) ?>
<? else: ?>
<?= Icon::create('decline', 'status-red', ['class' => 'correction_marker', 'title' => _vips('falsch')]) ?>
......
......@@ -9,8 +9,8 @@
<?= formatReady($entry['text']) ?>
<? if ($solution->id && $print_correction): ?>
<? if ($response[$key] == $entry['score']): ?>
<? if (isset($response[$key]) && $print_correction): ?>
<? if ((int) $response[$key] == $entry['score']): ?>
<?= Icon::create('accept', 'status-green', ['class' => 'correction_marker', 'title' => _vips('richtig')]) ?>
<? else: ?>
<?= Icon::create('decline', 'status-red', ['class' => 'correction_marker', 'title' => _vips('falsch')]) ?>
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment