5 include_once(
"./Services/Skill/classes/class.ilSkillTreeNode.php");
6 include_once(
"./Services/Skill/interfaces/interface.ilSkillUsageInfo.php");
57 $ilDB->manipulate(
"DELETE FROM skl_level WHERE "
58 .
" skill_id = ".$ilDB->quote($this->getId(),
"integer")
61 $ilDB->manipulate(
"DELETE FROM skl_user_has_level WHERE "
62 .
" skill_id = ".$ilDB->quote($this->getId(),
"integer")
75 $skill->setType($this->
getType());
83 foreach($levels as $item)
85 $skill->addLevel($item[
"title"], $item[
"description"]);
110 $nid = $ilDB->nextId(
"skl_level");
111 $ilDB->insert(
"skl_level", array(
112 "id" => array(
"integer", $nid),
113 "skill_id" => array(
"integer", $this->
getId()),
114 "nr" => array(
"integer", $nr+1),
115 "title" => array(
"text", $a_title),
116 "description" => array(
"clob", $a_description)
130 $set = $ilDB->query(
"SELECT MAX(nr) mnr FROM skl_level WHERE ".
131 " skill_id = ".$ilDB->quote($this->getId(),
"integer")
133 $rec = $ilDB->fetchAssoc($set);
134 return (
int) $rec[
"mnr"];
148 $and =
" AND id = ".$ilDB->quote($a_id,
"integer");
151 $set = $ilDB->query(
"SELECT * FROM skl_level WHERE ".
152 " skill_id = ".$ilDB->quote($this->getId(),
"integer").
157 while ($rec = $ilDB->fetchAssoc($set))
178 $set = $ilDB->query(
"SELECT $a_prop FROM skl_level WHERE ".
179 " id = ".$ilDB->quote($a_id,
"integer")
181 $rec = $ilDB->fetchAssoc($set);
182 return $rec[$a_prop];
215 die(
"ilBasicSkill::lookupLevelTrigger is deprecated.");
218 return array(
"ref_id" =>
$ref_id,
"obj_id" => $obj_id);
242 $ilDB->update(
"skl_level", array(
243 $a_prop => array($a_type, $a_value),
245 "id" => array(
"integer", $a_id),
279 die(
"ilBasicSkill::writeLevelTrigger is deprecated.");
280 $a_trigger_obj_id = 0;
281 if ($a_trigger_ref_id > 0)
302 foreach ($order as
$id => $o)
304 $ilDB->manipulate(
"UPDATE skl_level SET ".
305 " nr = ".$ilDB->quote($cnt,
"integer").
306 " WHERE id = ".$ilDB->quote(
$id,
"integer")
322 $ilDB->manipulate(
"DELETE FROM skl_level WHERE "
323 .
" id = ".$ilDB->quote($a_id,
"integer")
338 $set = $ilDB->query(
"SELECT id, nr FROM skl_level WHERE ".
339 " skill_id = ".$ilDB->quote($this->getId(),
"integer").
343 while ($rec = $ilDB->fetchAssoc($set))
345 $ilDB->manipulate(
"UPDATE skl_level SET ".
346 " nr = ".$ilDB->quote($cnt,
"integer").
347 " WHERE id = ".$ilDB->quote($rec[
"id"],
"integer")
362 die(
"ilBasicSkill::lookupLevelsForTriggerRefId is deprecated.");
363 $set = $ilDB->query(
"SELECT id FROM skl_level WHERE ".
364 " trigger_ref_id = ".$ilDB->quote($a_ref_id,
"integer")
367 while ($rec = $ilDB->fetchAssoc($set))
369 $levels[] = $rec[
"id"];
384 $set = $ilDB->query(
"SELECT * FROM skl_level WHERE ".
385 " id = ".$ilDB->quote($a_level_id,
"integer")
388 if ($rec = $ilDB->fetchAssoc($set))
412 die(
"ilBasicSkill::updateAllUserSkillLevels is deprecated.");
413 $set = $ilDB->query(
"SELECT id, trigger_obj_id FROM skl_level WHERE ".
414 " trigger_obj_id > ".$ilDB->quote(0,
"integer")
416 while ($rec = $ilDB->fetchAssoc($set))
418 $skill_level_id = $rec[
"id"];
419 $tr_obj_id = $rec[
"trigger_obj_id"];
423 include_once(
"./Services/Tracking/classes/class.ilLPStatusWrapper.php");
425 foreach ($completed as $user_id)
441 die(
"ilBasicSkill::updateSkillLevelsByTriggerRef is deprecated.");
442 $set = $ilDB->query(
"SELECT id, trigger_obj_id FROM skl_level WHERE ".
443 " trigger_ref_id = ".$ilDB->quote($a_ref_id,
"integer")
445 while ($rec = $ilDB->fetchAssoc($set))
447 $skill_level_id = $rec[
"id"];
448 $tr_obj_id = $rec[
"trigger_obj_id"];
452 include_once(
"./Services/Tracking/classes/class.ilLPStatusWrapper.php");
454 foreach ($completed as $user_id)
456 if ($a_user_id == $user_id)
479 $trigger_ref_id = $a_trigger_ref_id;
495 $set = $ilDB->query(
"SELECT status, valid FROM skl_user_skill_level WHERE ".
496 "level_id = ".$ilDB->quote($a_level_id,
"integer").
" AND ".
497 "user_id = ".$ilDB->quote($a_user_id,
"integer").
" AND ".
498 "tref_id = ".$ilDB->quote((
int) $a_tref_id,
"integer").
" AND ".
499 "trigger_obj_id = ".$ilDB->quote($trigger_obj_id,
"integer").
500 " ORDER BY status_date DESC"
502 $rec = $ilDB->fetchAssoc($set);
503 if (!$rec[
"valid"] || $rec[
"status"] != $a_status)
512 $ilDB->manipulate(
"INSERT INTO skl_user_skill_level ".
513 "(level_id, user_id, tref_id, status_date, skill_id, status, valid, trigger_ref_id,".
514 "trigger_obj_id, trigger_obj_type, trigger_title) VALUES (".
515 $ilDB->quote($a_level_id,
"integer").
",".
516 $ilDB->quote($a_user_id,
"integer").
",".
517 $ilDB->quote((
int) $a_tref_id,
"integer").
",".
518 $ilDB->quote($now,
"timestamp").
",".
519 $ilDB->quote($skill_id,
"integer").
",".
520 $ilDB->quote($a_status,
"integer").
",".
521 $ilDB->quote(1,
"integer").
",".
522 $ilDB->quote($trigger_ref_id,
"integer").
",".
523 $ilDB->quote($trigger_obj_id,
"integer").
",".
524 $ilDB->quote($trigger_type,
"text").
",".
525 $ilDB->quote($trigger_title,
"text").
528 $ilDB->manipulate(
"DELETE FROM skl_user_has_level WHERE "
529 .
" user_id = ".$ilDB->quote($a_user_id,
"integer")
530 .
" AND level_id = ".$ilDB->quote($a_level_id,
"integer")
531 .
" AND tref_id = ".$ilDB->quote((
int) $a_tref_id,
"integer")
532 .
" AND trigger_obj_id = ".$ilDB->quote($trigger_obj_id,
"integer")
537 $ilDB->manipulate(
"INSERT INTO skl_user_has_level ".
538 "(level_id, user_id, tref_id, status_date, skill_id, trigger_ref_id, trigger_obj_id, trigger_obj_type, trigger_title) VALUES (".
539 $ilDB->quote($a_level_id,
"integer").
",".
540 $ilDB->quote($a_user_id,
"integer").
",".
541 $ilDB->quote($a_tref_id,
"integer").
",".
542 $ilDB->quote($now,
"timestamp").
",".
543 $ilDB->quote($skill_id,
"integer").
",".
544 $ilDB->quote($trigger_ref_id,
"integer").
",".
545 $ilDB->quote($trigger_obj_id,
"integer").
",".
546 $ilDB->quote($trigger_type,
"text").
",".
547 $ilDB->quote($trigger_title,
"text").
565 $a_user_id = $ilUser->getId();
568 $set = $ilDB->query($q =
"SELECT level_id FROM skl_user_has_level ".
569 " WHERE trigger_obj_type = ".$ilDB->quote($a_type,
"text").
570 " AND skill_id = ".$ilDB->quote($this->
getId(),
"integer").
571 " AND tref_id = ".$ilDB->quote((
int) $a_tref_id,
"integer").
572 " AND user_id = ".$ilDB->quote($a_user_id,
"integer")
575 $has_level = array();
576 while ($rec = $ilDB->fetchAssoc($set))
578 $has_level[$rec[
"level_id"]] =
true;
583 if (isset($has_level[$l[
"id"]]))
585 $max_level = $l[
"id"];
603 $a_user_id = $ilUser->getId();
606 $set = $ilDB->query($q =
"SELECT * FROM skl_user_has_level ".
607 " WHERE skill_id = ".$ilDB->quote($this->getId(),
"integer").
608 " AND tref_id = ".$ilDB->quote((
int) $a_tref_id,
"integer").
609 " AND user_id = ".$ilDB->quote($a_user_id,
"integer").
610 " ORDER BY status_date DESC"
614 while ($rec = $ilDB->fetchAssoc($set))
633 $a_user_id = $ilUser->getId();
636 $set = $ilDB->query($q =
"SELECT level_id FROM skl_user_has_level ".
637 " WHERE trigger_obj_id = ".$ilDB->quote($a_object_id,
"integer").
638 " AND skill_id = ".$ilDB->quote($this->
getId(),
"integer").
639 " AND tref_id = ".$ilDB->quote((
int) $a_tref_id,
"integer").
640 " AND user_id = ".$ilDB->quote($a_user_id,
"integer")
643 $has_level = array();
644 while ($rec = $ilDB->fetchAssoc($set))
646 $has_level[$rec[
"level_id"]] =
true;
651 if (isset($has_level[$l[
"id"]]))
653 $max_level = $l[
"id"];
668 die(
"ilBasicSkill::getCompletionDateForTriggerRefId is deprecated.");
673 else if (!is_array($a_ref_id))
675 $a_ref_id = array($a_ref_id);
677 if (!is_array($a_user_id))
679 $a_user_id = array($a_user_id);
682 if ($a_ref_id != null)
684 if (!is_array($a_ref_id))
686 $a_ref_id = array($a_ref_id);
689 $set = $ilDB->query($q =
"SELECT user_id, status_date, trigger_ref_id FROM skl_user_has_level WHERE ".
690 $ilDB->in(
"user_id", $a_user_id,
false,
"integer").
" AND ".
691 $ilDB->in(
"trigger_ref_id", $a_ref_id,
false,
"integer")
694 $completion = array();
695 while ($rec = $ilDB->fetchAssoc($set))
697 if (!isset($completion[$rec[
"user_id"]][$rec[
"trigger_ref_id"]]))
699 $completion[$rec[
"user_id"]][$rec[
"trigger_ref_id"]] = $rec[
"status_date"];
701 else if ($rec[
"status_date"] < $completion[$rec[
"user_id"]][$rec[
"trigger_ref_id"]])
703 $completion[$rec[
"user_id"]][$rec[
"trigger_ref_id"]] = $rec[
"status_date"];
709 foreach ($a_user_id as $user_id)
711 if (!isset($completion[$user_id][$ref_id]))
713 $completion[$user_id][
$ref_id] =
false;
720 $completion = array();
721 foreach ($a_user_id as $user_id)
723 include_once
'Services/Membership/classes/class.ilParticipants.php';
726 $set = $ilDB->query($q =
"SELECT user_id, status_date, trigger_ref_id FROM skl_user_has_level WHERE ".
727 "user_id = ".$ilDB->quote($user_id,
"integer").
" AND ".
728 $ilDB->in(
"trigger_ref_id", $a_ref_id,
false,
"integer")
731 while ($rec = $ilDB->fetchAssoc($set))
733 if (!isset($completion[$user_id][$rec[
"trigger_ref_id"]]))
735 $completion[$user_id][$rec[
"trigger_ref_id"]] = $rec[
"status_date"];
737 else if ($rec[
"status_date"] < $completion[$user_id][$rec[
"trigger_ref_id"]])
739 $completion[$user_id][$rec[
"trigger_ref_id"]] = $rec[
"status_date"];
744 if (!isset($completion[$user_id][$ref_id]))
746 $completion[$user_id][
$ref_id] =
false;
764 die(
"ilBasicSkill::checkUserCertificateForTriggerRefId is deprecated.");
765 if (!is_array($a_ref_id))
767 $a_ref_id = array($a_ref_id);
769 if (!is_array($a_user_id))
771 $a_user_id = array($a_user_id);
773 $set = $ilDB->query($q =
"SELECT user_id, status_date, trigger_ref_id, level_id, skill_id FROM skl_user_has_level WHERE ".
774 $ilDB->in(
"user_id", $a_user_id,
false,
"integer").
" AND ".
775 $ilDB->in(
"trigger_ref_id", $a_ref_id,
false,
"integer")
778 $completion = array();
780 $completion = array();
781 while ($rec = $ilDB->fetchAssoc($set))
783 if (!isset($completion[$rec[
"user_id"]][$rec[
"trigger_ref_id"]])
786 $completion[$rec[
"user_id"]][$rec[
"trigger_ref_id"]] =
true;
792 foreach ($a_user_id as $user_id)
794 if (!isset($completion[$user_id][$ref_id]))
796 $completion[$user_id][
$ref_id] =
false;
813 die(
"ilBasicSkill::lookupLevelAchievementDate is deprecated.");
814 $set = $ilDB->query(
"SELECT user_id, status_date, trigger_ref_id, level_id, skill_id FROM skl_user_has_level WHERE ".
815 " user_id = ".$ilDB->quote($a_user_id,
"integer").
816 " AND user_id = ".$ilDB->quote($a_user_id,
"integer")
818 if ($rec = $ilDB->fetchAssoc($set))
820 return $rec[
"status_date"];
835 die(
"ilBasicSkill::getTriggerOfAllCertificates is deprecated.");
836 if (!is_array($a_user_id))
838 $a_user_id = array($a_user_id);
841 $set = $ilDB->query($q =
"SELECT user_id, status_date, trigger_ref_id, level_id, skill_id FROM skl_user_has_level WHERE ".
842 $ilDB->in(
"user_id", $a_user_id,
false,
"integer")
845 $completion = array();
847 while ($rec = $ilDB->fetchAssoc($set))
849 if ((!is_array($completion[$rec[
"user_id"]]) || !in_array($rec[
"trigger_ref_id"], $completion[$rec[
"user_id"]]))
852 if ($tree->isInTree($rec[
"trigger_ref_id"]))
854 $completion[$rec[
"user_id"]][] = $rec[
"trigger_ref_id"];
859 foreach ($a_user_id as $user_id)
861 if (!is_array($completion[$user_id]))
863 $completion[$user_id] = array();
878 die(
"ilBasicSkill::getSkillLevelsForTrigger is deprecated.");
879 $set = $ilDB->query($q =
"SELECT id FROM skl_level".
880 " WHERE trigger_ref_id = ".$ilDB->quote($a_ref_id,
"integer"));
882 $skill_levels = array();
883 while ($rec = $ilDB->fetchAssoc($set))
885 $skill_levels[] = $rec[
"id"];
888 return $skill_levels;
917 die(
"ilBasicSkill::getLevelTitleForCertificate is deprecated.");
929 die(
"ilBasicSkill::getTriggerTitleForCertificate is deprecated.");
953 $certificatefile = CLIENT_WEB_DIR.
"/certificates/skill/".
954 ((int)$a_skill_id).
"/".((int) $a_skill_level_id).
"/certificate.xml";
955 if (@file_exists($certificatefile))
975 include_once(
"./Services/Skill/classes/class.ilSkillUsage.php");
977 "skl_user_skill_level",
"user_id");