ILIAS  release_8 Revision v8.24
ilLSPlayer Class Reference

Implementation of KioskMode Player. More...

+ Collaboration diagram for ilLSPlayer:

Public Member Functions

 __construct (ilLSLearnerItemsQueries $ls_items, LSControlBuilder $control_builder, LSUrlBuilder $url_builder, ilLSCurriculumBuilder $curriculum_builder, ilLSViewFactory $view_factory, ilKioskPageRenderer $renderer, Factory $ui_factory, ScreenContext $current_context, Refinery\Factory $refinery)
 
 play (RequestWrapper $get)
 
 getCurrentItemLearningProgress ()
 

Data Fields

const PARAM_LSO_COMMAND = 'lsocmd'
 
const PARAM_LSO_PARAMETER = 'lsov'
 
const LSO_CMD_NEXT = 'lsonext'
 
const LSO_CMD_GOTO = 'lsogoto'
 
const LSO_CMD_SUSPEND = 'lsosuspend'
 
const LSO_CMD_FINISH = 'lsofinish'
 
const GS_DATA_LS_KIOSK_MODE = 'ls_kiosk_mode'
 
const GS_DATA_LS_CONTENT = 'ls_content'
 
const GS_DATA_LS_MAINBARCONTROLS = 'ls_mainbar_controls'
 
const GS_DATA_LS_METABARCONTROLS = 'ls_metabar_controls'
 

Protected Member Functions

 getCurrentItem (array $items)
 
 updateViewState (ILIAS\KioskMode\State $state, ILIAS\KioskMode\View $view, RequestWrapper $get)
 
 getNextItem (array $items, LSLearnerItem $current_item, int $direction)
 $direction is either -1 or 1; More...
 
 findItemByRefId (array $items, int $ref_id)
 
 buildDefaultControls (LSControlBuilder $control_builder, LSLearnerItem $item, int $item_position, array $items)
 
 renderComponentView ($state, ILIAS\KioskMode\View $view)
 

Protected Attributes

ilLSLearnerItemsQueries $ls_items
 
LSControlBuilder $control_builder
 
LSUrlBuilder $url_builder
 
ilLSCurriculumBuilder $curriculum_builder
 
ilLSViewFactory $view_factory
 
ilKioskPageRenderer $page_renderer
 
Factory $ui_factory
 
ScreenContext $current_context
 
Refinery Factory $refinery
 

Detailed Description

Implementation of KioskMode Player.

Definition at line 32 of file class.ilLSPlayer.php.

Constructor & Destructor Documentation

◆ __construct()

ilLSPlayer::__construct ( ilLSLearnerItemsQueries  $ls_items,
LSControlBuilder  $control_builder,
LSUrlBuilder  $url_builder,
ilLSCurriculumBuilder  $curriculum_builder,
ilLSViewFactory  $view_factory,
ilKioskPageRenderer  $renderer,
Factory  $ui_factory,
ScreenContext  $current_context,
Refinery\Factory  $refinery 
)

Definition at line 57 of file class.ilLSPlayer.php.

67 {
68 $this->ls_items = $ls_items;
69 $this->control_builder = $control_builder;
70 $this->url_builder = $url_builder;
71 $this->curriculum_builder = $curriculum_builder;
72 $this->view_factory = $view_factory;
73 $this->page_renderer = $renderer;
74 $this->ui_factory = $ui_factory;
75 $this->current_context = $current_context;
76 $this->refinery = $refinery;
77 }
ilLSViewFactory $view_factory
ilLSLearnerItemsQueries $ls_items
ilLSCurriculumBuilder $curriculum_builder
Refinery Factory $refinery
LSUrlBuilder $url_builder
Factory $ui_factory
ScreenContext $current_context
LSControlBuilder $control_builder

References $control_builder, $current_context, $curriculum_builder, $ls_items, $refinery, $ui_factory, $url_builder, $view_factory, and ILIAS\Repository\refinery().

+ Here is the call graph for this function:

Member Function Documentation

◆ buildDefaultControls()

ilLSPlayer::buildDefaultControls ( LSControlBuilder  $control_builder,
LSLearnerItem  $item,
int  $item_position,
array  $items 
)
protected

Definition at line 262 of file class.ilLSPlayer.php.

268 $is_first = $item_position === 0;
269 $is_last = $item_position === count($items) - 1;
270
273 if ($is_last) {
275 }
277 }
278
280 $direction_prev = -1;
281 $cmd = ''; //disables control
282
283 if (!$is_first) {
284 $available = $this->getNextItem($items, $item, $direction_prev)
285 ->getAvailability() === Step::AVAILABLE;
286
287 if ($available) {
288 $cmd = self::LSO_CMD_NEXT;
289 }
290 }
291
293 ->previous($cmd, $direction_prev);
294 }
295
297 $direction_next = 1;
298 $cmd = '';
299 if (!$is_last) {
300 $available = $this->getNextItem($items, $item, $direction_next)
301 ->getAvailability() === Step::AVAILABLE;
302
303 if ($available) {
304 $cmd = self::LSO_CMD_NEXT;
305 }
306 }
307
309 ->next($cmd, $direction_next);
310 }
311
312 return $control_builder;
313 }
previous(string $command, int $parameter=null)
A previous control allows the user to go back to the previous item in the object.
exit(string $command)
An exit control allows the user to gracefully leave the object providing the kiosk mode.
next(string $command, int $parameter=null)
A next control allows the user to progress to the next item in the object.
const LSO_CMD_SUSPEND
getNextItem(array $items, LSLearnerItem $current_item, int $direction)
$direction is either -1 or 1;
const LSO_CMD_FINISH
Build controls for the view.

References LSControlBuilder\exit().

Referenced by play().

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

◆ findItemByRefId()

ilLSPlayer::findItemByRefId ( array  $items,
int  $ref_id 
)
protected
Returns
array <int, LSLearnerItem> position=>item

Definition at line 252 of file class.ilLSPlayer.php.

252 : array
253 {
254 foreach ($items as $index => $item) {
255 if ($item->getRefId() === $ref_id) {
256 return [$index, $item];
257 }
258 }
259 throw new \Exception("This is not a valid item.", 1);
260 }
$ref_id
Definition: ltiauth.php:67
$index
Definition: metadata.php:145

References $index, and $ref_id.

Referenced by getCurrentItem(), and play().

+ Here is the caller graph for this function:

◆ getCurrentItem()

ilLSPlayer::getCurrentItem ( array  $items)
protected
Parameters
arrayLSLearnerItem[]

Definition at line 207 of file class.ilLSPlayer.php.

208 {
209 $current_item = $items[0];
210 $current_item_ref_id = $this->ls_items->getCurrentItemRefId();
211 if ($current_item_ref_id !== 0) {
212 $valid_ref_ids = array_map(
213 fn ($item) => $item->getRefId(),
214 array_values($this->ls_items->getItems())
215 );
216 if (in_array($current_item_ref_id, $valid_ref_ids)) {
217 list(, $current_item) = $this->findItemByRefId($items, $current_item_ref_id);
218 }
219 }
220 return $current_item;
221 }
This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Le...
findItemByRefId(array $items, int $ref_id)

References findItemByRefId().

Referenced by play().

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

◆ getCurrentItemLearningProgress()

ilLSPlayer::getCurrentItemLearningProgress ( )

Definition at line 326 of file class.ilLSPlayer.php.

326 : int
327 {
328 $item = $this->getCurrentItem($this->ls_items->getItems());
329 return $item->getLearningProgressStatus();
330 }
getCurrentItem(array $items)

References LSLearnerItem\getLearningProgressStatus().

+ Here is the call graph for this function:

◆ getNextItem()

ilLSPlayer::getNextItem ( array  $items,
LSLearnerItem  $current_item,
int  $direction 
)
protected

$direction is either -1 or 1;

Definition at line 239 of file class.ilLSPlayer.php.

240 {
241 list($position) = $this->findItemByRefId($items, $current_item->getRefId());
242 $next = $position + $direction;
243 if ($next >= 0 && $next < count($items)) {
244 return $items[$next];
245 }
246 return $current_item;
247 }
getRefId()
Definition: LSItem.php:90

References LSItem\getRefId().

Referenced by play().

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

◆ play()

ilLSPlayer::play ( RequestWrapper  $get)

Definition at line 79 of file class.ilLSPlayer.php.

79 : ?string
80 {
81 //init state and current item
82 $items = $this->ls_items->getItems();
83
84 if (count($items) === 0) {
85 return null;
86 }
87
88 $current_item = $this->getCurrentItem($items);
89
90 while ($current_item->getAvailability() !== Step::AVAILABLE) {
91 $prev_item = $this->getNextItem($items, $current_item, -1);
92 if ($prev_item === $current_item) {
93 throw new \Exception("Cannot view first LSO-item", 1);
94 }
95 $current_item = $prev_item;
96 }
97
98 $view = $this->view_factory->getViewFor($current_item);
99 $state = $this->ls_items->getStateFor($current_item, $view);
100 $state = $this->updateViewState($state, $view, $get);
101 //reload items after update viewState
102 $items = $this->ls_items->getItems();
103
104 $current_item_ref_id = $current_item->getRefId();
105 //now, digest parameter:
106 $command = null;
107 if ($get->has(self::PARAM_LSO_COMMAND)) {
108 $command = $get->retrieve(self::PARAM_LSO_COMMAND, $this->refinery->kindlyTo()->string());
109 }
110 $param = null;
111 if ($get->has(self::PARAM_LSO_PARAMETER)) {
112 $param = $get->retrieve(self::PARAM_LSO_PARAMETER, $this->refinery->kindlyTo()->int());
113 }
114
115 switch ($command) {
118 $this->ls_items->storeState($state, $current_item_ref_id, $current_item_ref_id);
119 return 'EXIT::' . $command;
121 $next_item = $this->getNextItem($items, $current_item, $param);
122 if ($next_item->getAvailability() !== Step::AVAILABLE) {
123 $next_item = $current_item;
124 }
125 break;
127 list(, $next_item) = $this->findItemByRefId($items, $param);
128 break;
129 default: //view-internal / unknown command
130 $next_item = $current_item;
131 }
132 //write State to DB
133 $this->ls_items->storeState($state, $current_item_ref_id, $next_item->getRefId());
134
135 //get proper view
136 if ($next_item != $current_item) {
137 $view = $this->view_factory->getViewFor($next_item);
138 $state = $this->ls_items->getStateFor($next_item, $view);
139 }
140
141 //content
142 $obj_title = $next_item->getTitle();
143 $icon = $this->ui_factory->symbol()->icon()->standard(
144 $next_item->getType(),
145 $next_item->getType(),
146 'medium'
147 );
148
149 $content = $this->renderComponentView($state, $view);
150
151 $panel = $this->ui_factory->panel()->standard(
152 '',
153 $content
154 );
155 $content = [$panel];
156
157 $items = $this->ls_items->getItems(); //reload items after renderComponentView content
158
159 //get position
160 list($item_position, $item) = $this->findItemByRefId($items, $next_item->getRefId());
161
162 //have the view build controls
164 $view->buildControls($state, $control_builder);
165
166 //amend controls not set by the view
167 $control_builder = $this->buildDefaultControls($control_builder, $item, $item_position, $items);
168
169 $rendered_body = $this->page_renderer->render(
171 $obj_title,
172 $icon,
173 $content
174 );
175
176 $metabar_controls = [
178 ];
179
180 $curriculum_slate = $this->page_renderer->buildCurriculumSlate(
181 $this->curriculum_builder
182 ->getLearnerCurriculum(true)
183 ->withActive($item_position)
184 );
185 $mainbar_controls = [
186 'curriculum' => $curriculum_slate
187 ];
188
189 $toc = $control_builder->getToc();
190 if ($toc) {
191 $toc_slate = $this->page_renderer->buildToCSlate($toc, $icon);
192 $mainbar_controls['toc'] = $toc_slate;
193 }
194
196 $cc->addAdditionalData(self::GS_DATA_LS_KIOSK_MODE, true);
197 $cc->addAdditionalData(self::GS_DATA_LS_METABARCONTROLS, $metabar_controls);
198 $cc->addAdditionalData(self::GS_DATA_LS_MAINBARCONTROLS, $mainbar_controls);
199 $cc->addAdditionalData(self::GS_DATA_LS_CONTENT, $rendered_body);
200
201 return null;
202 }
renderComponentView($state, ILIAS\KioskMode\View $view)
updateViewState(ILIAS\KioskMode\State $state, ILIAS\KioskMode\View $view, RequestWrapper $get)
buildDefaultControls(LSControlBuilder $control_builder, LSLearnerItem $item, int $item_position, array $items)
if(isset($_FILES['img_file']) &&is_array($_FILES['img_file'])) $panel
Definition: imgupload.php:198
retrieve(string $key, Transformation $transformation)
$param
Definition: xapitoken.php:46

References $control_builder, $current_context, $panel, $param, ILIAS\GlobalScreen\ScreenContext\ScreenContext\addAdditionalData(), buildDefaultControls(), findItemByRefId(), getCurrentItem(), LSControlBuilder\getExitControl(), getNextItem(), LSControlBuilder\getToc(), ILIAS\HTTP\Wrapper\RequestWrapper\has(), LSO_CMD_FINISH, LSO_CMD_GOTO, LSO_CMD_NEXT, LSO_CMD_SUSPEND, ILIAS\Repository\refinery(), renderComponentView(), ILIAS\HTTP\Wrapper\RequestWrapper\retrieve(), and updateViewState().

+ Here is the call graph for this function:

◆ renderComponentView()

ilLSPlayer::renderComponentView (   $state,
ILIAS\KioskMode\View  $view 
)
protected

Definition at line 315 of file class.ilLSPlayer.php.

315 : Component
316 {
317 return $view->render(
318 $state,
319 $this->ui_factory,
320 $this->url_builder,
321 []
322 );
323 }
This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Le...

Referenced by play().

+ Here is the caller graph for this function:

◆ updateViewState()

ilLSPlayer::updateViewState ( ILIAS\KioskMode\State  $state,
ILIAS\KioskMode\View  $view,
RequestWrapper  $get 
)
protected

Definition at line 223 of file class.ilLSPlayer.php.

228 if ($get->has(self::PARAM_LSO_COMMAND) && $get->has(self::PARAM_LSO_PARAMETER)) {
229 $command = $get->retrieve(self::PARAM_LSO_COMMAND, $this->refinery->kindlyTo()->string());
230 $param = $get->retrieve(self::PARAM_LSO_PARAMETER, $this->refinery->kindlyTo()->int());
231 $state = $view->updateGet($state, $command, $param);
232 }
233 return $state;
234 }
Keeps the state of a view in a simple stringly type key-value store.
Definition: State.php:13

References $param, ILIAS\Repository\refinery(), and ILIAS\HTTP\Wrapper\RequestWrapper\retrieve().

Referenced by play().

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

Field Documentation

◆ $control_builder

LSControlBuilder ilLSPlayer::$control_builder
protected

Definition at line 48 of file class.ilLSPlayer.php.

Referenced by __construct(), and play().

◆ $current_context

ScreenContext ilLSPlayer::$current_context
protected

Definition at line 54 of file class.ilLSPlayer.php.

Referenced by __construct(), and play().

◆ $curriculum_builder

ilLSCurriculumBuilder ilLSPlayer::$curriculum_builder
protected

Definition at line 50 of file class.ilLSPlayer.php.

Referenced by __construct().

◆ $ls_items

ilLSLearnerItemsQueries ilLSPlayer::$ls_items
protected

Definition at line 47 of file class.ilLSPlayer.php.

Referenced by __construct().

◆ $page_renderer

ilKioskPageRenderer ilLSPlayer::$page_renderer
protected

Definition at line 52 of file class.ilLSPlayer.php.

◆ $refinery

Refinery Factory ilLSPlayer::$refinery
protected

Definition at line 55 of file class.ilLSPlayer.php.

Referenced by __construct().

◆ $ui_factory

Factory ilLSPlayer::$ui_factory
protected

Definition at line 53 of file class.ilLSPlayer.php.

Referenced by __construct().

◆ $url_builder

LSUrlBuilder ilLSPlayer::$url_builder
protected

Definition at line 49 of file class.ilLSPlayer.php.

Referenced by __construct().

◆ $view_factory

ilLSViewFactory ilLSPlayer::$view_factory
protected

Definition at line 51 of file class.ilLSPlayer.php.

Referenced by __construct().

◆ GS_DATA_LS_CONTENT

const ilLSPlayer::GS_DATA_LS_CONTENT = 'ls_content'

Definition at line 43 of file class.ilLSPlayer.php.

Referenced by ilLSViewLayoutProvider\getContentModification().

◆ GS_DATA_LS_KIOSK_MODE

const ilLSPlayer::GS_DATA_LS_KIOSK_MODE = 'ls_kiosk_mode'

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

Referenced by ilLSViewLayoutProvider\isKioskModeEnabled().

◆ GS_DATA_LS_MAINBARCONTROLS

const ilLSPlayer::GS_DATA_LS_MAINBARCONTROLS = 'ls_mainbar_controls'

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

Referenced by ilLSViewLayoutProvider\getMainBarModification().

◆ GS_DATA_LS_METABARCONTROLS

const ilLSPlayer::GS_DATA_LS_METABARCONTROLS = 'ls_metabar_controls'

Definition at line 45 of file class.ilLSPlayer.php.

Referenced by ilLSViewLayoutProvider\getPageBuilderDecorator().

◆ LSO_CMD_FINISH

const ilLSPlayer::LSO_CMD_FINISH = 'lsofinish'

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

Referenced by LSControlBuilder\exit(), and play().

◆ LSO_CMD_GOTO

const ilLSPlayer::LSO_CMD_GOTO = 'lsogoto'

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

Referenced by play().

◆ LSO_CMD_NEXT

const ilLSPlayer::LSO_CMD_NEXT = 'lsonext'

Definition at line 37 of file class.ilLSPlayer.php.

Referenced by play().

◆ LSO_CMD_SUSPEND

const ilLSPlayer::LSO_CMD_SUSPEND = 'lsosuspend'

Definition at line 39 of file class.ilLSPlayer.php.

Referenced by play().

◆ PARAM_LSO_COMMAND

const ilLSPlayer::PARAM_LSO_COMMAND = 'lsocmd'

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

◆ PARAM_LSO_PARAMETER

const ilLSPlayer::PARAM_LSO_PARAMETER = 'lsov'

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


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