ILIAS  release_5-4 Revision v5.4.26-12-gabc799a52e6
class.ilObjIndividualAssessment.php
Go to the documentation of this file.
1 <?php
11 require_once 'Services/Object/classes/class.ilObject.php';
12 require_once 'Modules/IndividualAssessment/classes/Settings/class.ilIndividualAssessmentSettings.php';
13 require_once 'Modules/IndividualAssessment/classes/Settings/class.ilIndividualAssessmentSettingsStorageDB.php';
14 require_once 'Modules/IndividualAssessment/classes/Members/class.ilIndividualAssessmentMembersStorageDB.php';
15 require_once 'Modules/IndividualAssessment/classes/AccessControl/class.ilIndividualAssessmentAccessHandler.php';
16 require_once 'Modules/IndividualAssessment/classes/FileStorage/class.ilIndividualAssessmentFileStorage.php';
18 {
19  protected $lp_active = null;
20 
21  public function __construct($a_id = 0, $a_call_by_reference = true)
22  {
23  global $DIC;
24  $this->type = 'iass';
25  $this->il_access_handler = $DIC["ilAccess"];
26  parent::__construct($a_id, $a_call_by_reference);
27  $this->settings_storage = new ilIndividualAssessmentSettingsStorageDB($DIC['ilDB']);
28  $this->members_storage = new ilIndividualAssessmentMembersStorageDB($DIC['ilDB']);
29  $this->access_handler = new ilIndividualAssessmentAccessHandler(
30  $this,
31  $DIC['ilAccess'],
32  $DIC['rbacadmin'],
33  $DIC['rbacreview'],
34  $DIC['ilUser']
35  );
36  }
37 
41  public function create()
42  {
43  parent::create();
44  $this->settings = new ilIndividualAssessmentSettings($this);
45  $this->settings_storage->createSettings($this->settings);
46  }
47 
51  public function read()
52  {
53  parent::read();
54  global $DIC;
55  $settings_storage = new ilIndividualAssessmentSettingsStorageDB($DIC['ilDB']);
56  $this->settings = $settings_storage->loadSettings($this);
57  $this->info_settings = $settings_storage->loadInfoSettings($this);
58  }
59 
63  public function getSettings()
64  {
65  if (!$this->settings) {
66  $this->settings = $this->settings_storage->loadSettings($this);
67  }
68  return $this->settings;
69  }
70 
74  public function setSettings(ilIndividualAssessmentSettings $settings)
75  {
76  $this->settings = $settings;
77  }
78 
79  public function getInfoSettings()
80  {
81  if (!$this->info_settings) {
82  $this->info_settings = $this->settings_storage->loadInfoSettings($this);
83  }
84  return $this->info_settings;
85  }
86 
91  {
92  $this->info_settings = $info;
93  }
94 
100  public function loadMembers()
101  {
102  return $this->members_storage->loadMembers($this);
103  }
104 
110  public function loadMembersAsSingleObjects(string $filter = null, string $sort = null)
111  {
112  return $this->members_storage->loadMembersAsSingleObjects($this, $filter, $sort);
113  }
114 
120  public function loadVisibleMembers()
121  {
122  return $this->members_storage->loadMembers($this)
123  ->withAccessHandling($this->il_access_handler);
124  }
125 
132  {
133  $members->updateStorageAndRBAC($this->members_storage, $this->access_handler);
134  }
135 
139  public function delete()
140  {
141  $this->settings_storage->deleteSettings($this);
142  $this->members_storage->deleteMembers($this);
143  parent::delete();
144  }
145 
149  public function update()
150  {
151  parent::update();
152  $this->settings_storage->updateSettings($this->settings);
153  }
154 
155  public function updateInfo()
156  {
157  $this->settings_storage->updateInfoSettings($this->info_settings);
158  }
159 
165  public function membersStorage()
166  {
167  return $this->members_storage;
168  }
169 
173  public function initDefaultRoles()
174  {
175  $this->access_handler->initDefaultRolesForObject($this);
176  }
177 
183  public function accessHandler()
184  {
185  return $this->access_handler;
186  }
187 
191  public function cloneObject($a_target_id, $a_copy_id = 0, $a_omit_tree = false)
192  {
193  $new_obj = parent::cloneObject($a_target_id, $a_copy_id, $a_omit_tree);
194  $settings = $this->getSettings();
195  $info_settings = $this->getInfoSettings();
196  $new_settings = new ilIndividualAssessmentSettings(
197  $new_obj,
198  $settings->content(),
199  $settings->recordTemplate()
200  );
201  $new_obj->settings = $new_settings;
202 
203  $new_info_settings = new ilIndividualAssessmentInfoSettings(
204  $new_obj,
205  $info_settings->contact(),
206  $info_settings->responsibility(),
207  $info_settings->phone(),
208  $info_settings->mails(),
209  $info_settings->consultationHours()
210  );
211  $new_obj->settings = $new_settings;
212  $new_obj->info_settings = $new_info_settings;
213  $new_obj->settings_storage->updateSettings($new_settings);
214  $new_obj->settings_storage->updateInfoSettings($new_info_settings);
215 
216  $fstorage = $this->getFileStorage();
217  if (count($fstorage->readDir()) > 0) {
218  $n_fstorage = $new_obj->getFileStorage();
219  $n_fstorage->create();
220  $fstorage->_copyDirectory($fstorage->getAbsolutePath(), $n_fstorage->getAbsolutePath());
221  }
222  return $new_obj;
223  }
224 
230  public function getFileStorage()
231  {
232  if ($this->file_storage === null) {
233  $this->file_storage = ilIndividualAssessmentFileStorage::getInstance($this->getId());
234  }
235  return $this->file_storage;
236  }
237 
243  public function isActiveLP()
244  {
245  if ($this->lp_active === null) {
246  require_once 'Modules/IndividualAssessment/classes/LearningProgress/class.ilIndividualAssessmentLPInterface.php';
247  $this->lp_active = ilIndividualAssessmentLPInterface::isActiveLP($this->getId());
248  }
249  return $this->lp_active;
250  }
251 
263  public function getParentContainerIdByType($id, array $types)
264  {
265  global $DIC;
266 
267  $tree = $DIC['tree'];
268  $node = $tree->getParentNodeData($id);
269 
270  while ($node['type'] !== "root") {
271  if (in_array($node['type'], $types)) {
272  return $node['ref_id'];
273  }
274  $node = $tree->getParentNodeData($node['ref_id']);
275  }
276  return 0;
277  }
278 }
settings()
Definition: settings.php:2
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.
global $DIC
Definition: saml.php:7
An object carrying settings of an Individual Assessment obj beyond the standart information.
membersStorage()
Get the member storage object used by this.
setInfoSettings(ilIndividualAssessmentInfoSettings $info)
Set info settings.
loadVisibleMembers()
Get the members object associated with this and visible by the current user.
getFileStorage()
Get the file storage system.
isActiveLP()
Check wether the LP is activated for current object.
getId()
get object id public
setSettings(ilIndividualAssessmentSettings $settings)
Set the settings.
__construct($a_id=0, $a_call_by_reference=true)
loadMembersAsSingleObjects(string $filter=null, string $sort=null)
Get the members as single object associated with this.
update($pash, $contents, Config $config)
loadMembers()
Get the members object associated with this.
updateStorageAndRBAC(ilIndividualAssessmentMembersStorage $storage, IndividualAssessmentAccessHandler $access_handler)
Store the data to a persistent medium.
accessHandler()
Get the access handler of this.
$info
Definition: index.php:5
getParentContainerIdByType($id, array $types)
Bubbles up the tree.
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.
cloneObject($a_target_id, $a_copy_id=0, $a_omit_tree=false)