5 include_once(
"./Services/Skill/classes/class.ilSkillTreeNode.php");
56 $ilDB->manipulate(
"DELETE FROM skl_level WHERE "
57 .
" skill_id = ".$ilDB->quote($this->getId(),
"integer")
60 $ilDB->manipulate(
"DELETE FROM skl_user_has_level WHERE "
61 .
" skill_id = ".$ilDB->quote($this->getId(),
"integer")
74 $skill->setType($this->
getType());
82 foreach($levels as $item)
84 $skill->addLevel($item[
"title"], $item[
"description"]);
109 $nid = $ilDB->nextId(
"skl_level");
110 $ilDB->insert(
"skl_level", array(
111 "id" => array(
"integer", $nid),
112 "skill_id" => array(
"integer", $this->
getId()),
113 "nr" => array(
"integer", $nr+1),
114 "title" => array(
"text", $a_title),
115 "description" => array(
"clob", $a_description)
129 $set = $ilDB->query(
"SELECT MAX(nr) mnr FROM skl_level WHERE ".
130 " skill_id = ".$ilDB->quote($this->getId(),
"integer")
132 $rec = $ilDB->fetchAssoc($set);
133 return (
int) $rec[
"mnr"];
147 $and =
" AND id = ".$ilDB->quote($a_id,
"integer");
150 $set = $ilDB->query(
"SELECT * FROM skl_level WHERE ".
151 " skill_id = ".$ilDB->quote($this->getId(),
"integer").
156 while ($rec = $ilDB->fetchAssoc($set))
177 $set = $ilDB->query(
"SELECT $a_prop FROM skl_level WHERE ".
178 " id = ".$ilDB->quote($a_id,
"integer")
180 $rec = $ilDB->fetchAssoc($set);
181 return $rec[$a_prop];
216 return array(
"ref_id" =>
$ref_id,
"obj_id" => $obj_id);
240 $ilDB->update(
"skl_level", array(
241 $a_prop => array($a_type, $a_value),
243 "id" => array(
"integer", $a_id),
277 $a_trigger_obj_id = 0;
278 if ($a_trigger_ref_id > 0)
299 foreach ($order as
$id => $o)
301 $ilDB->manipulate(
"UPDATE skl_level SET ".
302 " nr = ".$ilDB->quote($cnt,
"integer").
303 " WHERE id = ".$ilDB->quote(
$id,
"integer")
319 $ilDB->manipulate(
"DELETE FROM skl_level WHERE "
320 .
" id = ".$ilDB->quote($a_id,
"integer")
335 $set = $ilDB->query(
"SELECT id, nr FROM skl_level WHERE ".
336 " skill_id = ".$ilDB->quote($this->getId(),
"integer").
340 while ($rec = $ilDB->fetchAssoc($set))
342 $ilDB->manipulate(
"UPDATE skl_level SET ".
343 " nr = ".$ilDB->quote($cnt,
"integer").
344 " WHERE id = ".$ilDB->quote($rec[
"id"],
"integer")
360 $set = $ilDB->query(
"SELECT id FROM skl_level WHERE ".
361 " trigger_ref_id = ".$ilDB->quote($a_ref_id,
"integer")
364 while ($rec = $ilDB->fetchAssoc($set))
366 $levels[] = $rec[
"id"];
381 $set = $ilDB->query(
"SELECT * FROM skl_level WHERE ".
382 " id = ".$ilDB->quote($a_level_id,
"integer")
385 if ($rec = $ilDB->fetchAssoc($set))
410 $set = $ilDB->query(
"SELECT id, trigger_obj_id FROM skl_level WHERE ".
411 " trigger_obj_id > ".$ilDB->quote(0,
"integer")
413 while ($rec = $ilDB->fetchAssoc($set))
415 $skill_level_id = $rec[
"id"];
416 $tr_obj_id = $rec[
"trigger_obj_id"];
420 include_once(
"./Services/Tracking/classes/class.ilLPStatusWrapper.php");
422 foreach ($completed as $user_id)
439 $set = $ilDB->query(
"SELECT id, trigger_obj_id FROM skl_level WHERE ".
440 " trigger_ref_id = ".$ilDB->quote($a_ref_id,
"integer")
442 while ($rec = $ilDB->fetchAssoc($set))
444 $skill_level_id = $rec[
"id"];
445 $tr_obj_id = $rec[
"trigger_obj_id"];
449 include_once(
"./Services/Tracking/classes/class.ilLPStatusWrapper.php");
451 foreach ($completed as $user_id)
453 if ($a_user_id == $user_id)
477 $trigger_ref_id = $trigger[
"ref_id"];
478 $trigger_obj_id = $trigger[
"obj_id"];
492 $set = $ilDB->query(
"SELECT status, valid FROM skl_user_skill_level WHERE ".
493 "level_id = ".$ilDB->quote($a_level_id,
"integer").
" AND ".
494 "user_id = ".$ilDB->quote($a_user_id,
"integer").
495 " ORDER BY status_date DESC"
497 $rec = $ilDB->fetchAssoc($set);
498 if (!$rec[
"valid"] || $rec[
"status"] != $a_status)
507 $ilDB->manipulate(
"INSERT INTO skl_user_skill_level ".
508 "(level_id, user_id, status_date, skill_id, status, valid, trigger_ref_id,".
509 "trigger_obj_id, trigger_title) VALUES (".
510 $ilDB->quote($a_level_id,
"integer").
",".
511 $ilDB->quote($a_user_id,
"integer").
",".
512 $ilDB->quote($now,
"timestamp").
",".
513 $ilDB->quote($skill_id,
"integer").
",".
514 $ilDB->quote($a_status,
"integer").
",".
515 $ilDB->quote(1,
"integer").
",".
516 $ilDB->quote($trigger_ref_id,
"integer").
",".
517 $ilDB->quote($trigger_obj_id,
"integer").
",".
518 $ilDB->quote($trigger_title,
"text").
521 $ilDB->manipulate(
"DELETE FROM skl_user_has_level WHERE "
522 .
" user_id = ".$ilDB->quote($a_user_id,
"integer")
523 .
" AND level_id = ".$ilDB->quote($a_level_id,
"integer")
528 $ilDB->manipulate(
"INSERT INTO skl_user_has_level ".
529 "(level_id, user_id, status_date, skill_id, trigger_ref_id, trigger_obj_id, trigger_title) VALUES (".
530 $ilDB->quote($a_level_id,
"integer").
",".
531 $ilDB->quote($a_user_id,
"integer").
",".
532 $ilDB->quote($now,
"timestamp").
",".
533 $ilDB->quote($skill_id,
"integer").
",".
534 $ilDB->quote($trigger_ref_id,
"integer").
",".
535 $ilDB->quote($trigger_obj_id,
"integer").
",".
536 $ilDB->quote($trigger_title,
"text").
556 else if (!is_array($a_ref_id))
558 $a_ref_id = array($a_ref_id);
560 if (!is_array($a_user_id))
562 $a_user_id = array($a_user_id);
565 if ($a_ref_id != null)
567 if (!is_array($a_ref_id))
569 $a_ref_id = array($a_ref_id);
572 $set = $ilDB->query($q =
"SELECT user_id, status_date, trigger_ref_id FROM skl_user_has_level WHERE ".
573 $ilDB->in(
"user_id", $a_user_id,
false,
"integer").
" AND ".
574 $ilDB->in(
"trigger_ref_id", $a_ref_id,
false,
"integer")
577 $completion = array();
578 while ($rec = $ilDB->fetchAssoc($set))
580 if (!isset($completion[$rec[
"user_id"]][$rec[
"trigger_ref_id"]]))
582 $completion[$rec[
"user_id"]][$rec[
"trigger_ref_id"]] = $rec[
"status_date"];
584 else if ($rec[
"status_date"] < $completion[$rec[
"user_id"]][$rec[
"trigger_ref_id"]])
586 $completion[$rec[
"user_id"]][$rec[
"trigger_ref_id"]] = $rec[
"status_date"];
592 foreach ($a_user_id as $user_id)
594 if (!isset($completion[$user_id][$ref_id]))
596 $completion[$user_id][
$ref_id] =
false;
603 $completion = array();
604 foreach ($a_user_id as $user_id)
606 include_once
'Services/Membership/classes/class.ilParticipants.php';
609 $set = $ilDB->query($q =
"SELECT user_id, status_date, trigger_ref_id FROM skl_user_has_level WHERE ".
610 "user_id = ".$ilDB->quote($user_id,
"integer").
" AND ".
611 $ilDB->in(
"trigger_ref_id", $a_ref_id,
false,
"integer")
614 while ($rec = $ilDB->fetchAssoc($set))
616 if (!isset($completion[$user_id][$rec[
"trigger_ref_id"]]))
618 $completion[$user_id][$rec[
"trigger_ref_id"]] = $rec[
"status_date"];
620 else if ($rec[
"status_date"] < $completion[$user_id][$rec[
"trigger_ref_id"]])
622 $completion[$user_id][$rec[
"trigger_ref_id"]] = $rec[
"status_date"];
627 if (!isset($completion[$user_id][$ref_id]))
629 $completion[$user_id][
$ref_id] =
false;
648 if (!is_array($a_ref_id))
650 $a_ref_id = array($a_ref_id);
652 if (!is_array($a_user_id))
654 $a_user_id = array($a_user_id);
656 $set = $ilDB->query($q =
"SELECT user_id, status_date, trigger_ref_id, level_id, skill_id FROM skl_user_has_level WHERE ".
657 $ilDB->in(
"user_id", $a_user_id,
false,
"integer").
" AND ".
658 $ilDB->in(
"trigger_ref_id", $a_ref_id,
false,
"integer")
661 $completion = array();
663 $completion = array();
664 while ($rec = $ilDB->fetchAssoc($set))
666 if (!isset($completion[$rec[
"user_id"]][$rec[
"trigger_ref_id"]])
669 $completion[$rec[
"user_id"]][$rec[
"trigger_ref_id"]] =
true;
675 foreach ($a_user_id as $user_id)
677 if (!isset($completion[$user_id][$ref_id]))
679 $completion[$user_id][
$ref_id] =
false;
697 $set = $ilDB->query(
"SELECT user_id, status_date, trigger_ref_id, level_id, skill_id FROM skl_user_has_level WHERE ".
698 " user_id = ".$ilDB->quote($a_user_id,
"integer").
699 " AND user_id = ".$ilDB->quote($a_user_id,
"integer")
701 if ($rec = $ilDB->fetchAssoc($set))
703 return $rec[
"status_date"];
719 if (!is_array($a_user_id))
721 $a_user_id = array($a_user_id);
724 $set = $ilDB->query($q =
"SELECT user_id, status_date, trigger_ref_id, level_id, skill_id FROM skl_user_has_level WHERE ".
725 $ilDB->in(
"user_id", $a_user_id,
false,
"integer")
728 $completion = array();
730 while ($rec = $ilDB->fetchAssoc($set))
732 if ((!is_array($completion[$rec[
"user_id"]]) || !in_array($rec[
"trigger_ref_id"], $completion[$rec[
"user_id"]]))
735 if ($tree->isInTree($rec[
"trigger_ref_id"]))
737 $completion[$rec[
"user_id"]][] = $rec[
"trigger_ref_id"];
742 foreach ($a_user_id as $user_id)
744 if (!is_array($completion[$user_id]))
746 $completion[$user_id] = array();
762 $set = $ilDB->query($q =
"SELECT id FROM skl_level".
763 " WHERE trigger_ref_id = ".$ilDB->quote($a_ref_id,
"integer"));
765 $skill_levels = array();
766 while ($rec = $ilDB->fetchAssoc($set))
768 $skill_levels[] = $rec[
"id"];
771 return $skill_levels;
834 $certificatefile = CLIENT_WEB_DIR.
"/certificates/skill/".
835 ((int)$a_skill_id).
"/".((int) $a_skill_level_id).
"/certificate.xml";
836 if (@file_exists($certificatefile))