ILIAS  release_6 Revision v6.24-5-g0c8bfefb3b8
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'
 

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 28 of file class.ilLSPlayer.php.

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

Member Function Documentation

◆ buildDefaultControls()

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

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

218 $is_first = $item_position === 0;
219 $is_last = $item_position === count($items) - 1;
220
221 if (!$control_builder->getExitControl()) {
223 if ($is_last) {
225 }
226 $control_builder = $control_builder->exit($cmd);
227 }
228
229 if (!$control_builder->getPreviousControl()) {
230 $direction_prev = -1;
231 $cmd = ''; //disables control
232
233 if (!$is_first) {
234 $available = $this->getNextItem($items, $item, $direction_prev)
235 ->getAvailability() === Step::AVAILABLE;
236
237 if ($available) {
238 $cmd = self::LSO_CMD_NEXT;
239 }
240 }
241
242 $control_builder = $control_builder
243 ->previous($cmd, $direction_prev);
244 }
245
246 if (!$control_builder->getNextControl()) {
247 $direction_next = 1;
248 $cmd = '';
249 if (!$is_last) {
250 $available = $this->getNextItem($items, $item, $direction_next)
251 ->getAvailability() === Step::AVAILABLE;
252
253 if ($available) {
254 $cmd = self::LSO_CMD_NEXT;
255 }
256 }
257
258 $control_builder = $control_builder
259 ->next($cmd, $direction_next);
260 }
261
262 return $control_builder;
263 }
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 202 of file class.ilLSPlayer.php.

202 : array
203 {
204 foreach ($items as $index => $item) {
205 if ($item->getRefId() === $ref_id) {
206 return [$index, $item];
207 }
208 }
209 throw new \Exception("This is not a valid item.", 1);
210 }
$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 153 of file class.ilLSPlayer.php.

154 {
155 $current_item = $items[0];
156 $current_item_ref_id = $this->ls_items->getCurrentItemRefId();
157 if ($current_item_ref_id !== 0) {
158 $valid_ref_ids = array_map(
159 function($item) {
160 return $item->getRefId();
161 },
162 array_values($this->ls_items->getItems())
163 );
164 if(in_array($current_item_ref_id, $valid_ref_ids)) {
165 list($position, $current_item) = $this->findItemByRefId($items, $current_item_ref_id);
166 }
167 }
168 return $current_item;
169 }
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 279 of file class.ilLSPlayer.php.

280 {
281 $item = $this->getCurrentItem($this->ls_items->getItems());
282 return $item->getLearningProgressStatus();
283 }
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 189 of file class.ilLSPlayer.php.

190 {
191 list($position, $item) = $this->findItemByRefId($items, $current_item->getRefId());
192 $next = $position + $direction;
193 if ($next >= 0 && $next < count($items)) {
194 return $items[$next];
195 }
196 return $current_item;
197 }
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 50 of file class.ilLSPlayer.php.

51 {
52 //init state and current item
53 $items = $this->ls_items->getItems();
54 $current_item = $this->getCurrentItem($items);
55 $current_item_ref_id = $current_item->getRefId();
56 $view = $this->view_factory->getViewFor($current_item);
57 $state = $this->ls_items->getStateFor($current_item, $view);
58 $state = $this->updateViewState($state, $view, $get, $post);
59 $items = $this->ls_items->getItems(); //reload items after update viewState
60
61 //now, digest parameter:
63 $param = (int) $_GET[self::PARAM_LSO_PARAMETER];
64
65 switch ($command) {
68 //store state and exit
69 $this->ls_items->storeState($state, $current_item_ref_id, $current_item_ref_id);
70 return 'EXIT::' . $command;
72 $next_item = $this->getNextItem($items, $current_item, $param);
73 break;
75 list($position, $next_item) = $this->findItemByRefId($items, $param);
76 break;
77 default: //view-internal / unknown command
78 $next_item = $current_item;
79 }
80 //write State to DB
81 $this->ls_items->storeState($state, $current_item_ref_id, $next_item->getRefId());
82
83 //get proper view
84 if ($next_item !== $current_item) {
85 $view = $this->view_factory->getViewFor($next_item);
86 $state = $this->ls_items->getStateFor($next_item, $view);
87 }
88
89 //get position
90 list($item_position, $item) = $this->findItemByRefId($items, $next_item->getRefId());
91
92 //have the view build controls
93 $control_builder = $this->control_builder;
94 $view->buildControls($state, $control_builder);
95
96 //amend controls not set by the view
97 $control_builder = $this->buildDefaultControls($control_builder, $item, $item_position, $items);
98
99 //content
100 $obj_title = $next_item->getTitle();
101 $icon = $this->ui_factory->symbol()->icon()
102 ->standard($next_item->getType(), $next_item->getType(), 'medium');
103
104 $content = $this->renderComponentView($state, $view);
105
106 $panel = $this->ui_factory->panel()->standard(
107 '', //panel_title
108 $content
109 );
110 $content = [$panel];
111
112
113 $rendered_body = $this->page_renderer->render(
114 $this->lso_title,
115 $control_builder,
116 $obj_title,
117 $icon,
118 $content
119 );
120
121 $metabar_controls = [
122 'exit' => $control_builder->getExitControl()
123 ];
124
125 //curriculum
126 $curriculum_slate = $this->page_renderer->buildCurriculumSlate(
127 $this->curriculum_builder
128 ->getLearnerCurriculum(true)
129 ->withActive($item_position)
130 );
131 $mainbar_controls = [
132 'curriculum' => $curriculum_slate
133 ];
134
135 //ToC
136 $toc = $control_builder->getToc();
137 if ($toc) {
138 $toc_slate = $this->page_renderer->buildToCSlate($toc, $icon);
139 $mainbar_controls['toc'] = $toc_slate;
140 }
141
142 $cc = $this->current_context;
143 $cc->addAdditionalData(self::GS_DATA_LS_KIOSK_MODE, true);
144 $cc->addAdditionalData(self::GS_DATA_LS_METABARCONTROLS, $metabar_controls);
145 $cc->addAdditionalData(self::GS_DATA_LS_MAINBARCONTROLS, $mainbar_controls);
146 $cc->addAdditionalData(self::GS_DATA_LS_CONTENT, $rendered_body);
147 return;
148 }
$_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)
$param
Definition: xapitoken.php:31

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

+ Here is the call graph for this function:

◆ renderComponentView()

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

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

268 {
269 $component = $view->render(
270 $state,
271 $this->ui_factory,
272 $this->url_builder,
273 []
274 );
275 return $component;
276 }

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 171 of file class.ilLSPlayer.php.

177 //get view internal command
178 $command = $_GET[self::PARAM_LSO_COMMAND];
179 $param = (int) $_GET[self::PARAM_LSO_PARAMETER];
180 if (!is_null($command)) {
181 $state = $view->updateGet($state, $command, $param);
182 }
183 return $state;
184 }
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 24 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 23 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 25 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 26 of file class.ilLSPlayer.php.

Referenced by ilLSViewLayoutProvider\getMetaBarModification().

◆ LSO_CMD_FINISH

const ilLSPlayer::LSO_CMD_FINISH = 'lsofinish'

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

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

◆ 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 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.


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