aboutsummaryrefslogtreecommitdiff
path: root/app/views/questionnaire/_overview_questionnaire.php
blob: dc166a0d4177121955ebe6e3fa2bc94295186114 (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
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
<tr id="questionnaire_<?= $questionnaire->id ?>">
    <td>
        <input type="checkbox" name="q[]" value="<?= htmlReady($questionnaire->id) ?>">
    </td>
    <td>
        <a href="<?= $controller->link_for('questionnaire/answer/' . $questionnaire->id) ?>" data-dialog>
            <?= htmlReady($questionnaire['title']) ?>
        </a>
        <span>
        <?
            $icons = [];
            foreach ($questionnaire->questions as $question) {
                $class = get_class($question);
                $icons[$class] = $class::getIcon();
            }
            foreach ($icons as $class => $icon) {
                echo $icon->asImg(16, ['class' => 'text-bottom', 'title' => $class::getName()])." ";
            }
        ?>
        </span>
    </td>
    <td>
    <? if ($questionnaire['startdate']): ?>
        <?= date('d.m.Y H:i', $questionnaire['startdate']) ?>
    <? else: ?>
        <?= _('händisch') ?>
    <? endif; ?>
    </td>
    <td>
    <? if ($questionnaire['stopdate']): ?>
        <?= date('d.m.Y H:i', $questionnaire['stopdate']) ?>
    <? else: ?>
        <?= _('händisch') ?>
    <? endif; ?>
    </td>
    <td class="context">
    <? if (count($questionnaire->assignments) > 0) : ?>
        <ul class="clean">
        <? foreach ($questionnaire->assignments as $assignment) : ?>
            <li>
            <? if ($assignment['range_id'] === 'start') : ?>
                <?= _('Stud.IP Startseite')?>
            <? elseif ($assignment['range_id'] === 'public') : ?>
                <?= _('Öffentlich per Link')?>
            <? endif ?>

            <? if ($assignment['range_type'] === 'user') : ?>
                <?= _('Profilseite')?>
            <? elseif ($assignment['range_type'] === 'course') : ?>
                <?= htmlReady(Course::find($assignment['range_id'])->name) ?>
            <? elseif ($assignment['range_type'] === 'statusgruppe') : ?>
                <? $statusgruppe = Statusgruppen::find($assignment['range_id']) ?>
                <? if ($statusgruppe) : ?>
                    <?= $statusgruppe->course ? htmlReady($statusgruppe->course->name).":" : "" ?>
                    <?= $statusgruppe->institute ? htmlReady($statusgruppe->institute->name).":" : "" ?>
                    <?= htmlReady($statusgruppe->name) ?>
                <? endif ?>
            <? elseif ($assignment['range_type'] === 'institute') : ?>
                <?= htmlReady(Institute::find($assignment['range_id'])->name) ?>
            <? elseif ($assignment['range_type'] === 'plugin') : ?>
                <?= htmlReady(Institute::find($assignment['range_id'])->name) ?>
            <? else : ?>
                <?
                foreach (PluginManager::getInstance()->getPlugins("QuestionnaireAssignmentPlugin") as $plugin) {
                    $name = $plugin->getQuestionnaireAssignmentName($assignment);
                    if ($name) {
                        echo htmlReady($name);
                    }
                }
                ?>
            <? endif ?>
            </li>
        <? endforeach ?>
        </ul>
    <? else : ?>
        <?= _('Nirgendwo') ?>
    <? endif ?>
    </td>
    <td>
        <? $countedAnswers = $questionnaire->countAnswers() ?>
        <?= htmlReady($countedAnswers) ?>
    </td>
    <td class="actions">
    <? if ($questionnaire->isRunning() && $countedAnswers) : ?>
        <?= Icon::create('edit', 'inactive')->asImg(20, ['title' => _('Der Fragebogen wurde gestartet und kann nicht mehr bearbeitet werden.')]) ?>
    <? else : ?>
        <a href="<?= $controller->link_for('questionnaire/edit/' . $questionnaire->id) ?>" data-dialog title="<?= _('Fragebogen bearbeiten') ?>">
            <?= Icon::create('edit', 'clickable')->asImg(20) ?>
        </a>
    <? endif ?>
        <a href="<?= $controller->link_for('questionnaire/context/' . $questionnaire->id) ?>" data-dialog title="<?= _('Zuweisungen bearbeiten') ?>">
            <?= Icon::create('group2', 'clickable')->asImg(20) ?>
        </a>

        <?
        $menu = ActionMenu::get();
        if ($questionnaire->isRunning()) {
            $menu->addLink(
                $controller->url_for('questionnaire/stop/' . $questionnaire->id, in_array($range_type, ['course', 'institute']) ? ['redirect' => 'questionnaire/courseoverview'] : []),
                _('Fragebogen beenden'),
                Icon::create('pause', 'clickable')
            );
        } else {
            $menu->addLink(
                $controller->url_for('questionnaire/start/'  .$questionnaire->id, in_array($range_type, ['course', 'institute']) ? ['redirect' => 'questionnaire/courseoverview'] : []),
                _('Fragebogen starten'),
                Icon::create('play', 'clickable')
            );
        }
        $menu->addLink(
            $controller->url_for('questionnaire/evaluate/'  .$questionnaire->id),
            _('Auswertung'),
            Icon::create('stat', 'clickable'),
            ['data-dialog' => '']
        );
        $menu->addLink(
            $controller->url_for('questionnaire/export/'  .$questionnaire->id),
            _('Export als CSV'),
            Icon::create('file-excel', 'clickable')
        );
        $menu->addLink(
            $controller->url_for('questionnaire/delete/'  .$questionnaire->id),
            _('Fragebogen löschen'),
            Icon::create('trash', 'clickable'),
            ['data-confirm' => _('Wirklich löschen?')]
        );
        echo $menu->render();
        ?>
    </td>
</tr>