ILIAS  release_7 Revision v7.30-3-g800a261c036
ilBasicSkillUserLevelDBRepository Class Reference
+ Inheritance diagram for ilBasicSkillUserLevelDBRepository:
+ Collaboration diagram for ilBasicSkillUserLevelDBRepository:

Public Member Functions

 __construct (ilDBInterface $db=null)
 
 deleteUserLevelsOfSkill (int $skill_id)
 @inheritDoc More...
 
 resetUserSkillLevelStatus (bool $update, int $trigger_obj_id, $status_date, int $a_user_id, int $a_skill_id, int $a_tref_id=0, int $a_trigger_ref_id=0, bool $a_self_eval=false)
 @inheritDoc More...
 
 hasRecentSelfEvaluation (int $trigger_obj_id, int $a_user_id, int $a_skill_id, int $a_tref_id=0, int $a_trigger_ref_id=0)
 @inheritDoc More...
 
 getNewAchievementsPerUser (string $a_timestamp, string $a_timestamp_to=null, int $a_user_id=0, int $a_self_eval=0)
 @inheritDoc More...
 
 writeUserSkillLevelStatus (int $skill_id, int $trigger_ref_id, int $trigger_obj_id, ?string $trigger_title, ?string $trigger_type, bool $update, $status_date, int $a_level_id, int $a_user_id, int $a_tref_id=0, bool $a_self_eval=false, string $a_unique_identifier="", float $a_next_level_fulfilment=0.0)
 @inheritDoc More...
 
 removeAllUserSkillLevelStatusOfObject (int $a_user_id, int $a_trigger_obj_id, bool $a_self_eval=false, string $a_unique_identifier="")
 @inheritDoc More...
 
 removeAllUserData (int $a_user_id)
 @inheritDoc More...
 
 getMaxLevelPerType (int $skill_id, array $levels, int $a_tref_id, string $a_type, int $a_user_id=0, int $a_self_eval=0)
 @inheritDoc More...
 
 getAllLevelEntriesOfUser (int $skill_id, int $a_tref_id, int $a_user_id=0, int $a_self_eval=0)
 @inheritDoc More...
 
 getAllHistoricLevelEntriesOfUser (int $skill_id, int $a_tref_id, int $a_user_id=0, int $a_eval_by=0)
 @inheritDoc More...
 
 getMaxLevelPerObject (int $skill_id, array $levels, int $a_tref_id, int $a_object_id, int $a_user_id=0, int $a_self_eval=0)
 @inheritDoc More...
 
 getMaxLevel (int $skill_id, array $levels, int $a_tref_id, int $a_user_id=0, int $a_self_eval=0)
 @inheritDoc More...
 
 hasSelfEvaluated (int $a_user_id, int $a_skill_id, int $a_tref_id)
 @inheritDoc More...
 
 getLastLevelPerObject (int $skill_id, int $a_tref_id, int $a_object_id, int $a_user_id=0, int $a_self_eval=0)
 @inheritDoc More...
 
 getLastUpdatePerObject (int $skill_id, int $a_tref_id, int $a_object_id, int $a_user_id=0, int $a_self_eval=0)
 @inheritDoc More...
 
 deleteUserLevelsOfSkill (int $skill_id)
 Delete user levels of a skill. More...
 
 resetUserSkillLevelStatus (bool $update, int $trigger_obj_id, $status_date, int $a_user_id, int $a_skill_id, int $a_tref_id=0, int $a_trigger_ref_id=0, bool $a_self_eval=false)
 Reset skill level status. More...
 
 hasRecentSelfEvaluation (int $trigger_obj_id, int $a_user_id, int $a_skill_id, int $a_tref_id=0, int $a_trigger_ref_id=0)
 Has recent self evaluation. More...
 
 getNewAchievementsPerUser (string $a_timestamp, string $a_timestamp_to=null, int $a_user_id=0, int $a_self_eval=0)
 Get new achievements. More...
 
 writeUserSkillLevelStatus (int $skill_id, int $trigger_ref_id, int $trigger_obj_id, ?string $trigger_title, ?string $trigger_type, bool $update, $status_date, int $a_level_id, int $a_user_id, int $a_tref_id=0, bool $a_self_eval=false, string $a_unique_identifier="", float $a_next_level_fulfilment=0.0)
 Write skill level status. More...
 
 removeAllUserSkillLevelStatusOfObject (int $a_user_id, int $a_trigger_obj_id, bool $a_self_eval=false, string $a_unique_identifier="")
 Remove a user skill completely. More...
 
 removeAllUserData (int $a_user_id)
 Remove all data of a user. More...
 
 getMaxLevelPerType (int $skill_id, array $levels, int $a_tref_id, string $a_type, int $a_user_id=0, int $a_self_eval=0)
 Get max levels per type. More...
 
 getAllLevelEntriesOfUser (int $skill_id, int $a_tref_id, int $a_user_id=0, int $a_self_eval=0)
 Get all level entries. More...
 
 getAllHistoricLevelEntriesOfUser (int $skill_id, int $a_tref_id, int $a_user_id=0, int $a_eval_by=0)
 Get all historic level entries. More...
 
 getMaxLevelPerObject (int $skill_id, array $levels, int $a_tref_id, int $a_object_id, int $a_user_id=0, int $a_self_eval=0)
 Get max levels per object. More...
 
 getMaxLevel (int $skill_id, array $levels, int $a_tref_id, int $a_user_id=0, int $a_self_eval=0)
 Get max levels. More...
 
 hasSelfEvaluated (int $a_user_id, int $a_skill_id, int $a_tref_id)
 Has user self evaluated a skill? More...
 
 getLastLevelPerObject (int $skill_id, int $a_tref_id, int $a_object_id, int $a_user_id=0, int $a_self_eval=0)
 Get last level set per object. More...
 
 getLastUpdatePerObject (int $skill_id, int $a_tref_id, int $a_object_id, int $a_user_id=0, int $a_self_eval=0)
 Get last update per object. More...
 

Protected Attributes

 $db
 

Detailed Description

Definition at line 3 of file class.ilBasicSkillUserLevelDBRepository.php.

Constructor & Destructor Documentation

◆ __construct()

ilBasicSkillUserLevelDBRepository::__construct ( ilDBInterface  $db = null)

Definition at line 10 of file class.ilBasicSkillUserLevelDBRepository.php.

11 {
12 global $DIC;
13
14 $this->db = ($db)
15 ? $db
16 : $DIC->database();
17 }
global $DIC
Definition: goto.php:24

References $db, and $DIC.

Member Function Documentation

◆ deleteUserLevelsOfSkill()

ilBasicSkillUserLevelDBRepository::deleteUserLevelsOfSkill ( int  $skill_id)

@inheritDoc

Implements ilBasicSkillUserLevelRepository.

Definition at line 22 of file class.ilBasicSkillUserLevelDBRepository.php.

23 {
25
26 $ilDB->manipulate("DELETE FROM skl_user_has_level WHERE "
27 . " skill_id = " . $ilDB->quote($skill_id, "integer")
28 );
29 }
global $ilDB

References $db, and $ilDB.

◆ getAllHistoricLevelEntriesOfUser()

ilBasicSkillUserLevelDBRepository::getAllHistoricLevelEntriesOfUser ( int  $skill_id,
int  $a_tref_id,
int  $a_user_id = 0,
int  $a_eval_by = 0 
)

@inheritDoc

Implements ilBasicSkillUserLevelRepository.

Definition at line 374 of file class.ilBasicSkillUserLevelDBRepository.php.

379 : array {
381
382 $by = ($a_eval_by != ilBasicSkill::EVAL_BY_ALL)
383 ? " AND self_eval = " . $ilDB->quote($a_self_eval, "integer")
384 : "";
385
386 $set = $ilDB->query($q = "SELECT * FROM skl_user_skill_level " .
387 " WHERE skill_id = " . $ilDB->quote($skill_id, "integer") .
388 " AND tref_id = " . $ilDB->quote((int) $a_tref_id, "integer") .
389 " AND user_id = " . $ilDB->quote($a_user_id, "integer") .
390 $by .
391 " ORDER BY status_date DESC"
392 );
393 $levels = array();
394 while ($rec = $ilDB->fetchAssoc($set)) {
395 $levels[] = $rec;
396 }
397 return $levels;
398 }

◆ getAllLevelEntriesOfUser()

ilBasicSkillUserLevelDBRepository::getAllLevelEntriesOfUser ( int  $skill_id,
int  $a_tref_id,
int  $a_user_id = 0,
int  $a_self_eval = 0 
)

@inheritDoc

Implements ilBasicSkillUserLevelRepository.

Definition at line 348 of file class.ilBasicSkillUserLevelDBRepository.php.

353 : array {
355
356 $set = $ilDB->query($q = "SELECT * FROM skl_user_has_level " .
357 " WHERE skill_id = " . $ilDB->quote($skill_id, "integer") .
358 " AND tref_id = " . $ilDB->quote((int) $a_tref_id, "integer") .
359 " AND user_id = " . $ilDB->quote($a_user_id, "integer") .
360 " AND self_eval = " . $ilDB->quote($a_self_eval, "integer") .
361 " ORDER BY status_date DESC"
362 );
363
364 $levels = array();
365 while ($rec = $ilDB->fetchAssoc($set)) {
366 $levels[] = $rec;
367 }
368 return $levels;
369 }

◆ getLastLevelPerObject()

ilBasicSkillUserLevelDBRepository::getLastLevelPerObject ( int  $skill_id,
int  $a_tref_id,
int  $a_object_id,
int  $a_user_id = 0,
int  $a_self_eval = 0 
)

@inheritDoc

Implements ilBasicSkillUserLevelRepository.

Definition at line 489 of file class.ilBasicSkillUserLevelDBRepository.php.

495 : ?int {
497
498 $ilDB->setLimit(1);
499 $set = $ilDB->query($q = "SELECT level_id FROM skl_user_has_level " .
500 " WHERE trigger_obj_id = " . $ilDB->quote($a_object_id, "integer") .
501 " AND skill_id = " . $ilDB->quote($skill_id, "integer") .
502 " AND tref_id = " . $ilDB->quote((int) $a_tref_id, "integer") .
503 " AND user_id = " . $ilDB->quote($a_user_id, "integer") .
504 " AND self_eval = " . $ilDB->quote($a_self_eval, "integer") .
505 " ORDER BY status_date DESC"
506 );
507
508 $rec = $ilDB->fetchAssoc($set);
509
510 return $rec["level_id"];
511 }

◆ getLastUpdatePerObject()

ilBasicSkillUserLevelDBRepository::getLastUpdatePerObject ( int  $skill_id,
int  $a_tref_id,
int  $a_object_id,
int  $a_user_id = 0,
int  $a_self_eval = 0 
)

@inheritDoc

Implements ilBasicSkillUserLevelRepository.

Definition at line 516 of file class.ilBasicSkillUserLevelDBRepository.php.

522 : ?string {
524
525 $ilDB->setLimit(1);
526 $set = $ilDB->query($q = "SELECT status_date FROM skl_user_has_level " .
527 " WHERE trigger_obj_id = " . $ilDB->quote($a_object_id, "integer") .
528 " AND skill_id = " . $ilDB->quote($skill_id, "integer") .
529 " AND tref_id = " . $ilDB->quote((int) $a_tref_id, "integer") .
530 " AND user_id = " . $ilDB->quote($a_user_id, "integer") .
531 " AND self_eval = " . $ilDB->quote($a_self_eval, "integer") .
532 " ORDER BY status_date DESC"
533 );
534
535 $rec = $ilDB->fetchAssoc($set);
536
537 return $rec["status_date"];
538 }

◆ getMaxLevel()

ilBasicSkillUserLevelDBRepository::getMaxLevel ( int  $skill_id,
array  $levels,
int  $a_tref_id,
int  $a_user_id = 0,
int  $a_self_eval = 0 
)

@inheritDoc

Implements ilBasicSkillUserLevelRepository.

Definition at line 437 of file class.ilBasicSkillUserLevelDBRepository.php.

443 : int {
445
446 $set = $ilDB->query($q = "SELECT level_id FROM skl_user_has_level " .
447 " WHERE skill_id = " . $ilDB->quote($skill_id, "integer") .
448 " AND tref_id = " . $ilDB->quote((int) $a_tref_id, "integer") .
449 " AND user_id = " . $ilDB->quote($a_user_id, "integer") .
450 " AND self_eval = " . $ilDB->quote($a_self_eval, "integer")
451 );
452
453 $has_level = array();
454 while ($rec = $ilDB->fetchAssoc($set)) {
455 $has_level[$rec["level_id"]] = true;
456 }
457 $max_level = 0;
458 foreach ($levels as $l) {
459 if (isset($has_level[$l["id"]])) {
460 $max_level = $l["id"];
461 }
462 }
463 return $max_level;
464 }

◆ getMaxLevelPerObject()

ilBasicSkillUserLevelDBRepository::getMaxLevelPerObject ( int  $skill_id,
array  $levels,
int  $a_tref_id,
int  $a_object_id,
int  $a_user_id = 0,
int  $a_self_eval = 0 
)

@inheritDoc

Implements ilBasicSkillUserLevelRepository.

Definition at line 403 of file class.ilBasicSkillUserLevelDBRepository.php.

410 : int {
412
413 $set = $ilDB->query($q = "SELECT level_id FROM skl_user_has_level " .
414 " WHERE trigger_obj_id = " . $ilDB->quote($a_object_id, "integer") .
415 " AND skill_id = " . $ilDB->quote($skill_id, "integer") .
416 " AND tref_id = " . $ilDB->quote((int) $a_tref_id, "integer") .
417 " AND user_id = " . $ilDB->quote($a_user_id, "integer") .
418 " AND self_eval = " . $ilDB->quote($a_self_eval, "integer")
419 );
420
421 $has_level = array();
422 while ($rec = $ilDB->fetchAssoc($set)) {
423 $has_level[$rec["level_id"]] = true;
424 }
425 $max_level = 0;
426 foreach ($levels as $l) {
427 if (isset($has_level[$l["id"]])) {
428 $max_level = $l["id"];
429 }
430 }
431 return $max_level;
432 }

◆ getMaxLevelPerType()

ilBasicSkillUserLevelDBRepository::getMaxLevelPerType ( int  $skill_id,
array  $levels,
int  $a_tref_id,
string  $a_type,
int  $a_user_id = 0,
int  $a_self_eval = 0 
)

@inheritDoc

Implements ilBasicSkillUserLevelRepository.

Definition at line 314 of file class.ilBasicSkillUserLevelDBRepository.php.

321 : int {
323
324 $set = $ilDB->query($q = "SELECT level_id FROM skl_user_has_level " .
325 " WHERE trigger_obj_type = " . $ilDB->quote($a_type, "text") .
326 " AND skill_id = " . $ilDB->quote($skill_id, "integer") .
327 " AND tref_id = " . $ilDB->quote((int) $a_tref_id, "integer") .
328 " AND user_id = " . $ilDB->quote($a_user_id, "integer") .
329 " AND self_eval = " . $ilDB->quote($a_self_eval, "integer")
330 );
331
332 $has_level = array();
333 while ($rec = $ilDB->fetchAssoc($set)) {
334 $has_level[$rec["level_id"]] = true;
335 }
336 $max_level = 0;
337 foreach ($levels as $l) {
338 if (isset($has_level[$l["id"]])) {
339 $max_level = $l["id"];
340 }
341 }
342 return $max_level;
343 }

◆ getNewAchievementsPerUser()

ilBasicSkillUserLevelDBRepository::getNewAchievementsPerUser ( string  $a_timestamp,
string  $a_timestamp_to = null,
int  $a_user_id = 0,
int  $a_self_eval = 0 
)

@inheritDoc

Implements ilBasicSkillUserLevelRepository.

Definition at line 130 of file class.ilBasicSkillUserLevelDBRepository.php.

135 : array {
137
138 $to = (!is_null($a_timestamp_to))
139 ? " AND status_date <= " . $ilDB->quote($a_timestamp_to, "timestamp")
140 : "";
141
142 $user = ($a_user_id > 0)
143 ? " AND user_id = " . $ilDB->quote($a_user_id, "integer")
144 : "";
145
146 $set = $ilDB->query("SELECT * FROM skl_user_skill_level " .
147 " WHERE status_date >= " . $ilDB->quote($a_timestamp, "timestamp") .
148 " AND valid = " . $ilDB->quote(1, "integer") .
149 " AND status = " . $ilDB->quote(ilBasicSkill::ACHIEVED, "integer") .
150 " AND self_eval = " . $ilDB->quote($a_self_eval, "integer") .
151 $to .
152 $user .
153 " ORDER BY user_id, status_date ASC ");
154 $achievments = array();
155 while ($rec = $ilDB->fetchAssoc($set)) {
156 $achievments[$rec["user_id"]][] = $rec;
157 }
158
159 return $achievments;
160 }

◆ hasRecentSelfEvaluation()

ilBasicSkillUserLevelDBRepository::hasRecentSelfEvaluation ( int  $trigger_obj_id,
int  $a_user_id,
int  $a_skill_id,
int  $a_tref_id = 0,
int  $a_trigger_ref_id = 0 
)

@inheritDoc

Implements ilBasicSkillUserLevelRepository.

Definition at line 96 of file class.ilBasicSkillUserLevelDBRepository.php.

102 {
104
105 $recent = "";
106
107 $ilDB->setLimit(1);
108 $set = $ilDB->query("SELECT * FROM skl_user_skill_level WHERE " .
109 "skill_id = " . $ilDB->quote($a_skill_id, "integer") . " AND " .
110 "user_id = " . $ilDB->quote($a_user_id, "integer") . " AND " .
111 "tref_id = " . $ilDB->quote((int) $a_tref_id, "integer") . " AND " .
112 "trigger_obj_id = " . $ilDB->quote($trigger_obj_id, "integer") . " AND " .
113 "self_eval = " . $ilDB->quote(1, "integer") .
114 " ORDER BY status_date DESC"
115 );
116 if ($rec = $ilDB->fetchAssoc($set)) {
117 $status_day = substr($rec["status_date"], 0, 10);
118 $today = substr(ilUtil::now(), 0, 10);
119 if ($rec["valid"] && $rec["status"] == ilBasicSkill::ACHIEVED && $status_day == $today) {
120 $recent = $rec["status_date"];
121 }
122 }
123
124 return $recent;
125 }
static now()
Return current timestamp in Y-m-d H:i:s format.

References $db, $ilDB, ilBasicSkill\ACHIEVED, and ilUtil\now().

+ Here is the call graph for this function:

◆ hasSelfEvaluated()

ilBasicSkillUserLevelDBRepository::hasSelfEvaluated ( int  $a_user_id,
int  $a_skill_id,
int  $a_tref_id 
)

@inheritDoc

Implements ilBasicSkillUserLevelRepository.

Definition at line 469 of file class.ilBasicSkillUserLevelDBRepository.php.

469 : bool
470 {
472
473 $set = $ilDB->query($q = "SELECT level_id FROM skl_user_has_level " .
474 " WHERE skill_id = " . $ilDB->quote((int) $a_skill_id, "integer") .
475 " AND tref_id = " . $ilDB->quote((int) $a_tref_id, "integer") .
476 " AND user_id = " . $ilDB->quote($a_user_id, "integer") .
477 " AND self_eval = " . $ilDB->quote(1, "integer")
478 );
479
480 if ($rec = $ilDB->fetchAssoc($set)) {
481 return true;
482 }
483 return false;
484 }

References $ilDB.

◆ removeAllUserData()

ilBasicSkillUserLevelDBRepository::removeAllUserData ( int  $a_user_id)

@inheritDoc

Implements ilBasicSkillUserLevelRepository.

Definition at line 299 of file class.ilBasicSkillUserLevelDBRepository.php.

300 {
302
303 $ilDB->manipulate("DELETE FROM skl_user_skill_level WHERE "
304 . " user_id = " . $ilDB->quote($a_user_id, "integer")
305 );
306 $ilDB->manipulate("DELETE FROM skl_user_has_level WHERE "
307 . " user_id = " . $ilDB->quote($a_user_id, "integer")
308 );
309 }

References $ilDB.

◆ removeAllUserSkillLevelStatusOfObject()

ilBasicSkillUserLevelDBRepository::removeAllUserSkillLevelStatusOfObject ( int  $a_user_id,
int  $a_trigger_obj_id,
bool  $a_self_eval = false,
string  $a_unique_identifier = "" 
)

@inheritDoc

Implements ilBasicSkillUserLevelRepository.

Definition at line 265 of file class.ilBasicSkillUserLevelDBRepository.php.

270 : bool {
272
273 $changed = false;
274
275 $aff_rows = $ilDB->manipulate("DELETE FROM skl_user_skill_level WHERE "
276 . " user_id = " . $ilDB->quote($a_user_id, "integer")
277 . " AND trigger_obj_id = " . $ilDB->quote($a_trigger_obj_id, "integer")
278 . " AND self_eval = " . $ilDB->quote($a_self_eval, "integer")
279 . " AND unique_identifier = " . $ilDB->quote($a_unique_identifier, "text")
280 );
281 if ($aff_rows > 0) {
282 $changed = true;
283 }
284
285 $aff_rows = $ilDB->manipulate("DELETE FROM skl_user_has_level WHERE "
286 . " user_id = " . $ilDB->quote($a_user_id, "integer")
287 . " AND trigger_obj_id = " . $ilDB->quote($a_trigger_obj_id, "integer")
288 . " AND self_eval = " . $ilDB->quote($a_self_eval, "integer")
289 );
290 if ($aff_rows > 0) {
291 $changed = true;
292 }
293 return $changed;
294 }

References $changed.

◆ resetUserSkillLevelStatus()

ilBasicSkillUserLevelDBRepository::resetUserSkillLevelStatus ( bool  $update,
int  $trigger_obj_id,
  $status_date,
int  $a_user_id,
int  $a_skill_id,
int  $a_tref_id = 0,
int  $a_trigger_ref_id = 0,
bool  $a_self_eval = false 
)

@inheritDoc

Implements ilBasicSkillUserLevelRepository.

Definition at line 34 of file class.ilBasicSkillUserLevelDBRepository.php.

43 {
45
46 if ($update) {
47 // this will only be set in self eval case, means this will always have a $rec
48 $now = ilUtil::now();
49 $ilDB->manipulate("UPDATE skl_user_skill_level SET " .
50 " level_id = " . $ilDB->quote(0, "integer") . "," .
51 " next_level_fulfilment = " . $ilDB->quote(0.0, "float") . "," .
52 " status_date = " . $ilDB->quote($now, "timestamp") .
53 " WHERE user_id = " . $ilDB->quote($a_user_id, "integer") .
54 " AND status_date = " . $ilDB->quote($status_date, "timestamp") .
55 " AND skill_id = " . $ilDB->quote($a_skill_id, "integer") .
56 " AND status = " . $ilDB->quote(ilBasicSkill::ACHIEVED, "integer") .
57 " AND trigger_obj_id = " . $ilDB->quote($trigger_obj_id, "integer") .
58 " AND tref_id = " . $ilDB->quote((int) $a_tref_id, "integer") .
59 " AND self_eval = " . $ilDB->quote($a_self_eval, "integer")
60 );
61 } else {
62 $now = ilUtil::now();
63 $ilDB->manipulate("INSERT INTO skl_user_skill_level " .
64 "(level_id, user_id, tref_id, status_date, skill_id, status, valid, trigger_ref_id," .
65 "trigger_obj_id, trigger_obj_type, trigger_title, self_eval, unique_identifier," .
66 "next_level_fulfilment) VALUES (" .
67 $ilDB->quote(0, "integer") . "," .
68 $ilDB->quote($a_user_id, "integer") . "," .
69 $ilDB->quote((int) $a_tref_id, "integer") . "," .
70 $ilDB->quote($now, "timestamp") . "," .
71 $ilDB->quote($a_skill_id, "integer") . "," .
72 $ilDB->quote(ilBasicSkill::ACHIEVED, "integer") . "," .
73 $ilDB->quote(1, "integer") . "," .
74 $ilDB->quote($a_trigger_ref_id, "integer") . "," .
75 $ilDB->quote($trigger_obj_id, "integer") . "," .
76 $ilDB->quote("", "text") . "," .
77 $ilDB->quote("", "text") . "," .
78 $ilDB->quote($a_self_eval, "integer") . "," .
79 $ilDB->quote("", "text") . "," .
80 $ilDB->quote(0.0, "float") .
81 ")");
82 }
83
84 $ilDB->manipulate("DELETE FROM skl_user_has_level WHERE "
85 . " user_id = " . $ilDB->quote($a_user_id, "integer")
86 . " AND skill_id = " . $ilDB->quote($a_skill_id, "integer")
87 . " AND tref_id = " . $ilDB->quote((int) $a_tref_id, "integer")
88 . " AND trigger_obj_id = " . $ilDB->quote($trigger_obj_id, "integer")
89 . " AND self_eval = " . $ilDB->quote($a_self_eval, "integer")
90 );
91 }

References $db, $ilDB, ilBasicSkill\ACHIEVED, and ilUtil\now().

+ Here is the call graph for this function:

◆ writeUserSkillLevelStatus()

ilBasicSkillUserLevelDBRepository::writeUserSkillLevelStatus ( int  $skill_id,
int  $trigger_ref_id,
int  $trigger_obj_id,
?string  $trigger_title,
?string  $trigger_type,
bool  $update,
  $status_date,
int  $a_level_id,
int  $a_user_id,
int  $a_tref_id = 0,
bool  $a_self_eval = false,
string  $a_unique_identifier = "",
float  $a_next_level_fulfilment = 0.0 
)

@inheritDoc

Implements ilBasicSkillUserLevelRepository.

Definition at line 165 of file class.ilBasicSkillUserLevelDBRepository.php.

179 {
181 $a_status = ilBasicSkill::ACHIEVED;
182
183 if ($update) {
184 // this will only be set in self eval case, means this will always have a $rec
185 $now = ilUtil::now();
186 $ilDB->manipulate("UPDATE skl_user_skill_level SET " .
187 " level_id = " . $ilDB->quote($a_level_id, "integer") . "," .
188 " status_date = " . $ilDB->quote($now, "timestamp") . "," .
189 " next_level_fulfilment = " . $ilDB->quote((float) $a_next_level_fulfilment, "float") .
190 " WHERE user_id = " . $ilDB->quote($a_user_id, "integer") .
191 " AND status_date = " . $ilDB->quote($status_date, "timestamp") .
192 " AND skill_id = " . $ilDB->quote($skill_id, "integer") .
193 " AND status = " . $ilDB->quote($a_status, "integer") .
194 " AND trigger_obj_id = " . $ilDB->quote($trigger_obj_id, "integer") .
195 " AND tref_id = " . $ilDB->quote((int) $a_tref_id, "integer") .
196 " AND self_eval = " . $ilDB->quote($a_self_eval, "integer")
197 );
198 } else {
199 if ($a_unique_identifier != "") {
200 $ilDB->manipulate("DELETE FROM skl_user_skill_level WHERE " .
201 " user_id = " . $ilDB->quote($a_user_id, "integer") .
202 " AND tref_id = " . $ilDB->quote($a_tref_id, "integer") .
203 " AND skill_id = " . $ilDB->quote($skill_id, "integer") .
204 " AND trigger_ref_id = " . $ilDB->quote($trigger_ref_id, "integer") .
205 " AND trigger_obj_id = " . $ilDB->quote($trigger_obj_id, "integer") .
206 " AND self_eval = " . $ilDB->quote($a_self_eval, "integer") .
207 " AND unique_identifier = " . $ilDB->quote($a_unique_identifier, "text")
208 );
209 }
210
211 $now = ilUtil::now();
212 $ilDB->manipulate("INSERT INTO skl_user_skill_level " .
213 "(level_id, user_id, tref_id, status_date, skill_id, status, valid, trigger_ref_id," .
214 "trigger_obj_id, trigger_obj_type, trigger_title, self_eval, unique_identifier," .
215 "next_level_fulfilment) VALUES (" .
216 $ilDB->quote($a_level_id, "integer") . "," .
217 $ilDB->quote($a_user_id, "integer") . "," .
218 $ilDB->quote((int) $a_tref_id, "integer") . "," .
219 $ilDB->quote($now, "timestamp") . "," .
220 $ilDB->quote($skill_id, "integer") . "," .
221 $ilDB->quote($a_status, "integer") . "," .
222 $ilDB->quote(1, "integer") . "," .
223 $ilDB->quote($trigger_ref_id, "integer") . "," .
224 $ilDB->quote($trigger_obj_id, "integer") . "," .
225 $ilDB->quote($trigger_type, "text") . "," .
226 $ilDB->quote($trigger_title, "text") . "," .
227 $ilDB->quote($a_self_eval, "integer") . "," .
228 $ilDB->quote($a_unique_identifier, "text") . "," .
229 $ilDB->quote((float) $a_next_level_fulfilment, "float") .
230 ")");
231 }
232
233 // fix (removed level_id and added skill id, since table should hold only
234 // one entry per skill)
235 $ilDB->manipulate("DELETE FROM skl_user_has_level WHERE "
236 . " user_id = " . $ilDB->quote($a_user_id, "integer")
237 . " AND skill_id = " . $ilDB->quote($skill_id, "integer")
238 . " AND tref_id = " . $ilDB->quote((int) $a_tref_id, "integer")
239 . " AND trigger_obj_id = " . $ilDB->quote($trigger_obj_id, "integer")
240 . " AND self_eval = " . $ilDB->quote($a_self_eval, "integer")
241 );
242
243 if ($a_status == ilBasicSkill::ACHIEVED) {
244 $ilDB->manipulate("INSERT INTO skl_user_has_level " .
245 "(level_id, user_id, tref_id, status_date, skill_id, trigger_ref_id, trigger_obj_id, trigger_obj_type," .
246 "trigger_title, self_eval, next_level_fulfilment) VALUES (" .
247 $ilDB->quote($a_level_id, "integer") . "," .
248 $ilDB->quote($a_user_id, "integer") . "," .
249 $ilDB->quote($a_tref_id, "integer") . "," .
250 $ilDB->quote($now, "timestamp") . "," .
251 $ilDB->quote($skill_id, "integer") . "," .
252 $ilDB->quote($trigger_ref_id, "integer") . "," .
253 $ilDB->quote($trigger_obj_id, "integer") . "," .
254 $ilDB->quote($trigger_type, "text") . "," .
255 $ilDB->quote($trigger_title, "text") . "," .
256 $ilDB->quote($a_self_eval, "integer") . "," .
257 $ilDB->quote((float) $a_next_level_fulfilment, "float") .
258 ")");
259 }
260 }

References $ilDB, ilBasicSkill\ACHIEVED, and ilUtil\now().

+ Here is the call graph for this function:

Field Documentation

◆ $db

ilBasicSkillUserLevelDBRepository::$db
protected

The documentation for this class was generated from the following file: