/**
  * Fill table row
  */
 protected function fillRow($a_set)
 {
     global $lng, $ilCtrl, $ilUser;
     include_once "./Services/Skill/classes/class.ilPersonalSkill.php";
     $mat = ilPersonalSkill::getAssignedMaterial($ilUser->getId(), $this->tref_id, $a_set["id"]);
     $ilCtrl->setParameter($this->parent_obj, "level_id", $a_set["id"]);
     foreach ($mat as $m) {
         $this->tpl->setCurrentBlock("mat");
         $obj_id = $this->ws_tree->lookupObjectId($m["wsp_id"]);
         $this->tpl->setVariable("MAT_TITLE", ilObject::_lookupTitle($obj_id));
         $this->tpl->setVariable("MAT_IMG", ilUtil::img(ilUtil::getImagePath("icon_" . ilObject::_lookupType($obj_id) . ".svg")));
         $this->tpl->setVariable("TXT_REMOVE", $lng->txt("remove"));
         $ilCtrl->setParameter($this->parent_obj, "wsp_id", $m["wsp_id"]);
         $this->tpl->setVariable("HREF_REMOVE", $ilCtrl->getLinkTarget($this->parent_obj, "removeMaterial"));
         $obj_id = $this->ws_tree->lookupObjectId($m["wsp_id"]);
         $url = $this->ws_access->getGotoLink($m["wsp_id"], $obj_id);
         $this->tpl->setVariable("HREF_MAT", $url);
         $this->tpl->parseCurrentBlock();
     }
     $this->tpl->setCurrentBlock("cmd");
     $this->tpl->setVariable("HREF_CMD", $ilCtrl->getLinkTarget($this->parent_obj, "assignMaterial"));
     $this->tpl->setVariable("TXT_CMD", $lng->txt("skmg_assign_materials"));
     $this->tpl->parseCurrentBlock();
     $ilCtrl->setParameter($this->parent_obj, "level_id", "");
     $this->tpl->setVariable("LEVEL_ID", $a_set["id"]);
     $this->tpl->setVariable("SKILL_ID", $this->basic_skill_id);
     $this->tpl->setVariable("TXT_SKILL", $a_set["title"]);
     $this->tpl->setVariable("TXT_SKILL_DESC", $a_set["description"]);
 }
 /**
  * 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"];
             // get user id from portfolio page
             include_once "Services/Portfolio/classes/class.ilPortfolioPage.php";
             $page = new ilPortfolioPage(0, $a_id);
             $user_id = $page->create_user;
             // 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
             $b_skills = ilSkillTreeNode::getSkillTreeNodes($skill_id, true);
             foreach ($b_skills as $bs) {
                 $skill = ilSkillTreeNodeFactory::getInstance($bs["id"]);
                 $level_data = $skill->getLevelData();
                 foreach ($level_data as $k => $v) {
                     // get assigned materials from personal skill
                     $mat = ilPersonalSkill::getAssignedMaterial($user_id, $bs["tref"], $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;
                             }
                         }
                     }
                 }
             }
         }
     }
 }
 /**
  * Render materials row
  *
  * @param
  * @return
  */
 function renderMaterialsRow($a_tpl, $a_levels, $a_top_skill_id, $a_base_skill, $a_tref_id = 0, $a_user_id = 0)
 {
     global $ilUser, $lng;
     if ($a_user_id == 0) {
         $a_user_id = $ilUser->getId();
     }
     foreach ($a_levels as $k => $v) {
         $mat_cnt = ilPersonalSkill::countAssignedMaterial($a_user_id, $a_tref_id, $v["id"]);
         if ($mat_cnt == 0) {
             $a_tpl->setCurrentBlock("val_level_td");
             $a_tpl->setVariable("VAL_LEVEL", " ");
             $a_tpl->parseCurrentBlock();
         } else {
             // links to material files
             $a_tpl->setCurrentBlock("level_link");
             $mat_tt = array();
             $cnt = 1;
             foreach (ilPersonalSkill::getAssignedMaterial($a_user_id, $a_tref_id, $v["id"]) as $item) {
                 $mat_data = $this->getMaterialInfo($item["wsp_id"]);
                 $a_tpl->setVariable("HREF_LINK", $mat_data[1]);
                 $a_tpl->setVariable("TXT_LINK", $cnt);
                 // tooltip
                 $mat_tt_id = "skmg_skl_tt_mat_" . self::$skill_tt_cnt;
                 self::$skill_tt_cnt++;
                 $a_tpl->setVariable("LEVEL_LINK_ID", $mat_tt_id);
                 if (!$this->offline_mode) {
                     ilTooltipGUI::addTooltip($mat_tt_id, $mat_data[0]);
                 } else {
                     $this->tooltips[] = ilTooltipGUI::getTooltip($mat_tt_id, $mat_data[0]);
                 }
                 $a_tpl->parseCurrentBlock();
                 $cnt++;
             }
             $a_tpl->setCurrentBlock("val_level_td");
             $a_tpl->setVariable("TD_CLASS", "ilSkillMat");
             $a_tpl->parseCurrentBlock();
         }
     }
     $a_tpl->setCurrentBlock("value_row");
     $a_tpl->setVariable("TXT_VAL_TITLE", $lng->txt("skmg_material"));
     $a_tpl->parseCurrentBlock();
 }
 /**
  * Get skill presentation HTML
  *
  * @return
  */
 function getSkillHTML($a_top_skill_id, $a_user_id = 0, $a_edit = false)
 {
     global $ilUser, $lng, $ilCtrl, $ilSetting;
     $this->tooltips = array();
     if ($a_user_id == 0) {
         $user = $ilUser;
     } else {
         $user = new ilObjUser($a_user_id);
     }
     $tpl = new ilTemplate("tpl.skill_pres.html", true, true, "Services/Skill");
     include_once "./Services/UIComponent/Tooltip/classes/class.ilTooltipGUI.php";
     include_once "./Services/Skill/classes/class.ilSkillTree.php";
     $stree = new ilSkillTree();
     include_once "./Services/Skill/classes/class.ilSkillTreeNode.php";
     include_once "./Services/Skill/classes/class.ilSkillTreeNodeFactory.php";
     // general settings for the action drop down
     include_once "Services/UIComponent/AdvancedSelectionList/classes/class.ilAdvancedSelectionListGUI.php";
     $act_list = new ilAdvancedSelectionListGUI();
     $act_list->setListTitle($lng->txt("actions"));
     $act_list->setSelectionHeaderClass("small");
     //		$act_list->setLinksMode("il_ContainerItemCommand2");
     $act_list->setHeaderIcon(ilAdvancedSelectionListGUI::DOWN_ARROW_DARK);
     $act_list->setUseImages(false);
     $b_skills = ilSkillTreeNode::getSkillTreeNodes($a_top_skill_id, true);
     foreach ($b_skills as $bs) {
         $path = $stree->getSkillTreePath($bs["id"], $bs["tref"]);
         // check draft
         foreach ($path as $p) {
             if ($p["draft"]) {
                 continue 2;
             }
         }
         reset($path);
         $se_level = ilPersonalSkill::getSelfEvaluation($user->getId(), $a_top_skill_id, $bs["tref"], $bs["id"]);
         $skill = ilSkillTreeNodeFactory::getInstance($bs["id"]);
         $level_data = $skill->getLevelData();
         // check, if current self eval level is in current level data
         $valid_sel_level = false;
         if ($se_level > 0) {
             foreach ($level_data as $k => $v) {
                 if ($v["id"] == $se_level) {
                     $valid_sel_level = true;
                 }
             }
         }
         reset($level_data);
         $found = false;
         foreach ($level_data as $k => $v) {
             // level
             $tpl->setCurrentBlock("level_td");
             $tpl->setVariable("VAL_LEVEL", $v["title"]);
             $tt_id = "skmg_skl_tt_" . self::$skill_tt_cnt;
             self::$skill_tt_cnt++;
             $tpl->setVariable("TT_ID", $tt_id);
             if ($v["description"] != "") {
                 ilTooltipGUI::addTooltip($tt_id, $v["description"]);
             }
             $tpl->parseCurrentBlock();
             // self evaluation
             $tpl->setCurrentBlock("self_eval_td");
             if ($valid_sel_level && !$found) {
                 $tpl->setVariable("VAL_SELF_EVAL", "x");
                 $tpl->setVariable("CLASS_SELF_EVAL", "ilSkillSelf");
             } else {
                 $tpl->setVariable("VAL_SELF_EVAL", " ");
             }
             $tpl->parseCurrentBlock();
             if ($v["id"] == $se_level) {
                 $found = true;
             }
             // assigned materials
             if ($this->use_materials) {
                 $mat_cnt = ilPersonalSkill::countAssignedMaterial($user->getId(), $bs["tref"], $v["id"]);
                 if ($mat_cnt == 0) {
                     $tpl->setCurrentBlock("material_td");
                     $tpl->setVariable("VAL_MATERIAL", " ");
                     $tpl->parseCurrentBlock();
                 } else {
                     // links to material files
                     $tpl->setCurrentBlock("material_links");
                     $mat_tt = array();
                     $cnt = 1;
                     foreach (ilPersonalSkill::getAssignedMaterial($user->getId(), $bs["tref"], $v["id"]) as $item) {
                         $mat_data = $this->getMaterialInfo($item["wsp_id"]);
                         $tpl->setVariable("URL_MATERIAL", $mat_data[1]);
                         $tpl->setVariable("TXT_MATERIAL", $cnt);
                         // tooltip
                         $mat_tt_id = "skmg_skl_tt_mat_" . self::$skill_tt_cnt;
                         self::$skill_tt_cnt++;
                         $tpl->setVariable("TOOLTIP_MATERIAL_ID", $mat_tt_id);
                         if (!$this->offline_mode) {
                             ilTooltipGUI::addTooltip($mat_tt_id, $mat_data[0]);
                         } else {
                             $this->tooltips[] = ilTooltipGUI::getTooltip($mat_tt_id, $mat_data[0]);
                         }
                         $tpl->parseCurrentBlock();
                         $cnt++;
                     }
                     $tpl->setCurrentBlock("material_td");
                     $tpl->setVariable("CLASS_MAT", "ilSkillMat");
                     $tpl->parseCurrentBlock();
                 }
             }
         }
         $title = $sep = "";
         $found = false;
         foreach ($path as $p) {
             if ($found) {
                 $title .= $sep . $p["title"];
                 $sep = " > ";
             }
             if ($a_top_skill_id == $p["child"]) {
                 $found = true;
             }
         }
         $tpl->setCurrentBlock("skill");
         $tpl->setVariable("BSKILL_TITLE", $title);
         $tpl->setVariable("TXT_LEVEL", $lng->txt("skmg_level"));
         $tpl->setVariable("TXT_SELF_EVAL", $lng->txt("skmg_self_evaluation"));
         if ($this->use_materials) {
             $tpl->setVariable("TXT_MATERIAL", $lng->txt("skmg_material"));
         }
         if ($a_edit) {
             $act_list->flush();
             $act_list->setId("act_" . $a_top_skill_id . "_" . $bs["id"]);
             $ilCtrl->setParameterByClass("ilpersonalskillsgui", "skill_id", $a_top_skill_id);
             $ilCtrl->setParameterByClass("ilpersonalskillsgui", "tref_id", $bs["tref"]);
             $ilCtrl->setParameterByClass("ilpersonalskillsgui", "basic_skill_id", $bs["id"]);
             if ($this->use_materials) {
                 $act_list->addItem($lng->txt('skmg_assign_materials'), "", $ilCtrl->getLinkTargetByClass("ilpersonalskillsgui", "assignMaterials"));
             }
             $act_list->addItem($lng->txt('skmg_self_evaluation'), "", $ilCtrl->getLinkTargetByClass("ilpersonalskillsgui", "selfEvaluation"));
             $tpl->setVariable("ACTIONS2", $act_list->getHTML());
         }
         $tpl->parseCurrentBlock();
     }
     $tpl->setVariable("SKILL_TITLE", ilSkillTreeNode::_lookupTitle($a_top_skill_id));
     if ($a_edit) {
         $act_list->flush();
         $act_list->setId("act_" . $a_top_skill_id);
         $ilCtrl->setParameterByClass("ilpersonalskillsgui", "skill_id", $a_top_skill_id);
         //			$act_list->addItem($lng->txt('skmg_assign_materials'), "",
         //				$ilCtrl->getLinkTargetByClass("ilpersonalskillsgui", "assignMaterials"));
         $act_list->addItem($lng->txt('skmg_remove_skill'), "", $ilCtrl->getLinkTargetByClass("ilpersonalskillsgui", "confirmSkillRemove"));
         $tpl->setVariable("ACTIONS1", $act_list->getHTML());
     }
     return $tpl->get();
 }