ILIAS  trunk Revision v11.0_alpha-1753-gb21ca8c4367
All Data Structures Namespaces Files Functions Variables Enumerations Enumerator Modules Pages
class.ilFileKioskModeView.php
Go to the documentation of this file.
1 <?php
2 
19 declare(strict_types=1);
20 
30 
35 {
39  private const CMD_TOGGLE_LEARNING_PROGRESS = 'toggleManualLearningProgress';
40 
41  protected ilObjFile $file_obj;
42  protected ilObjUser $user;
43  protected Factory $ui_factory;
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
89  $this->buildLearningProgressToggleControl($builder);
90  }
91  }
92 
93  public function updateGet(State $state, string $command, ?int $parameter = null): State
94  {
95  if ($command === self::CMD_TOGGLE_LEARNING_PROGRESS) {
96  $this->toggleLearningProgress();
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 }
const LP_STATUS_COMPLETED_NUM
static _hasUserCompleted(int $a_obj_id, int $a_user_id)
Lookup user object completion.
legacy()
description: purpose: > legacy components are used as provisional elements in the UI framework while...
Base class to be implemented and put in class-directory of module with the name il$MODULEKioskModeVie...
buildControls(State $state, ControlBuilder $builder)
Construct the controls for the view based on the current state.
This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Le...
This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Le...
updatePost(State $state, string $command, array $post)
Update the state and the object based on the provided command and post-data.
generic(string $label, string $command, ?int $parameter=null)
A generic control needs to have a label that tells what it does.
Keeps the state of a view in a simple stringly type key-value store.
Definition: State.php:26
while($session_entry=$r->fetchRow(ilDBConstants::FETCHMODE_ASSOC)) return null
static http()
Fetches the global http state from ILIAS.
setObject(ilObject $object)
Set the object for this view.
This is how the factory for UI elements looks.
Definition: Factory.php:37
Class ilObjFile.
global $DIC
Definition: shib_login.php:22
ilGlobalTemplateInterface $main_template
$learning_progress
Definition: plugin.php:29
const LP_STATUS_NOT_ATTEMPTED_NUM
The URLBuilder allows views to get links that are used somewhere inline in the content.
Definition: URLBuilder.php:29
GUI class for file objects.
buildInitialState(State $empty_state)
Build an initial state based on the Provided empty state.
buildLearningProgressToggleControl(ControlBuilder $builder)
updateGet(State $state, string $command, ?int $parameter=null)
Update the state based on the provided command.
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.
Build controls for the view.
render(State $state, Factory $factory, URLBuilder $url_builder, ?array $post=null)
$post
Definition: ltitoken.php:46
static getInstance(int $obj_id)