19 declare(strict_types=1);
62 $items = $this->ls_items->getItems();
64 if (count($items) === 0) {
69 if ($current_item ===
null) {
73 $view = $this->view_factory->getViewFor($current_item);
74 $state = $this->ls_items->getStateFor($current_item, $view);
77 $items = $this->ls_items->getItems();
79 $current_item_ref_id = $current_item->getRefId();
82 if ($get->
has(self::PARAM_LSO_COMMAND)) {
83 $command = $get->
retrieve(self::PARAM_LSO_COMMAND, $this->
refinery->kindlyTo()->string());
86 if ($get->
has(self::PARAM_LSO_PARAMETER)) {
91 case self::LSO_CMD_SUSPEND:
92 case self::LSO_CMD_FINISH:
93 $this->ls_items->storeState($state, $current_item_ref_id, $current_item_ref_id);
94 return 'EXIT::' . $command;
95 case self::LSO_CMD_NEXT:
97 if ($next_item->getAvailability() !== Step::AVAILABLE) {
98 $next_item = $current_item;
101 case self::LSO_CMD_GOTO:
105 $next_item = $current_item;
108 $this->ls_items->storeState($state, $current_item_ref_id, $next_item->getRefId());
111 if ($next_item != $current_item) {
112 $view = $this->view_factory->getViewFor($next_item);
113 $state = $this->ls_items->getStateFor($next_item, $view);
117 $obj_title = $next_item->getTitle();
118 $icon = $this->ui_factory->symbol()->icon()->standard(
119 $next_item->getType(),
120 $next_item->getType(),
126 $panel = $this->ui_factory->panel()->standard(
132 $items = $this->ls_items->getItems();
135 list($item_position, $item) = $this->
findItemByRefId($items, $next_item->getRefId());
138 $control_builder = $this->control_builder;
139 $view->buildControls($state, $control_builder);
142 $control_builder = $this->
buildDefaultControls($control_builder, $item, $item_position, $items);
144 $rendered_body = $this->page_renderer->render(
151 $metabar_controls = [
152 'exit' => $control_builder->getExitControl()
155 $curriculum_slate = $this->page_renderer->buildCurriculumSlate(
156 $this->curriculum_builder
157 ->getLearnerCurriculum(
true)
158 ->withActive($item_position)
160 $mainbar_controls = [
161 'curriculum' => $curriculum_slate
164 $toc = $control_builder->getToc();
166 $toc_slate = $this->page_renderer->buildToCSlate($toc, $icon);
167 $mainbar_controls[
'toc'] = $toc_slate;
170 $cc = $this->current_context;
171 $cc->addAdditionalData(self::GS_DATA_LS_KIOSK_MODE,
true);
172 $cc->addAdditionalData(self::GS_DATA_LS_METABARCONTROLS, $metabar_controls);
173 $cc->addAdditionalData(self::GS_DATA_LS_MAINBARCONTROLS, $mainbar_controls);
174 $cc->addAdditionalData(self::GS_DATA_LS_CONTENT, $rendered_body);
184 $current_item = $items[0];
185 $current_item_ref_id = $this->ls_items->getCurrentItemRefId();
186 if ($current_item_ref_id !== 0) {
188 fn($item) => $item->getRefId(),
189 array_values($this->ls_items->getItems())
191 if (in_array($current_item_ref_id, $valid_ref_ids)) {
192 list(, $current_item) = $this->
findItemByRefId($items, $current_item_ref_id);
195 return $current_item;
203 return $current_item;
206 $new_next_item =
null;
207 $idx = array_search($current_item, $items);
209 for ($i = $idx - 1; $i >= 0; $i--) {
210 if ($items[$i]->getAvailability() === Step::AVAILABLE) {
211 $new_next_item = $items[$i];
215 if ($new_next_item ===
null) {
216 for ($i = $idx + 1; $i < count($items); $i++) {
217 if ($items[$i]->getAvailability() === Step::AVAILABLE) {
218 $new_next_item = $items[$i];
223 return $new_next_item;
228 ILIAS\KioskMode\View $view,
231 if ($get->
has(self::PARAM_LSO_COMMAND) && $get->
has(self::PARAM_LSO_PARAMETER)) {
232 $command = $get->
retrieve(self::PARAM_LSO_COMMAND, $this->
refinery->kindlyTo()->string());
234 $state = $view->updateGet($state, $command,
$param);
245 $next = $position + $direction;
246 if ($next >= 0 && $next < count($items)) {
247 return $items[$next];
249 return $current_item;
257 foreach ($items as $index => $item) {
258 if ($item->getRefId() ===
$ref_id) {
259 return [$index, $item];
262 throw new \Exception(
"This is not a valid item.", 1);
271 $is_first = $item_position === 0;
272 $is_last = $item_position === count($items) - 1;
275 $cmd = self::LSO_CMD_SUSPEND;
277 $cmd = self::LSO_CMD_FINISH;
279 $control_builder = $control_builder->
exit($cmd);
283 $direction_prev = -1;
287 $available = $this->
getNextItem($items, $item, $direction_prev)
288 ->getAvailability() === Step::AVAILABLE;
291 $cmd = self::LSO_CMD_NEXT;
295 $control_builder = $control_builder
303 $available = $this->
getNextItem($items, $item, $direction_next)
304 ->getAvailability() === Step::AVAILABLE;
307 $cmd = self::LSO_CMD_NEXT;
311 $control_builder = $control_builder
312 ->
next($cmd, $direction_next);
315 return $control_builder;
320 return $view->render(
331 return $item->getLearningProgressStatus();
buildDefaultControls(LSControlBuilder $control_builder, LSLearnerItem $item, int $item_position, array $items)
play(RequestWrapper $get)
const GS_DATA_LS_KIOSK_MODE
getCurrentItem(array $items)
Interface Observer Contains several chained tasks and infos about them.
This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Le...
renderComponentView($state, ILIAS\KioskMode\View $view)
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...
while($session_entry=$r->fetchRow(ilDBConstants::FETCHMODE_ASSOC)) return null
getNextAvailableItem(array $items, LSLearnerItem $current_item)
const GS_DATA_LS_MAINBARCONTROLS
next(string $command, ?int $parameter=null)
A next control allows the user to progress to the next item in the object.
previous(string $command, ?int $parameter=null)
A previous control allows the user to go back to the previous item in the object. ...
This combines calls to ProgressDB and StateDB to handle learner-items in the context of a specific LS...
updateViewState(ILIAS\KioskMode\State $state, ILIAS\KioskMode\View $view, RequestWrapper $get)
retrieve(string $key, Transformation $transformation)
Implementation of KioskMode Player.
Build controls for the view.
getCurrentItemLearningProgress()
__construct(protected ilLSLearnerItemsQueries $ls_items, protected LSControlBuilder $control_builder, protected LSUrlBuilder $url_builder, protected ilLSCurriculumBuilder $curriculum_builder, protected ilLSViewFactory $view_factory, protected ilKioskPageRenderer $page_renderer, protected Factory $ui_factory, protected ScreenContext $current_context, protected Refinery\Factory $refinery)
Builds the overview (curriculum) of a LearningSequence.
const GS_DATA_LS_METABARCONTROLS
Add learning progress and availability information to the LSItem.