ILIAS  release_7 Revision v7.30-3-g800a261c036
ilLSPlayer Class Reference

Implementation of KioskMode Player. More...

+ Collaboration diagram for ilLSPlayer:

Public Member Functions

 __construct (string $lso_title, ilLSLearnerItemsQueries $ls_items, LSControlBuilder $control_builder, LSUrlBuilder $url_builder, ilLSCurriculumBuilder $curriculum_builder, ilLSViewFactory $view_factory, ilKioskPageRenderer $renderer, ILIAS\UI\Factory $ui_factory, ScreenContext $current_context)
 
 play (array $get, array $post=null)
 
 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'
 
const RET_EXIT = 'EXIT::'
 
const RET_NOITEMS = 'NOITEMS'
 

Protected Member Functions

 getCurrentItem (array $items)
 
 updateViewState (ILIAS\KioskMode\State $state, ILIAS\KioskMode\View $view, array $get, array $post=null)
 
 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)
 

Detailed Description

Implementation of KioskMode Player.

Author
Nils Haagen nils..nosp@m.haag.nosp@m.en@co.nosp@m.ncep.nosp@m.ts-an.nosp@m.d-tr.nosp@m.ainin.nosp@m.g.de

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

Constructor & Destructor Documentation

◆ __construct()

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

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

40 {
41 $this->lso_title = $lso_title;
42 $this->ls_items = $ls_items;
43 $this->control_builder = $control_builder;
44 $this->url_builder = $url_builder;
45 $this->curriculum_builder = $curriculum_builder;
46 $this->view_factory = $view_factory;
47 $this->page_renderer = $renderer;
48 $this->ui_factory = $ui_factory;
49 $this->current_context = $current_context;
50 }

Member Function Documentation

◆ buildDefaultControls()

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

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

236 $is_first = $item_position === 0;
237 $is_last = $item_position === count($items) - 1;
238
239 if (!$control_builder->getExitControl()) {
241 if ($is_last) {
243 }
244 $control_builder = $control_builder->exit($cmd);
245 }
246
247 if (!$control_builder->getPreviousControl()) {
248 $direction_prev = -1;
249 $cmd = ''; //disables control
250
251 if (!$is_first) {
252 $available = $this->getNextItem($items, $item, $direction_prev)
253 ->getAvailability() === Step::AVAILABLE;
254
255 if ($available) {
256 $cmd = self::LSO_CMD_NEXT;
257 }
258 }
259
260 $control_builder = $control_builder
261 ->previous($cmd, $direction_prev);
262 }
263
264 if (!$control_builder->getNextControl()) {
265 $direction_next = 1;
266 $cmd = '';
267 if (!$is_last) {
268 $available = $this->getNextItem($items, $item, $direction_next)
269 ->getAvailability() === Step::AVAILABLE;
270
271 if ($available) {
272 $cmd = self::LSO_CMD_NEXT;
273 }
274 }
275
276 $control_builder = $control_builder
277 ->next($cmd, $direction_next);
278 }
279
280 return $control_builder;
281 }
previous(string $command, int $parameter=null)
A previous control allows the user to go back to the previous item in the object.The $parameter can b...
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.The $parameter can be used ...
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 220 of file class.ilLSPlayer.php.

220 : array
221 {
222 foreach ($items as $index => $item) {
223 if ($item->getRefId() === $ref_id) {
224 return [$index, $item];
225 }
226 }
227 throw new \Exception("This is not a valid item.", 1);
228 }
$index
Definition: metadata.php:128

References $index.

Referenced by getCurrentItem(), and play().

+ Here is the caller graph for this function:

◆ getCurrentItem()

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

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

172 {
173 $current_item = $items[0];
174 $current_item_ref_id = $this->ls_items->getCurrentItemRefId();
175 if ($current_item_ref_id !== 0) {
176 $valid_ref_ids = array_map(
177 function ($item) {
178 return $item->getRefId();
179 },
180 array_values($this->ls_items->getItems())
181 );
182 if (in_array($current_item_ref_id, $valid_ref_ids)) {
183 list($position, $current_item) = $this->findItemByRefId($items, $current_item_ref_id);
184 }
185 }
186 return $current_item;
187 }
Add learning progress and availability information to the LSItem.
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 297 of file class.ilLSPlayer.php.

298 {
299 $item = $this->getCurrentItem($this->ls_items->getItems());
300 return $item->getLearningProgressStatus();
301 }
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 207 of file class.ilLSPlayer.php.

208 {
209 list($position, $item) = $this->findItemByRefId($items, $current_item->getRefId());
210 $next = $position + $direction;
211 if ($next >= 0 && $next < count($items)) {
212 return $items[$next];
213 }
214 return $current_item;
215 }
getRefId()
Definition: LSItem.php:129

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 ( array  $get,
array  $post = null 
)

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

53 {
54 //init state and current item
55 $items = $this->ls_items->getItems();
56 if (count($items) === 0) {
57 return self::RET_NOITEMS;
58 }
59 $current_item = $this->getCurrentItem($items);
60
61 while ($current_item->getAvailability() !== \ILIAS\UI\Component\Listing\Workflow\Step::AVAILABLE) {
62 $prev_item = $this->getNextItem($items, $current_item, -1);
63 if ($prev_item === $current_item) {
64 throw new \Exception("Cannot view first LSO-item", 1);
65 }
66 $current_item = $prev_item;
67 }
68
69 $view = $this->view_factory->getViewFor($current_item);
70 $state = $this->ls_items->getStateFor($current_item, $view);
71 $state = $this->updateViewState($state, $view, $get, $post);
72 $items = $this->ls_items->getItems(); //reload items after update viewState
73
74 $current_item_ref_id = $current_item->getRefId();
75 //now, digest parameter:
77 $param = (int) $_GET[self::PARAM_LSO_PARAMETER];
78
79 switch ($command) {
82 //store state and exit
83 $this->ls_items->storeState($state, $current_item_ref_id, $current_item_ref_id);
84 return 'EXIT::' . $command;
86 $next_item = $this->getNextItem($items, $current_item, $param);
87 if ($next_item->getAvailability() !== \ILIAS\UI\Component\Listing\Workflow\Step::AVAILABLE) {
88 $next_item = $current_item;
89 }
90 break;
92 list($position, $next_item) = $this->findItemByRefId($items, $param);
93 break;
94 default: //view-internal / unknown command
95 $next_item = $current_item;
96 }
97 //write State to DB
98 $this->ls_items->storeState($state, $current_item_ref_id, $next_item->getRefId());
99
100 //get proper view
101 if ($next_item != $current_item) {
102 $view = $this->view_factory->getViewFor($next_item);
103 $state = $this->ls_items->getStateFor($next_item, $view);
104 }
105
106 //content
107 $obj_title = $next_item->getTitle();
108 $icon = $this->ui_factory->symbol()->icon()
109 ->standard($next_item->getType(), $next_item->getType(), 'medium');
110
111 $content = $this->renderComponentView($state, $view);
112
113 $panel = $this->ui_factory->panel()->standard(
114 '', //panel_title
115 $content
116 );
117 $content = [$panel];
118
119 $items = $this->ls_items->getItems(); //reload items after renderComponentView content
120
121 //get position
122 list($item_position, $item) = $this->findItemByRefId($items, $next_item->getRefId());
123
124 //have the view build controls
125 $control_builder = $this->control_builder;
126 $view->buildControls($state, $control_builder);
127
128 //amend controls not set by the view
129 $control_builder = $this->buildDefaultControls($control_builder, $item, $item_position, $items);
130
131 $rendered_body = $this->page_renderer->render(
132 $this->lso_title,
133 $control_builder,
134 $obj_title,
135 $icon,
136 $content
137 );
138
139 $metabar_controls = [
140 'exit' => $control_builder->getExitControl()
141 ];
142
143 //curriculum
144 $curriculum_slate = $this->page_renderer->buildCurriculumSlate(
145 $this->curriculum_builder
146 ->getLearnerCurriculum(true)
147 ->withActive($item_position)
148 );
149 $mainbar_controls = [
150 'curriculum' => $curriculum_slate
151 ];
152
153 //ToC
154 $toc = $control_builder->getToc();
155 if ($toc) {
156 $toc_slate = $this->page_renderer->buildToCSlate($toc, $icon);
157 $mainbar_controls['toc'] = $toc_slate;
158 }
159
160 $cc = $this->current_context;
161 $cc->addAdditionalData(self::GS_DATA_LS_KIOSK_MODE, true);
162 $cc->addAdditionalData(self::GS_DATA_LS_METABARCONTROLS, $metabar_controls);
163 $cc->addAdditionalData(self::GS_DATA_LS_MAINBARCONTROLS, $mainbar_controls);
164 $cc->addAdditionalData(self::GS_DATA_LS_CONTENT, $rendered_body);
165 return;
166 }
$_GET["client_id"]
const PARAM_LSO_COMMAND
updateViewState(ILIAS\KioskMode\State $state, ILIAS\KioskMode\View $view, array $get, array $post=null)
buildDefaultControls(LSControlBuilder $control_builder, LSLearnerItem $item, int $item_position, array $items)
renderComponentView( $state, ILIAS\KioskMode\View $view)
if(isset($_FILES['img_file']) &&is_array($_FILES['img_file'])) $panel
Definition: imgupload.php:138
Class ChatMainBarProvider \MainMenu\Provider.
Class Factory.
$param
Definition: xapitoken.php:29

References $_GET, $panel, $param, buildDefaultControls(), findItemByRefId(), getCurrentItem(), getNextItem(), LSO_CMD_FINISH, LSO_CMD_GOTO, LSO_CMD_NEXT, LSO_CMD_SUSPEND, PARAM_LSO_COMMAND, renderComponentView(), RET_NOITEMS, and updateViewState().

+ Here is the call graph for this function:

◆ renderComponentView()

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

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

286 {
287 $component = $view->render(
288 $state,
289 $this->ui_factory,
290 $this->url_builder,
291 []
292 );
293 return $component;
294 }

Referenced by play().

+ Here is the caller graph for this function:

◆ updateViewState()

ilLSPlayer::updateViewState ( ILIAS\KioskMode\State  $state,
ILIAS\KioskMode\View  $view,
array  $get,
array  $post = null 
)
protected

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

195 //get view internal command
196 $command = $_GET[self::PARAM_LSO_COMMAND];
197 $param = (int) $_GET[self::PARAM_LSO_PARAMETER];
198 if (!is_null($command)) {
199 $state = $view->updateGet($state, $command, $param);
200 }
201 return $state;
202 }
Keeps the state of a view in a simple stringly type key-value store.
Definition: State.php:10

References $param.

Referenced by play().

+ Here is the caller graph for this function:

Field Documentation

◆ GS_DATA_LS_CONTENT

const ilLSPlayer::GS_DATA_LS_CONTENT = 'ls_content'

Definition at line 23 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 22 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 24 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 25 of file class.ilLSPlayer.php.

Referenced by ilLSViewLayoutProvider\getMetaBarModification().

◆ LSO_CMD_FINISH

const ilLSPlayer::LSO_CMD_FINISH = 'lsofinish'

◆ LSO_CMD_GOTO

const ilLSPlayer::LSO_CMD_GOTO = 'lsogoto'

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

Referenced by ilLSLocalDI\init(), and play().

◆ LSO_CMD_NEXT

const ilLSPlayer::LSO_CMD_NEXT = 'lsonext'

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

Referenced by play().

◆ LSO_CMD_SUSPEND

const ilLSPlayer::LSO_CMD_SUSPEND = 'lsosuspend'

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

Referenced by ilObjLearningSequenceLearnerGUI\play(), and play().

◆ PARAM_LSO_COMMAND

const ilLSPlayer::PARAM_LSO_COMMAND = 'lsocmd'

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

Referenced by play().

◆ PARAM_LSO_PARAMETER

const ilLSPlayer::PARAM_LSO_PARAMETER = 'lsov'

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

◆ RET_EXIT

const ilLSPlayer::RET_EXIT = 'EXIT::'

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

Referenced by ilObjLearningSequenceLearnerGUI\play().

◆ RET_NOITEMS

const ilLSPlayer::RET_NOITEMS = 'NOITEMS'

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

Referenced by ilObjLearningSequenceLearnerGUI\play(), and play().


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