ILIAS  trunk Revision v11.0_alpha-3011-gc6b235a2e85
ilLearningModuleKioskModeView Class Reference

Class ilLearningModuleKioskModeView. More...

+ Inheritance diagram for ilLearningModuleKioskModeView:
+ Collaboration diagram for ilLearningModuleKioskModeView:

Public Member Functions

 updateGet (State $state, string $command, ?int $parameter=null)
 Update the state based on the provided command. More...
 
 buildInitialState (State $empty_state)
 Build an initial state based on the Provided empty state. More...
 
 buildControls (State $state, ControlBuilder $builder)
 Construct the controls for the view based on the current state. More...
 
 updatePost (State $state, string $command, array $post)
 Update the state and the object based on the provided command and post-data. More...
 
 render (State $state, Factory $factory, URLBuilder $url_builder, ?array $post=null)
 
- Public Member Functions inherited from ilKioskModeView
 __construct (ilObject $object, ilCtrl $ctrl, ilLanguage $lng, ilAccessHandler $access)
 
- Public Member Functions inherited from ILIAS\KioskMode\View
 buildInitialState (State $empty_state)
 Build an initial state based on the Provided empty state. More...
 
 buildControls (State $state, ControlBuilder $builder)
 Construct the controls for the view based on the current state. More...
 
 updateGet (State $state, string $command, ?int $parameter=null)
 Update the state based on the provided command. More...
 
 updatePost (State $state, string $command, array $post)
 Update the state and the object based on the provided command and post-data. More...
 
 render (State $state, UI\Factory $factory, URLBuilder $url_builder, ?array $post=null)
 Render a state using the ui-factory and URLs from the builder. More...
 

Data Fields

const CMD_TOGGLE_LEARNING_PROGRESS = 'toggleManualLearningProgress'
 

Protected Member Functions

 getObjectClass ()
 Get the class of objects this view displays. More...
 
 initLMService (?int $current_page)
 
 hasPermissionToAccessKioskMode ()
 Check if the global user has permission to access the kiosk mode of the supplied object. More...
 
 getMenuEntries ()
 
 maybeBuildLearningProgressToggleControl (ControlBuilder $builder)
 
 toggleLearningProgress (string $command)
 
- Protected Member Functions inherited from ilKioskModeView
 getObjectClass ()
 Get the class of objects this view displays. More...
 
 setObject (ilObject $object)
 Set the object for this view. More...
 
 hasPermissionToAccessKioskMode ()
 Check if the global user has permission to access the kiosk mode of the supplied object. More...
 

Protected Attributes

ilPageObject $contentPageObject
 
ilObjLearningModule $lm
 
ilLMPresentationService $lm_pres_service
 
ilLMPresentationGUI $lm_pres = null
 
ilObjUser $user
 
Factory $uiFactory
 
Renderer $uiRenderer
 
ilGlobalTemplateInterface $mainTemplate
 
ServerRequestInterface $httpRequest
 
ilTabsGUI $tabs
 
array $messages = []
 
int $current_page_id = 0
 
array $additional_content = []
 
array $menu_entries = null
 
- Protected Attributes inherited from ilKioskModeView
ilCtrl $ctrl
 
ilLanguage $lng
 
ilAccessHandler $access
 

Detailed Description

Member Function Documentation

◆ buildControls()

ilLearningModuleKioskModeView::buildControls ( State  $state,
ControlBuilder  $builder 
)

Construct the controls for the view based on the current state.

The interaction with the controls build via the ControlBuilder will always be delegated to updateGet.

Implements ILIAS\KioskMode\View.

Definition at line 123 of file class.ilLearningModuleKioskModeView.php.

127 global $DIC;
128
129 $main_tpl = $DIC->ui()->mainTemplate();
130
131 // this may be necessary if updateGet has not been processed
132
133 // THIS currently fails
134 $this->initLMService((int) $state->getValueFor("current_page"));
135 $nav_stat = $this->lm_pres_service->getNavigationStatus();
136
137 // next
138 $succ_id = $nav_stat->getSuccessorPageId();
139 if ($succ_id > 0) {
140 $builder->next("layout", $succ_id);
141 }
142
143 // previous
144 $prev_id = $nav_stat->getPredecessorPageId();
145 if ($prev_id > 0) {
146 $builder->previous("layout", $prev_id);
147 }
148
149 $toc = $builder->tableOfContent($this->lm->getTitle(), 'layout', 0);
150 $lm_toc_renderer = new ilLMSlateTocRendererGUI($this->lm_pres_service);
151 $lm_toc_renderer->renderLSToc($toc);
152
153 // learning progress
154 $builder = $this->maybeBuildLearningProgressToggleControl($builder);
155
156 // menu
157 foreach ($this->getMenuEntries() as $entry) {
158 if (is_object($entry["signal"])) {
159 $builder = $builder->genericWithSignal(
160 $entry["label"],
161 $entry["signal"]
162 );
163 }
164 if ($entry["on_load"] != "") {
165 $main_tpl->addOnLoadCode($entry["on_load"]);
166 }
167 }
168
169 //$builder = $this->addPrintViewSelectionMenuButton($builder);
170
171 return $builder;
172 }
getValueFor(string $key)
Get the value for the given key.
Definition: State.php:56
This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Le...
maybeBuildLearningProgressToggleControl(ControlBuilder $builder)
Build controls for the view.
tableOfContent(string $label, string $command, ?int $parameter=null, $state=null)
A table of content allows the user to get an overview over the generally available content in the obj...
next(string $command, ?int $parameter=null)
A next control allows the user to progress to the next item in the object.
genericWithSignal(string $label, UI\Component\Signal $signal)
A genericWithSignal will trigger the Signal rather than refreshing the View.
previous(string $command, ?int $parameter=null)
A previous control allows the user to go back to the previous item in the object.
global $DIC
Definition: shib_login.php:26

◆ buildInitialState()

ilLearningModuleKioskModeView::buildInitialState ( State  $empty_state)

Build an initial state based on the Provided empty state.

Implements ILIAS\KioskMode\View.

Definition at line 118 of file class.ilLearningModuleKioskModeView.php.

118 : State
119 {
120 return $empty_state->withValueFor("current_page", "");
121 }
Keeps the state of a view in a simple stringly type key-value store.
Definition: State.php:27
withValueFor(string $key, string $value)
Set a value for a key of the state.
Definition: State.php:36

References ILIAS\KioskMode\State\withValueFor().

+ Here is the call graph for this function:

◆ getMenuEntries()

ilLearningModuleKioskModeView::getMenuEntries ( )
protected

Definition at line 174 of file class.ilLearningModuleKioskModeView.php.

174 : array
175 {
176 if (is_null($this->menu_entries)) {
177 $menu = new \ILIAS\LearningModule\Menu\ilLMMenuGUI($this->lm_pres_service);
178 $this->menu_entries = $menu->getEntries();
179 }
180 return $this->menu_entries;
181 }

◆ getObjectClass()

ilLearningModuleKioskModeView::getObjectClass ( )
protected

Get the class of objects this view displays.

Reimplemented from ilKioskModeView.

Definition at line 52 of file class.ilLearningModuleKioskModeView.php.

52 : string
53 {
54 return \ilObjLearningModule::class;
55 }

◆ hasPermissionToAccessKioskMode()

ilLearningModuleKioskModeView::hasPermissionToAccessKioskMode ( )
protected

Check if the global user has permission to access the kiosk mode of the supplied object.

Reimplemented from ilKioskModeView.

Definition at line 113 of file class.ilLearningModuleKioskModeView.php.

113 : bool
114 {
115 return $this->access->checkAccess('read', '', $this->lm->getRefId());
116 }

References ILIAS\Repository\access().

+ Here is the call graph for this function:

◆ initLMService()

ilLearningModuleKioskModeView::initLMService ( ?int  $current_page)
protected

Definition at line 95 of file class.ilLearningModuleKioskModeView.php.

95 : void
96 {
97 if (is_object($this->lm_pres)) {
98 return;
99 }
100 $this->lm_pres = new ilLMPresentationGUI(
101 "",
102 false,
103 "",
104 false,
105 ["ref_id" => $this->lm->getRefId(),
106 "obj_id" => (int) $current_page],
107 true
108 );
109
110 $this->lm_pres_service = $this->lm_pres->getService();
111 }
Class ilLMPresentationGUI GUI class for learning module presentation.

◆ maybeBuildLearningProgressToggleControl()

ilLearningModuleKioskModeView::maybeBuildLearningProgressToggleControl ( ControlBuilder  $builder)
protected

Definition at line 183 of file class.ilLearningModuleKioskModeView.php.

186 $learningProgress = \ilObjectLP::getInstance($this->lm->getId());
187 if ($learningProgress->getCurrentMode() == \ilLPObjSettings::LP_MODE_MANUAL) {
188 $isCompleted = \ilLPMarks::_hasCompleted($this->user->getId(), $this->lm->getId());
189
190 $this->lng->loadLanguageModule('lm');
191 $learningProgressToggleCtrlLabel = $this->lng->txt('lm_btn_lp_toggle_state_completed');
192 if (!$isCompleted) {
193 $learningProgressToggleCtrlLabel = $this->lng->txt('lm_btn_lp_toggle_state_not_completed');
194 }
195 $builder = $builder->generic(
196 $learningProgressToggleCtrlLabel,
197 self::CMD_TOGGLE_LEARNING_PROGRESS,
198 1
199 );
200 }
201 return $builder;
202 }
static _hasCompleted(int $a_usr_id, int $a_obj_id)
static getInstance(int $obj_id)
generic(string $label, string $command, ?int $parameter=null)
A generic control needs to have a label that tells what it does.

References ilLPMarks\_hasCompleted(), ILIAS\KioskMode\ControlBuilder\generic(), ILIAS\Repository\lng(), and ILIAS\Repository\user().

+ Here is the call graph for this function:

◆ render()

ilLearningModuleKioskModeView::render ( State  $state,
Factory  $factory,
URLBuilder  $url_builder,
?array  $post = null 
)

Definition at line 232 of file class.ilLearningModuleKioskModeView.php.

237 : Component {
238 $this->initLMService((int) $state->getValueFor("current_page"));
239
241 foreach ($this->getMenuEntries() as $entry) {
242 if (is_object($entry["modal"])) {
243 $additional_content[] = $entry["modal"];
244 }
245 }
246
247 $this->ctrl->setParameterByClass("illmpresentationgui", 'ref_id', $this->lm->getRefId());
248 $content = $this->uiRenderer->render($this->messages);
249 $content .= $this->ctrl->getHTML($this->lm_pres, ["cmd" => "layout"], ["illmpresentationgui"]);
250 $content .= $this->uiRenderer->render($additional_content);
251 return $factory->legacy()->content($content);
252 }

◆ toggleLearningProgress()

ilLearningModuleKioskModeView::toggleLearningProgress ( string  $command)
protected

Definition at line 204 of file class.ilLearningModuleKioskModeView.php.

206 : void {
207 if (self::CMD_TOGGLE_LEARNING_PROGRESS === $command) {
208 $learningProgress = \ilObjectLP::getInstance($this->lm->getId());
209 if ($learningProgress->getCurrentMode() == \ilLPObjSettings::LP_MODE_MANUAL) {
210 $marks = new \ilLPMarks($this->lm->getId(), $this->user->getId());
211 $marks->setCompleted(!$marks->getCompleted());
212 $marks->update();
213
214 \ilLPStatusWrapper::_updateStatus($this->lm->getId(), $this->user->getId());
215
216 $this->lng->loadLanguageModule('trac');
217 $this->messages[] = $this->uiFactory->messageBox()->success(
218 $this->lng->txt('trac_updated_status')
219 );
220 }
221 }
222 }
static _updateStatus(int $a_obj_id, int $a_usr_id, ?object $a_obj=null, bool $a_percentage=false, bool $a_force_raise=false)

References ilLPStatusWrapper\_updateStatus(), ilObjectLP\getInstance(), ILIAS\Repository\lng(), and ilLPObjSettings\LP_MODE_MANUAL.

Referenced by updateGet().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ updateGet()

ilLearningModuleKioskModeView::updateGet ( State  $state,
string  $command,
?int  $parameter = null 
)

Update the state based on the provided command.

If the update was caused by a control with a $parameter (see ControlBuilder) that value is passed to $parameter here.

Commands and parameters are defined by the view in buildControl.

Implements ILIAS\KioskMode\View.

Definition at line 72 of file class.ilLearningModuleKioskModeView.php.

76 : State {
77 switch ($command) {
78 case "layout":
79 if ($parameter > 0) {
80 $this->current_page_id = $parameter;
81 $state = $state->withValueFor("current_page", (string) $this->current_page_id);
82 }
83 break;
85 $this->toggleLearningProgress($command);
86 break;
87 }
88
89 //$this->initLMService($this->current_page_id);
90
91 return $state;
92 }

References CMD_TOGGLE_LEARNING_PROGRESS, toggleLearningProgress(), and ILIAS\KioskMode\State\withValueFor().

+ Here is the call graph for this function:

◆ updatePost()

ilLearningModuleKioskModeView::updatePost ( State  $state,
string  $command,
array  $post 
)

Update the state and the object based on the provided command and post-data.

Commands are defined via the url-builder provided to render.

The POSTed data will be passed via $post.

Implements ILIAS\KioskMode\View.

Definition at line 224 of file class.ilLearningModuleKioskModeView.php.

228 : State {
229 return $state;
230 }

Field Documentation

◆ $additional_content

array ilLearningModuleKioskModeView::$additional_content = []
protected

Definition at line 49 of file class.ilLearningModuleKioskModeView.php.

◆ $contentPageObject

ilPageObject ilLearningModuleKioskModeView::$contentPageObject
protected

Definition at line 36 of file class.ilLearningModuleKioskModeView.php.

◆ $current_page_id

int ilLearningModuleKioskModeView::$current_page_id = 0
protected

Definition at line 48 of file class.ilLearningModuleKioskModeView.php.

◆ $httpRequest

ServerRequestInterface ilLearningModuleKioskModeView::$httpRequest
protected

Definition at line 45 of file class.ilLearningModuleKioskModeView.php.

◆ $lm

ilObjLearningModule ilLearningModuleKioskModeView::$lm
protected

Definition at line 38 of file class.ilLearningModuleKioskModeView.php.

◆ $lm_pres

ilLMPresentationGUI ilLearningModuleKioskModeView::$lm_pres = null
protected

Definition at line 40 of file class.ilLearningModuleKioskModeView.php.

◆ $lm_pres_service

ilLMPresentationService ilLearningModuleKioskModeView::$lm_pres_service
protected

Definition at line 39 of file class.ilLearningModuleKioskModeView.php.

◆ $mainTemplate

ilGlobalTemplateInterface ilLearningModuleKioskModeView::$mainTemplate
protected

Definition at line 44 of file class.ilLearningModuleKioskModeView.php.

◆ $menu_entries

array ilLearningModuleKioskModeView::$menu_entries = null
protected

Definition at line 50 of file class.ilLearningModuleKioskModeView.php.

◆ $messages

array ilLearningModuleKioskModeView::$messages = []
protected

Definition at line 47 of file class.ilLearningModuleKioskModeView.php.

◆ $tabs

ilTabsGUI ilLearningModuleKioskModeView::$tabs
protected

Definition at line 46 of file class.ilLearningModuleKioskModeView.php.

◆ $uiFactory

Factory ilLearningModuleKioskModeView::$uiFactory
protected

Definition at line 42 of file class.ilLearningModuleKioskModeView.php.

◆ $uiRenderer

Renderer ilLearningModuleKioskModeView::$uiRenderer
protected

Definition at line 43 of file class.ilLearningModuleKioskModeView.php.

◆ $user

ilObjUser ilLearningModuleKioskModeView::$user
protected

Definition at line 41 of file class.ilLearningModuleKioskModeView.php.

◆ CMD_TOGGLE_LEARNING_PROGRESS

const ilLearningModuleKioskModeView::CMD_TOGGLE_LEARNING_PROGRESS = 'toggleManualLearningProgress'

Definition at line 35 of file class.ilLearningModuleKioskModeView.php.

Referenced by updateGet().


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