aboutsummaryrefslogtreecommitdiff
path: root/app/views/vips/exercises/MatchingTask/correct.php
blob: 64faca600648a403db770cde8f784004b1f3cc4c (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
<?php
/**
 * @var Exercise $exercise
 * @var VipsSolution $solution
 * @var array $results
 * @var array $response
 * @var bool $show_solution
 */
?>
<? $exercise->sortAnswersById(); ?>

<table class="default description inline-content">
    <thead>
        <tr>
            <th>
                <?= _('Vorgegebener Text') ?>
            </th>

            <th>
                <?= _('Zugeordnete Antworten') ?>
            </th>

            <? if ($show_solution): ?>
                <th>
                    <?= _('Richtige Antworten') ?>
                </th>
            <? endif ?>
        </tr>
    </thead>

    <tbody>
        <? foreach ($exercise->task['groups'] as $i => $group) : ?>
            <tr style="vertical-align: top;">
                <td>
                    <div class="mc_item">
                        <?= formatReady($group) ?>
                    </div>
                </td>

                <td>
                    <? foreach ($exercise->task['answers'] as $answer): ?>
                        <? if (isset($response[$answer['id']]) && $response[$answer['id']] == $i): ?>
                            <div class="<?= $exercise->isCorrectAnswer($answer, $i) ? 'correct_item' : 'mc_item' ?>">
                                <?= formatReady($answer['text']) ?>

                                <? if ($exercise->isCorrectAnswer($answer, $i)): ?>
                                    <?= Icon::create('accept', Icon::ROLE_STATUS_GREEN)->asImg(['class' => 'correction_marker', 'title' => _('richtig')]) ?>
                                <? else: ?>
                                    <?= Icon::create('decline', Icon::ROLE_STATUS_RED)->asImg(['class' => 'correction_marker', 'title' => _('falsch')]) ?>
                                <? endif ?>
                            </div>
                        <? endif ?>
                    <? endforeach ?>
                </td>

                <? if ($show_solution): ?>
                    <td>
                        <? foreach ($exercise->correctAnswers($i) as $correct_answer): ?>
                            <div class="correct_item">
                                <?= formatReady($correct_answer) ?>
                            </div>
                        <? endforeach ?>
                    </td>
                <? endif ?>
            </tr>
        <? endforeach ?>
    </tbody>
</table>

<div class="label-text">
    <?= _('Nicht zugeordnete Antworten:') ?>
</div>

<? foreach ($exercise->task['answers'] as $answer): ?>
    <? if (!isset($response[$answer['id']]) || $response[$answer['id']] == -1): ?>
        <div class="inline-block inline-content <?= $exercise->isCorrectAnswer($answer, -1) ? 'correct_item' : 'mc_item' ?>">
            <?= formatReady($answer['text']) ?>

            <? if ($solution->id): ?>
                <? if ($exercise->isCorrectAnswer($answer, -1)): ?>
                    <?= Icon::create('accept', Icon::ROLE_STATUS_GREEN)->asImg(['class' => 'correction_inline', 'title' => _('richtig')]) ?>
                <? else: ?>
                    <?= Icon::create('decline', Icon::ROLE_STATUS_RED)->asImg(['class' => 'correction_inline', 'title' => _('falsch')]) ?>
                <? endif ?>
            <? endif ?>
        </div>
    <? endif ?>
<? endforeach ?>