ILIAS  release_7 Revision v7.30-3-g800a261c036
All Data Structures Namespaces Files Functions Variables Modules Pages
ilLearningModuleKioskModeView Class Reference

Class ilLearningModuleKioskModeView. More...

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

Public Member Functions

 updateGet (State $state, string $command, int $param=null)
 
 buildInitialState (State $state)
 
 buildControls (State $state, ControlBuilder $builder)
 
 updatePost (State $state, string $command, array $post)
 
 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
 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 ()
 
 setObject (\ilObject $object)
 
 initLMService ($current_page)
 Init learning module presentation service. More...
 
 hasPermissionToAccessKioskMode ()
 
 getMenuEntries ()
 
 maybeBuildLearningProgressToggleControl (ControlBuilder $builder)
 
 toggleLearningProgress (string $command)
 
 renderContentStyle ()
 Renders the content style of a ContentPage object into main template. More...
 
- 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

 $menu_entries = null
 
 $lm
 
 $lm_pres_service
 
 $lm_pres
 
 $user
 
 $uiFactory
 
 $uiRenderer
 
 $ctrl
 
 $mainTemplate
 
 $httpRequest
 
 $tabs
 
 $messages = []
 
 $current_page_id = 0
 
 $additional_content = []
 
- Protected Attributes inherited from ilKioskModeView
 $ctrl
 
 $lng
 
 $access
 

Detailed Description

Member Function Documentation

◆ buildControls()

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

Implements ILIAS\KioskMode\View.

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

References $builder, $DIC, ILIAS\KioskMode\ControlBuilder\genericWithSignal(), getMenuEntries(), ILIAS\KioskMode\State\getValueFor(), initLMService(), maybeBuildLearningProgressToggleControl(), ILIAS\KioskMode\ControlBuilder\next(), ILIAS\KioskMode\ControlBuilder\previous(), and ILIAS\KioskMode\ControlBuilder\tableOfContent().

156  {
157  global $DIC;
158 
159  $main_tpl = $DIC->ui()->mainTemplate();
160 
161  // this may be necessary if updateGet has not been processed
162 
163  // THIS currently fails
164  $this->initLMService($state->getValueFor("current_page"));
165  $nav_stat = $this->lm_pres_service->getNavigationStatus();
166 
167  // next
168  $succ_id = $nav_stat->getSuccessorPageId();
169  if ($succ_id > 0) {
170  $builder->next("layout", $succ_id);
171  }
172 
173  // previous
174  $prev_id = $nav_stat->getPredecessorPageId();
175  if ($prev_id > 0) {
176  $builder->previous("layout", $prev_id);
177  }
178 
179  $toc = $builder->tableOfContent($this->lm->getTitle(), 'layout', 0);
180  $lm_toc_renderer = new ilLMSlateTocRendererGUI($this->lm_pres_service);
181  $lm_toc_renderer->renderLSToc($toc, $lm_toc_renderer, 0);
182 
183 
184  // learning progress
185  $builder = $this->maybeBuildLearningProgressToggleControl($builder);
186 
187  // menu
188  foreach ($this->getMenuEntries() as $entry) {
189  if (is_object($entry["signal"])) {
190  $builder = $builder->genericWithSignal(
191  $entry["label"],
192  $entry["signal"]
193  );
194  }
195  if ($entry["on_load"] != "") {
196  $main_tpl->addOnLoadCode($entry["on_load"]);
197  }
198  }
199 
200  //$builder = $this->addPrintViewSelectionMenuButton($builder);
201 
202  return $builder;
203  }
next(string $command, int $parameter=null)
A next control allows the user to progress to the next item in the object.
getValueFor(string $key)
Get the value for the given key.
Definition: State.php:40
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...
genericWithSignal(string $label, UI\Component\Signal $signal)
A genericWithSignal will trigger the Signal rather than refreshing the View.
global $DIC
Definition: goto.php:24
maybeBuildLearningProgressToggleControl(ControlBuilder $builder)
initLMService($current_page)
Init learning module presentation service.
previous(string $command, int $parameter=null)
A previous control allows the user to go back to the previous item in the object. ...
Build controls for the view.
$builder
Definition: parser.php:5
+ Here is the call graph for this function:

◆ buildInitialState()

ilLearningModuleKioskModeView::buildInitialState ( State  $state)

Implements ILIAS\KioskMode\View.

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

References ILIAS\KioskMode\State\withValueFor().

147  : State
148  {
149  return $state->withValueFor("current_page", "");
150  }
withValueFor(string $key, string $value)
Set a value for a key of the state.
Definition: State.php:20
Keeps the state of a view in a simple stringly type key-value store.
Definition: State.php:9
+ Here is the call graph for this function:

◆ getMenuEntries()

ilLearningModuleKioskModeView::getMenuEntries ( )
protected
Parameters

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

References $menu_entries.

Referenced by buildControls(), and render().

211  : array
212  {
213  if (is_null($this->menu_entries)) {
214  $menu = new \ILIAS\LearningModule\Menu\ilLMMenuGUI($this->lm_pres_service);
215  $this->menu_entries = $menu->getEntries();
216  }
217  return $this->menu_entries;
218  }
+ Here is the caller graph for this function:

◆ getObjectClass()

ilLearningModuleKioskModeView::getObjectClass ( )
protected

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

71  : string
72  {
73  return \ilObjLearningModule::class;
74  }

◆ hasPermissionToAccessKioskMode()

ilLearningModuleKioskModeView::hasPermissionToAccessKioskMode ( )
protected

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

139  : bool
140  {
141  return $this->access->checkAccess('read', '', $this->lm->getRefId());
142  }

◆ initLMService()

ilLearningModuleKioskModeView::initLMService (   $current_page)
protected

Init learning module presentation service.

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

Referenced by buildControls(), and render().

119  {
120  if (is_object($this->lm_pres)) {
121  return;
122  }
123  $this->lm_pres = new ilLMPresentationGUI(
124  "",
125  false,
126  "",
127  false,
128  ["ref_id" => $this->lm->getRefId(),
129  "obj_id" => (int) $current_page],
130  true
131  );
132 
133  $this->lm_pres_service = $this->lm_pres->getService();
134  }
Class ilLMPresentationGUI.
+ Here is the caller graph for this function:

◆ maybeBuildLearningProgressToggleControl()

ilLearningModuleKioskModeView::maybeBuildLearningProgressToggleControl ( ControlBuilder  $builder)
protected
Parameters
ControlBuilder$builder

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

References $builder, ilLPMarks\_hasCompleted(), ILIAS\KioskMode\ControlBuilder\generic(), ilObjectLP\getInstance(), ilLPObjSettings\LP_MODE_MANUAL, and user().

Referenced by buildControls().

224  {
225  $learningProgress = \ilObjectLP::getInstance($this->lm->getId());
226  if ($learningProgress->getCurrentMode() == \ilLPObjSettings::LP_MODE_MANUAL) {
227  $isCompleted = \ilLPMarks::_hasCompleted($this->user->getId(), $this->lm->getId());
228 
229  $this->lng->loadLanguageModule('lm');
230  $learningProgressToggleCtrlLabel = $this->lng->txt('lm_btn_lp_toggle_state_completed');
231  if (!$isCompleted) {
232  $learningProgressToggleCtrlLabel = $this->lng->txt('lm_btn_lp_toggle_state_not_completed');
233  }
234  $builder = $builder->generic(
235  $learningProgressToggleCtrlLabel,
236  self::CMD_TOGGLE_LEARNING_PROGRESS,
237  1
238  );
239  }
240  return $builder;
241  }
static _hasCompleted($a_usr_id, $a_obj_id)
user()
Definition: user.php:4
Build controls for the view.
$builder
Definition: parser.php:5
static getInstance($a_obj_id)
generic(string $label, string $command, int $parameter=null)
A generic control needs to have a label that tells what it does.
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ render()

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

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

References $additional_content, getMenuEntries(), ILIAS\KioskMode\State\getValueFor(), initLMService(), and ILIAS\UI\Factory\legacy().

281  : Component {
282  $this->initLMService($state->getValueFor("current_page"));
283 
284  $additional_content = [];
285  foreach ($this->getMenuEntries() as $entry) {
286  if (is_object($entry["modal"])) {
287  $additional_content[] = $entry["modal"];
288  }
289  }
290 
291  $this->ctrl->setParameterByClass("illmpresentationgui", 'ref_id', $this->lm->getRefId());
292  $content = $this->uiRenderer->render($this->messages);
293  $content .= $this->ctrl->getHTML($this->lm_pres, ["cmd" => "layout"], ["illmpresentationgui"]);
294  $content .= $this->uiRenderer->render($additional_content);
295  return $factory->legacy($content);
296  }
getValueFor(string $key)
Get the value for the given key.
Definition: State.php:40
legacy($content)
description: purpose: > This component is used to wrap an existing ILIAS UI element into a UI compon...
initLMService($current_page)
Init learning module presentation service.
+ Here is the call graph for this function:

◆ renderContentStyle()

ilLearningModuleKioskModeView::renderContentStyle ( )
protected

Renders the content style of a ContentPage object into main template.

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

References ilObjStyleSheet\getContentStylePath(), and ilObjStyleSheet\getSyntaxStylePath().

302  {
303  $this->mainTemplate->addCss(\ilObjStyleSheet::getSyntaxStylePath());
304  $this->mainTemplate->addCss(
306  $this->contentPageObject->getStyleSheetId()
307  )
308  );
309  }
static getContentStylePath($a_style_id, $add_random=true, $add_token=true)
get content style path
static getSyntaxStylePath()
get syntax style path
+ Here is the call graph for this function:

◆ setObject()

ilLearningModuleKioskModeView::setObject ( \ilObject  $object)
protected

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

References $DIC, and user().

80  {
81  global $DIC;
82 
83  $this->lm = $object;
84  $this->ctrl = $DIC->ctrl();
85  $this->mainTemplate = $DIC->ui()->mainTemplate();
86  $this->uiFactory = $DIC->ui()->factory();
87  $this->uiRenderer = $DIC->ui()->renderer();
88  $this->httpRequest = $DIC->http()->request();
89  $this->tabs = $DIC->tabs();
90  $this->user = $DIC->user();
91  }
user()
Definition: user.php:4
global $DIC
Definition: goto.php:24
+ Here is the call graph for this function:

◆ toggleLearningProgress()

ilLearningModuleKioskModeView::toggleLearningProgress ( string  $command)
protected
Parameters
string$command

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

References ilLPStatusWrapper\_updateStatus(), ilObjectLP\getInstance(), ilLPObjSettings\LP_MODE_MANUAL, and user().

Referenced by updateGet().

247  {
248  if (self::CMD_TOGGLE_LEARNING_PROGRESS === $command) {
249  $learningProgress = \ilObjectLP::getInstance($this->lm->getId());
250  if ($learningProgress->getCurrentMode() == \ilLPObjSettings::LP_MODE_MANUAL) {
251  $marks = new \ilLPMarks($this->lm->getId(), $this->user->getId());
252  $marks->setCompleted(!$marks->getCompleted());
253  $marks->update();
254 
255  \ilLPStatusWrapper::_updateStatus($this->lm->getId(), $this->user->getId());
256 
257  $this->lng->loadLanguageModule('trac');
258  $this->messages[] = $this->uiFactory->messageBox()->success(
259  $this->lng->txt('trac_updated_status')
260  );
261  }
262  }
263  }
static _updateStatus($a_obj_id, $a_usr_id, $a_obj=null, $a_percentage=false, $a_force_raise=false)
Update status.
user()
Definition: user.php:4
static getInstance($a_obj_id)
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ updateGet()

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

Implements ILIAS\KioskMode\View.

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

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

96  : State
97  {
98  switch ($command) {
99  case "layout":
100  if ($param > 0) {
101  $this->current_page_id = $param;
102  $state = $state->withValueFor("current_page", (string) $this->current_page_id);
103  }
104  break;
105  case self::CMD_TOGGLE_LEARNING_PROGRESS:
106  $this->toggleLearningProgress($command);
107  break;
108  }
109 
110  //$this->initLMService($this->current_page_id);
111 
112  return $state;
113  }
withValueFor(string $key, string $value)
Set a value for a key of the state.
Definition: State.php:20
Keeps the state of a view in a simple stringly type key-value store.
Definition: State.php:9
$param
Definition: xapitoken.php:29
+ Here is the call graph for this function:

◆ updatePost()

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

Implements ILIAS\KioskMode\View.

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

268  : State
269  {
270  return $state;
271  }
Keeps the state of a view in a simple stringly type key-value store.
Definition: State.php:9

Field Documentation

◆ $additional_content

ilLearningModuleKioskModeView::$additional_content = []
protected

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

Referenced by render().

◆ $ctrl

ilLearningModuleKioskModeView::$ctrl
protected

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

◆ $current_page_id

ilLearningModuleKioskModeView::$current_page_id = 0
protected

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

◆ $httpRequest

ilLearningModuleKioskModeView::$httpRequest
protected

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

◆ $lm

ilLearningModuleKioskModeView::$lm
protected

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

◆ $lm_pres

ilLearningModuleKioskModeView::$lm_pres
protected

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

◆ $lm_pres_service

ilLearningModuleKioskModeView::$lm_pres_service
protected

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

◆ $mainTemplate

ilLearningModuleKioskModeView::$mainTemplate
protected

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

◆ $menu_entries

ilLearningModuleKioskModeView::$menu_entries = null
protected

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

Referenced by getMenuEntries().

◆ $messages

ilLearningModuleKioskModeView::$messages = []
protected

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

◆ $tabs

ilLearningModuleKioskModeView::$tabs
protected

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

◆ $uiFactory

ilLearningModuleKioskModeView::$uiFactory
protected

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

◆ $uiRenderer

ilLearningModuleKioskModeView::$uiRenderer
protected

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

◆ $user

ilLearningModuleKioskModeView::$user
protected

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

◆ CMD_TOGGLE_LEARNING_PROGRESS

const ilLearningModuleKioskModeView::CMD_TOGGLE_LEARNING_PROGRESS = 'toggleManualLearningProgress'

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


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