diff options
| author | Philipp Schüttlöffel <schuettloeffel@zqs.uni-hannover.de> | 2024-09-24 10:53:31 +0200 |
|---|---|---|
| committer | Philipp Schüttlöffel <schuettloeffel@zqs.uni-hannover.de> | 2024-09-24 10:53:31 +0200 |
| commit | 4459dd7917f4d1c34f40bb68f0e991e9c3d53e4c (patch) | |
| tree | 5c07151ae61276d334e88f6309c30d439a85c12e /lib/modules/CoreElearningInterface.php | |
| parent | da0022e5c1abbf9825ae76debaabdff7e8623bb4 (diff) | |
| parent | 97a188592c679890a25c37ab78463add76a52ff7 (diff) | |
Merge branch 'main' into issue-3911issue-3911
Diffstat (limited to 'lib/modules/CoreElearningInterface.php')
| -rw-r--r-- | lib/modules/CoreElearningInterface.php | 143 |
1 files changed, 143 insertions, 0 deletions
diff --git a/lib/modules/CoreElearningInterface.php b/lib/modules/CoreElearningInterface.php new file mode 100644 index 0000000..a5f7119 --- /dev/null +++ b/lib/modules/CoreElearningInterface.php @@ -0,0 +1,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; + } +} |
