5 include_once(
"./Services/Skill/classes/class.ilSkillTreeNode.php");
6 include_once(
"./Services/Skill/interfaces/interface.ilSkillUsageInfo.php");
33 parent::__construct($a_id);
61 $ilDB->manipulate(
"DELETE FROM skl_level WHERE " 62 .
" skill_id = ".$ilDB->quote($this->getId(),
"integer")
65 $ilDB->manipulate(
"DELETE FROM skl_user_has_level WHERE " 66 .
" skill_id = ".$ilDB->quote($this->getId(),
"integer")
79 $skill->setType($this->
getType());
87 foreach($levels as $item)
89 $skill->addLevel($item[
"title"], $item[
"description"]);
109 function addLevel($a_title, $a_description, $a_import_id =
"")
114 $nid = $ilDB->nextId(
"skl_level");
115 $ilDB->insert(
"skl_level",
array(
116 "id" =>
array(
"integer", $nid),
117 "skill_id" =>
array(
"integer", $this->
getId()),
118 "nr" =>
array(
"integer", $nr+1),
119 "title" =>
array(
"text", $a_title),
120 "description" =>
array(
"clob", $a_description),
121 "import_id" =>
array(
"text", $a_import_id),
136 $set = $ilDB->query(
"SELECT MAX(nr) mnr FROM skl_level WHERE ".
137 " skill_id = ".$ilDB->quote($this->getId(),
"integer")
139 $rec = $ilDB->fetchAssoc($set);
140 return (
int) $rec[
"mnr"];
154 $and =
" AND id = ".$ilDB->quote($a_id,
"integer");
157 $set = $ilDB->query(
"SELECT * FROM skl_level WHERE ".
158 " skill_id = ".$ilDB->quote($this->getId(),
"integer").
163 while ($rec = $ilDB->fetchAssoc($set))
184 $set = $ilDB->query(
"SELECT $a_prop FROM skl_level WHERE ".
185 " id = ".$ilDB->quote($a_id,
"integer")
187 $rec = $ilDB->fetchAssoc($set);
188 return $rec[$a_prop];
234 $ilDB->update(
"skl_level",
array(
237 "id" =>
array(
"integer", $a_id),
276 foreach ($order as $id => $o)
278 $ilDB->manipulate(
"UPDATE skl_level SET ".
279 " nr = ".$ilDB->quote($cnt,
"integer").
280 " WHERE id = ".$ilDB->quote($id,
"integer")
296 $ilDB->manipulate(
"DELETE FROM skl_level WHERE " 297 .
" id = ".$ilDB->quote($a_id,
"integer")
312 $set = $ilDB->query(
"SELECT id, nr FROM skl_level WHERE ".
313 " skill_id = ".$ilDB->quote($this->getId(),
"integer").
317 while ($rec = $ilDB->fetchAssoc($set))
319 $ilDB->manipulate(
"UPDATE skl_level SET ".
320 " nr = ".$ilDB->quote($cnt,
"integer").
321 " WHERE id = ".$ilDB->quote($rec[
"id"],
"integer")
337 $set = $ilDB->query(
"SELECT * FROM skl_level WHERE ".
338 " id = ".$ilDB->quote($a_level_id,
"integer")
341 if ($rec = $ilDB->fetchAssoc($set))
374 $db = $DIC->database();
378 include_once(
"./Services/Skill/exceptions/class.ilSkillException.php");
379 throw new ilSkillException(
"resetUserSkillLevelStatus currently only provided for self evaluations.");
382 $trigger_obj_id = ($a_trigger_ref_id > 0)
387 $status_date = self::hasRecentSelfEvaluation($a_user_id, $a_skill_id, $a_tref_id, $a_trigger_ref_id);
388 if ($status_date !=
"")
397 $db->manipulate(
"UPDATE skl_user_skill_level SET ".
398 " level_id = ".$db->quote(0,
"integer").
",".
399 " status_date = ".$db->quote($now,
"timestamp").
400 " WHERE user_id = ".$db->quote($a_user_id,
"integer").
401 " AND status_date = ".$db->quote($status_date,
"timestamp").
402 " AND skill_id = ".$db->quote($a_skill_id,
"integer").
403 " AND status = ".$db->quote(self::ACHIEVED,
"integer").
404 " AND trigger_obj_id = ".$db->quote($trigger_obj_id,
"integer").
405 " AND tref_id = ".$db->quote((
int) $a_tref_id,
"integer").
406 " AND self_eval = ".$db->quote($a_self_eval,
"integer")
412 $db->manipulate(
"INSERT INTO skl_user_skill_level ".
413 "(level_id, user_id, tref_id, status_date, skill_id, status, valid, trigger_ref_id,".
414 "trigger_obj_id, trigger_obj_type, trigger_title, self_eval, unique_identifier) VALUES (".
415 $db->quote(0,
"integer").
",".
416 $db->quote($a_user_id,
"integer").
",".
417 $db->quote((
int) $a_tref_id,
"integer").
",".
418 $db->quote($now,
"timestamp").
",".
419 $db->quote($a_skill_id,
"integer").
",".
420 $db->quote(self::ACHIEVED,
"integer").
",".
421 $db->quote(1,
"integer").
",".
422 $db->quote($a_trigger_ref_id,
"integer").
",".
423 $db->quote($trigger_obj_id,
"integer").
",".
424 $db->quote(
"",
"text").
",".
425 $db->quote(
"",
"text").
",".
426 $db->quote($a_self_eval,
"integer").
",".
427 $db->quote(
"",
"text").
431 $db->manipulate(
"DELETE FROM skl_user_has_level WHERE " 432 .
" user_id = ".$db->quote($a_user_id,
"integer")
433 .
" AND skill_id = ".$db->quote($a_skill_id,
"integer")
434 .
" AND tref_id = ".$db->quote((
int) $a_tref_id,
"integer")
435 .
" AND trigger_obj_id = ".$db->quote($trigger_obj_id,
"integer")
436 .
" AND self_eval = ".$db->quote($a_self_eval,
"integer")
452 $db = $DIC->database();
454 $trigger_obj_id = ($a_trigger_ref_id > 0)
461 $set = $db->query(
"SELECT * FROM skl_user_skill_level WHERE ".
462 "skill_id = ".$db->quote($a_skill_id,
"integer").
" AND ".
463 "user_id = ".$db->quote($a_user_id,
"integer").
" AND ".
464 "tref_id = ".$db->quote((
int) $a_tref_id,
"integer").
" AND ".
465 "trigger_obj_id = ".$db->quote($trigger_obj_id,
"integer").
" AND ".
466 "self_eval = ".$db->quote(1,
"integer").
467 " ORDER BY status_date DESC" 469 $rec = $db->fetchAssoc($set);
470 $status_day = substr($rec[
"status_date"], 0, 10);
474 $recent = $rec[
"status_date"];
495 $a_self_eval =
false, $a_unique_identifier =
"")
500 $trigger_ref_id = $a_trigger_ref_id;
508 if ($a_self_eval && self::hasRecentSelfEvaluation($a_user_id, $skill_id, $a_tref_id, $trigger_ref_id))
510 $status_date = self::hasRecentSelfEvaluation($a_user_id, $skill_id, $a_tref_id, $trigger_ref_id);
511 if ($status_date !=
"")
521 $ilDB->manipulate(
"UPDATE skl_user_skill_level SET ".
522 " level_id = ".$ilDB->quote($a_level_id,
"integer").
",".
523 " status_date = ".$ilDB->quote($now,
"timestamp").
524 " WHERE user_id = ".$ilDB->quote($a_user_id,
"integer").
525 " AND status_date = ".$ilDB->quote($status_date,
"timestamp").
526 " AND skill_id = ".$ilDB->quote($skill_id,
"integer").
527 " AND status = ".$ilDB->quote($a_status,
"integer").
528 " AND trigger_obj_id = ".$ilDB->quote($trigger_obj_id,
"integer").
529 " AND tref_id = ".$ilDB->quote((
int) $a_tref_id,
"integer").
530 " AND self_eval = ".$ilDB->quote($a_self_eval,
"integer")
535 if ($a_unique_identifier !=
"")
537 $ilDB->manipulate(
"DELETE FROM skl_user_skill_level WHERE ".
538 " user_id = ".$ilDB->quote($a_user_id,
"integer").
539 " AND tref_id = ".$ilDB->quote($a_tref_id,
"integer").
540 " AND skill_id = ".$ilDB->quote($skill_id,
"integer").
541 " AND trigger_ref_id = ".$ilDB->quote($trigger_ref_id,
"integer").
542 " AND trigger_obj_id = ".$ilDB->quote($trigger_obj_id,
"integer").
543 " AND self_eval = ".$ilDB->quote($a_self_eval,
"integer").
544 " AND unique_identifier = ".$ilDB->quote($a_unique_identifier,
"text")
549 $ilDB->manipulate(
"INSERT INTO skl_user_skill_level ".
550 "(level_id, user_id, tref_id, status_date, skill_id, status, valid, trigger_ref_id,".
551 "trigger_obj_id, trigger_obj_type, trigger_title, self_eval, unique_identifier) VALUES (".
552 $ilDB->quote($a_level_id,
"integer").
",".
553 $ilDB->quote($a_user_id,
"integer").
",".
554 $ilDB->quote((
int) $a_tref_id,
"integer").
",".
555 $ilDB->quote($now,
"timestamp").
",".
556 $ilDB->quote($skill_id,
"integer").
",".
557 $ilDB->quote($a_status,
"integer").
",".
558 $ilDB->quote(1,
"integer").
",".
559 $ilDB->quote($trigger_ref_id,
"integer").
",".
560 $ilDB->quote($trigger_obj_id,
"integer").
",".
561 $ilDB->quote($trigger_type,
"text").
",".
562 $ilDB->quote($trigger_title,
"text").
",".
563 $ilDB->quote($a_self_eval,
"integer").
",".
564 $ilDB->quote($a_unique_identifier,
"text").
570 $ilDB->manipulate(
"DELETE FROM skl_user_has_level WHERE " 571 .
" user_id = ".$ilDB->quote($a_user_id,
"integer")
572 .
" AND skill_id = ".$ilDB->quote($skill_id,
"integer")
573 .
" AND tref_id = ".$ilDB->quote((
int) $a_tref_id,
"integer")
574 .
" AND trigger_obj_id = ".$ilDB->quote($trigger_obj_id,
"integer")
575 .
" AND self_eval = ".$ilDB->quote($a_self_eval,
"integer")
580 $ilDB->manipulate(
"INSERT INTO skl_user_has_level ".
581 "(level_id, user_id, tref_id, status_date, skill_id, trigger_ref_id, trigger_obj_id, trigger_obj_type, trigger_title, self_eval) VALUES (".
582 $ilDB->quote($a_level_id,
"integer").
",".
583 $ilDB->quote($a_user_id,
"integer").
",".
584 $ilDB->quote($a_tref_id,
"integer").
",".
585 $ilDB->quote($now,
"timestamp").
",".
586 $ilDB->quote($skill_id,
"integer").
",".
587 $ilDB->quote($trigger_ref_id,
"integer").
",".
588 $ilDB->quote($trigger_obj_id,
"integer").
",".
589 $ilDB->quote($trigger_type,
"text").
",".
590 $ilDB->quote($trigger_title,
"text").
",".
591 $ilDB->quote($a_self_eval,
"integer").
608 $a_user_id = $ilUser->getId();
611 $set = $ilDB->query($q =
"SELECT level_id FROM skl_user_has_level ".
612 " WHERE trigger_obj_type = ".$ilDB->quote(
$a_type,
"text").
613 " AND skill_id = ".$ilDB->quote($this->
getId(),
"integer").
614 " AND tref_id = ".$ilDB->quote((
int) $a_tref_id,
"integer").
615 " AND user_id = ".$ilDB->quote($a_user_id,
"integer").
616 " AND self_eval = ".$ilDB->quote($a_self_eval,
"integer")
619 $has_level =
array();
620 while ($rec = $ilDB->fetchAssoc($set))
622 $has_level[$rec[
"level_id"]] =
true;
627 if (isset($has_level[
$l[
"id"]]))
629 $max_level = $l[
"id"];
647 $a_user_id = $ilUser->getId();
650 $set = $ilDB->query($q =
"SELECT * FROM skl_user_has_level ".
651 " WHERE skill_id = ".$ilDB->quote($this->getId(),
"integer").
652 " AND tref_id = ".$ilDB->quote((
int) $a_tref_id,
"integer").
653 " AND user_id = ".$ilDB->quote($a_user_id,
"integer").
654 " AND self_eval = ".$ilDB->quote($a_self_eval,
"integer").
655 " ORDER BY status_date DESC" 659 while ($rec = $ilDB->fetchAssoc($set))
678 $a_user_id = $ilUser->getId();
681 $by = ($a_eval_by != self::EVAL_BY_ALL)
682 ?
" AND self_eval = ".$ilDB->quote($a_self_eval,
"integer")
685 $set = $ilDB->query($q =
"SELECT * FROM skl_user_skill_level ".
686 " WHERE skill_id = ".$ilDB->quote($this->getId(),
"integer").
687 " AND tref_id = ".$ilDB->quote((
int) $a_tref_id,
"integer").
688 " AND user_id = ".$ilDB->quote($a_user_id,
"integer").
690 " ORDER BY status_date DESC" 693 while ($rec = $ilDB->fetchAssoc($set))
713 $a_user_id = $ilUser->getId();
716 $set = $ilDB->query($q =
"SELECT level_id FROM skl_user_has_level ".
717 " WHERE trigger_obj_id = ".$ilDB->quote($a_object_id,
"integer").
718 " AND skill_id = ".$ilDB->quote($this->
getId(),
"integer").
719 " AND tref_id = ".$ilDB->quote((
int) $a_tref_id,
"integer").
720 " AND user_id = ".$ilDB->quote($a_user_id,
"integer").
721 " AND self_eval = ".$ilDB->quote($a_self_eval,
"integer")
724 $has_level =
array();
725 while ($rec = $ilDB->fetchAssoc($set))
727 $has_level[$rec[
"level_id"]] =
true;
732 if (isset($has_level[
$l[
"id"]]))
734 $max_level = $l[
"id"];
752 $a_user_id = $ilUser->getId();
756 $set = $ilDB->query($q =
"SELECT level_id FROM skl_user_has_level ".
757 " WHERE trigger_obj_id = ".$ilDB->quote($a_object_id,
"integer").
758 " AND skill_id = ".$ilDB->quote($this->
getId(),
"integer").
759 " AND tref_id = ".$ilDB->quote((
int) $a_tref_id,
"integer").
760 " AND user_id = ".$ilDB->quote($a_user_id,
"integer").
761 " AND self_eval = ".$ilDB->quote($a_self_eval,
"integer").
762 " ORDER BY status_date DESC" 765 $rec = $ilDB->fetchAssoc($set);
767 return $rec[
"level_id"];
782 $a_user_id = $ilUser->getId();
786 $set = $ilDB->query($q =
"SELECT status_date FROM skl_user_has_level ".
787 " WHERE trigger_obj_id = ".$ilDB->quote($a_object_id,
"integer").
788 " AND skill_id = ".$ilDB->quote($this->
getId(),
"integer").
789 " AND tref_id = ".$ilDB->quote((
int) $a_tref_id,
"integer").
790 " AND user_id = ".$ilDB->quote($a_user_id,
"integer").
791 " AND self_eval = ".$ilDB->quote($a_self_eval,
"integer").
792 " ORDER BY status_date DESC" 795 $rec = $ilDB->fetchAssoc($set);
797 return $rec[
"status_date"];
836 $certificatefile = CLIENT_WEB_DIR.
"/certificates/skill/".
837 ((int)$a_skill_id).
"/".((int) $a_skill_level_id).
"/certificate.xml";
838 if (@file_exists($certificatefile))
858 include_once(
"./Services/Skill/classes/class.ilSkillUsage.php");
860 "skl_user_skill_level",
"user_id");
875 include_once(
"./Services/Skill/classes/class.ilSkillTree.php");
876 include_once(
"./Services/Skill/classes/class.ilSkillTemplateReference.php");
879 if ($a_source_inst_id == 0)
884 $template_ids =
array();
885 if ($a_tref_import_id > 0)
887 $skill_node_type =
"sktp";
890 $set = $ilDB->query(
"SELECT * FROM skl_tree_node n JOIN skl_tree t ON (n.obj_id = t.child) ".
891 " WHERE n.import_id = ".$ilDB->quote(
"il_".((int)$a_source_inst_id).
"_sktr_".$a_tref_import_id,
"text").
892 " ORDER BY n.creation_date DESC ");
893 while ($rec = $ilDB->fetchAssoc($set))
897 $template_ids[
$t] = $rec[
"obj_id"];
903 $skill_node_type =
"skll";
905 $set = $ilDB->query(
"SELECT * FROM skl_tree_node n JOIN skl_tree t ON (n.obj_id = t.child) ".
906 " WHERE n.import_id = ".$ilDB->quote(
"il_".((int)$a_source_inst_id).
"_".$skill_node_type.
"_".$a_skill_import_id,
"text").
907 " ORDER BY n.creation_date DESC ");
909 while ($rec = $ilDB->fetchAssoc($set))
911 $matching_trefs =
array();
912 if ($a_tref_import_id > 0)
914 $skill_template_id = $tree->getTopParentNodeId($rec[
"obj_id"]);
917 foreach ($template_ids as $templ => $tref)
919 if ($skill_template_id == $templ)
921 $matching_trefs[] = $tref;
927 $matching_trefs =
array(0);
930 foreach ($matching_trefs as
$t)
932 $results[] =
array(
"skill_id" => $rec[
"obj_id"],
"tref_id" => $t,
"creation_date" => $rec[
"creation_date"]);
949 $set = $ilDB->query(
"SELECT * FROM skl_level l JOIN skl_tree t ON (l.skill_id = t.child) " .
950 " WHERE l.import_id = " . $ilDB->quote(
"il_" . ((
int)$a_source_inst_id) .
"_sklv_" . $a_level_import_id,
"text") .
951 " ORDER BY l.creation_date DESC ");
953 while ($rec = $ilDB->fetchAssoc($set))
955 $results[] =
array(
"level_id" => $rec[
"id"],
"creation_date" => $rec[
"creation_date"]);
968 $level_id_data = self::getLevelIdForImportId($a_source_inst_id, $a_level_import_id);
969 $skill_data = self::getCommonSkillIdForImportId($a_source_inst_id, $a_skill_import_id, $a_tref_import_id);
971 foreach($level_id_data as
$l)
974 foreach ($skill_data as $s)
979 "level_id" => $l[
"level_id"],
980 "creation_date" => $l[
"creation_date"],
981 "skill_id" => $s[
"skill_id"],
982 "tref_id" => $s[
"tref_id"]
Get info on usages of skills.
getShortTitleForCertificate()
Get short title for certificate.
setType($a_type)
Set type.
addLevel($a_title, $a_description, $a_import_id="")
Add new level.
getLevelData($a_id=0)
Get level data.
static lookupLevelTitle($a_id)
Lookup level title.
getLastLevelPerObject($a_tref_id, $a_object_id, $a_user_id=0, $a_self_eval=0)
Get last level set per object.
static getLevelIdForImportId($a_source_inst_id, $a_level_import_id)
Get level ids for import IDs (newest first)
getSkillForLevelId($a_level_id)
Get skill for level id.
getMaxLevelNr()
Get maximum level nr.
static _lookupTitle($a_id)
lookup object title
getSelfEvaluation()
Get self evaluation.
static now()
Return current timestamp in Y-m-d H:i:s format.
deleteLevel($a_id)
Delete level.
getOrderNr()
Get order nr.
static getLevelIdForImportIdMatchSkill($a_source_inst_id, $a_level_import_id, $a_skill_import_id, $a_tref_import_id=0)
Get level ids for import Ids matching common skills.
static getUsageInfo($a_cskill_ids, &$a_usages)
Get usage info.
static writeLevelProperty($a_id, $a_prop, $a_value, $a_type)
Write level property.
static writeLevelDescription($a_id, $a_description)
Write level description.
fixLevelNumbering()
Fix level numbering.
static isInTree($a_id)
Is id in tree?
read()
Read data from database.
static _lookupObjId($a_id)
static writeLevelTitle($a_id, $a_title)
Write level title.
getMaxLevelPerType($a_tref_id, $a_type, $a_user_id=0, $a_self_eval=0)
Get max levels per type.
static lookupLevelProperty($a_id, $a_prop)
Lookup level property.
static _lookupTemplateId($a_obj_id)
Lookup template ID.
static writeUserSkillLevelStatus($a_level_id, $a_user_id, $a_trigger_ref_id, $a_tref_id=0, $a_status=ilBasicSkill::ACHIEVED, $a_force=false, $a_self_eval=false, $a_unique_identifier="")
Write skill level status.
Create styles array
The data for the language used.
static _lookupType($a_id, $a_reference=false)
lookup object type
static lookupLevelDescription($a_id)
Lookup level description.
static getUsageInfoGeneric($a_cskill_ids, &$a_usages, $a_usage_type, $a_table, $a_key_field, $a_skill_field="skill_id", $a_tref_field="tref_id")
Get standard usage query.
static _lookupCertificate($a_skill_id, $a_skill_level_id)
Checks whether a skill level has a certificate or not.
getTitleForCertificate()
Get title for certificate.
getMaxLevelPerObject($a_tref_id, $a_object_id, $a_user_id=0, $a_self_eval=0)
Get max levels per object.
updateLevelOrder($order)
Update level order.
A node in the skill tree.
static hasRecentSelfEvaluation($a_user_id, $a_skill_id, $a_tref_id=0, $a_trigger_ref_id=0)
Has recent self evaluation.
getAllHistoricLevelEntriesOfUser($a_tref_id, $a_user_id=0, $a_eval_by=0)
Get all historic level entries.
static lookupLevelSkillId($a_id)
Lookup level skill id.
__construct($a_id=0)
Constructor public.
getLastUpdatePerObject($a_tref_id, $a_object_id, $a_user_id=0, $a_self_eval=0)
Get last update per object.
getAllLevelEntriesOfUser($a_tref_id, $a_user_id=0, $a_self_eval=0)
Get all level entries.
static getCommonSkillIdForImportId($a_source_inst_id, $a_skill_import_id, $a_tref_import_id=0)
Get common skill ids for import IDs (newest first)
static resetUserSkillLevelStatus($a_user_id, $a_skill_id, $a_tref_id=0, $a_trigger_ref_id=0, $a_self_eval=false)
Reset skill level status.