ILIAS  trunk Revision v11.0_alpha-3011-gc6b235a2e85
class.ilObjUserTracking.php
Go to the documentation of this file.
1<?php
2
19declare(strict_types=0);
28{
29 private int $valid_time = 0;
30 protected int $extended_data = 0;
31 protected bool $learning_progress = false;
32 protected bool $tracking_user_related = false;
33 protected bool $object_statistics_enabled = false;
34 protected bool $lp_learner = false;
35 protected bool $session_statistics_enabled = false;
36 protected bool $lp_list_gui = false;
37
42
43 public const EXTENDED_DATA_LAST_ACCESS = 1;
44 public const EXTENDED_DATA_READ_COUNT = 2;
46
47 public const DEFAULT_TIME_SPAN = 300;
48
50
51 public function __construct(int $a_id = 0, bool $a_call_by_reference = true)
52 {
53 global $DIC;
54
55 $this->settings = $DIC->settings();
56
57 $this->type = "trac";
58 parent::__construct($a_id, $a_call_by_reference);
59 $this->__readSettings();
60 }
61
62 public function enableLearningProgress(bool $a_enable): void
63 {
64 $this->learning_progress = $a_enable;
65 }
66
67 public function enabledLearningProgress(): bool
68 {
70 }
71
72 public static function _enabledLearningProgress(): bool
73 {
74 global $DIC;
75
76 $ilSetting = $DIC->settings();
77
78 return (bool) $ilSetting->get("enable_tracking", '0');
79 }
80
81 public function enableUserRelatedData(bool $a_enable): void
82 {
83 $this->tracking_user_related = $a_enable;
84 }
85
86 public function enabledUserRelatedData(): bool
87 {
89 }
90
91 public static function _enabledUserRelatedData()
92 {
93 global $DIC;
94
95 $ilSetting = $DIC->settings();
96 return (bool) $ilSetting->get('save_user_related_data', '0');
97 }
98
99 public static function _enabledObjectStatistics(): bool
100 {
101 global $DIC;
102
103 $ilSetting = $DIC->settings();
104 return (bool) $ilSetting->get('object_statistics', '0');
105 }
106
107 public function enableObjectStatistics(bool $newValue): void
108 {
109 $this->object_statistics_enabled = $newValue;
110 }
111
112 public function enabledObjectStatistics(): bool
113 {
115 }
116
117 public function enableSessionStatistics(bool $newValue): void
118 {
119 $this->session_statistics_enabled = $newValue;
120 }
121
122 public function enabledSessionStatistics(): bool
123 {
125 }
126
127 public static function _enabledSessionStatistics(): bool
128 {
129 global $DIC;
130
131 $ilSetting = $DIC->settings();
132 return (bool) $ilSetting->get('session_statistics', '1');
133 }
134
135 public function setValidTimeSpan(int $a_time_span): void
136 {
137 $this->valid_time = $a_time_span;
138 }
139
140 public function getValidTimeSpan(): int
141 {
142 return $this->valid_time;
143 }
144
145 public static function _getValidTimeSpan(): int
146 {
147 global $DIC;
148
149 $ilSetting = $DIC->settings();
150 return (int) $ilSetting->get(
151 "tracking_time_span",
152 (string) self::DEFAULT_TIME_SPAN
153 );
154 }
155
156 public function enableChangeEventTracking(bool $newValue): void
157 {
158 $this->is_change_event_tracking_enabled = $newValue;
159 }
160
161 public function enabledChangeEventTracking(): bool
162 {
164 }
165
166 // END ChangeEvent
167
168 public function setExtendedData(int $a_value): void
169 {
170 $this->extended_data = $a_value;
171 }
172
173 public function hasExtendedData(int $a_code): bool
174 {
175 return (bool) ($this->extended_data & $a_code);
176 }
177
178 public function updateSettings()
179 {
180 $this->settings->set(
181 "enable_tracking",
182 (string) $this->enabledLearningProgress()
183 );
184 $this->settings->set(
185 "save_user_related_data",
186 (string) $this->enabledUserRelatedData()
187 );
188 $this->settings->set(
189 "tracking_time_span",
190 (string) $this->getValidTimeSpan()
191 );
192 $this->settings->set("lp_extended_data", (string) $this->extended_data);
193 $this->settings->set(
194 "object_statistics",
195 (string) $this->enabledObjectStatistics()
196 );
197 // $this->settings->set("lp_desktop", (int)$this->hasLearningProgressDesktop());
198 $this->settings->set(
199 "lp_learner",
200 (string) $this->hasLearningProgressLearner()
201 );
202 $this->settings->set(
203 "session_statistics",
204 (string) $this->enabledSessionStatistics()
205 );
206 $this->settings->set(
207 "lp_list_gui",
208 (string) $this->hasLearningProgressListGUI()
209 );
210 }
211
212 protected function __readSettings(): void
213 {
215 (bool) $this->settings->get("enable_tracking", '0')
216 );
218 (bool) $this->settings->get("save_user_related_data", '0')
219 );
221 (bool) $this->settings->get("object_statistics", '0')
222 );
223 $this->setValidTimeSpan(
224 (int) $this->settings->get(
225 "tracking_time_span",
226 (string) self::DEFAULT_TIME_SPAN
227 )
228 );
230 (bool) $this->settings->get("lp_learner", '1')
231 );
233 (bool) $this->settings->get("session_statistics", '1')
234 );
236 (bool) $this->settings->get("lp_list_gui", '0')
237 );
238
239 // BEGIN ChangeEvent
241 // END ChangeEvent
242
243 $this->setExtendedData(
244 (int) $this->settings->get("lp_extended_data", '0')
245 );
246 }
247
248 public static function _deleteUser(int $a_usr_id): void
249 {
250 global $DIC;
251
252 $ilDB = $DIC['ilDB'];
253 $query = sprintf(
254 'DELETE FROM read_event WHERE usr_id = %s ',
255 $ilDB->quote($a_usr_id, 'integer')
256 );
257 $aff = $ilDB->manipulate($query);
258
259 $query = sprintf(
260 'DELETE FROM write_event WHERE usr_id = %s ',
261 $ilDB->quote($a_usr_id, 'integer')
262 );
263 $aff = $ilDB->manipulate($query);
264
265 $query = "DELETE FROM ut_lp_marks WHERE usr_id = " . $ilDB->quote(
266 $a_usr_id,
267 'integer'
268 ) . " ";
269 $res = $ilDB->manipulate($query);
270
271 $ilDB->manipulate(
272 "DELETE FROM ut_online WHERE usr_id = " .
273 $ilDB->quote($a_usr_id, "integer")
274 );
275 }
276
277 public static function _hasLearningProgressOtherUsers(): bool
278 {
279 global $DIC;
280
281 $rbacsystem = $DIC['rbacsystem'];
282 $obj_ids = array_keys(ilObject::_getObjectsByType("trac"));
283 $obj_id = array_pop($obj_ids);
284 $ref_ids = ilObject::_getAllReferences($obj_id);
285 $ref_id = array_pop($ref_ids);
286 return $rbacsystem->checkAccess("lp_other_users", $ref_id);
287 }
288
289 public function setLearningProgressLearner(bool $a_value): void
290 {
291 $this->lp_learner = $a_value;
292 }
293
294 public function hasLearningProgressLearner(): bool
295 {
296 return $this->lp_learner;
297 }
298
299 public static function _hasLearningProgressLearner(): bool
300 {
301 global $DIC;
302
303 $ilSetting = $DIC->settings();
304 return (bool) $ilSetting->get("lp_learner", '1');
305 }
306
307 public function setLearningProgressListGUI(bool $a_value): void
308 {
309 $this->lp_list_gui = $a_value;
310 }
311
312 public function hasLearningProgressListGUI(): bool
313 {
314 return $this->lp_list_gui;
315 }
316
317 public static function _hasLearningProgressListGUI(): bool
318 {
319 global $DIC;
320
321 $ilSetting = $DIC->settings();
322 return (bool) $ilSetting->get("lp_list_gui", '0');
323 }
324} // END class.ilObjUserTracking
static _isActive()
Returns true, if change event tracking is active.
bool $is_change_event_tracking_enabled
This variable holds the enabled state of the change event tracking.
setLearningProgressLearner(bool $a_value)
enableSessionStatistics(bool $newValue)
enableObjectStatistics(bool $newValue)
static _deleteUser(int $a_usr_id)
setLearningProgressListGUI(bool $a_value)
setValidTimeSpan(int $a_time_span)
enableLearningProgress(bool $a_enable)
enableChangeEventTracking(bool $newValue)
enableUserRelatedData(bool $a_enable)
__construct(int $a_id=0, bool $a_call_by_reference=true)
Class ilObject Basic functions for all objects.
static _getAllReferences(int $id)
get all reference ids for object ID
static _getObjectsByType(string $obj_type="", ?int $owner=null)
ILIAS Setting Class.
$res
Definition: ltiservices.php:69
__construct(Container $dic, ilPlugin $plugin)
@inheritDoc
global $ilSetting
Definition: privfeed.php:31
global $DIC
Definition: shib_login.php:26