5 include_once(
"./Services/Skill/classes/class.ilSkillTreeNode.php");
6 include_once(
"./Services/Skill/interfaces/interface.ilSkillUsageInfo.php");
33 parent::ilSkillTreeNode($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"]);
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)
134 $set = $ilDB->query(
"SELECT MAX(nr) mnr FROM skl_level WHERE ".
135 " skill_id = ".$ilDB->quote($this->getId(),
"integer")
137 $rec = $ilDB->fetchAssoc($set);
138 return (
int) $rec[
"mnr"];
152 $and =
" AND id = ".$ilDB->quote($a_id,
"integer");
155 $set = $ilDB->query(
"SELECT * FROM skl_level WHERE ".
156 " skill_id = ".$ilDB->quote($this->getId(),
"integer").
161 while ($rec = $ilDB->fetchAssoc($set))
182 $set = $ilDB->query(
"SELECT $a_prop FROM skl_level WHERE ".
183 " id = ".$ilDB->quote($a_id,
"integer")
185 $rec = $ilDB->fetchAssoc($set);
186 return $rec[$a_prop];
219 die(
"ilBasicSkill::lookupLevelTrigger is deprecated.");
222 return array(
"ref_id" =>
$ref_id,
"obj_id" => $obj_id);
246 $ilDB->update(
"skl_level", array(
247 $a_prop => array($a_type, $a_value),
249 "id" => array(
"integer", $a_id),
283 die(
"ilBasicSkill::writeLevelTrigger is deprecated.");
284 $a_trigger_obj_id = 0;
285 if ($a_trigger_ref_id > 0)
306 foreach ($order as $id => $o)
308 $ilDB->manipulate(
"UPDATE skl_level SET ".
309 " nr = ".$ilDB->quote($cnt,
"integer").
310 " WHERE id = ".$ilDB->quote($id,
"integer")
326 $ilDB->manipulate(
"DELETE FROM skl_level WHERE " 327 .
" id = ".$ilDB->quote($a_id,
"integer")
342 $set = $ilDB->query(
"SELECT id, nr FROM skl_level WHERE ".
343 " skill_id = ".$ilDB->quote($this->getId(),
"integer").
347 while ($rec = $ilDB->fetchAssoc($set))
349 $ilDB->manipulate(
"UPDATE skl_level SET ".
350 " nr = ".$ilDB->quote($cnt,
"integer").
351 " WHERE id = ".$ilDB->quote($rec[
"id"],
"integer")
366 die(
"ilBasicSkill::lookupLevelsForTriggerRefId is deprecated.");
367 $set = $ilDB->query(
"SELECT id FROM skl_level WHERE ".
368 " trigger_ref_id = ".$ilDB->quote($a_ref_id,
"integer")
371 while ($rec = $ilDB->fetchAssoc($set))
373 $levels[] = $rec[
"id"];
388 $set = $ilDB->query(
"SELECT * FROM skl_level WHERE ".
389 " id = ".$ilDB->quote($a_level_id,
"integer")
392 if ($rec = $ilDB->fetchAssoc($set))
416 die(
"ilBasicSkill::updateAllUserSkillLevels is deprecated.");
417 $set = $ilDB->query(
"SELECT id, trigger_obj_id FROM skl_level WHERE ".
418 " trigger_obj_id > ".$ilDB->quote(0,
"integer")
420 while ($rec = $ilDB->fetchAssoc($set))
422 $skill_level_id = $rec[
"id"];
423 $tr_obj_id = $rec[
"trigger_obj_id"];
427 include_once(
"./Services/Tracking/classes/class.ilLPStatusWrapper.php");
429 foreach ($completed as $user_id)
445 die(
"ilBasicSkill::updateSkillLevelsByTriggerRef is deprecated.");
446 $set = $ilDB->query(
"SELECT id, trigger_obj_id FROM skl_level WHERE ".
447 " trigger_ref_id = ".$ilDB->quote($a_ref_id,
"integer")
449 while ($rec = $ilDB->fetchAssoc($set))
451 $skill_level_id = $rec[
"id"];
452 $tr_obj_id = $rec[
"trigger_obj_id"];
456 include_once(
"./Services/Tracking/classes/class.ilLPStatusWrapper.php");
458 foreach ($completed as $user_id)
460 if ($a_user_id == $user_id)
484 $trigger_ref_id = $a_trigger_ref_id;
511 $set = $ilDB->query(
"SELECT * FROM skl_user_skill_level WHERE ".
512 "skill_id = ".$ilDB->quote($skill_id,
"integer").
" AND ".
513 "user_id = ".$ilDB->quote($a_user_id,
"integer").
" AND ".
514 "tref_id = ".$ilDB->quote((
int) $a_tref_id,
"integer").
" AND ".
515 "trigger_obj_id = ".$ilDB->quote($trigger_obj_id,
"integer").
" AND ".
516 "self_eval = ".$ilDB->quote($a_self_eval,
"integer").
517 " ORDER BY status_date DESC" 519 $rec = $ilDB->fetchAssoc($set);
520 $status_day = substr($rec[
"status_date"], 0, 10);
522 if ($rec[
"valid"] && $rec[
"status"] == $a_status && $status_day == $today)
531 $ilDB->manipulate(
"UPDATE skl_user_skill_level SET ".
532 " level_id = ".$ilDB->quote($a_level_id,
"integer").
",".
533 " status_date = ".$ilDB->quote($now,
"timestamp").
534 " WHERE user_id = ".$ilDB->quote($a_user_id,
"integer").
535 " AND status_date = ".$ilDB->quote($rec[
"status_date"],
"timestamp").
536 " AND skill_id = ".$ilDB->quote($rec[
"skill_id"],
"integer").
537 " AND status = ".$ilDB->quote($a_status,
"integer").
538 " AND trigger_obj_id = ".$ilDB->quote($trigger_obj_id,
"integer").
539 " AND tref_id = ".$ilDB->quote((
int) $a_tref_id,
"integer").
540 " AND self_eval = ".$ilDB->quote($a_self_eval,
"integer")
546 $ilDB->manipulate(
"INSERT INTO skl_user_skill_level ".
547 "(level_id, user_id, tref_id, status_date, skill_id, status, valid, trigger_ref_id,".
548 "trigger_obj_id, trigger_obj_type, trigger_title, self_eval) VALUES (".
549 $ilDB->quote($a_level_id,
"integer").
",".
550 $ilDB->quote($a_user_id,
"integer").
",".
551 $ilDB->quote((
int) $a_tref_id,
"integer").
",".
552 $ilDB->quote($now,
"timestamp").
",".
553 $ilDB->quote($skill_id,
"integer").
",".
554 $ilDB->quote($a_status,
"integer").
",".
555 $ilDB->quote(1,
"integer").
",".
556 $ilDB->quote($trigger_ref_id,
"integer").
",".
557 $ilDB->quote($trigger_obj_id,
"integer").
",".
558 $ilDB->quote($trigger_type,
"text").
",".
559 $ilDB->quote($trigger_title,
"text").
",".
560 $ilDB->quote($a_self_eval,
"integer").
566 $ilDB->manipulate(
"DELETE FROM skl_user_has_level WHERE " 567 .
" user_id = ".$ilDB->quote($a_user_id,
"integer")
568 .
" AND skill_id = ".$ilDB->quote($skill_id,
"integer")
569 .
" AND tref_id = ".$ilDB->quote((
int) $a_tref_id,
"integer")
570 .
" AND trigger_obj_id = ".$ilDB->quote($trigger_obj_id,
"integer")
571 .
" AND self_eval = ".$ilDB->quote($a_self_eval,
"integer")
576 $ilDB->manipulate(
"INSERT INTO skl_user_has_level ".
577 "(level_id, user_id, tref_id, status_date, skill_id, trigger_ref_id, trigger_obj_id, trigger_obj_type, trigger_title, self_eval) VALUES (".
578 $ilDB->quote($a_level_id,
"integer").
",".
579 $ilDB->quote($a_user_id,
"integer").
",".
580 $ilDB->quote($a_tref_id,
"integer").
",".
581 $ilDB->quote($now,
"timestamp").
",".
582 $ilDB->quote($skill_id,
"integer").
",".
583 $ilDB->quote($trigger_ref_id,
"integer").
",".
584 $ilDB->quote($trigger_obj_id,
"integer").
",".
585 $ilDB->quote($trigger_type,
"text").
",".
586 $ilDB->quote($trigger_title,
"text").
",".
587 $ilDB->quote($a_self_eval,
"integer").
604 $a_user_id = $ilUser->getId();
607 $set = $ilDB->query($q =
"SELECT level_id FROM skl_user_has_level ".
608 " WHERE trigger_obj_type = ".$ilDB->quote($a_type,
"text").
609 " AND skill_id = ".$ilDB->quote($this->
getId(),
"integer").
610 " AND tref_id = ".$ilDB->quote((
int) $a_tref_id,
"integer").
611 " AND user_id = ".$ilDB->quote($a_user_id,
"integer").
612 " AND self_eval = ".$ilDB->quote($a_self_eval,
"integer")
615 $has_level = array();
616 while ($rec = $ilDB->fetchAssoc($set))
618 $has_level[$rec[
"level_id"]] =
true;
623 if (isset($has_level[$l[
"id"]]))
625 $max_level = $l[
"id"];
643 $a_user_id = $ilUser->getId();
646 $set = $ilDB->query($q =
"SELECT * FROM skl_user_has_level ".
647 " WHERE skill_id = ".$ilDB->quote($this->getId(),
"integer").
648 " AND tref_id = ".$ilDB->quote((
int) $a_tref_id,
"integer").
649 " AND user_id = ".$ilDB->quote($a_user_id,
"integer").
650 " AND self_eval = ".$ilDB->quote($a_self_eval,
"integer").
651 " ORDER BY status_date DESC" 655 while ($rec = $ilDB->fetchAssoc($set))
674 $a_user_id = $ilUser->getId();
677 $by = ($a_eval_by != self::EVAL_BY_ALL)
678 ?
" AND self_eval = ".$ilDB->quote($a_self_eval,
"integer")
681 $set = $ilDB->query($q =
"SELECT * FROM skl_user_skill_level ".
682 " WHERE skill_id = ".$ilDB->quote($this->getId(),
"integer").
683 " AND tref_id = ".$ilDB->quote((
int) $a_tref_id,
"integer").
684 " AND user_id = ".$ilDB->quote($a_user_id,
"integer").
686 " ORDER BY status_date DESC" 689 while ($rec = $ilDB->fetchAssoc($set))
709 $a_user_id = $ilUser->getId();
712 $set = $ilDB->query($q =
"SELECT level_id FROM skl_user_has_level ".
713 " WHERE trigger_obj_id = ".$ilDB->quote($a_object_id,
"integer").
714 " AND skill_id = ".$ilDB->quote($this->
getId(),
"integer").
715 " AND tref_id = ".$ilDB->quote((
int) $a_tref_id,
"integer").
716 " AND user_id = ".$ilDB->quote($a_user_id,
"integer").
717 " AND self_eval = ".$ilDB->quote($a_self_eval,
"integer")
720 $has_level = array();
721 while ($rec = $ilDB->fetchAssoc($set))
723 $has_level[$rec[
"level_id"]] =
true;
728 if (isset($has_level[$l[
"id"]]))
730 $max_level = $l[
"id"];
748 $a_user_id = $ilUser->getId();
752 $set = $ilDB->query($q =
"SELECT level_id FROM skl_user_has_level ".
753 " WHERE trigger_obj_id = ".$ilDB->quote($a_object_id,
"integer").
754 " AND skill_id = ".$ilDB->quote($this->
getId(),
"integer").
755 " AND tref_id = ".$ilDB->quote((
int) $a_tref_id,
"integer").
756 " AND user_id = ".$ilDB->quote($a_user_id,
"integer").
757 " AND self_eval = ".$ilDB->quote($a_self_eval,
"integer").
758 " ORDER BY status_date DESC" 761 $rec = $ilDB->fetchAssoc($set);
763 return $rec[
"level_id"];
778 $a_user_id = $ilUser->getId();
782 $set = $ilDB->query($q =
"SELECT status_date FROM skl_user_has_level ".
783 " WHERE trigger_obj_id = ".$ilDB->quote($a_object_id,
"integer").
784 " AND skill_id = ".$ilDB->quote($this->
getId(),
"integer").
785 " AND tref_id = ".$ilDB->quote((
int) $a_tref_id,
"integer").
786 " AND user_id = ".$ilDB->quote($a_user_id,
"integer").
787 " AND self_eval = ".$ilDB->quote($a_self_eval,
"integer").
788 " ORDER BY status_date DESC" 791 $rec = $ilDB->fetchAssoc($set);
793 return $rec[
"status_date"];
805 die(
"ilBasicSkill::getCompletionDateForTriggerRefId is deprecated.");
810 else if (!is_array($a_ref_id))
812 $a_ref_id = array($a_ref_id);
814 if (!is_array($a_user_id))
816 $a_user_id = array($a_user_id);
819 if ($a_ref_id != null)
821 if (!is_array($a_ref_id))
823 $a_ref_id = array($a_ref_id);
826 $set = $ilDB->query($q =
"SELECT user_id, status_date, trigger_ref_id FROM skl_user_has_level WHERE ".
827 $ilDB->in(
"user_id", $a_user_id,
false,
"integer").
" AND ".
828 $ilDB->in(
"trigger_ref_id", $a_ref_id,
false,
"integer")
831 $completion = array();
832 while ($rec = $ilDB->fetchAssoc($set))
834 if (!isset($completion[$rec[
"user_id"]][$rec[
"trigger_ref_id"]]))
836 $completion[$rec[
"user_id"]][$rec[
"trigger_ref_id"]] = $rec[
"status_date"];
838 else if ($rec[
"status_date"] < $completion[$rec[
"user_id"]][$rec[
"trigger_ref_id"]])
840 $completion[$rec[
"user_id"]][$rec[
"trigger_ref_id"]] = $rec[
"status_date"];
846 foreach ($a_user_id as $user_id)
848 if (!isset($completion[$user_id][$ref_id]))
850 $completion[$user_id][
$ref_id] =
false;
857 $completion = array();
858 foreach ($a_user_id as $user_id)
860 include_once
'Services/Membership/classes/class.ilParticipants.php';
863 $set = $ilDB->query($q =
"SELECT user_id, status_date, trigger_ref_id FROM skl_user_has_level WHERE ".
864 "user_id = ".$ilDB->quote($user_id,
"integer").
" AND ".
865 $ilDB->in(
"trigger_ref_id", $a_ref_id,
false,
"integer")
868 while ($rec = $ilDB->fetchAssoc($set))
870 if (!isset($completion[$user_id][$rec[
"trigger_ref_id"]]))
872 $completion[$user_id][$rec[
"trigger_ref_id"]] = $rec[
"status_date"];
874 else if ($rec[
"status_date"] < $completion[$user_id][$rec[
"trigger_ref_id"]])
876 $completion[$user_id][$rec[
"trigger_ref_id"]] = $rec[
"status_date"];
881 if (!isset($completion[$user_id][$ref_id]))
883 $completion[$user_id][
$ref_id] =
false;
901 die(
"ilBasicSkill::checkUserCertificateForTriggerRefId is deprecated.");
902 if (!is_array($a_ref_id))
904 $a_ref_id = array($a_ref_id);
906 if (!is_array($a_user_id))
908 $a_user_id = array($a_user_id);
910 $set = $ilDB->query($q =
"SELECT user_id, status_date, trigger_ref_id, level_id, skill_id FROM skl_user_has_level WHERE ".
911 $ilDB->in(
"user_id", $a_user_id,
false,
"integer").
" AND ".
912 $ilDB->in(
"trigger_ref_id", $a_ref_id,
false,
"integer")
915 $completion = array();
917 $completion = array();
918 while ($rec = $ilDB->fetchAssoc($set))
920 if (!isset($completion[$rec[
"user_id"]][$rec[
"trigger_ref_id"]])
923 $completion[$rec[
"user_id"]][$rec[
"trigger_ref_id"]] =
true;
929 foreach ($a_user_id as $user_id)
931 if (!isset($completion[$user_id][$ref_id]))
933 $completion[$user_id][
$ref_id] =
false;
950 die(
"ilBasicSkill::lookupLevelAchievementDate is deprecated.");
951 $set = $ilDB->query(
"SELECT user_id, status_date, trigger_ref_id, level_id, skill_id FROM skl_user_has_level WHERE ".
952 " user_id = ".$ilDB->quote($a_user_id,
"integer").
953 " AND user_id = ".$ilDB->quote($a_user_id,
"integer")
955 if ($rec = $ilDB->fetchAssoc($set))
957 return $rec[
"status_date"];
972 die(
"ilBasicSkill::getTriggerOfAllCertificates is deprecated.");
973 if (!is_array($a_user_id))
975 $a_user_id = array($a_user_id);
978 $set = $ilDB->query($q =
"SELECT user_id, status_date, trigger_ref_id, level_id, skill_id FROM skl_user_has_level WHERE ".
979 $ilDB->in(
"user_id", $a_user_id,
false,
"integer")
982 $completion = array();
984 while ($rec = $ilDB->fetchAssoc($set))
986 if ((!is_array($completion[$rec[
"user_id"]]) || !in_array($rec[
"trigger_ref_id"], $completion[$rec[
"user_id"]]))
989 if ($tree->isInTree($rec[
"trigger_ref_id"]))
991 $completion[$rec[
"user_id"]][] = $rec[
"trigger_ref_id"];
996 foreach ($a_user_id as $user_id)
998 if (!is_array($completion[$user_id]))
1000 $completion[$user_id] = array();
1015 die(
"ilBasicSkill::getSkillLevelsForTrigger is deprecated.");
1016 $set = $ilDB->query($q =
"SELECT id FROM skl_level".
1017 " WHERE trigger_ref_id = ".$ilDB->quote($a_ref_id,
"integer"));
1019 $skill_levels = array();
1020 while ($rec = $ilDB->fetchAssoc($set))
1022 $skill_levels[] = $rec[
"id"];
1025 return $skill_levels;
1054 die(
"ilBasicSkill::getLevelTitleForCertificate is deprecated.");
1066 die(
"ilBasicSkill::getTriggerTitleForCertificate is deprecated.");
1090 $certificatefile = CLIENT_WEB_DIR.
"/certificates/skill/".
1091 ((int)$a_skill_id).
"/".((int) $a_skill_level_id).
"/certificate.xml";
1092 if (@file_exists($certificatefile))
1112 include_once(
"./Services/Skill/classes/class.ilSkillUsage.php");
1114 "skl_user_skill_level",
"user_id");
Get info on usages of skills.
getShortTitleForCertificate()
Get short title for certificate.
static updateSkillLevelsByTriggerRef($a_user_id, $a_ref_id)
Look for all skill level that have a trigger and update the user skill level information, if it has changed.
setType($a_type)
Set type.
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=0)
Write skill level status.
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.
getSkillForLevelId($a_level_id)
Get skill for level id.
static lookupLevelTrigger($a_id)
Lookup level trigger.
static getTriggerOfAllCertificates($a_user_id, $a_self_eval=0)
Get trigger completion.
static _getMembershipByType($a_usr_id, $a_type, $a_only_member_role=false)
get membership by type Get course or group membership
getTriggerTitleForCertificate($a_level_id)
Get trigger title for certificate.
getMaxLevelNr()
Get maximum level nr.
static _lookupTitle($a_id)
lookup object title
static updateAllUserSkillLevels()
Look for all skill level that have a trigger and update the user skill level information, if it has changed.
getSelfEvaluation()
Get self evaluation.
static now()
Return current timestamp in Y-m-d H:i:s format.
lookupLevelsForTriggerRefId($a_ref_id)
Lookup levels for trigger.
deleteLevel($a_id)
Delete level.
getOrderNr()
Get order nr.
addLevel($a_title, $a_description)
Add new level.
getLevelTitleForCertificate($a_level_id)
Get title for certificate.
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?
lookupLevelAchievementDate($a_user_id, $a_level_id, $a_self_eval=0)
Lookup level achievement date.
read()
Read data from database.
static _lookupObjId($a_id)
static checkUserCertificateForTriggerRefId($a_user_id, $a_ref_id, $a_self_eval=0)
Get trigger completion.
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 _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 writeLevelTrigger($a_id, $a_trigger_ref_id)
Write trigger.
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.
_hasUntrashedReference($a_obj_id)
checks wether an object has at least one reference that is not in trash
static getSkillLevelsForTrigger($a_ref_id)
Get assigned skill levels for trigger.
A node in the skill tree.
getAllHistoricLevelEntriesOfUser($a_tref_id, $a_user_id=0, $a_eval_by=0)
Get all historic level entries.
static _lookupCompletedForObject($a_obj_id, $a_user_ids=null)
Get completed users for object.
static lookupLevelSkillId($a_id)
Lookup level skill id.
__construct($a_id=0)
Constructor public.
static getCompletionDateForTriggerRefId($a_user_id, $a_ref_id=null, $a_self_eval=0)
Get trigger completion.
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.