ILIAS  release_7 Revision v7.30-3-g800a261c036
class.ilObjLearningSequenceLearnerGUI.php
Go to the documentation of this file.
1<?php declare(strict_types=1);
2
7{
8 const CMD_STANDARD = 'learnerView';
9 const CMD_EXTRO = 'learnerViewFinished';
10 const CMD_UNSUBSCRIBE = 'unsubscribe';
11 const CMD_VIEW = 'view';
12 const CMD_START = 'start';
13 const PARAM_LSO_NEXT_ITEM = 'lsoni';
14 const LSO_CMD_NEXT = 'lson';
15 const LSO_CMD_PREV = 'lsop';
16
17 public function __construct(
18 int $ls_ref_id,
19 $first_access,
20 int $usr_id,
21 ilAccess $access,
22 ilCtrl $ctrl,
25 ilToolbarGUI $toolbar,
26 ILIAS\UI\Factory $ui_factory,
27 ILIAS\UI\Renderer $ui_renderer,
30 ilLSCurriculumBuilder $curriculum_builder,
31 ilLSPlayer $player
32 ) {
33 $this->ls_object = $ls_object;
34 $this->ls_ref_id = $ls_ref_id;
35 $this->first_access = $first_access;
36 $this->usr_id = $usr_id;
37 $this->access = $access;
38 $this->ctrl = $ctrl;
39 $this->lng = $lng;
40 $this->tpl = $tpl;
41 $this->toolbar = $toolbar;
42 $this->ui_factory = $ui_factory;
43 $this->renderer = $ui_renderer;
44 $this->roles = $roles;
45 $this->settings = $settings;
46 $this->curriculum_builder = $curriculum_builder;
47 $this->player = $player;
48 }
49
50 public function executeCommand()
51 {
52 $cmd = $this->ctrl->getCmd();
53 switch ($cmd) {
55 case self::CMD_EXTRO:
56 $this->view($cmd);
57 break;
58 case self::CMD_START:
59 $this->addMember($this->usr_id);
60 $this->ctrl->redirect($this, self::CMD_VIEW);
61 break;
63 if ($this->userMayUnparticipate()) {
64 $this->roles->leave($this->usr_id);
65 }
66 $this->ctrl->redirect($this, self::CMD_STANDARD);
67 break;
68 case self::CMD_VIEW:
69 $this->play();
70 break;
71
74
75 // no break
76 default:
77 throw new ilException(
78 "ilObjLearningSequenceLearnerGUI: " .
79 "Command not supported: $cmd"
80 );
81 }
82 }
83
84 protected function view(string $cmd)
85 {
86 $this->initToolbar($cmd);
87
88 $content = $this->getMainContent($cmd);
89 $this->tpl->setContent(
90 $this->getWrappedHTML($content)
91 );
92
93 $curriculum = $this->curriculum_builder->getLearnerCurriculum();
94 if (count($curriculum->getSteps()) > 0) {
95 $this->tpl->setRightContent(
96 $this->getWrappedHTML([$curriculum])
97 );
98 }
99 }
100
101 protected function addMember(int $usr_id)
102 {
103 $admins = $this->roles->getLearningSequenceAdminIds();
104 if (!in_array($usr_id, $admins)) {
105 $this->roles->join($usr_id);
106 }
107 }
108
109
110 protected function userMayUnparticipate() : bool
111 {
112 return $this->access->checkAccess('unparticipate', '', $this->ls_ref_id);
113 }
114
115 protected function userMayJoin() : bool
116 {
117 return $this->access->checkAccess('participate', '', $this->ls_ref_id);
118 }
119
120 protected function initToolbar(string $cmd)
121 {
122 $is_member = $this->roles->isMember($this->usr_id);
123 $completed = $this->roles->isCompletedByUser($this->usr_id);
124
125 if (!$is_member) {
126 $may_subscribe = $this->userMayJoin();
127 if ($may_subscribe) {
128 $sub_button = ilLinkButton::getInstance();
129 $sub_button->setPrimary(true);
130 $sub_button->setCaption("lso_player_start");
131 $sub_button->setUrl($this->ctrl->getLinkTarget($this,self::CMD_START));
132 $this->toolbar->addButtonInstance($sub_button);
133 }
134 } else {
135 if (!$completed) {
136 $res_button = ilLinkButton::getInstance();
137 $res_button->setPrimary(true);
138 $res_button->setCaption("lso_player_resume");
139 if ($this->first_access === -1) {
140 $res_button->setCaption("lso_player_start");
141 }
142 $res_button->setUrl($this->ctrl->getLinkTarget($this, self::CMD_VIEW));
143 $this->toolbar->addButtonInstance($res_button);
144 } else {
145 $review_button = ilLinkButton::getInstance();
146 $review_button->setCaption("lso_player_review");
147 $review_button->setUrl($this->ctrl->getLinkTarget($this, self::CMD_VIEW));
148 $this->toolbar->addButtonInstance($review_button);
149
150 if ($cmd === self::CMD_STANDARD) {
151 $button = ilLinkButton::getInstance();
152 $button->setCaption("lso_player_extro");
153 $button->setUrl($this->ctrl->getLinkTarget($this, self::CMD_EXTRO));
154 $this->toolbar->addButtonInstance($button);
155 }
156 if ($cmd === self::CMD_EXTRO) {
157 $button = ilLinkButton::getInstance();
158 $button->setCaption("lso_player_abstract");
159 $button->setUrl($this->ctrl->getLinkTarget($this, self::CMD_STANDARD));
160 $this->toolbar->addButtonInstance($button);
161 }
162 }
163
164 $may_unsubscribe = $this->userMayUnparticipate();
165 if ($may_unsubscribe) {
166 $unsub_button = ilLinkButton::getInstance();
167 $unsub_button->setCaption("unparticipate");
168 $unsub_button->setUrl($this->ctrl->getLinkTarget($this, self::CMD_UNSUBSCRIBE));
169 $this->toolbar->addButtonInstance($unsub_button);
170 }
171 }
172 }
173
174 private function getWrappedHTML(array $components) : string
175 {
176 array_unshift(
177 $components,
178 $this->ui_factory->legacy('<div class="ilLSOLearnerView">')
179 );
180 $components[] = $this->ui_factory->legacy('</div>');
181
182 return $this->renderer->render($components);
183 }
184
185 private function getMainContent(string $cmd) : array
186 {
187 if ($cmd === self::CMD_STANDARD) {
188 $txt = $this->settings->getAbstract();
189 $img = $this->settings->getAbstractImage();
190 }
191
192 if ($cmd === self::CMD_EXTRO) {
193 $txt = $this->settings->getExtro();
194 $img = $this->settings->getExtroImage();
195 }
196
197 $contents = [$this->ui_factory->legacy($txt)];
198 if (!is_null($img)) {
199 $contents[] = $this->ui_factory->image()->responsive($img, '');
200 }
201
202 return $contents;
203 }
204
205 protected function play()
206 {
207 $response = $this->player->play($_GET, $_POST);
208
209 switch ($response) {
210 case null:
211 $this->tpl->enableDragDropFileUpload(null);
212 $this->tpl->setContent('THIS SHOULD NOT SHOW');
213 return;
214
216 \ilUtil::sendInfo($this->lng->txt('container_no_items'));
217 $this->tpl->setContent('');
218 return;
219
221 $cmd = self::CMD_EXTRO;
222 break;
223
225 default:
226 $cmd = self::CMD_STANDARD;
227 break;
228 }
229 $href = $this->ctrl->getLinkTarget($this, $cmd, '', false, false);
230 \ilUtil::redirect($href);
231 }
232
234 {
235 print $this->player->getCurrentItemLearningProgress();
236 exit;
237 }
238}
if(! $in) print
$_GET["client_id"]
$_POST["username"]
An exception for terminatinating execution or to throw for unit testing.
Class ilAccessHandler.
This class provides processing control methods.
This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Le...
Builds the overview (curriculum) of a LearningSequence.
Implementation of KioskMode Player.
const LSO_CMD_SUSPEND
const LSO_CMD_FINISH
language handling
Settings for an LSO (like abstract, extro)
static getInstance()
Factory.
Class ilObjLearningSequenceLearnerGUI.
__construct(int $ls_ref_id, $first_access, int $usr_id, ilAccess $access, ilCtrl $ctrl, ilLanguage $lng, ilGlobalTemplateInterface $tpl, ilToolbarGUI $toolbar, ILIAS\UI\Factory $ui_factory, ILIAS\UI\Renderer $ui_renderer, ilLearningSequenceRoles $roles, ilLearningSequenceSettings $settings, ilLSCurriculumBuilder $curriculum_builder, ilLSPlayer $player)
static redirect($a_script)
static sendInfo($a_info="", $a_keep=false)
Send Info Message to Screen.
$txt
Definition: error.php:13
$img
Definition: imgupload.php:57
if($DIC->http() ->request() ->getMethod()=="GET" &&isset($DIC->http() ->request() ->getQueryParams()['tex'])) $tpl
Definition: latex.php:41
exit
Definition: login.php:29
Class ChatMainBarProvider \MainMenu\Provider.
Class Factory.
$response
$lng
settings()
Definition: settings.php:2