ILIAS  trunk Revision v11.0_alpha-3011-gc6b235a2e85
class.ilFileKioskModeView.php
Go to the documentation of this file.
1<?php
2
19declare(strict_types=1);
20
29use ILIAS\Refinery\Factory as Refinery;
30
35{
39 private const CMD_TOGGLE_LEARNING_PROGRESS = 'toggleManualLearningProgress';
40
42 protected ilObjUser $user;
47 protected Refinery $refinery;
48 protected ilTabsGUI $tabs;
50 protected array $messages = [];
51
52 protected function getObjectClass(): string
53 {
54 return ilObjFile::class;
55 }
56
57 protected function setObject(ilObject $object): void
58 {
59 global $DIC;
60
62 $this->file_obj = $object;
63
64 $this->ctrl = $DIC->ctrl();
65 $this->main_template = $DIC->ui()->mainTemplate();
66 $this->ui_factory = $DIC->ui()->factory();
67 $this->ui_renderer = $DIC->ui()->renderer();
68 $this->http = $DIC->http();
69 $this->refinery = $DIC->refinery();
70 $this->tabs = $DIC->tabs();
71 $this->user = $DIC->user();
72 }
73
74 protected function hasPermissionToAccessKioskMode(): bool
75 {
76 return $this->access->checkAccess('read', '', $this->file_obj->getRefId());
77 }
78
79 public function buildInitialState(State $empty_state): State
80 {
81 return $empty_state;
82 }
83
84 public function buildControls(State $state, ControlBuilder $builder): void
85 {
86 $learning_progress = \ilObjectLP::getInstance($this->file_obj->getId());
87 if ($learning_progress->getCurrentMode(
88 ) === \ilLPObjSettings::LP_MODE_MANUAL) { //TODO: create and implement handling for second lp mode
90 }
91 }
92
93 public function updateGet(State $state, string $command, ?int $parameter = null): State
94 {
95 if ($command === self::CMD_TOGGLE_LEARNING_PROGRESS) {
97 }
98 return $state;
99 }
100
101 public function updatePost(State $state, string $command, array $post): State
102 {
103 return $state;
104 }
105
106 public function render(State $state, Factory $factory, URLBuilder $url_builder, ?array $post = null): Component
107 {
108 $file_gui = new ilObjFileGUI($this->file_obj->getRefId());
109 return $factory->legacy()->content($file_gui->buildInfoScreen(true)->getHTML());
110 }
111
113 {
114 $this->lng->loadLanguageModule('file');
115 if (ilLPStatus::_hasUserCompleted($this->file_obj->getId(), $this->user->getId())) {
116 $learning_progress_toggle_ctrl_label = $this->lng->txt('file_btn_lp_toggle_state_completed');
117 } else {
118 $learning_progress_toggle_ctrl_label = $this->lng->txt('file_btn_lp_toggle_state_not_completed');
119 }
120
121 return $builder->generic(
122 $learning_progress_toggle_ctrl_label,
123 self::CMD_TOGGLE_LEARNING_PROGRESS,
124 1
125 );
126 }
127
128 protected function toggleLearningProgress(): void
129 {
130 if (!ilLPStatus::_hasUserCompleted($this->file_obj->getId(), $this->user->getId())) {
132 $this->file_obj->getId(),
133 $this->user->getId(),
135 );
136 } else {
138 $this->file_obj->getId(),
139 $this->user->getId(),
141 );
142 }
143 }
144}
$learning_progress
Definition: plugin.php:29
Builds a Color from either hex- or rgb values.
Definition: Factory.php:31
Builds data types.
Definition: Factory.php:36
Keeps the state of a view in a simple stringly type key-value store.
Definition: State.php:27
buildLearningProgressToggleControl(ControlBuilder $builder)
hasPermissionToAccessKioskMode()
Check if the global user has permission to access the kiosk mode of the supplied object.
updateGet(State $state, string $command, ?int $parameter=null)
Update the state based on the provided command.
render(State $state, Factory $factory, URLBuilder $url_builder, ?array $post=null)
ilGlobalTemplateInterface $main_template
buildInitialState(State $empty_state)
Build an initial state based on the Provided empty state.
buildControls(State $state, ControlBuilder $builder)
Construct the controls for the view based on the current state.
updatePost(State $state, string $command, array $post)
Update the state and the object based on the provided command and post-data.
getObjectClass()
Get the class of objects this view displays.
Base class to be implemented and put in class-directory of module with the name il$MODULEKioskModeVie...
setObject(ilObject $object)
Set the object for this view.
static writeStatus(int $a_obj_id, int $a_user_id, int $a_status, int $a_percentage=0, bool $a_force_per=false, ?int &$a_old_status=self::LP_STATUS_NOT_ATTEMPTED_NUM)
Write status for user and object.
const LP_STATUS_COMPLETED_NUM
static _hasUserCompleted(int $a_obj_id, int $a_user_id)
Lookup user object completion.
const LP_STATUS_NOT_ATTEMPTED_NUM
GUI class for file objects.
Class ilObjFile.
User class.
static getInstance(int $obj_id)
Class ilObject Basic functions for all objects.
This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Le...
Interface GlobalHttpState.
Build controls for the view.
generic(string $label, string $command, ?int $parameter=null)
A generic control needs to have a label that tells what it does.
The URLBuilder allows views to get links that are used somewhere inline in the content.
Definition: URLBuilder.php:30
A component is the most general form of an entity in the UI.
Definition: Component.php:28
This is how the factory for UI elements looks.
Definition: Factory.php:38
An entity that renders components to a string output.
Definition: Renderer.php:31
$post
Definition: ltitoken.php:46
static http()
Fetches the global http state from ILIAS.
global $DIC
Definition: shib_login.php:26