1 <?php declare(strict_types=1);
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;
50 public function play(array $get, array $post = null)
53 $items = $this->ls_items->getItems();
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);
59 $items = $this->ls_items->getItems();
62 $command =
$_GET[self::PARAM_LSO_COMMAND];
66 case self::LSO_CMD_SUSPEND:
67 case self::LSO_CMD_FINISH:
69 $this->ls_items->storeState($state, $current_item_ref_id, $current_item_ref_id);
70 return 'EXIT::' . $command;
71 case self::LSO_CMD_NEXT:
74 case self::LSO_CMD_GOTO:
78 $next_item = $current_item;
81 $this->ls_items->storeState($state, $current_item_ref_id, $next_item->getRefId());
84 if ($next_item !== $current_item) {
85 $view = $this->view_factory->getViewFor($next_item);
86 $state = $this->ls_items->getStateFor($next_item, $view);
90 list($item_position, $item) = $this->
findItemByRefId($items, $next_item->getRefId());
93 $control_builder = $this->control_builder;
94 $view->buildControls($state, $control_builder);
100 $obj_title = $next_item->getTitle();
101 $icon = $this->ui_factory->symbol()->icon()
102 ->standard($next_item->getType(), $next_item->getType(),
'medium');
106 $panel = $this->ui_factory->panel()->standard(
113 $rendered_body = $this->page_renderer->render(
121 $metabar_controls = [
122 'exit' => $control_builder->getExitControl()
126 $curriculum_slate = $this->page_renderer->buildCurriculumSlate(
127 $this->curriculum_builder
128 ->getLearnerCurriculum(
true)
129 ->withActive($item_position)
131 $mainbar_controls = [
132 'curriculum' => $curriculum_slate
136 $toc = $control_builder->getToc();
138 $toc_slate = $this->page_renderer->buildToCSlate($toc, $icon);
139 $mainbar_controls[
'toc'] = $toc_slate;
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);
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(
160 return $item->getRefId();
162 array_values($this->ls_items->getItems())
164 if(in_array($current_item_ref_id, $valid_ref_ids)) {
165 list($position, $current_item) = $this->
findItemByRefId($items, $current_item_ref_id);
168 return $current_item;
172 ILIAS\KioskMode\State $state,
173 ILIAS\KioskMode\View $view,
176 ) :
ILIAS\KioskMode\State {
178 $command =
$_GET[self::PARAM_LSO_COMMAND];
180 if (!is_null($command)) {
181 $state = $view->updateGet($state, $command,
$param);
192 $next = $position + $direction;
193 if ($next >= 0 && $next < count($items)) {
194 return $items[$next];
196 return $current_item;
204 foreach ($items as
$index => $item) {
205 if ($item->getRefId() === $ref_id) {
209 throw new \Exception(
"This is not a valid item.", 1);
218 $is_first = $item_position === 0;
219 $is_last = $item_position === count($items) - 1;
222 $cmd = self::LSO_CMD_SUSPEND;
224 $cmd = self::LSO_CMD_FINISH;
226 $control_builder = $control_builder->
exit($cmd);
230 $direction_prev = -1;
234 $available = $this->
getNextItem($items, $item, $direction_prev)
235 ->getAvailability() === Step::AVAILABLE;
238 $cmd = self::LSO_CMD_NEXT;
242 $control_builder = $control_builder
250 $available = $this->
getNextItem($items, $item, $direction_next)
251 ->getAvailability() === Step::AVAILABLE;
254 $cmd = self::LSO_CMD_NEXT;
258 $control_builder = $control_builder
259 ->
next($cmd, $direction_next);
262 return $control_builder;
267 ILIAS\KioskMode\View $view
269 $component = $view->render(
282 return $item->getLearningProgressStatus();
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...
buildDefaultControls(LSControlBuilder $control_builder, LSLearnerItem $item, int $item_position, array $items)
const GS_DATA_LS_KIOSK_MODE
updateViewState(ILIAS\KioskMode\State $state, ILIAS\KioskMode\View $view, array $get, array $post=null)
getCurrentItem(array $items)
Class ChatMainBarProvider .
findItemByRefId(array $items, int $ref_id)
const PARAM_LSO_PARAMETER
getNextItem(array $items, LSLearnerItem $current_item, int $direction)
$direction is either -1 or 1;
exit(string $command)
An exit control allows the user to gracefully leave the object providing the kiosk mode...
const GS_DATA_LS_MAINBARCONTROLS
This combines calls to ProgressDB and StateDB to handle learner-items in the context of a specific LS...
__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)
Implementation of KioskMode Player.
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.
getCurrentItemLearningProgress()
Builds the overview (curriculum) of a LearningSequence.
const GS_DATA_LS_METABARCONTROLS
Add learning progress and availability information to the LSItem.