aboutsummaryrefslogtreecommitdiff
path: root/lib/modules/CoreElearningInterface.php
blob: a5f71196a0c8863166ba9d63c4d292b5c2a2959d (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
131
132
133
134
135
136
137
138
139
140
141
142
143
<?php

/*
 *  Copyright (c) 2012  Rasmus Fuhse <fuhse@data-quest.de>
 *
 *  This program is free software; you can redistribute it and/or
 *  modify it under the terms of the GNU General Public License as
 *  published by the Free Software Foundation; either version 2 of
 *  the License, or (at your option) any later version.
 */

class CoreElearningInterface extends CorePlugin implements StudipModule
{
    /**
     * {@inheritdoc}
     */
    public function getIconNavigation($course_id, $last_visit, $user_id)
    {
        if (!Config::get()->ELEARNING_INTERFACE_ENABLE) {
            return null;
        }

        $sql = "SELECT COUNT(module_id) AS count,
                       COUNT(IF((chdate > IFNULL(b.visitdate, :threshold) AND a.module_type != 'crs'), module_id, NULL)) AS neue
                FROM object_contentmodules AS a
                LEFT JOIN object_user_visits AS b
                  ON b.object_id = a.object_id
                     AND b.user_id = :user_id
                     AND b.plugin_id = :plugin_id
                WHERE a.object_id = :course_id
                  AND a.module_type != 'crs'
                GROUP BY a.object_id";

        $statement = DBManager::get()->prepare($sql);
        $statement->bindValue(':user_id', $user_id);
        $statement->bindValue(':course_id', $course_id);
        $statement->bindValue(':threshold', $last_visit);
        $statement->bindValue(':plugin_id', $this->getPluginId());
        $statement->execute();
        $result = $statement->fetch(PDO::FETCH_ASSOC);
        if (!empty($result)) {
            $nav = new Navigation(_('Lernmodule'), 'dispatch.php/course/elearning/show');
            if ($result['neue']) {
                $nav->setImage(Icon::create('learnmodule', Icon::ROLE_ATTENTION), [
                    'title' => sprintf(
                        ngettext(
                            '%1$d Lernmodul, %2$d neues',
                            '%1$d Lernmodule, %2$d neue',
                            $result['count']
                        ),
                        $result['count'],
                        $result['neue']
                    )
                ]);
            } elseif ($result['count']) {
                $nav->setImage(Icon::create('learnmodule', Icon::ROLE_CLICKABLE), [
                    'title' => sprintf(
                        ngettext(
                            '%d Lernmodul',
                            '%d Lernmodule',
                            $result['count']
                        ),
                        $result['count']
                    )
                ]);
            }
            return $nav;
        }

        return null;
    }

    /**
     * {@inheritdoc}
     */
    public function getTabNavigation($course_id)
    {
        if (!Config::get()->ELEARNING_INTERFACE_ENABLE) {
            return null;
        }

        $navigation = new Navigation(_('Lernmodule'));
        $navigation->setImage(Icon::create('learnmodule', Icon::ROLE_INFO_ALT));
        $navigation->setActiveImage(Icon::create('learnmodule', Icon::ROLE_INFO));

        if (ObjectConnections::isObjectConnected($course_id)) {
            $elearning_nav = new Navigation(_('Lernmodule dieser Veranstaltung'), 'dispatch.php/course/elearning/show?seminar_id=' . $course_id);

            if (get_object_type($course_id, ['inst'])) {
                $elearning_nav->setTitle(_('Lernmodule dieser Einrichtung'));
            }

            $navigation->addSubNavigation('show', $elearning_nav);
        }

        if ($GLOBALS['perm']->have_studip_perm('tutor', $course_id)) {
            $navigation->addSubNavigation('edit', new Navigation(_('Lernmodule hinzufügen / entfernen'), 'dispatch.php/course/elearning/edit?seminar_id=' . $course_id));
        }

        return ['elearning' => $navigation];
    }

    /**
     * {@inheritdoc}
     */
    public function getMetadata()
    {
        return [
            'summary' => _('Zugang zu extern erstellten Lernmodulen'),
            'description' => _('Über diese Schnittstelle ist es möglich, '.
                'Selbstlerneinheiten, die in externen Programmen erstellt '.
                'werden, in Stud.IP zur Verfügung zu stellen. Ein häufig '.
                'angebundenes System ist ILIAS. Besteht eine Anbindung zu '.
                'einem ILIAS-System, haben Lehrende die Möglichkeit, in '.
                'ILIAS Selbstlerneinheiten zu erstellen und in Stud.IP '.
                'bereit zu stellen.'),
            'displayname' => _('Lernmodulschnittstelle'),
            'category' => _('Inhalte und Aufgabenstellungen'),
            'keywords' => _('Einbindung z. B. von ILIAS-Lerneinheiten;
                            Zugang zu externen Lernplattformen;
                            Aufgaben- und Test-Erstellung'),
            'icon' => Icon::create('learnmodule', Icon::ROLE_INFO),
            'icon_clickable' => Icon::create('learnmodule', Icon::ROLE_CLICKABLE),
            'descriptionshort' => _('Zugang zu extern erstellten Lernmodulen'),
            'descriptionlong' => _('Über diese Schnittstelle ist es möglich, Selbstlerneinheiten, '.
                                    'die in externen Programmen erstellt werden, in Stud.IP zur Verfügung '.
                                    'zu stellen. Ein häufig angebundenes System ist ILIAS. Besteht eine '.
                                    'Anbindung zu einem ILIAS-System, haben Lehrende die Möglichkeit, in '.
                                    'ILIAS Selbstlerneinheiten zu erstellen und in Stud.IP bereit zu stellen.')
        ];
    }

    public function isActivatableForContext(Range $context)
    {
        return Config::get()->ELEARNING_INTERFACE_ENABLE && $context->getRangeType() === 'course';
    }

    public function getInfoTemplate($course_id)
    {
        // TODO: Implement getInfoTemplate() method.
        return null;
    }
}