aboutsummaryrefslogtreecommitdiff
path: root/app/views/course/lti/index.php
blob: f28dc5e4e3b0069fe59a279c59420d6aea017123 (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
<?php
/**
 * @var Course_LtiController $controller
 * @var \LtiResourceLink[] $links
 * @var bool $edit_perm
 */
?>
<? if (empty($links)): ?>
    <?= MessageBox::info(_('Es sind keine LTI-Tools konfiguriert.')) ?>
<? endif ?>

<? foreach ($links as $link): ?>
    <?
    $launch_url = $link->getLaunchURL();
    $unfinished_deep_linking = !empty($link->options['unfinished_deep_linking']);
    $no_consent = !LtiToolPrivacySettings::countBySql(
        '`tool_id` = :tool_id AND `user_id` = :user_id',
        ['tool_id' => $link->deployment->tool_id, 'user_id' => $GLOBALS['user']->id]
    );
    ?>

    <article class="studip">
        <header>
            <h1>
                <?= htmlReady($link->title) ?>
                <?= $unfinished_deep_linking ? '(' . _('LTI Deep Linking noch nicht fertig eingerichtet') . ')' : '' ?>
            </h1>

            <? if ($edit_perm): ?>
                <nav>
                    <form action="" method="post">
                        <?= CSRFProtection::tokenTag() ?>
                        <? if ($link->position > 0): ?>
                            <?= Icon::create('arr_2up', Icon::ROLE_SORT)->asInput([
                                'formaction' => $controller->url_for('course/lti/move/' . $link->id . '/up'),
                                'title'      => _('Nach oben verschieben'),
                                'aria-label' => _('Nach oben verschieben')
                            ]) ?>
                        <? endif ?>
                        <? if ($link->position < count($links) - 1): ?>
                            <?= Icon::create('arr_2down', Icon::ROLE_SORT)->asInput([
                                'formaction' => $controller->url_for('course/lti/move/' . $link->id . '/down'),
                                'title'      => _('Nach unten verschieben'),
                                'aria-label' => _('Nach unten verschieben')
                            ]) ?>
                        <? endif ?>

                        <?
                        $menu = ActionMenu::get();
                        $show_admin_actions = $GLOBALS['perm']->have_studip_perm('tutor', $link->course_id);
                        if ($show_admin_actions) {
                            $menu->addLink(
                                $controller->url_for('lti/tool/index/' . $link->course_id . '/' . $link->deployment->tool_id, ['link_id' => $link->id]),
                                _('Konfiguration des LTI-Tools anzeigen'),
                                Icon::create('info-circle'),
                                ['data-dialog' => 'size=default']
                            );
                        }
                        $menu->addLink(
                            $controller->url_for('course/lti/consent/' . $link->id),
                            _('Datenschutzeinstellungen'),
                            Icon::create('privacy'),
                            ['data-dialog' => 'size=default']
                        );

                        if ($link->deployment->tool->isEditableByUser()) {
                            $menu->addLink(
                                $controller->url_for('lti/tool/edit/' . $link->course_id . '/' . $link->deployment->tool_id),
                                _('LTI-Tool konfigurieren'),
                                Icon::create('edit'),
                                ['data-dialog' => 'size=default']
                            );
                        }
                        if ($show_admin_actions) {
                            $menu->addLink(
                                sprintf(
                                    'javascript:void(STUDIP.Dialog.confirmAsPost(\'%s\', \'%s\'))',
                                    sprintf(_('Wollen Sie das LTI-Tool "%s" wirklich entfernen?'), $link->title),
                                    $controller->url_for('lti/tool/delete/' . $link->course_id . '/' . $link->deployment->tool_id)
                                ),
                                _('LTI-Tool entfernen'),
                                Icon::create('trash')
                            );
                        }
                        ?>
                        <?= $menu->render() ?>
                    </form>
                </nav>
            <? endif ?>
        </header>
        <section>
            <? if ($unfinished_deep_linking) : ?>
                <?= Studip\LinkButton::create(
                    _('Einrichtung abschließen'),
                    $controller->url_for('course/lti/select_link/' . $link->id, ['tool_id' => $link->deployment->tool_id]),
                    ['target' => '_blank']
                ) ?>
            <? elseif ($no_consent) : ?>
                <?= formatReady($link->description) ?>
                <p><?= _('Sie haben der Datenweitergabe an das LTI-Tool noch nicht zugestimmt und können es deswegen noch nicht nutzen.') ?></p>
                <?= Studip\LinkButton::create(
                    _('Datenschutzeinstellungen öffnen'),
                    $controller->url_for('course/lti/consent/' . $link->id),
                    ['data-dialog' => 'reload-on-close']
                ) ?>
            <? elseif ($launch_url) : ?>
                <?
                $document_target = $link->options['document_target'] ?? '';
                ?>
                <?= formatReady($link->description) ?>
                <? if ($document_target === 'iframe') : ?>
                    <iframe style="border: none; height: 640px; width: 100%;"
                            src="<?= $controller->link_for('course/lti/iframe/' . $link->id) ?>"></iframe>
                <? else : ?>
                    <?= Studip\LinkButton::create(
                        _('Anwendung starten'),
                        $controller->url_for('course/lti/iframe/' . $link->id),
                        ['target' => '_blank']
                    ) ?>
                <? endif ?>
            <? endif ?>
        </section>
    </article>
<? endforeach ?>