3 declare(strict_types=1);
36 $this->lso_ref_id = $lso_ref_id;
37 $this->lso_title = $lso_title;
38 $this->usr_id = $usr_id;
39 $this->items = $items;
40 $this->state_db = $state_db;
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;
52 $stored = $this->state_db->getCurrentItemsFor(
57 $current_item = $this->items[0];
58 $current_item_ref_id = $current_item->getRefId();
60 if (count($stored) > 0 ||
61 $stored[$this->usr_id] > -1
63 $current_item_ref_id = $stored[$this->usr_id];
66 $valid_ref_ids = array_map(
68 return $item->getRefId();
70 array_values($this->items)
73 if (in_array($current_item_ref_id, $valid_ref_ids)) {
74 list($position, $current_item) = $this->
findItemByRefId($current_item_ref_id);
78 $command =
$_GET[self::PARAM_LSO_COMMAND];
79 $param = (int)
$_GET[self::PARAM_LSO_PARAMETER];
83 if ($prev_item === $current_item) {
84 throw new \Exception(
"Cannot view first LSO-item", 1);
86 $current_item = $prev_item;
89 $view = $this->view_factory->getViewFor($current_item);
90 $state = $current_item->getState();
94 case self::LSO_CMD_SUSPEND:
95 case self::LSO_CMD_FINISH:
98 return 'EXIT::' . $command;
99 case self::LSO_CMD_NEXT:
100 $next_item = $this->
getNextItem($current_item, $param);
102 $next_item = $current_item;
105 case self::LSO_CMD_GOTO:
109 $next_item = $current_item;
115 if ($next_item !== $current_item) {
116 $view = $this->view_factory->getViewFor($next_item);
119 list($item_position, $item) = $this->
findItemByRefId($next_item->getRefId());
122 $control_builder = $this->control_builder;
123 $view->buildControls(
$state, $control_builder);
128 $obj_title = $next_item->getTitle();
129 $icon = $this->ui_factory->icon()
130 ->standard($next_item->getType(), $next_item->getType(),
'medium');
132 $curriculum = $this->curriculum_builder->getLearnerCurriculum(
true)
133 ->withActive($item_position);
136 $panel = $this->ui_factory->panel()->standard(
142 return $this->page_renderer->render(
154 int $state_item_ref_id,
155 int $current_item_ref_id
157 $this->state_db->updateState(
168 ILIAS\KioskMode\View $view,
171 ) :
ILIAS\KioskMode\State {
173 $command =
$_GET[self::PARAM_LSO_COMMAND];
174 $param = (int)
$_GET[self::PARAM_LSO_PARAMETER];
175 if (!is_null($command)) {
176 $state = $view->updateGet($state, $command, $param);
188 $next = $position + $direction;
189 if ($next >= 0 && $next < count($this->items)) {
190 return $this->items[$next];
192 return $current_item;
200 foreach ($this->items as
$index => $item) {
201 if ($item->getRefId() === $ref_id) {
205 throw new \Exception(
"This is not a valid item.", 1);
213 $is_first = $item_position === 0;
214 $is_last = $item_position === count($this->items) - 1;
217 $cmd = self::LSO_CMD_SUSPEND;
219 $cmd = self::LSO_CMD_FINISH;
221 $control_builder = $control_builder->
exit($cmd);
225 $direction_prev = -1;
229 $available = $this->
getNextItem($item, $direction_prev)
230 ->getAvailability() === Step::AVAILABLE;
233 $cmd = self::LSO_CMD_NEXT;
237 $control_builder = $control_builder
245 $available = $this->
getNextItem($item, $direction_next)
246 ->getAvailability() === Step::AVAILABLE;
249 $cmd = self::LSO_CMD_NEXT;
253 $control_builder = $control_builder
254 ->
next($cmd, $direction_next);
257 return $control_builder;
262 ILIAS\KioskMode\View $view
264 $component = $view->render(
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...
updateViewState(ILIAS\KioskMode\State $state, ILIAS\KioskMode\View $view, array $get, array $post=null)
getNextItem(LSLearnerItem $current_item, int $direction)
$direction is either -1 or 1;
storeState(ILIAS\KioskMode\State $state, int $state_item_ref_id, int $current_item_ref_id)
const PARAM_LSO_PARAMETER
findItemByRefId(int $ref_id)
render(array $get, array $post=null)
exit(string $command)
An exit control allows the user to gracefully leave the object providing the kiosk mode...
if(!array_key_exists('stateid', $_REQUEST)) $state
Handle linkback() response from LinkedIn.
Persistence for View-States.
Implementation of KioskMode Player.
buildDefaultControls(LSControlBuilder $control_builder, LSLearnerItem $item, int $item_position)
__construct(int $lso_ref_id, string $lso_title, int $usr_id, array $items, ilLSStateDB $state_db, LSControlBuilder $control_builder, LSUrlBuilder $url_builder, ilLSCurriculumBuilder $curriculum_builder, ilLSViewFactory $view_factory, ilKioskPageRenderer $renderer, ILIAS\UI\Factory $ui_factory)
renderComponentView( $state, ILIAS\KioskMode\View $view)
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 ...
Build controls for the view.
Builds the overview (curriculum) of a LearningSequence.
Add learning progress and availability information to the LSItem.