/**
  * Get node content
  *
  * @param array $a_node node data
  * @return string content
  */
 function getNodeContent($a_node)
 {
     global $lng;
     $a_parent_id_parts = explode(":", $a_node["id"]);
     $a_parent_skl_tree_id = $a_parent_id_parts[0];
     $a_parent_skl_template_tree_id = $a_parent_id_parts[1];
     // title
     $title = $a_node["title"];
     // root?
     if ($a_node["type"] == "skrt") {
         $title = $lng->txt("skmg_skills");
     } else {
         if ($a_node["type"] == "sktr") {
             include_once "./Services/Skill/classes/class.ilSkillTemplateReference.php";
             $tid = ilSkillTemplateReference::_lookupTemplateId($a_parent_skl_tree_id);
             $title .= " (" . ilSkillTreeNode::_lookupTitle($tid) . ")";
         }
         // @todo: fix this if possible for skill/tref_id combination
         if (ilSkillTreeNode::_lookupSelfEvaluation($a_parent_skl_tree_id)) {
             if ($a_parent_skl_template_tree_id == 0 || $a_node["type"] == "sktr") {
                 $title = "<u>" . $title . "</u>";
             }
         }
     }
     if ($this->vtree->isOutdated($a_node["id"])) {
         $title = "<span class='light'>" . $title . "</span>";
     }
     return $title;
 }
 static function getInstance($a_id = 0)
 {
     global $ilias, $ilDB;
     $query = "SELECT * FROM skl_tree_node WHERE obj_id = " . $ilDB->quote($a_id, "integer");
     $obj_set = $ilDB->query($query);
     $obj_rec = $ilDB->fetchAssoc($obj_set);
     $obj = null;
     switch ($obj_rec["type"]) {
         case "skll":
             $obj = new ilBasicSkill();
             $obj->setId($obj_rec["obj_id"]);
             $obj->setDataRecord($obj_rec);
             $obj->read();
             break;
         case "scat":
             $obj = new ilSkillCategory();
             $obj->setId($obj_rec["obj_id"]);
             $obj->setDataRecord($obj_rec);
             $obj->read();
             break;
         case "sktp":
             $obj = new ilBasicSkillTemplate();
             $obj->setId($obj_rec["obj_id"]);
             $obj->setDataRecord($obj_rec);
             $obj->read();
             break;
         case "sctp":
             $obj = new ilSkillTemplateCategory();
             $obj->setId($obj_rec["obj_id"]);
             $obj->setDataRecord($obj_rec);
             $obj->read();
             break;
         case "skrt":
             $obj = new ilSkillRoot();
             $obj->setId($obj_rec["obj_id"]);
             $obj->setDataRecord($obj_rec);
             $obj->read();
             break;
         case "sktr":
             $obj = new ilSkillTemplateReference();
             $obj->setId($obj_rec["obj_id"]);
             $obj->setDataRecord($obj_rec);
             $obj->read();
             break;
     }
     return $obj;
 }
 /**
  * Fill table row
  */
 protected function fillRow($a_set)
 {
     global $lng, $ilCtrl;
     switch ($a_set["type"]) {
         // category
         case "scat":
             $ilCtrl->setParameterByClass("ilskillcategorygui", "obj_id", $a_set["child"]);
             $ret = $ilCtrl->getLinkTargetByClass("ilskillcategorygui", "listItems");
             $ilCtrl->setParameterByClass("ilskillcategorygui", "obj_id", $_GET["obj_id"]);
             break;
             // skill template reference
         // skill template reference
         case "sktr":
             $tid = ilSkillTemplateReference::_lookupTemplateId($a_set["child"]);
             $ilCtrl->setParameterByClass("ilskilltemplatereferencegui", "tref_id", $a_set["child"]);
             $ilCtrl->setParameterByClass("ilskilltemplatereferencegui", "obj_id", $tid);
             $ret = $ilCtrl->getLinkTargetByClass("ilskilltemplatereferencegui", "listItems");
             $ilCtrl->setParameterByClass("ilskilltemplatereferencegui", "obj_id", $_GET["obj_id"]);
             $ilCtrl->setParameterByClass("ilskilltemplatereferencegui", "tref_id", $_GET["tref_id"]);
             break;
             // skill
         // skill
         case "skll":
             $ilCtrl->setParameterByClass("ilbasicskillgui", "obj_id", $a_set["child"]);
             $ret = $ilCtrl->getLinkTargetByClass("ilbasicskillgui", "edit");
             $ilCtrl->setParameterByClass("ilbasicskillgui", "obj_id", $_GET["obj_id"]);
             break;
             // --------
             // template
         // --------
         // template
         case "sktp":
             $ilCtrl->setParameterByClass("ilbasicskilltemplategui", "obj_id", $a_set["child"]);
             $ret = $ilCtrl->getLinkTargetByClass("ilbasicskilltemplategui", "edit");
             $ilCtrl->setParameterByClass("ilbasicskilltemplategui", "obj_id", $_GET["obj_id"]);
             break;
             // template category
         // template category
         case "sctp":
             $ilCtrl->setParameterByClass("ilskilltemplatecategorygui", "obj_id", $a_set["child"]);
             $ret = $ilCtrl->getLinkTargetByClass("ilskilltemplatecategorygui", "listItems");
             $ilCtrl->setParameterByClass("ilskilltemplatecategorygui", "obj_id", $_GET["obj_id"]);
             break;
     }
     if ($this->tref_id == 0) {
         $this->tpl->setCurrentBlock("cb");
         $this->tpl->setVariable("CB_ID", $a_set["child"]);
         $this->tpl->parseCurrentBlock();
         $this->tpl->setCurrentBlock("nr");
         $this->tpl->setVariable("OBJ_ID", $a_set["child"]);
         $this->tpl->setVariable("ORDER_NR", $a_set["order_nr"]);
         $this->tpl->parseCurrentBlock();
     }
     $this->tpl->setVariable("HREF_TITLE", $ret);
     $this->tpl->setVariable("TITLE", $a_set["title"]);
     $icon = ilSkillTreeNode::getIconPath($a_set["child"], $a_set["type"], "", ilSkillTreeNode::_lookupStatus($a_set["child"]));
     $this->tpl->setVariable("ICON", ilUtil::img($icon, ""));
 }
 /**
  * Copy basic skill template
  */
 function copy()
 {
     $sktr = new ilSkillTemplateReference();
     $sktr->setTitle($this->getTitle());
     $sktr->setType($this->getType());
     $sktr->setSkillTemplateId($this->getSkillTemplateId());
     $sktr->setSelfEvaluation($this->getSelfEvaluation());
     $sktr->setOrderNr($this->getOrderNr());
     $sktr->create();
     return $sktr;
 }
 /**
  * Get childs of node
  *
  * @param int $a_parent_id parent id
  * @return array childs
  */
 function getChildsOfNode($a_parent_id)
 {
     $a_parent_id_parts = explode(":", $a_parent_id);
     $a_parent_skl_tree_id = $a_parent_id_parts[0];
     $a_parent_skl_template_tree_id = $a_parent_id_parts[1];
     if ($a_parent_skl_template_tree_id == 0) {
         $childs = $this->tree->getChildsByTypeFilter($a_parent_skl_tree_id, array("scat", "skll", "sktr"), "order_nr");
     } else {
         $childs = $this->tree->getChildsByTypeFilter($a_parent_skl_template_tree_id, array("sktp", "sctp"), "order_nr");
     }
     include_once "./Services/Skill/classes/class.ilSkillTreeNode.php";
     $drafts = array();
     foreach ($childs as $k => $c) {
         if ($a_parent_skl_template_tree_id > 0) {
             // we are in template tree only
             $child_id = $a_parent_skl_tree_id . ":" . $c["child"];
         } else {
             if (!in_array($c["type"], array("sktr", "sctr"))) {
                 // we are in main tree only
                 $child_id = $c["child"] . ":0";
             } else {
                 // get template id for references
                 include_once "./Services/Skill/classes/class.ilSkillTemplateReference.php";
                 $child_id = $c["child"] . ":" . ilSkillTemplateReference::_lookupTemplateId($c["child"]);
             }
         }
         unset($childs[$k]["child"]);
         unset($childs[$k]["skl_tree_id"]);
         unset($childs[$k]["lft"]);
         unset($childs[$k]["rgt"]);
         unset($childs[$k]["depth"]);
         $childs[$k]["id"] = $child_id;
         $childs[$k]["parent"] = $a_parent_id;
         $this->parent[$c["id"]] = $a_parent_id;
         if (ilSkillTreeNode::_lookupDraft($c["child"])) {
             $drafts[] = $k;
         }
     }
     foreach ($drafts as $d) {
         unset($childs[$d]);
     }
     return $childs;
 }
Esempio n. 6
0
 /**
  * Get skill tree path
  *
  * @param int $a_base_skill_id base skill id
  * @param int $a_tref_id template reference id
  */
 function getSkillTreePath($a_base_skill_id, $a_tref_id = 0)
 {
     if ($a_tref_id > 0) {
         $path = $this->getPathFull($a_tref_id);
         $sub_path = $this->getPathFull($a_base_skill_id);
         $found = false;
         foreach ($sub_path as $s) {
             include_once "./Services/Skill/classes/class.ilSkillTemplateReference.php";
             if ($found) {
                 $path[] = $s;
             }
             if ($s["child"] == ilSkillTemplateReference::_lookupTemplateId($a_tref_id)) {
                 $found = true;
             }
         }
     } else {
         $path = $this->getPathFull($a_base_skill_id);
     }
     return $path;
 }
 /**
  * Get node content
  *
  * @param array 
  * @return
  */
 function getNodeContent($a_node)
 {
     global $lng;
     // title
     $title = $a_node["title"];
     // root?
     if ($a_node["type"] == "skrt") {
         $title = $this->templates ? $lng->txt("skmg_skill_templates") : $lng->txt("skmg_skills");
     } else {
         if ($a_node["type"] == "sktr") {
             include_once "./Services/Skill/classes/class.ilSkillTemplateReference.php";
             $tid = ilSkillTemplateReference::_lookupTemplateId($a_node["child"]);
             $title .= " (" . ilSkillTreeNode::_lookupTitle($tid) . ")";
         }
         if (ilSkillTreeNode::_lookupSelfEvaluation($a_node["child"])) {
             $title = "<u>" . $title . "</u>";
         }
     }
     return $title;
 }
Esempio n. 8
0
 /**
  * Get skill tree path
  *
  * @param int $a_base_skill_id base skill id
  * @param int $a_tref_id template reference id
  * @return array path
  */
 function getSkillTreePath($a_base_skill_id, $a_tref_id = 0)
 {
     if ($a_tref_id > 0) {
         include_once "./Services/Skill/classes/class.ilSkillTemplateReference.php";
         $path = $this->getPathFull($a_tref_id);
         $sub_path = $this->getPathFull($a_base_skill_id);
         foreach ($path as $k => $v) {
             if ($v["child"] != $a_tref_id) {
                 $path[$k]["skill_id"] = $v["child"];
                 $path[$k]["tref_id"] = 0;
             } else {
                 $path[$k]["skill_id"] = ilSkillTemplateReference::_lookupTemplateId($a_tref_id);
                 $path[$k]["tref_id"] = $a_tref_id;
             }
         }
         $found = false;
         foreach ($sub_path as $s) {
             if ($found) {
                 $s["skill_id"] = $s["child"];
                 $s["tref_id"] = $a_tref_id;
                 $path[] = $s;
             }
             if ($s["child"] == ilSkillTemplateReference::_lookupTemplateId($a_tref_id)) {
                 $found = true;
             }
         }
     } else {
         $path = $this->getPathFull($a_base_skill_id);
         if (is_array($path)) {
             foreach ($path as $k => $v) {
                 $path[$k]["skill_id"] = $v["child"];
                 $path[$k]["tref_id"] = 0;
             }
         }
     }
     return $path;
 }
 /**
  * Collect page elements (that need to be exported separately)
  *
  * @param string $a_pg_type page type
  * @param int $a_pg_id page id
  */
 function collectPageElements($a_type, $a_id)
 {
     // collect media objects
     $pg_mobs = ilObjMediaObject::_getMobsOfObject($a_type, $a_id);
     foreach ($pg_mobs as $pg_mob) {
         $this->mobs[$pg_mob] = $pg_mob;
     }
     // collect all files
     include_once "./Modules/File/classes/class.ilObjFile.php";
     $files = ilObjFile::_getFilesOfObject($a_type, $a_id);
     foreach ($files as $f) {
         $this->files[$f] = $f;
     }
     $skill_tree = $ws_tree = null;
     $pcs = ilPageContentUsage::getUsagesOfPage($a_id, $a_type);
     foreach ($pcs as $pc) {
         // skils
         if ($pc["type"] == "skmg") {
             $skill_id = $pc["id"];
             // trying to find user id
             $user_id = null;
             switch ($a_type) {
                 case "prtf:pg":
                     include_once "Modules/Portfolio/classes/class.ilPortfolioPage.php";
                     $page = new ilPortfolioPage($a_id);
                     $user_id = $page->create_user;
                     break;
                 default:
                     // :TODO:
                     break;
             }
             if ($user_id) {
                 // we only need 1 instance each
                 if (!$skill_tree) {
                     include_once "Services/Skill/classes/class.ilSkillTree.php";
                     $skill_tree = new ilSkillTree();
                     include_once "Services/Skill/classes/class.ilPersonalSkill.php";
                     include_once "Services/PersonalWorkspace/classes/class.ilWorkspaceTree.php";
                     $ws_tree = new ilWorkspaceTree($user_id);
                 }
                 // walk skill tree
                 include_once "./Services/Skill/classes/class.ilVirtualSkillTree.php";
                 $vtree = new ilVirtualSkillTree();
                 $tref_id = 0;
                 $skill_id = (int) $skill_id;
                 include_once "./Services/Skill/classes/class.ilSkillTreeNode.php";
                 if (ilSkillTreeNode::_lookupType($skill_id) == "sktr") {
                     include_once "./Services/Skill/classes/class.ilSkillTemplateReference.php";
                     $tref_id = $skill_id;
                     $skill_id = ilSkillTemplateReference::_lookupTemplateId($skill_id);
                 }
                 $b_skills = $vtree->getSubTreeForCSkillId($skill_id . ":" . $tref_id, true);
                 foreach ($b_skills as $bs) {
                     $skill = ilSkillTreeNodeFactory::getInstance($bs["skill_id"]);
                     $level_data = $skill->getLevelData();
                     foreach ($level_data as $k => $v) {
                         // get assigned materials from personal skill
                         $mat = ilPersonalSkill::getAssignedMaterial($user_id, $bs["tref_id"], $v["id"]);
                         if (sizeof($mat)) {
                             foreach ($mat as $item) {
                                 $wsp_id = $item["wsp_id"];
                                 $obj_id = $ws_tree->lookupObjectId($wsp_id);
                                 // all possible material types for now
                                 switch (ilObject::_lookupType($obj_id)) {
                                     case "file":
                                         $this->files[$obj_id] = $obj_id;
                                         break;
                                     case "tstv":
                                         include_once "Modules/Test/classes/class.ilObjTestVerification.php";
                                         $obj = new ilObjTestVerification($obj_id, false);
                                         $this->files_direct[$obj_id] = array($obj->getFilePath(), $obj->getOfflineFilename());
                                         break;
                                     case "excv":
                                         include_once "Modules/Exercise/classes/class.ilObjExerciseVerification.php";
                                         $obj = new ilObjExerciseVerification($obj_id, false);
                                         $this->files_direct[$obj_id] = array($obj->getFilePath(), $obj->getOfflineFilename());
                                         break;
                                     case "crsv":
                                         include_once "Modules/Course/classes/Verification/class.ilObjCourseVerification.php";
                                         $obj = new ilObjCourseVerification($obj_id, false);
                                         $this->files_direct[$obj_id] = array($obj->getFilePath(), $obj->getOfflineFilename());
                                         break;
                                     case "scov":
                                         include_once "Modules/ScormAicc/classes/Verification/class.ilObjSCORMVerification.php";
                                         $obj = new ilObjSCORMVerification($obj_id, false);
                                         $this->files_direct[$obj_id] = array($obj->getFilePath(), $obj->getOfflineFilename());
                                         break;
                                 }
                             }
                         }
                     }
                 }
             }
         }
     }
 }
 /**
  * standard implementation for title, may be overwritten by derived classes
  */
 function buildTitle($a_title, $a_id, $a_type)
 {
     if ($a_type == "sktr") {
         include_once "./Services/Skill/classes/class.ilSkillTemplateReference.php";
         $tid = ilSkillTemplateReference::_lookupTemplateId($a_id);
         $a_title .= " (" . ilSkillTreeNode::_lookupTitle($tid) . ")";
     }
     if (ilSkillTreeNode::_lookupSelfEvaluation($a_id)) {
         $a_title = "<u>" . $a_title . "</u>";
     }
     return $a_title;
 }
Esempio n. 11
0
 /**
  * Assign materials to skill levels
  *
  * @param
  * @return
  */
 function selfEvaluation()
 {
     global $ilTabs, $lng, $ilCtrl, $tpl, $ilToolbar;
     $ilTabs->setBackTarget($lng->txt("back"), $ilCtrl->getLinkTarget($this, "listSkills"));
     $ilCtrl->saveParameter($this, "skill_id");
     $ilCtrl->saveParameter($this, "basic_skill_id");
     $ilCtrl->saveParameter($this, "tref_id");
     include_once "./Services/Skill/classes/class.ilSkillTreeNode.php";
     $tpl->setTitle(ilSkillTreeNode::_lookupTitle((int) $_GET["skill_id"]));
     $tpl->setTitleIcon(ilUtil::getImagePath("icon_" . ilSkillTreeNode::_lookupType((int) $_GET["skill_id"]) . ".svg"));
     // basic skill selection
     include_once "./Services/Skill/classes/class.ilVirtualSkillTree.php";
     $vtree = new ilVirtualSkillTree();
     $tref_id = 0;
     $skill_id = (int) $_GET["skill_id"];
     if (ilSkillTreeNode::_lookupType((int) $_GET["skill_id"]) == "sktr") {
         include_once "./Services/Skill/classes/class.ilSkillTemplateReference.php";
         $tref_id = $_GET["skill_id"];
         $skill_id = ilSkillTemplateReference::_lookupTemplateId($_GET["skill_id"]);
     }
     $bs = $vtree->getSubTreeForCSkillId($skill_id . ":" . $tref_id, true);
     $options = array();
     foreach ($bs as $b) {
         $options[$b["skill_id"]] = ilSkillTreeNode::_lookupTitle($b["skill_id"]);
     }
     $cur_basic_skill_id = (int) $_POST["basic_skill_id"] > 0 ? (int) $_POST["basic_skill_id"] : ((int) $_GET["basic_skill_id"] > 0 ? (int) $_GET["basic_skill_id"] : key($options));
     $ilCtrl->setParameter($this, "basic_skill_id", $cur_basic_skill_id);
     include_once "./Services/Form/classes/class.ilSelectInputGUI.php";
     $si = new ilSelectInputGUI($lng->txt("skmg_skill"), "basic_skill_id");
     $si->setOptions($options);
     $si->setValue($cur_basic_skill_id);
     $ilToolbar->addInputItem($si, true);
     $ilToolbar->addFormButton($lng->txt("select"), "selfEvaluation");
     $ilToolbar->setFormAction($ilCtrl->getFormAction($this));
     // table
     include_once "./Services/Skill/classes/class.ilSelfEvaluationSimpleTableGUI.php";
     $tab = new ilSelfEvaluationSimpleTableGUI($this, "selfEvaluation", (int) $_GET["skill_id"], (int) $_GET["tref_id"], $cur_basic_skill_id);
     $tpl->setContent($tab->getHTML());
 }
 /**
  * Get icon path
  *
  * @param
  * @return
  */
 function getIconPath($a_obj_id, $a_type, $a_size = "", $a_draft = false)
 {
     $off = $a_draft ? "_off" : "";
     $a_name = "icon_" . $a_type . $a_size . $off . ".png";
     if ($a_type == "sktr") {
         include_once "./Services/Skill/classes/class.ilSkillTemplateReference.php";
         $tid = ilSkillTemplateReference::_lookupTemplateId($a_obj_id);
         $type = ilSkillTreeNode::_lookupType($tid);
         if ($type == "sctp") {
             $a_name = "icon_sctr" . $a_size . $off . ".png";
         }
     }
     $vers = "vers=" . str_replace(array(".", " "), "-", ILIAS_VERSION);
     return ilUtil::getImagePath($a_name) . "?" . $vers;
 }
 /**
  * Save item
  */
 function saveItem()
 {
     $sktr = new ilSkillTemplateReference();
     $sktr->setTitle($_POST["title"]);
     $sktr->setSkillTemplateId($_POST["skill_template_id"]);
     $sktr->setSelfEvaluation($_POST["selectable"]);
     $sktr->setOrderNr($_POST["order_nr"]);
     $sktr->setStatus($_POST["status"]);
     $sktr->create();
     ilSkillTreeNode::putInTree($sktr, (int) $_GET["obj_id"], IL_LAST_NODE);
     $this->node_object = $sktr;
 }
 /**
  * standard implementation for title, may be overwritten by derived classes
  */
 function buildTitle($a_title, $a_id, $a_type)
 {
     global $lng;
     if ($a_type == "sktr") {
         include_once "./Services/Skill/classes/class.ilSkillTemplateReference.php";
         $tid = ilSkillTemplateReference::_lookupTemplateId($a_id);
         //			$a_title.= " (".ilSkillTreeNode::_lookupTitle($tid).")";
     }
     /*		if (ilSkillTreeNode::_lookupSelfEvaluation($a_id))
     		{
     			$a_title.= " [".$lng->txt("add")."]";
     		}*/
     return $a_title;
 }
 /**
  * Get childs of node
  *
  * @param string $a_parent_id parent id
  * @return array childs
  */
 function getChildsOfNode($a_parent_id)
 {
     $a_parent_id_parts = explode(":", $a_parent_id);
     $a_parent_skl_tree_id = $a_parent_id_parts[0];
     $a_parent_skl_template_tree_id = $a_parent_id_parts[1];
     if ($a_parent_skl_template_tree_id == 0) {
         $childs = $this->tree->getChildsByTypeFilter($a_parent_skl_tree_id, array("scat", "skll", "sktr"), "order_nr");
     } else {
         $childs = $this->tree->getChildsByTypeFilter($a_parent_skl_template_tree_id, array("sktp", "sctp"), "order_nr");
     }
     include_once "./Services/Skill/classes/class.ilSkillTreeNode.php";
     $drafts = array();
     $outdated = array();
     foreach ($childs as $k => $c) {
         if ($a_parent_skl_template_tree_id > 0) {
             // we are in template tree only
             $child_id = $a_parent_skl_tree_id . ":" . $c["child"];
         } else {
             if (!in_array($c["type"], array("sktr", "sctr"))) {
                 // we are in main tree only
                 $child_id = $c["child"] . ":0";
             } else {
                 // get template id for references
                 include_once "./Services/Skill/classes/class.ilSkillTemplateReference.php";
                 $child_id = $c["child"] . ":" . ilSkillTemplateReference::_lookupTemplateId($c["child"]);
             }
         }
         unset($childs[$k]["child"]);
         unset($childs[$k]["skl_tree_id"]);
         unset($childs[$k]["lft"]);
         unset($childs[$k]["rgt"]);
         unset($childs[$k]["depth"]);
         $childs[$k]["id"] = $child_id;
         //echo "-".$child_id."-";
         $cid = $this->getCSkillIdForVTreeId($child_id);
         //echo "-".$cid."-";
         $cid_parts = explode(":", $cid);
         $childs[$k]["skill_id"] = $cid_parts[0];
         $childs[$k]["tref_id"] = $cid_parts[1];
         $childs[$k]["cskill_id"] = $cid;
         $childs[$k]["parent"] = $a_parent_id;
         $this->parent[$c["id"]] = $a_parent_id;
         // @todo: prepare this for tref id?
         if (ilSkillTreeNode::_lookupStatus($c["child"]) == ilSkillTreeNode::STATUS_DRAFT || in_array($a_parent_id, $this->drafts)) {
             $this->drafts[] = $child_id;
             $drafts[] = $k;
         }
         if (ilSkillTreeNode::_lookupStatus($c["child"]) == ilSkillTreeNode::STATUS_OUTDATED || in_array($a_parent_id, $this->outdated)) {
             $this->outdated[] = $child_id;
             $outdated[] = $k;
         }
     }
     if (!$this->getIncludeDrafts()) {
         foreach ($drafts as $d) {
             unset($childs[$d]);
         }
     }
     if (!$this->getIncludeOutdated()) {
         foreach ($outdated as $d) {
             unset($childs[$d]);
         }
     }
     return $childs;
 }
Esempio n. 16
0
 /**
  * Get usage info
  *
  * @param array $a_cskill_ids skill ids
  * @param array $a_usages usages array
  */
 public static function getUsageInfo($a_cskill_ids, &$a_usages)
 {
     global $ilDB;
     // material
     include_once "./Services/Skill/classes/class.ilSkillUsage.php";
     ilSkillUsage::getUsageInfoGeneric($a_cskill_ids, $a_usages, ilSkillUsage::USER_MATERIAL, "skl_assigned_material", "user_id");
     // self evaluations
     ilSkillUsage::getUsageInfoGeneric($a_cskill_ids, $a_usages, ilSkillUsage::SELF_EVAL, "skl_self_eval_level", "user_id");
     // users that use the skills as personal skills
     $pskill_ids = array();
     $tref_ids = array();
     foreach ($a_cskill_ids as $cs) {
         if ($cs["tref_id"] > 0) {
             include_once "./Services/Skill/classes/class.ilSkillTemplateReference.php";
             if (ilSkillTemplateReference::_lookupTemplateId($cs["tref_id"]) == $cs["skill_id"]) {
                 $pskill_ids[$cs["tref_id"]] = $cs["tref_id"];
                 $tref_ids[(int) $cs["tref_id"]] = $cs["skill_id"];
             }
         } else {
             $pskill_ids[$cs["skill_id"]] = $cs["skill_id"];
         }
     }
     $set = $ilDB->query("SELECT skill_node_id, user_id FROM skl_personal_skill " . " WHERE " . $ilDB->in("skill_node_id", $pskill_ids, false, "integer") . " GROUP BY skill_node_id, user_id");
     while ($rec = $ilDB->fetchAssoc($set)) {
         if (isset($tref_ids[(int) $rec["skill_node_id"]])) {
             $a_usages[$tref_ids[$rec["skill_node_id"]] . ":" . $rec["skill_node_id"]][ilSkillUsage::PERSONAL_SKILL][] = array("key" => $rec["user_id"]);
         } else {
             $a_usages[$rec["skill_node_id"] . ":0"][ilSkillUsage::PERSONAL_SKILL][] = array("key" => $rec["user_id"]);
         }
     }
 }
Esempio n. 17
0
 /**
  * Find skills
  *
  * @param
  * @return
  */
 public static function findSkills($a_term)
 {
     global $ilDB;
     $res = array();
     $candidates = array();
     $skill_tree = new ilSkillTree();
     $sql = "SELECT * " . " FROM skl_tree_node" . " WHERE " . $ilDB->like("title", "text", "%" . $a_term . "%");
     $sql .= " ORDER BY title";
     $set = $ilDB->query($sql);
     include_once "./Services/Skill/classes/class.ilSkillTemplateReference.php";
     while ($row = $ilDB->fetchAssoc($set)) {
         if (in_array($row["type"], array("sctp", "sktp"))) {
             // need to get "top template" first! (if it is already the top level, do not use it!)
             $path = $skill_tree->getSkillTreePath($row["obj_id"]);
             if ($path[1]["child"] != $row["obj_id"]) {
                 $trefs = ilSkillTemplateReference::_lookupTrefIdsForTopTemplateId($path[1]["child"]);
                 foreach ($trefs as $tref) {
                     $candidates[] = array("tref_id" => $tref, "skill_id" => $row["obj_id"], "title" => $row["title"]);
                 }
             }
         } else {
             if ($row["type"] == "sktr") {
                 // works
                 $candidates[] = array("tref_id" => $row["obj_id"], "skill_id" => ilSkillTemplateReference::_lookupTemplateId($row["obj_id"]), "title" => $row["title"]);
             } else {
                 // works
                 $candidates[] = array("tref_id" => 0, "skill_id" => $row["obj_id"], "title" => $row["title"]);
             }
         }
     }
     foreach ($candidates as $c) {
         // if we get a path array, and the array has items try to use the data
         $path = $skill_tree->getSkillTreePath($c["skill_id"], $c["tref_id"]);
         $use = false;
         if (is_array($path) && count($path) > 0) {
             $use = true;
         }
         // if any inactive/outdated -> do not use the data
         if (is_array($path)) {
             foreach ($path as $p) {
                 if ($p["status"] > 0) {
                     $use = false;
                 }
             }
         }
         if ($use) {
             if (!in_array($c["title"], $res)) {
                 $res[] = $c["title"];
             }
         }
     }
     return $res;
 }
 /**
  * confirm deletion screen of skill tree nodes
  */
 function deleteNodes($a_gui)
 {
     global $lng, $tpl, $ilCtrl, $ilTabs, $ilToolbar;
     if (!isset($_POST["id"])) {
         $this->ilias->raiseError($this->lng->txt("no_checkbox"), $this->ilias->error_obj->MESSAGE);
     }
     $ilTabs->clearTargets();
     // check usages
     $mode = "";
     $cskill_ids = array();
     foreach ($_POST["id"] as $id) {
         if (in_array(ilSkillTreeNode::_lookupType($id), array("skll", "scat", "sktr"))) {
             if ($mode == "templates") {
                 $this->ilias->raiseError("Skill Deletion - type mismatch.", $this->ilias->error_obj->MESSAGE);
             }
             $mode = "basic";
             $skill_id = $id;
             $tref_id = 0;
             if (ilSkillTreeNode::_lookupType($id) == "sktr") {
                 include_once "./Services/Skill/classes/class.ilSkillTemplateReference.php";
                 $skill_id = ilSkillTemplateReference::_lookupTemplateId($id);
                 $tref_id = $id;
             }
             $cskill_ids[] = array("skill_id" => $skill_id, "tref_id" => $tref_id);
         }
         if (in_array(ilSkillTreeNode::_lookupType($id), array("sktp", "sctp"))) {
             if ($mode == "basic") {
                 $this->ilias->raiseError("Skill Deletion - type mismatch.", $this->ilias->error_obj->MESSAGE);
             }
             $mode = "templates";
             foreach (ilSkillTemplateReference::_lookupTrefIdsForTemplateId($id) as $tref_id) {
                 $cskill_ids[] = array("skill_id" => $id, "tref_id" => $tref_id);
             }
         }
         // for cats, skills and template references, get "real" usages
         // for skill and category templates check usage in references
     }
     if ($mode == "basic" || $mode == "templates") {
         include_once "./Services/Skill/classes/class.ilSkillUsage.php";
         $u = new ilSkillUsage();
         $usages = $u->getAllUsagesInfoOfSubtrees($cskill_ids);
         if (count($usages) > 0) {
             $html = "";
             foreach ($usages as $k => $usage) {
                 include_once "./Services/Skill/classes/class.ilSkillUsageTableGUI.php";
                 $tab = new ilSkillUsageTableGUI($this, "showUsage", $k, $usage);
                 $html .= $tab->getHTML() . "<br/><br/>";
             }
             $tpl->setContent($html);
             $ilToolbar->addButton($lng->txt("back"), $ilCtrl->getLinkTarget($a_gui, "cancelDelete"));
             ilUtil::sendFailure($lng->txt("skmg_cannot_delete_nodes_in_use"));
             return;
         }
     } else {
         $this->ilias->raiseError("Skill Deletion - type mismatch.", $this->ilias->error_obj->MESSAGE);
     }
     // SAVE POST VALUES
     $_SESSION["saved_post"] = $_POST["id"];
     include_once "./Services/Utilities/classes/class.ilConfirmationGUI.php";
     $confirmation_gui = new ilConfirmationGUI();
     $ilCtrl->setParameter($a_gui, "tmpmode", $_GET["tmpmode"]);
     $a_form_action = $this->ctrl->getFormAction($a_gui);
     $confirmation_gui->setFormAction($a_form_action);
     $confirmation_gui->setHeaderText($this->lng->txt("info_delete_sure"));
     // Add items to delete
     include_once "./Services/Skill/classes/class.ilSkillTreeNodeFactory.php";
     foreach ($_POST["id"] as $id) {
         if ($id != IL_FIRST_NODE) {
             $node_obj = ilSkillTreeNodeFactory::getInstance($id);
             $confirmation_gui->addItem("id[]", $node_obj->getId(), $node_obj->getTitle(), ilUtil::getImagePath("icon_" . $node_obj->getType() . ".svg"));
         }
     }
     $confirmation_gui->setCancel($lng->txt("cancel"), "cancelDelete");
     $confirmation_gui->setConfirm($lng->txt("confirm"), "confirmedDelete");
     $tpl->setContent($confirmation_gui->getHTML());
 }