26 $ilDB->manipulate(
"DELETE FROM skl_user_has_level WHERE " 27 .
" skill_id = " .
$ilDB->quote($skill_id,
"integer")
41 int $a_trigger_ref_id = 0,
42 bool $a_self_eval =
false 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") .
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")
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") .
"," .
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") .
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")
101 int $a_trigger_ref_id = 0
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" 116 if ($rec =
$ilDB->fetchAssoc($set)) {
117 $status_day = substr($rec[
"status_date"], 0, 10);
120 $recent = $rec[
"status_date"];
132 string $a_timestamp_to = null,
138 $to = (!is_null($a_timestamp_to))
139 ?
" AND status_date <= " .
$ilDB->quote($a_timestamp_to,
"timestamp")
142 $user = ($a_user_id > 0)
143 ?
" AND user_id = " .
$ilDB->quote($a_user_id,
"integer")
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") .
150 " AND self_eval = " .
$ilDB->quote($a_self_eval,
"integer") .
153 " ORDER BY user_id, status_date ASC ");
154 $achievments = array();
155 while ($rec =
$ilDB->fetchAssoc($set)) {
156 $achievments[$rec[
"user_id"]][] = $rec;
169 ?
string $trigger_title,
170 ?
string $trigger_type,
176 bool $a_self_eval =
false,
177 string $a_unique_identifier =
"",
178 float $a_next_level_fulfilment = 0.0
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")
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")
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") .
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")
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") .
267 int $a_trigger_obj_id,
268 bool $a_self_eval =
false,
269 string $a_unique_identifier =
"" 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")
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")
303 $ilDB->manipulate(
"DELETE FROM skl_user_skill_level WHERE " 304 .
" user_id = " .
$ilDB->quote($a_user_id,
"integer")
306 $ilDB->manipulate(
"DELETE FROM skl_user_has_level WHERE " 307 .
" user_id = " .
$ilDB->quote($a_user_id,
"integer")
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")
332 $has_level = array();
333 while ($rec =
$ilDB->fetchAssoc($set)) {
334 $has_level[$rec[
"level_id"]] =
true;
337 foreach ($levels as $l) {
338 if (isset($has_level[$l[
"id"]])) {
339 $max_level = $l[
"id"];
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" 365 while ($rec =
$ilDB->fetchAssoc($set)) {
383 ?
" AND self_eval = " .
$ilDB->quote($a_self_eval,
"integer")
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") .
391 " ORDER BY status_date DESC" 394 while ($rec =
$ilDB->fetchAssoc($set)) {
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")
421 $has_level = array();
422 while ($rec =
$ilDB->fetchAssoc($set)) {
423 $has_level[$rec[
"level_id"]] =
true;
426 foreach ($levels as $l) {
427 if (isset($has_level[$l[
"id"]])) {
428 $max_level = $l[
"id"];
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")
453 $has_level = array();
454 while ($rec =
$ilDB->fetchAssoc($set)) {
455 $has_level[$rec[
"level_id"]] =
true;
458 foreach ($levels as $l) {
459 if (isset($has_level[$l[
"id"]])) {
460 $max_level = $l[
"id"];
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")
480 if ($rec =
$ilDB->fetchAssoc($set)) {
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" 508 $rec =
$ilDB->fetchAssoc($set);
510 return $rec[
"level_id"];
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" 535 $rec =
$ilDB->fetchAssoc($set);
537 return $rec[
"status_date"];
getLastLevelPerObject(int $skill_id, int $a_tref_id, int $a_object_id, int $a_user_id=0, int $a_self_eval=0)
hasSelfEvaluated(int $a_user_id, int $a_skill_id, int $a_tref_id)
getMaxLevelPerObject(int $skill_id, array $levels, int $a_tref_id, int $a_object_id, int $a_user_id=0, int $a_self_eval=0)
deleteUserLevelsOfSkill(int $skill_id)
removeAllUserData(int $a_user_id)
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)
static now()
Return current timestamp in Y-m-d H:i:s format.
getAllLevelEntriesOfUser(int $skill_id, int $a_tref_id, int $a_user_id=0, int $a_self_eval=0)
__construct(ilDBInterface $db=null)
hasRecentSelfEvaluation(int $trigger_obj_id, int $a_user_id, int $a_skill_id, int $a_tref_id=0, int $a_trigger_ref_id=0)
getLastUpdatePerObject(int $skill_id, int $a_tref_id, int $a_object_id, int $a_user_id=0, int $a_self_eval=0)
getNewAchievementsPerUser(string $a_timestamp, string $a_timestamp_to=null, int $a_user_id=0, int $a_self_eval=0)
getMaxLevelPerType(int $skill_id, array $levels, int $a_tref_id, string $a_type, int $a_user_id=0, int $a_self_eval=0)
getMaxLevel(int $skill_id, array $levels, int $a_tref_id, int $a_user_id=0, int $a_self_eval=0)
Interface ilBasicSkillUserLevelRepository.
getAllHistoricLevelEntriesOfUser(int $skill_id, int $a_tref_id, int $a_user_id=0, int $a_eval_by=0)
removeAllUserSkillLevelStatusOfObject(int $a_user_id, int $a_trigger_obj_id, bool $a_self_eval=false, string $a_unique_identifier="")
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)