37 $this->db = $DIC->database();
54 $this->title = $a_title;
74 $this->description = $a_description;
94 $this->type = $a_type;
134 $this->self_eval = $a_val;
144 return $this->self_eval;
154 $this->order_nr = $a_val;
164 return $this->order_nr;
174 $this->import_id = $a_val;
184 return $this->import_id;
194 $this->creation_date = $a_val;
204 return $this->creation_date;
216 $lng = $DIC->language();
219 self::STATUS_DRAFT =>
$lng->txt(
"skmg_status_draft"),
220 self::STATUS_PUBLISH =>
$lng->txt(
"skmg_status_publish"),
221 self::STATUS_OUTDATED =>
$lng->txt(
"skmg_status_outdated")
235 $lng = $DIC->language();
238 case self::STATUS_PUBLISH:
return $lng->txt(
"skmg_status_publish_info");
239 case self::STATUS_DRAFT:
return $lng->txt(
"skmg_status_draft_info");
240 case self::STATUS_OUTDATED:
return $lng->txt(
"skmg_status_outdated_info");
252 if (!isset($this->data_record)) {
253 $query =
"SELECT * FROM skl_tree_node WHERE obj_id = " .
254 $ilDB->quote($this->
id,
"integer");
256 $this->data_record =
$ilDB->fetchAssoc($obj_set);
258 $this->
setType($this->data_record[
"type"]);
259 $this->
setTitle($this->data_record[
"title"]);
261 $this->
setOrderNr($this->data_record[
"order_nr"]);
263 $this->
setStatus($this->data_record[
"status"]);
264 $this->
setImportId($this->data_record[
"import_id"]);
273 $this->data_record = $a_record;
282 protected static function _lookup($a_obj_id, $a_field)
286 $ilDB = $DIC->database();
288 $query =
"SELECT $a_field FROM skl_tree_node WHERE obj_id = " .
289 $ilDB->quote($a_obj_id,
"integer");
291 $obj_rec =
$ilDB->fetchAssoc($obj_set);
293 return $obj_rec[$a_field];
305 return self::_lookup($a_tref_id,
"title");
307 return self::_lookup($a_obj_id,
"title");
320 $ilDB = $DIC->database();
322 return self::_lookup($a_obj_id,
"description");
335 $ilDB = $DIC->database();
337 return self::_lookup($a_obj_id,
"self_eval");
350 $ilDB = $DIC->database();
352 return self::_lookup($a_obj_id,
"status");
365 $ilDB = $DIC->database();
367 $query =
"SELECT * FROM skl_tree_node WHERE obj_id = " .
368 $ilDB->quote($a_obj_id,
"integer");
370 $obj_rec =
$ilDB->fetchAssoc($obj_set);
372 return $obj_rec[
"type"];
382 $this->status = $a_val;
392 return $this->status;
405 $ilDB = $DIC->database();
407 $query =
"UPDATE skl_tree_node SET " .
408 " title = " .
$ilDB->quote($a_title,
"text") .
409 " WHERE obj_id = " .
$ilDB->quote($a_obj_id,
"integer");
424 $ilDB = $DIC->database();
426 $query =
"UPDATE skl_tree_node SET " .
427 " description = " .
$ilDB->quote($a_description,
"clob") .
428 " WHERE obj_id = " .
$ilDB->quote($a_obj_id,
"integer");
443 $ilDB = $DIC->database();
445 $query =
"UPDATE skl_tree_node SET " .
446 " order_nr = " .
$ilDB->quote($a_nr,
"integer") .
447 " WHERE obj_id = " .
$ilDB->quote($a_obj_id,
"integer");
461 $id =
$ilDB->nextId(
"skl_tree_node");
462 $query =
"INSERT INTO skl_tree_node (obj_id, title, description, type, create_date, self_eval, order_nr, status, creation_date, import_id) " .
464 $ilDB->quote(
$id,
"integer") .
"," .
468 $ilDB->now() .
", " .
472 $ilDB->now() .
", " .
486 $query =
"UPDATE skl_tree_node SET " .
491 " ,status = " .
$ilDB->quote((
int) $this->
getStatus(),
"integer") .
493 " WHERE obj_id = " .
$ilDB->quote($this->
getId(),
"integer");
501 public function delete()
505 $query =
"DELETE FROM skl_tree_node WHERE obj_id= " .
513 public static function putInTree($a_obj, $a_parent_id =
"", $a_target_node_id =
"")
518 $parent_id = ($a_parent_id !=
"")
525 "skrt" => array(
"skll",
"scat",
"sktr",
"sktp",
"sctp"),
526 "scat" => array(
"skll",
"scat",
"sktr"),
527 "sctp" => array(
"sktp",
"sctp"));
528 $par_type = self::_lookupType($parent_id);
529 if (!is_array($allowed[$par_type]) ||
530 !in_array($a_obj->getType(), $allowed[$par_type])) {
535 if ($a_target_node_id !=
"") {
536 $target = $a_target_node_id;
541 if (count($childs) == 0) {
544 $target = $childs[count($childs) - 1][
"obj_id"];
549 $skill_tree->insertNode($a_obj->getId(), $parent_id, $target);
573 if (is_array($a_items)) {
574 foreach ($a_items as $item) {
580 if (count($types) > 1) {
591 self::clearClipboard();
594 if (!is_array($a_ids)) {
598 foreach ($a_ids as
$id) {
599 $path = $tree->getPathId($id);
601 foreach ($path as $path_id) {
602 if ($path_id != $id && in_array($path_id, $a_ids)) {
617 foreach ($cut_ids as
$id) {
618 $curnode = $tree->getNodeData($id);
619 if ($tree->isInTree($id)) {
620 $tree->deleteTree($curnode);
635 self::clearClipboard();
639 $time = date(
"Y-m-d H:i:s", time());
640 foreach ($a_ids as
$id) {
642 if ($tree->isInTree($id)) {
643 $curnode = $tree->getNodeData($id);
644 $subnodes = $tree->getSubTree($curnode);
645 foreach ($subnodes as $subnode) {
646 if ($subnode[
"child"] != $id) {
658 $order = ($curnode[
"lft"] > 0)
660 : (
int) ($order + 1);
684 $parent_id = $a_obj_id;
688 $skills =
$ilUser->getClipboardObjects($a_type);
689 $copied_nodes = array();
690 foreach ($skills as $skill) {
692 if (!in_array($skill[
"id"], array_keys($copied_nodes))) {
697 $skill[
"insert_time"],
708 self::clearClipboard();
714 in_array($a_type, array(
"sktp",
"sctp"))
717 return $copied_nodes;
732 $ilUser->clipboardDeleteObjectsOfType(
"skll");
733 $ilUser->clipboardDeleteObjectsOfType(
"scat");
734 $ilUser->clipboardDeleteObjectsOfType(
"sktr");
735 $ilUser->clipboardDeleteObjectsOfType(
"sktp");
736 $ilUser->clipboardDeleteObjectsOfType(
"sctp");
751 $a_add_suffix =
false 756 $ilLog = $DIC[
"ilLog"];
757 $lng = $DIC->language();
761 if ($item_type ==
"scat") {
763 } elseif ($item_type ==
"skll") {
765 } elseif ($item_type ==
"sktr") {
767 } elseif ($item_type ==
"sktp") {
769 } elseif ($item_type ==
"sctp") {
773 $ilLog->write(
"Getting from clipboard type " . $item_type .
", " .
774 "Item ID: " . $a_item_id);
777 $target_item = $item->copy();
779 $target_item->setTitle($target_item->getTitle() .
" " .
$lng->txt(
"copy_of_suffix"));
780 $target_item->update();
782 $a_copied_nodes[$item->getId()] = $target_item->getId();
784 $target_item = $item;
787 $ilLog->write(
"Putting into skill tree type " . $target_item->getType() .
788 "Item ID: " . $target_item->getId() .
", Parent: " . $a_parent_id .
", " .
789 "Target: " . $a_target);
793 $childs =
$ilUser->getClipboardChilds($item->getId(), $a_insert_time);
795 foreach ($childs as $child) {
798 $target_item->getId(),
806 return $target_item->getId();
834 $ilDB = $DIC->database();
837 "SELECT obj_id, title FROM skl_tree_node WHERE " .
838 " self_eval = " .
$ilDB->quote(
true,
"integer") .
" ORDER BY TITLE " 841 while ($rec =
$ilDB->fetchAssoc($set)) {
842 $nodes[$rec[
"obj_id"]] = $rec[
"title"];
856 $childs = $tr->getChildsByTypeFilter($tr->getRootId(), array(
"sktp",
"sctp"));
871 $ilDB = $DIC->database();
874 "SELECT * FROM skl_tree_node " .
875 " WHERE self_eval = " .
$ilDB->quote(1,
"integer")
878 $sel_skills = array();
879 while ($rec =
$ilDB->fetchAssoc($set)) {
880 $sel_skills[] = $rec;
892 public static function saveChildsOrder($a_par_id, $a_childs_order, $a_templates =
false)
902 array(
"skrt",
"sktp",
"sctp")
907 array(
"skrt",
"skll",
"scat",
"sktr")
912 foreach ($childs as $k =>
$c) {
913 if (isset($a_childs_order[
$c[
"child"]])) {
914 $childs[$k][
"order_nr"] = (int) $a_childs_order[$c[
"child"]];
921 foreach ($childs as
$c) {
936 public static function getIconPath($a_obj_id, $a_type, $a_size =
"", $a_status = 0)
938 if ($a_status == self::STATUS_DRAFT && $a_type ==
"sctp") {
941 if ($a_status == self::STATUS_DRAFT && $a_type ==
"sktp") {
945 $off = ($a_status == self::STATUS_DRAFT)
949 $a_name =
"icon_" . $a_type . $a_size . $off .
".svg";
950 if ($a_type ==
"sktr") {
953 if (
$type ==
"sctp") {
954 $a_name =
"icon_sctr" . $a_size . $off .
".svg";
957 $vers =
"vers=" . str_replace(array(
".",
" "),
"-",
ILIAS_VERSION);
971 $ilDB = $DIC->database();
974 $candidates = array();
979 " FROM skl_tree_node" .
980 " WHERE " .
$ilDB->like(
"title",
"text",
"%" . $a_term .
"%");
981 $sql .=
" ORDER BY title";
982 $set =
$ilDB->query($sql);
983 while ($row =
$ilDB->fetchAssoc($set)) {
984 if (in_array($row[
"type"], array(
"sctp",
"sktp"))) {
986 $path =
$skill_tree->getSkillTreePath($row[
"obj_id"]);
987 if ($path[1][
"child"] != $row[
"obj_id"]) {
989 foreach ($trefs as $tref) {
990 $candidates[] = array(
"tref_id" => $tref,
"skill_id" => $row[
"obj_id"],
"title" => $row[
"title"]);
993 } elseif ($row[
"type"] ==
"sktr") {
998 $candidates[] = array(
"tref_id" => 0,
"skill_id" => $row[
"obj_id"],
"title" => $row[
"title"]);
1002 foreach ($candidates as
$c) {
1004 $path =
$skill_tree->getSkillTreePath($c[
"skill_id"], $c[
"tref_id"]);
1006 if (is_array($path) && count($path) > 0) {
1011 if (is_array($path)) {
1012 foreach ($path as $p) {
1013 if ($p[
"status"] > 0) {
1019 if (!in_array($c[
"title"],
$res)) {
1020 $res[] = $c[
"title"];
1037 $cskill_ids = array();
1038 foreach ($a_node_ids as
$id) {
1039 if (in_array(self::_lookupType($id), array(
"skll",
"scat",
"sktr"))) {
1046 $cskill_ids[] = array(
"skill_id" => $skill_id,
"tref_id" => $tref_id);
1050 $cskill_ids[] = array(
"skill_id" => $id,
"tref_id" => $tref_id);
static getAllCSkillIdsForNodeIds(array $a_node_ids)
Get all possible common skill IDs for node IDs.
static sortArray( $array, $a_array_sortby, $a_array_sortorder=0, $a_numeric=false, $a_keep_keys=false)
sortArray
static clearClipboard()
Remove all skill items from clipboard.
setType($a_type)
Set type.
static clipboardCut($a_tree_id, $a_ids)
Cut and copy a set of skills/skill categories into the clipboard.
static _writeTitle($a_obj_id, $a_title)
Write Title.
getDescription()
Get description.
static getAllStatus()
Get all status.
Skill Template Reference.
setTitle($a_title)
Set title.
static _lookupSelfEvaluation($a_obj_id)
Lookup self evaluation.
static getIconPath($a_obj_id, $a_type, $a_size="", $a_status=0)
Get icon path.
static _lookupTrefIdsForTemplateId($a_tid)
Get all tref ids for a template id.
static putInTree($a_obj, $a_parent_id="", $a_target_node_id="")
Put this object into the skill tree.
setDataRecord($a_record)
this method should only be called by class ilSCORM2004NodeFactory
static getAllSelfEvaluationNodes()
Get all self evaluation nodes.
setImportId($a_val)
Set import id.
static _lookup($a_obj_id, $a_field)
Lookup Title.
static getSelectableSkills()
Get selectable skills.
static getTree($a_slm_obj_id)
Get scorm module editing tree.
static insertItemsFromClip($a_type, $a_obj_id)
Insert basic skills from clipboard.
getSelfEvaluation()
Get self evaluation.
setSelfEvaluation($a_val)
Set self evaluation.
getImportId()
Get import id.
static _lookupType($a_obj_id)
Lookup Type.
getOrderNr()
Get order nr.
static uniqueTypesCheck($a_items)
Check for unique types.
static findSkills($a_term)
Find skills.
foreach($_POST as $key=> $value) $res
static isInTree($a_id)
Is id in tree?
static getImagePath($img, $module_path="", $mode="output", $offline=false)
get image path (for images located in a template directory)
static _lookupDescription($a_obj_id)
Lookup Description.
static _lookupTemplateId($a_obj_id)
Lookup template ID.
static clipboardCopy($a_tree_id, $a_ids)
Copy a set of skills/skill categories into the clipboard.
setCreationDate($a_val)
Set creation date.
static saveChildsOrder($a_par_id, $a_childs_order, $a_templates=false)
Save childs order.
static _lookupTitle($a_obj_id, $a_tref_id=0)
Lookup Title.
static getStatusInfo($a_status)
Get status info.
setOrderNr($a_val)
Set order nr.
setDescription($a_description)
Set description.
static _lookupTrefIdsForTopTemplateId($a_template_id)
Lookup tref ids for template id.
A node in the skill tree.
static _writeDescription($a_obj_id, $a_description)
Write Description.
setStatus($a_val)
Set status.
static _lookupStatus($a_obj_id)
Lookup Status.
static _writeOrderNr($a_obj_id, $a_nr)
Write Order Nr.
static pasteTree( $a_item_id, $a_parent_id, $a_target, $a_insert_time, &$a_copied_nodes, $a_as_copy=false, $a_add_suffix=false)
Paste item (tree) from clipboard to skill tree.
getCreationDate()
Get creation date.
static getTopTemplates()
Get top skill templates and template categories.