ILIAS  trunk Revision v13.0_alpha-62-g3b72d83f2e5
ilObjLearningSequenceLearnerGUI Class Reference

@ilCtrl_Calls ilObjLearningSequenceLearnerGUI: ilCommonActionDispatcherGUI More...

+ Inheritance diagram for ilObjLearningSequenceLearnerGUI:
+ Collaboration diagram for ilObjLearningSequenceLearnerGUI:

Public Member Functions

 __construct (protected int $usr_id, protected ilAccess $access, protected ilCtrl $ctrl, protected ilLanguage $lng, protected ilGlobalTemplateInterface $tpl, protected ilToolbarGUI $toolbar, protected ILIAS\UI\Factory $ui_factory, protected ILIAS\UI\Renderer $renderer, protected ilLearningSequenceRoles $roles, protected ilLearningSequenceSettings $settings, protected ilLSLaunchlinksBuilder $launchlinks_builder, protected ilLSLearnerItemsQueries $ls_items, protected ilLSPlayer $player, protected string $intro, protected string $extro, protected RequestWrapper $get)
 
 getUnsafeGetCommands ()
 Joining and leaving the learning sequence are triggered by links (launch button, interruptive modal action) and therefore need to be protected by an ilCtrl CSRF token. More...
 
 getSafePostCommands ()
 @inheritDoc More...
 
 executeCommand ()
 
 getUnsafeGetCommands ()
 This method must return a list of unsafe GET commands. More...
 
 getSafePostCommands ()
 This method must return a list of safe POST commands. More...
 

Data Fields

const CMD_SAVE_RATING = 'saveRating'
 
const CMD_REDRAW_LIST_ITEM = 'redrawListItem'
 
const CMD_STANDARD = 'learnerView'
 
const CMD_EXTRO = 'learnerViewFinished'
 
const CMD_UNSUBSCRIBE_CONFIRMATION = 'unsubscribeConfirmation'
 
const CMD_UNSUBSCRIBE = 'unsubscribe'
 
const CMD_VIEW = 'view'
 
const CMD_START = 'start'
 
const PARAM_LSO_NEXT_ITEM = 'lsoni'
 
const LSO_CMD_NEXT = 'lson'
 
const LSO_CMD_PREV = 'lsop'
 

Protected Member Functions

 executeCommandByCommand (string $cmd)
 
 redrawListItem ()
 
 isRatingListItemInCurrentLearningSequence (int $child_ref_id, int $parent_ref_id)
 
 unsubscribeConfirmationModal ()
 
 view (string $cmd)
 
 addMember (int $usr_id)
 
 initToolbar (string $cmd, Interruptive $modal)
 
 play ()
 

Private Member Functions

 getWrappedHTML (array $components)
 
 getMainContent (string $cmd)
 

Detailed Description

Constructor & Destructor Documentation

◆ __construct()

ilObjLearningSequenceLearnerGUI::__construct ( protected int  $usr_id,
protected ilAccess  $access,
protected ilCtrl  $ctrl,
protected ilLanguage  $lng,
protected ilGlobalTemplateInterface  $tpl,
protected ilToolbarGUI  $toolbar,
protected ILIAS\UI\Factory  $ui_factory,
protected ILIAS\UI\Renderer  $renderer,
protected ilLearningSequenceRoles  $roles,
protected ilLearningSequenceSettings  $settings,
protected ilLSLaunchlinksBuilder  $launchlinks_builder,
protected ilLSLearnerItemsQueries  $ls_items,
protected ilLSPlayer  $player,
protected string  $intro,
protected string  $extro,
protected RequestWrapper  $get 
)

Definition at line 44 of file class.ilObjLearningSequenceLearnerGUI.php.

61 {
62 }

Member Function Documentation

◆ addMember()

ilObjLearningSequenceLearnerGUI::addMember ( int  $usr_id)
protected

Definition at line 293 of file class.ilObjLearningSequenceLearnerGUI.php.

293 : void
294 {
295 $admins = $this->roles->getLearningSequenceAdminIds();
296 if (!in_array($usr_id, $admins)) {
297 $this->roles->join($usr_id);
298 }
299 }

Referenced by executeCommandByCommand().

+ Here is the caller graph for this function:

◆ executeCommand()

ilObjLearningSequenceLearnerGUI::executeCommand ( )

Definition at line 87 of file class.ilObjLearningSequenceLearnerGUI.php.

87 : void
88 {
89 // ilCtrl returns no command if the CSRF validation fails, fall back
90 // to the learner view in this case.
91 $cmd = $this->ctrl->getCmd(self::CMD_STANDARD);
92 $next_class = $this->ctrl->getNextClass($this);
93 switch ($next_class) {
94 case strtolower(ilCommonActionDispatcherGUI::class):
95 $dispatcher = ilCommonActionDispatcherGUI::getInstanceFromAjaxCall();
96 if ($dispatcher instanceof ilCommonActionDispatcherGUI) {
97 $this->ctrl->forwardCommand($dispatcher);
98 }
99 break;
100 default:
101 $this->executeCommandByCommand($cmd);
102 }
103 }
Class ilCommonActionDispatcherGUI.

References ILIAS\Repository\ctrl(), executeCommandByCommand(), and ilCommonActionDispatcherGUI\getInstanceFromAjaxCall().

+ Here is the call graph for this function:

◆ executeCommandByCommand()

ilObjLearningSequenceLearnerGUI::executeCommandByCommand ( string  $cmd)
protected

Definition at line 105 of file class.ilObjLearningSequenceLearnerGUI.php.

105 : void
106 {
107 switch ($cmd) {
109 case self::CMD_EXTRO:
110 $this->view($cmd);
111 break;
112 case self::CMD_START:
113 $this->addMember($this->usr_id);
114 $this->ctrl->redirect($this, self::CMD_VIEW);
115 break;
118 break;
120 if ($this->launchlinks_builder->currentUserMayUnparticipate()) {
121 $this->roles->leave($this->usr_id);
122 }
123 $this->ctrl->redirect($this, self::CMD_STANDARD);
124 break;
126 $this->redrawListItem();
127 break;
128 case self::CMD_VIEW:
129 $this->play();
130 break;
131
132 default:
133 throw new ilException(
134 "ilObjLearningSequenceLearnerGUI: " .
135 "Command not supported: $cmd"
136 );
137 }
138 }
Base class for ILIAS Exception handling.

References addMember(), CMD_EXTRO, CMD_REDRAW_LIST_ITEM, CMD_STANDARD, CMD_START, CMD_UNSUBSCRIBE, CMD_UNSUBSCRIBE_CONFIRMATION, CMD_VIEW, ILIAS\Repository\ctrl(), play(), redrawListItem(), unsubscribeConfirmationModal(), and view().

Referenced by executeCommand().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ getMainContent()

ilObjLearningSequenceLearnerGUI::getMainContent ( string  $cmd)
private

Definition at line 331 of file class.ilObjLearningSequenceLearnerGUI.php.

331 : array
332 {
333 $img = null;
334 $contents = [];
335
336 if ($cmd === self::CMD_STANDARD) {
337 if ($this->intro === '') {
338 $contents[] = $this->ui_factory->legacy()->content($this->settings->getAbstract());
339 $img = $this->settings->getAbstractImage();
340 if ($img) {
341 $contents[] = $this->ui_factory->image()->responsive($img, '');
342 }
343 } else {
344 $contents[] = $this->ui_factory->legacy()->content($this->intro);
345 }
346 }
347
348 if ($cmd === self::CMD_EXTRO) {
349 if ($this->extro === '') {
350 $contents[] = $this->ui_factory->legacy()->content($this->settings->getExtro());
351 $img = $this->settings->getExtroImage();
352 if ($img) {
353 $contents[] = $this->ui_factory->image()->responsive($img, '');
354 }
355 } else {
356 $contents[] = $this->ui_factory->legacy()->content($this->extro);
357 }
358 }
359 return $contents;
360 }

References $contents, and ILIAS\Repository\settings().

Referenced by view().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ getSafePostCommands()

ilObjLearningSequenceLearnerGUI::getSafePostCommands ( )

@inheritDoc

Implements ilCtrlSecurityInterface.

Definition at line 82 of file class.ilObjLearningSequenceLearnerGUI.php.

82 : array
83 {
84 return [];
85 }

◆ getUnsafeGetCommands()

ilObjLearningSequenceLearnerGUI::getUnsafeGetCommands ( )

Joining and leaving the learning sequence are triggered by links (launch button, interruptive modal action) and therefore need to be protected by an ilCtrl CSRF token.

@inheritDoc

Implements ilCtrlSecurityInterface.

Definition at line 71 of file class.ilObjLearningSequenceLearnerGUI.php.

71 : array
72 {
73 return [
76 ];
77 }

References CMD_START, and CMD_UNSUBSCRIBE.

◆ getWrappedHTML()

ilObjLearningSequenceLearnerGUI::getWrappedHTML ( array  $components)
private

Definition at line 320 of file class.ilObjLearningSequenceLearnerGUI.php.

320 : string
321 {
322 array_unshift(
324 $this->ui_factory->legacy()->content('<div class="ilLSOLearnerView">')
325 );
326 $components[] = $this->ui_factory->legacy()->content('</div>');
327
328 return $this->renderer->render($components);
329 }
renderer()
$components

References $components, and renderer().

Referenced by view().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ initToolbar()

ilObjLearningSequenceLearnerGUI::initToolbar ( string  $cmd,
Interruptive  $modal 
)
protected

Definition at line 301 of file class.ilObjLearningSequenceLearnerGUI.php.

301 : void
302 {
303 foreach ($this->launchlinks_builder->getLinks() as $entry) {
304 list($label, $link, $primary) = $entry;
305
306 if ($primary) {
307 $btn = $this->ui_factory->button()->primary($label, $link);
308 } else {
309 $btn = $this->ui_factory->button()->standard($label, $link);
310 }
311
312 if ($label === $this->lng->txt("unparticipate")) {
313 $btn = $this->ui_factory->button()->standard($label, $link)->withOnClick($modal->getShowSignal());
314 }
315
316 $this->toolbar->addComponent($btn);
317 }
318 }
getShowSignal()
Get the signal to show this modal in the frontend.

References ILIAS\UI\Component\Modal\Modal\getShowSignal(), ILIAS\Repository\lng(), and ILIAS\Repository\toolbar().

Referenced by view().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ isRatingListItemInCurrentLearningSequence()

ilObjLearningSequenceLearnerGUI::isRatingListItemInCurrentLearningSequence ( int  $child_ref_id,
int  $parent_ref_id 
)
protected

Definition at line 253 of file class.ilObjLearningSequenceLearnerGUI.php.

253 : bool
254 {
255 if ($parent_ref_id !== $this->ls_items->getLearningSequenceRefId()) {
256 return false;
257 }
258
259 foreach ($this->ls_items->getItems() as $item) {
260 if ($item->getRefId() === $child_ref_id) {
261 return true;
262 }
263 }
264
265 return false;
266 }

Referenced by redrawListItem().

+ Here is the caller graph for this function:

◆ play()

ilObjLearningSequenceLearnerGUI::play ( )
protected

Definition at line 362 of file class.ilObjLearningSequenceLearnerGUI.php.

362 : void
363 {
364 $response = $this->player->play($this->get);
365
366 if ($response !== null && str_starts_with($response, $this->player::REDIRECT_PREFIX)) {
367 $this->ctrl->redirectToURL(substr($response, strlen($this->player::REDIRECT_PREFIX)));
368 }
369
370 switch ($response) {
371 case null:
372 //render the page
373 $this->tpl->setContent($this->lng->txt('lso_player_noitems'));
374 return;
375
376 case 'EXIT::' . $this->player::LSO_CMD_FINISH:
377 $cmd = self::CMD_EXTRO;
378 break;
379
380 case 'EXIT::' . $this->player::LSO_CMD_SUSPEND:
381 default:
382 $cmd = self::CMD_STANDARD;
383 break;
384 }
385 $href = $this->ctrl->getLinkTarget($this, $cmd, '', false, false);
386 \ilUtil::redirect($href);
387 }
static redirect(string $a_script)
$response
Definition: xapitoken.php:92

References $response, CMD_EXTRO, CMD_STANDARD, ILIAS\Repository\ctrl(), ILIAS\Repository\lng(), and ilUtil\redirect().

Referenced by executeCommandByCommand().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ redrawListItem()

ilObjLearningSequenceLearnerGUI::redrawListItem ( )
protected

Definition at line 140 of file class.ilObjLearningSequenceLearnerGUI.php.

140 : void
141 {
142 global $DIC;
143
144 $http = $DIC->http();
145 $response = $http->response();
146
147 $child_ref_id = (int) $this->get->retrieve('child_ref_id', $DIC->refinery()->kindlyTo()->int());
148 $parent_ref_id = (int) $this->get->retrieve('parent_ref_id', $DIC->refinery()->kindlyTo()->int());
149
150 if ($child_ref_id <= 0 || $parent_ref_id <= 0) {
151 $http->saveResponse(
153 ->withBody(Streams::ofString(''))
154 ->withHeader(ResponseHeader::CONTENT_TYPE, 'text/html; charset=UTF-8')
155 );
156 $http->sendResponse();
157 $http->close();
158 return;
159 }
160
161 if (!$this->isRatingListItemInCurrentLearningSequence($child_ref_id, $parent_ref_id)) {
162 $http->saveResponse(
164 ->withBody(Streams::ofString(''))
165 ->withHeader(ResponseHeader::CONTENT_TYPE, 'text/html; charset=UTF-8')
166 );
167 $http->sendResponse();
168 $http->close();
169 return;
170 }
171
172 $obj_id = ilObject::_lookupObjId($child_ref_id);
173 if ($obj_id <= 0) {
174 $http->saveResponse(
176 ->withBody(Streams::ofString(''))
177 ->withHeader(ResponseHeader::CONTENT_TYPE, 'text/html; charset=UTF-8')
178 );
179 $http->sendResponse();
180 $http->close();
181 return;
182 }
183
184 $obj_type = ilObject::_lookupType($obj_id);
185 if ($obj_type === '') {
186 $http->saveResponse(
188 ->withBody(Streams::ofString(''))
189 ->withHeader(ResponseHeader::CONTENT_TYPE, 'text/html; charset=UTF-8')
190 );
191 $http->sendResponse();
192 $http->close();
193 return;
194 }
195
197 if (!ilRating::hasRatingInListGUI($obj_id, $obj_type)) {
198 $http->saveResponse(
200 ->withBody(Streams::ofString(''))
201 ->withHeader(ResponseHeader::CONTENT_TYPE, 'text/html; charset=UTF-8')
202 );
203 $http->sendResponse();
204 $http->close();
205 return;
206 }
207
210 $child_ref_id,
211 $obj_type,
212 $obj_id
213 );
214
215 $rating_gui = (new ilRatingGUI())->withAsyncRendering(true);
216 $rating_gui->setObject($obj_id, $obj_type);
217 $rating_gui->setCtrlPath([
218 ilCommonActionDispatcherGUI::class,
219 ilRatingGUI::class
220 ]);
221 $rating_gui->setYourRatingText($this->lng->txt('rating_your_rating'));
222
223 $container_id = 'lg_div_' . $child_ref_id . '_pref_' . $parent_ref_id;
224 $rating_content = $rating_gui->getListGUIProperty(
225 $child_ref_id,
226 $this->access->checkAccess('read', '', $child_ref_id),
227 $ajax_hash,
228 $parent_ref_id
229 );
230
231 $tpl = new ilTemplate(
232 'tpl.lso_kiosk_rating_container.html',
233 true,
234 true,
235 'components/ILIAS/LearningSequence'
236 );
237 $tpl->setVariable('CONTAINER_ID', $container_id);
238 $tpl->setVariable('CHILD_REF_ID', (string) $child_ref_id);
239 $tpl->setVariable('AJAX_HASH', htmlspecialchars($ajax_hash, ENT_QUOTES));
240 $tpl->setVariable('RATING_CONTENT', $rating_content);
241 $html = $tpl->get();
242
243 $http->saveResponse(
245 ->withBody(Streams::ofString($html))
246 ->withHeader(ResponseHeader::CONTENT_TYPE, 'text/html; charset=UTF-8')
247 );
248 $http->sendResponse();
249 $http->close();
250 return;
251 }
static buildAjaxHash(int $node_type, ?int $node_id, string $obj_type, int $obj_id, ?string $sub_type=null, ?int $sub_id=null, int $news_id=0)
Build ajax hash.
isRatingListItemInCurrentLearningSequence(int $child_ref_id, int $parent_ref_id)
static _lookupType(int $id, bool $reference=false)
static _lookupObjId(int $ref_id)
This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Le...
static preloadListGUIData(array $a_obj_ids)
Preload rating data for list guis.
static hasRatingInListGUI(int $a_obj_id, string $a_obj_type)
special template class to simplify handling of ITX/PEAR
setVariable(string $variable, $value='')
Sets the given variable to the given value.
get(string $part=self::DEFAULT_BLOCK)
Renders the given block and returns the html string.
get(string $class_name)
readonly ilGlobalTemplateInterface $tpl
global $DIC
Definition: shib_login.php:26

References $DIC, ILIAS\BookingManager\Common\Table\$http, $response, ILIAS\News\Common\Table\$tpl, ilObject\_lookupObjId(), ilObject\_lookupType(), ILIAS\Repository\access(), ilCommonActionDispatcherGUI\buildAjaxHash(), ILIAS\GlobalScreen\get(), ILIAS\UICore\GlobalTemplate\get(), ilRating\hasRatingInListGUI(), ILIAS\Repository\int(), isRatingListItemInCurrentLearningSequence(), ILIAS\Repository\lng(), ilRating\preloadListGUIData(), ILIAS\UICore\GlobalTemplate\setVariable(), and ilCommonActionDispatcherGUI\TYPE_REPOSITORY.

Referenced by executeCommandByCommand().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ unsubscribeConfirmationModal()

ilObjLearningSequenceLearnerGUI::unsubscribeConfirmationModal ( )
protected

Definition at line 268 of file class.ilObjLearningSequenceLearnerGUI.php.

269 {
270 return $this->ui_factory->modal()->interruptive(
271 $this->lng->txt('obj_lso'),
272 $this->lng->txt("unparticipate"),
273 $this->ctrl->getLinkTarget($this, self::CMD_UNSUBSCRIBE),
274 );
275 }

References ILIAS\Repository\lng().

Referenced by executeCommandByCommand(), and view().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ view()

ilObjLearningSequenceLearnerGUI::view ( string  $cmd)
protected

Definition at line 277 of file class.ilObjLearningSequenceLearnerGUI.php.

277 : void
278 {
279 $content = $this->getWrappedHTML(
280 $this->getMainContent($cmd)
281 );
282
283 $modal = $this->unsubscribeConfirmationModal();
284
285 $this->tpl->setContent($content . $this->renderer->render($modal));
286
287 $element = '<' . ilPCLauncher::PCELEMENT . '>';
288 if (!str_contains($content, $element)) {
289 $this->initToolbar($cmd, $modal);
290 }
291 }

References getMainContent(), getWrappedHTML(), initToolbar(), ilPCLauncher\PCELEMENT, renderer(), and unsubscribeConfirmationModal().

Referenced by executeCommandByCommand().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

Field Documentation

◆ CMD_EXTRO

const ilObjLearningSequenceLearnerGUI::CMD_EXTRO = 'learnerViewFinished'

Definition at line 35 of file class.ilObjLearningSequenceLearnerGUI.php.

Referenced by executeCommandByCommand(), and play().

◆ CMD_REDRAW_LIST_ITEM

const ilObjLearningSequenceLearnerGUI::CMD_REDRAW_LIST_ITEM = 'redrawListItem'

◆ CMD_SAVE_RATING

const ilObjLearningSequenceLearnerGUI::CMD_SAVE_RATING = 'saveRating'

Definition at line 31 of file class.ilObjLearningSequenceLearnerGUI.php.

◆ CMD_STANDARD

const ilObjLearningSequenceLearnerGUI::CMD_STANDARD = 'learnerView'

Definition at line 34 of file class.ilObjLearningSequenceLearnerGUI.php.

Referenced by executeCommandByCommand(), and play().

◆ CMD_START

const ilObjLearningSequenceLearnerGUI::CMD_START = 'start'

◆ CMD_UNSUBSCRIBE

const ilObjLearningSequenceLearnerGUI::CMD_UNSUBSCRIBE = 'unsubscribe'

◆ CMD_UNSUBSCRIBE_CONFIRMATION

const ilObjLearningSequenceLearnerGUI::CMD_UNSUBSCRIBE_CONFIRMATION = 'unsubscribeConfirmation'

Definition at line 36 of file class.ilObjLearningSequenceLearnerGUI.php.

Referenced by executeCommandByCommand().

◆ CMD_VIEW

const ilObjLearningSequenceLearnerGUI::CMD_VIEW = 'view'

Definition at line 38 of file class.ilObjLearningSequenceLearnerGUI.php.

Referenced by executeCommandByCommand().

◆ LSO_CMD_NEXT

const ilObjLearningSequenceLearnerGUI::LSO_CMD_NEXT = 'lson'

Definition at line 41 of file class.ilObjLearningSequenceLearnerGUI.php.

◆ LSO_CMD_PREV

const ilObjLearningSequenceLearnerGUI::LSO_CMD_PREV = 'lsop'

Definition at line 42 of file class.ilObjLearningSequenceLearnerGUI.php.

◆ PARAM_LSO_NEXT_ITEM

const ilObjLearningSequenceLearnerGUI::PARAM_LSO_NEXT_ITEM = 'lsoni'

Definition at line 40 of file class.ilObjLearningSequenceLearnerGUI.php.


The documentation for this class was generated from the following file: