ILIAS  release_9 Revision v9.13-25-g2c18ec4c24f
class.ilFileKioskModeView.php
Go to the documentation of this file.
1 <?php
2 
19 declare(strict_types=1);
20 
30 
35 {
36  private const CMD_TOGGLE_LEARNING_PROGRESS = 'toggleManualLearningProgress';
37 
38  protected ilObjFile $file_obj;
39  protected ilObjUser $user;
40  protected Factory $ui_factory;
44  protected Refinery $refinery;
45  protected ilTabsGUI $tabs;
47  protected array $messages = [];
48 
49  protected function getObjectClass(): string
50  {
51  return ilObjFile::class;
52  }
53 
54  protected function setObject(ilObject $object): void
55  {
56  global $DIC;
57 
59  $this->file_obj = $object;
60 
61  $this->ctrl = $DIC->ctrl();
62  $this->main_template = $DIC->ui()->mainTemplate();
63  $this->ui_factory = $DIC->ui()->factory();
64  $this->ui_renderer = $DIC->ui()->renderer();
65  $this->http = $DIC->http();
66  $this->refinery = $DIC->refinery();
67  $this->tabs = $DIC->tabs();
68  $this->user = $DIC->user();
69  }
70 
71  protected function hasPermissionToAccessKioskMode(): bool
72  {
73  return $this->access->checkAccess('read', '', $this->file_obj->getRefId());
74  }
75 
76  public function buildInitialState(State $empty_state): State
77  {
78  return $empty_state;
79  }
80 
81  public function buildControls(State $state, ControlBuilder $builder): void
82  {
83  $learning_progress = \ilObjectLP::getInstance($this->file_obj->getId());
84  if ($learning_progress->getCurrentMode(
85  ) === \ilLPObjSettings::LP_MODE_MANUAL) { //TODO: create and implement handling for second lp mode
86  $this->buildLearningProgressToggleControl($builder);
87  }
88  }
89 
90  public function updateGet(State $state, string $command, int $parameter = null): State
91  {
92  if ($command === self::CMD_TOGGLE_LEARNING_PROGRESS) {
93  $this->toggleLearningProgress();
94  }
95  return $state;
96  }
97 
98  public function updatePost(State $state, string $command, array $post): State
99  {
100  return $state;
101  }
102 
103  public function render(State $state, Factory $factory, URLBuilder $url_builder, array $post = null): Component
104  {
105  $file_gui = new ilObjFileGUI($this->file_obj->getRefId());
106  return $factory->legacy($file_gui->buildInfoScreen(true)->getHTML());
107  }
108 
110  {
111  $this->lng->loadLanguageModule('file');
112  if (ilLPStatus::_hasUserCompleted($this->file_obj->getId(), $this->user->getId())) {
113  $learning_progress_toggle_ctrl_label = $this->lng->txt('file_btn_lp_toggle_state_completed');
114  } else {
115  $learning_progress_toggle_ctrl_label = $this->lng->txt('file_btn_lp_toggle_state_not_completed');
116  }
117 
118  return $builder->generic(
119  $learning_progress_toggle_ctrl_label,
120  self::CMD_TOGGLE_LEARNING_PROGRESS,
121  1
122  );
123  }
124 
125  protected function toggleLearningProgress(): void
126  {
127  if (!ilLPStatus::_hasUserCompleted($this->file_obj->getId(), $this->user->getId())) {
129  $this->file_obj->getId(),
130  $this->user->getId(),
132  );
133  } else {
135  $this->file_obj->getId(),
136  $this->user->getId(),
138  );
139  }
140  }
141 }
const LP_STATUS_COMPLETED_NUM
static _hasUserCompleted(int $a_obj_id, int $a_user_id)
Lookup user object completion.
Interface GlobalHttpState.
An entity that renders components to a string output.
Definition: Renderer.php:30
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...
updateGet(State $state, string $command, int $parameter=null)
Update the state based on the provided command.
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.
legacy(string $content)
description: purpose: > This component is used to wrap an existing ILIAS UI element into a UI compon...
$learning_progress
Definition: plugin.php:29
Keeps the state of a view in a simple stringly type key-value store.
Definition: State.php:12
global $DIC
Definition: feed.php:28
static http()
Fetches the global http state from ILIAS.
setObject(ilObject $object)
Set the object for this view.
Class ilObjFile.
ilGlobalTemplateInterface $main_template
const LP_STATUS_NOT_ATTEMPTED_NUM
The URLBuilder allows views to get links that are used somewhere inline in the content.
Definition: URLBuilder.php:15
GUI class for file objects.
buildInitialState(State $empty_state)
Build an initial state based on the Provided empty state.
buildLearningProgressToggleControl(ControlBuilder $builder)
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.
$post
Definition: ltitoken.php:49
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.
render(State $state, Factory $factory, URLBuilder $url_builder, array $post=null)