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/elearning/LonCapaConnectedLink.php | |
| parent | da0022e5c1abbf9825ae76debaabdff7e8623bb4 (diff) | |
| parent | 97a188592c679890a25c37ab78463add76a52ff7 (diff) | |
Merge branch 'main' into issue-3911issue-3911
Diffstat (limited to 'lib/elearning/LonCapaConnectedLink.php')
| -rw-r--r-- | lib/elearning/LonCapaConnectedLink.php | 67 |
1 files changed, 67 insertions, 0 deletions
diff --git a/lib/elearning/LonCapaConnectedLink.php b/lib/elearning/LonCapaConnectedLink.php new file mode 100644 index 0000000..c00958b --- /dev/null +++ b/lib/elearning/LonCapaConnectedLink.php @@ -0,0 +1,67 @@ +<?php +/** + * + * This class contains methods to generate links to LonCapa + * + * @modulegroup elearning_interface_modules + * @module LonCapaConnectedLink + * @package ELearning-Interface + */ +class LonCapaConnectedLink extends ConnectedLink +{ + /** + * get user module links + * + * returns content module links for user + * @return string html-code + */ + public function getUserModuleLinks() + { + global $connected_cms, $current_module; + + $url = URLHelper::getURL('dispatch.php/loncapa/enter', ['cms_type' => $this->cms_type, 'module' => $current_module]); + + return Studip\LinkButton::create(_('Starten'), $url, [ + 'target' => '_blank', + 'rel' => 'noopener noreferrer', + ]); + } + + /** + * get admin module links + * + * returns links add or remove a module from course + * @return string returns html-code + */ + public function getAdminModuleLinks() + { + global $connected_cms, $view, $search_key, $cms_select, $current_module; + global $template_factory; + + $template = $template_factory->open('elearning/loncapa_connected_link_edit'); + $template->current_module = $connected_cms[$this->cms_type]->content_module[$current_module]->getId(); + $template->connected = $connected_cms[$this->cms_type]->content_module[$current_module]->isConnected(); + $template->cms_type = $this->cms_type; + $template->search_key = $search_key; + return $template->render(compact('view', 'search_key', 'cms_select', 'current_module')); + } + + /** + * returns url for connected LonCapa course + * + * @param string $module_id LonCapa ID + * @param string $course_id Stud.IP course ID + * @return string url for LonCapa + */ + public function getRedirectUrl($module_id, $course_id) + { + return sprintf( + '%s/enter/%s?token=%s&courseid=%s&systemid=%s', + $this->cms_link, + $module_id, + Token::create(60), + $course_id, + $this->cms_type + ); + } +} |
