ILIAS  trunk Revision v11.0_alpha-2638-g80c1d007f79
class.ilObjIndividualAssessment.php
Go to the documentation of this file.
1 <?php
2 
19 declare(strict_types=1);
20 
23 
30 {
32 
33  protected ?bool $lp_active = null;
39  protected ?Pimple\Container $dic = null;
40 
43 
44 
45 
46  public function __construct(int $id = 0, bool $call_by_reference = true)
47  {
48  global $DIC;
49  $this->type = 'iass';
50  $this->il_access_handler = $DIC["ilAccess"];
51 
53 
54  $this->settings_storage = new ilIndividualAssessmentSettingsStorageDB($DIC['ilDB']);
55 
56  $dic = $this->getDic();
57 
58  $this->members_storage = $dic['iass.member.storage'];
59  $this->access_handler = $dic['iass.accesshandler'];
60  }
61 
65  public function create(): int
66  {
67  $id = parent::create();
68  $this->createMetaData();
69 
71  $this->getId(),
72  '',
73  '',
74  '',
75  '',
76  false,
77  false
78  );
79  $this->settings_storage->createSettings($this->settings);
80  return $id;
81  }
82 
86  public function read(): void
87  {
88  parent::read();
89  global $DIC;
90  $settings_storage = new ilIndividualAssessmentSettingsStorageDB($DIC['ilDB']);
91  $this->settings = $settings_storage->loadSettings($this);
92  $this->info_settings = $settings_storage->loadInfoSettings($this);
93  }
94 
96  {
97  if (!$this->settings) {
98  $this->settings = $this->settings_storage->loadSettings($this);
99  }
100  return $this->settings;
101  }
102 
106  public function setSettings(ilIndividualAssessmentSettings $settings): void
107  {
108  $this->settings = $settings;
109  $this->setTitle($settings->getTitle());
110  $this->setDescription($settings->getDescription());
111  }
112 
114  {
115  if (!$this->info_settings) {
116  $this->info_settings = $this->settings_storage->loadInfoSettings($this);
117  }
118  return $this->info_settings;
119  }
120 
125  {
126  $this->info_settings = $info;
127  }
128 
133  {
134  return $this->members_storage->loadMembers($this);
135  }
136 
142  public function loadMembersAsSingleObjects(?string $filter = null, ?string $sort = null): array
143  {
144  return $this->members_storage->loadMembersAsSingleObjects($this, $filter, $sort);
145  }
146 
151  {
152  return $this->members_storage->loadMembers($this)
153  ->withAccessHandling($this->il_access_handler);
154  }
155 
159  public function updateMembers(ilIndividualAssessmentMembers $members): void
160  {
161  $members->updateStorageAndRBAC($this->members_storage, $this->access_handler);
162  }
163 
167  public function delete(): bool
168  {
169  $this->deleteMetaData();
170  $this->settings_storage->deleteSettings($this);
171  $this->members_storage->deleteMembers($this);
172  return parent::delete();
173  }
174 
178  public function update(): bool
179  {
180  parent::update();
181  $this->updateMetaData();
182 
183  $this->settings_storage->updateSettings($this->settings);
184  return true;
185  }
186 
187  public function updateInfo(): void
188  {
189  $this->settings_storage->updateInfoSettings($this->getInfoSettings());
190  }
191 
196  {
197  return $this->members_storage;
198  }
199 
203  public function initDefaultRoles(): void
204  {
205  $this->access_handler->initDefaultRolesForObject($this);
206  }
207 
212  {
213  return $this->access_handler;
214  }
215 
219  public function cloneObject(int $target_id, int $copy_id = 0, bool $omit_tree = false): ?ilObject
220  {
221  $new_obj = parent::cloneObject($target_id, $copy_id, $omit_tree);
222  $settings = $this->getSettings();
223  $info_settings = $this->getInfoSettings();
224  $new_settings = new ilIndividualAssessmentSettings(
225  $new_obj->getId(),
226  $new_obj->getTitle(),
227  $new_obj->getDescription(),
228  $settings->getContent(),
229  $settings->getRecordTemplate(),
230  $settings->isEventTimePlaceRequired(),
231  $settings->isFileRequired()
232  );
233  $new_obj->settings = $new_settings;
234 
235  $new_info_settings = new ilIndividualAssessmentInfoSettings(
236  $new_obj->getId(),
237  $info_settings->getContact(),
238  $info_settings->getResponsibility(),
239  $info_settings->getPhone(),
240  $info_settings->getMails(),
241  $info_settings->getConsultationHours()
242  );
243  $new_obj->settings = $new_settings;
244  $new_obj->info_settings = $new_info_settings;
245  $new_obj->settings_storage->updateSettings($new_settings);
246  $new_obj->settings_storage->updateInfoSettings($new_info_settings);
247 
248  return $new_obj;
249  }
250 
254  public function isActiveLP(): bool
255  {
256  if ($this->lp_active === null) {
257  $this->lp_active = ilIndividualAssessmentLPInterface::isActiveLP($this->getId());
258  }
259  return $this->lp_active;
260  }
261 
273  public function getParentContainerIdByType(int $id, array $types): int
274  {
275  global $DIC;
276 
277  $tree = $DIC['tree'];
278  $node = $tree->getParentNodeData($id);
279 
280  while ($node['type'] !== "root") {
281  if (in_array($node['type'], $types)) {
282  return (int) $node['ref_id'];
283  }
284  $node = $tree->getParentNodeData((int) $node['ref_id']);
285  }
286  return 0;
287  }
288 
289  protected function getDic(): Pimple\Container
290  {
291  if (is_null($this->dic)) {
292  global $DIC;
293  $this->dic = $this->getObjectDIC(
294  $this,
295  $DIC
296  );
297  }
298  return $this->dic;
299  }
300 
302  {
303  return $this->getDic()['ilIndividualAssessmentMembersGUI'];
304  }
305 
307  {
308  return $this->getDic()['ilIndividualAssessmentSettingsGUI'];
309  }
310 }
loadInfoSettings(ilObjIndividualAssessment $obj)
Load info-screen settings corresponding to obj.
ilIndividualAssessmentMembersStorageDB $members_storage
cloneObject(int $target_id, int $copy_id=0, bool $omit_tree=false)
For the purpose of streamlining the grading and learning-process status definition outside of tests...
A settings storage handler to write iass settings to db.
ilIndividualAssessmentSettings $settings
isEventTimePlaceRequired()
Get the value of the checkbox event_time_place_require.
An object carrying settings of an Individual Assessment obj beyond the standard information.
membersStorage()
Get the member storage object used by this.
ilTree $tree
__construct(int $id=0, bool $call_by_reference=true)
loadMembersAsSingleObjects(?string $filter=null, ?string $sort=null)
Get the members as single object associated with this.
getTitle()
Get the content of this assessment, e.g.
ilIndividualAssessmentAccessHandler $access_handler
setTitle(string $title)
setInfoSettings(ilIndividualAssessmentInfoSettings $info)
Set info settings.
getContent()
Get the content of this assessment, e.g.
loadVisibleMembers()
Get the members object associated with this and visible by the current user.
Mechanic regarding the access control and roles of an objet goes here.
while($session_entry=$r->fetchRow(ilDBConstants::FETCHMODE_ASSOC)) return null
getDescription()
Get the content of this assessment, e.g.
isActiveLP()
Check whether the LP is activated for current object.
ilIndividualAssessmentInfoSettings $info_settings
This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Le...
getParentNodeData(int $a_node_id)
get data of parent node from tree and object_data
bool $call_by_reference
global $DIC
Definition: shib_login.php:26
setSettings(ilIndividualAssessmentSettings $settings)
Set the settings.
loadSettings(ilObjIndividualAssessment $obj)
Load settings corresponding to obj.
ilIndividualAssessmentFileStorage $file_storage
withAccessHandling(ilOrgUnitPositionAndRBACAccessHandler $access_handler)
Get a collection like this, but only including users that are visible according to the supplied acces...
loadMembers()
Get the members object associated with this.
updateStorageAndRBAC(ilIndividualAssessmentMembersStorage $storage, IndividualAssessmentAccessHandler $access_handler)
Store the data to a persistent medium.
$id
plugin.php for ilComponentBuildPluginInfoObjectiveTest::testAddPlugins
Definition: plugin.php:23
__construct(Container $dic, ilPlugin $plugin)
isFileRequired()
Get the value of the checkbox file_required.
getRecordTemplate()
Get the record template to be used as default record with corresponding object.
$info
Definition: entry_point.php:21
ilIndividualAssessmentSettingsGUI: ilIndividualAssessmentCommonSettingsGUI
accessHandler()
Get the access handler of this.
For the purpose of streamlining the grading and learning-process status definition outside of tests...
updateMembers(ilIndividualAssessmentMembers $members)
Update the members object associated with this.
Member administration related logic, add and remove members, get the list of all members, etc ...
setDescription(string $description)
getParentContainerIdByType(int $id, array $types)
Bubbles up the tree.
ilIndividualAssessmentSettingsStorageDB $settings_storage