1 <?php declare(strict_types=1);
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;
52 public function play(array $get, array $post = null)
55 $items = $this->ls_items->getItems();
56 if (count($items) === 0) {
57 return self::RET_NOITEMS;
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);
66 $current_item = $prev_item;
69 $view = $this->view_factory->getViewFor($current_item);
70 $state = $this->ls_items->getStateFor($current_item, $view);
72 $items = $this->ls_items->getItems();
74 $current_item_ref_id = $current_item->getRefId();
76 $command =
$_GET[self::PARAM_LSO_COMMAND];
80 case self::LSO_CMD_SUSPEND:
81 case self::LSO_CMD_FINISH:
83 $this->ls_items->storeState($state, $current_item_ref_id, $current_item_ref_id);
84 return 'EXIT::' . $command;
85 case self::LSO_CMD_NEXT:
88 $next_item = $current_item;
91 case self::LSO_CMD_GOTO:
95 $next_item = $current_item;
98 $this->ls_items->storeState($state, $current_item_ref_id, $next_item->getRefId());
101 if ($next_item != $current_item) {
102 $view = $this->view_factory->getViewFor($next_item);
103 $state = $this->ls_items->getStateFor($next_item, $view);
107 $obj_title = $next_item->getTitle();
108 $icon = $this->ui_factory->symbol()->icon()
109 ->standard($next_item->getType(), $next_item->getType(),
'medium');
113 $panel = $this->ui_factory->panel()->standard(
119 $items = $this->ls_items->getItems();
122 list($item_position, $item) = $this->
findItemByRefId($items, $next_item->getRefId());
125 $control_builder = $this->control_builder;
126 $view->buildControls($state, $control_builder);
129 $control_builder = $this->
buildDefaultControls($control_builder, $item, $item_position, $items);
131 $rendered_body = $this->page_renderer->render(
139 $metabar_controls = [
140 'exit' => $control_builder->getExitControl()
144 $curriculum_slate = $this->page_renderer->buildCurriculumSlate(
145 $this->curriculum_builder
146 ->getLearnerCurriculum(
true)
147 ->withActive($item_position)
149 $mainbar_controls = [
150 'curriculum' => $curriculum_slate
154 $toc = $control_builder->getToc();
156 $toc_slate = $this->page_renderer->buildToCSlate($toc, $icon);
157 $mainbar_controls[
'toc'] = $toc_slate;
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);
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(
178 return $item->getRefId();
180 array_values($this->ls_items->getItems())
182 if (in_array($current_item_ref_id, $valid_ref_ids)) {
183 list($position, $current_item) = $this->
findItemByRefId($items, $current_item_ref_id);
186 return $current_item;
190 ILIAS\KioskMode\State $state,
191 ILIAS\KioskMode\View $view,
194 ) :
ILIAS\KioskMode\State {
196 $command =
$_GET[self::PARAM_LSO_COMMAND];
198 if (!is_null($command)) {
199 $state = $view->updateGet($state, $command,
$param);
210 $next = $position + $direction;
211 if ($next >= 0 && $next < count($items)) {
212 return $items[$next];
214 return $current_item;
222 foreach ($items as
$index => $item) {
223 if ($item->getRefId() === $ref_id) {
227 throw new \Exception(
"This is not a valid item.", 1);
236 $is_first = $item_position === 0;
237 $is_last = $item_position === count($items) - 1;
240 $cmd = self::LSO_CMD_SUSPEND;
242 $cmd = self::LSO_CMD_FINISH;
244 $control_builder = $control_builder->
exit($cmd);
248 $direction_prev = -1;
252 $available = $this->
getNextItem($items, $item, $direction_prev)
253 ->getAvailability() === Step::AVAILABLE;
256 $cmd = self::LSO_CMD_NEXT;
260 $control_builder = $control_builder
268 $available = $this->
getNextItem($items, $item, $direction_next)
269 ->getAvailability() === Step::AVAILABLE;
272 $cmd = self::LSO_CMD_NEXT;
276 $control_builder = $control_builder
277 ->
next($cmd, $direction_next);
280 return $control_builder;
285 ILIAS\KioskMode\View $view
287 $component = $view->render(
300 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)
if(isset($_FILES['img_file']) &&is_array($_FILES['img_file'])) $panel
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.