/**
  * Fill table row
  */
 protected function fillRow($a_set)
 {
     global $lng, $ilCtrl;
     $this->tpl->setCurrentBlock("cmd");
     $this->tpl->setVariable("CMD", $lng->txt("edit"));
     $ilCtrl->setParameter($this->parent_obj, "sprof_id", $a_set["id"]);
     $this->tpl->setVariable("CMD_HREF", $ilCtrl->getLinkTarget($this->parent_obj, "showUsers"));
     $ilCtrl->setParameter($this->parent_obj, "sprof_id", $_GET["sprof_id"]);
     $this->tpl->parseCurrentBlock();
     $this->tpl->setVariable("ID", $a_set["id"]);
     $this->tpl->setVariable("TITLE", $a_set["title"]);
     $this->tpl->setVariable("NUM_USERS", ilSkillProfile::countUsers($a_set["id"]));
 }
 /**
  * Competence Evaluation
  *
  * @param
  * @return
  */
 function competenceEval()
 {
     global $ilUser, $lng, $ilCtrl, $ilToolbar, $tpl, $ilTabs;
     $survey = $this->object;
     $ilTabs->activateSubtab("svy_eval_competences");
     $ilTabs->activateTab("svy_results");
     $ilToolbar->setFormAction($this->ctrl->getFormAction($this, "competenceEval"));
     if ($this->object->get360Mode()) {
         $appr_id = $this->getAppraiseeId();
         $this->addApprSelectionToToolbar();
     }
     if ($appr_id == 0) {
         return;
     }
     // evaluation modes
     $eval_modes = array();
     // get all competences of survey
     include_once "./Modules/Survey/classes/class.ilSurveySkill.php";
     $sskill = new ilSurveySkill($survey);
     $opts = $sskill->getAllAssignedSkillsAsOptions();
     $skills = array();
     foreach ($opts as $id => $o) {
         $idarr = explode(":", $id);
         $skills[$id] = array("id" => $id, "title" => $o, "profiles" => array(), "base_skill" => $idarr[0], "tref_id" => $idarr[1]);
     }
     //var_dump($opts);
     // get matching user competence profiles
     // -> add gap analysis to profile
     include_once "./Services/Skill/classes/class.ilSkillProfile.php";
     $profiles = ilSkillProfile::getProfilesOfUser($appr_id);
     foreach ($profiles as $p) {
         $prof = new ilSkillProfile($p["id"]);
         $prof_levels = $prof->getSkillLevels();
         foreach ($prof_levels as $pl) {
             if (isset($skills[$pl["base_skill_id"] . ":" . $pl["tref_id"]])) {
                 $skills[$pl["base_skill_id"] . ":" . $pl["tref_id"]]["profiles"][] = $p["id"];
                 $eval_modes["gap_" . $p["id"]] = $lng->txt("svy_gap_analysis") . ": " . $prof->getTitle();
             }
         }
     }
     //var_dump($skills);
     //var_dump($eval_modes);
     // if one competence does not match any profiles
     // -> add "competences of survey" alternative
     reset($skills);
     foreach ($skills as $sk) {
         if (count($sk["profiles"]) == 0) {
             $eval_modes["skills_of_survey"] = $lng->txt("svy_all_survey_competences");
         }
     }
     // final determination of current evaluation mode
     $comp_eval_mode = $_GET["comp_eval_mode"];
     if ($_POST["comp_eval_mode"] != "") {
         $comp_eval_mode = $_POST["comp_eval_mode"];
     }
     if (!isset($eval_modes[$comp_eval_mode])) {
         reset($eval_modes);
         $comp_eval_mode = key($eval_modes);
         $ilCtrl->setParameter($this, "comp_eval_mode", $comp_eval_mode);
     }
     $ilCtrl->saveParameter($this, "comp_eval_mode");
     include_once "./Services/Form/classes/class.ilSelectInputGUI.php";
     $mode_sel = new ilSelectInputGUI($lng->txt("svy_analysis"), "comp_eval_mode");
     $mode_sel->setOptions($eval_modes);
     $mode_sel->setValue($comp_eval_mode);
     $ilToolbar->addInputItem($mode_sel, true);
     $ilToolbar->addFormButton($lng->txt("select"), "competenceEval");
     if (substr($comp_eval_mode, 0, 4) == "gap_") {
         // gap analysis
         $profile_id = (int) substr($comp_eval_mode, 4);
         include_once "./Services/Skill/classes/class.ilPersonalSkillsGUI.php";
         $pskills_gui = new ilPersonalSkillsGUI();
         $pskills_gui->setProfileId($profile_id);
         $pskills_gui->setGapAnalysisActualStatusModePerObject($survey->getId(), $lng->txt("survey_360_raters"));
         if ($survey->getFinishedIdForAppraiseeIdAndRaterId($appr_id, $appr_id) > 0) {
             $sskill = new ilSurveySkill($survey);
             $self_levels = array();
             foreach ($sskill->determineSkillLevelsForAppraisee($appr_id, true) as $sl) {
                 $self_levels[$sl["base_skill_id"]][$sl["tref_id"]] = $sl["new_level_id"];
             }
             $pskills_gui->setGapAnalysisSelfEvalLevels($self_levels);
         }
         $html = $pskills_gui->getGapAnalysisHTML($appr_id);
         $tpl->setContent($html);
     } else {
         include_once "./Services/Skill/classes/class.ilPersonalSkillsGUI.php";
         $pskills_gui = new ilPersonalSkillsGUI();
         $pskills_gui->setGapAnalysisActualStatusModePerObject($survey->getId(), $lng->txt("survey_360_raters"));
         if ($survey->getFinishedIdForAppraiseeIdAndRaterId($appr_id, $appr_id) > 0) {
             $sskill = new ilSurveySkill($survey);
             $self_levels = array();
             foreach ($sskill->determineSkillLevelsForAppraisee($appr_id, true) as $sl) {
                 $self_levels[$sl["base_skill_id"]][$sl["tref_id"]] = $sl["new_level_id"];
             }
             $pskills_gui->setGapAnalysisSelfEvalLevels($self_levels);
         }
         $sk = array();
         foreach ($skills as $skill) {
             $sk[] = array("base_skill_id" => (int) $skill["base_skill"], "tref_id" => (int) $skill["tref_id"]);
         }
         $html = $pskills_gui->getGapAnalysisHTML($appr_id, $sk);
         $tpl->setContent($html);
     }
 }
 /**
  * Render suggested resources
  *
  * @param
  * @return
  */
 function renderSuggestedResources($a_tpl, $a_levels, $a_base_skill, $a_tref_id)
 {
     global $lng;
     if ($this->getProfileId() == 0) {
         return;
     }
     $profile = new ilSkillProfile($this->getProfileId());
     $profile_levels = $profile->getSkillLevels();
     $too_low = true;
     $current_target_level = 0;
     foreach ($a_levels as $k => $v) {
         foreach ($this->profile_levels as $pl) {
             if ($pl["level_id"] == $v["id"] && $pl["base_skill_id"] == $v["skill_id"]) {
                 $too_low = true;
                 $current_target_level = $v["id"];
             }
         }
         if ($this->actual_levels[$v["skill_id"]][0] == $v["id"]) {
             $too_low = false;
         }
     }
     // suggested resources
     if ($too_low) {
         include_once "./Services/Skill/classes/class.ilSkillResources.php";
         $skill_res = new ilSkillResources($a_base_skill, $a_tref_id);
         $res = $skill_res->getResources();
         $imp_resources = array();
         foreach ($res as $level) {
             foreach ($level as $r) {
                 if ($r["imparting"] == true && $current_target_level == $r["level_id"]) {
                     $imp_resources[] = $r;
                 }
             }
         }
         foreach ($imp_resources as $r) {
             $ref_id = $r["rep_ref_id"];
             $obj_id = ilObject::_lookupObjId($ref_id);
             $title = ilObject::_lookupTitle($obj_id);
             include_once "./Services/Link/classes/class.ilLink.php";
             $a_tpl->setCurrentBlock("resource_item");
             $a_tpl->setVariable("TXT_RES", $title);
             $a_tpl->setVariable("HREF_RES", ilLink::_getLink($ref_id));
             $a_tpl->parseCurrentBlock();
         }
         if (count($imp_resources) > 0) {
             $a_tpl->touchBlock("resources_list");
             $a_tpl->setCurrentBlock("resources");
             $a_tpl->setVariable("SUGGESTED_MAT_MESS", $lng->txt("skmg_skill_needs_impr_res"));
             $a_tpl->parseCurrentBlock();
         } else {
             $a_tpl->setCurrentBlock("resources");
             $a_tpl->setVariable("SUGGESTED_MAT_MESS", $lng->txt("skmg_skill_needs_impr_no_res"));
             $a_tpl->parseCurrentBlock();
         }
     } else {
         $a_tpl->setCurrentBlock("resources");
         $a_tpl->setVariable("SUGGESTED_MAT_MESS", $lng->txt("skmg_skill_no_needs_impr"));
         $a_tpl->parseCurrentBlock();
     }
 }
 /**
  * Delete profiles
  */
 function deleteProfiles()
 {
     global $ilCtrl, $tpl, $lng;
     if (is_array($_POST["id"])) {
         foreach ($_POST["id"] as $i) {
             $prof = new ilSkillProfile($i);
             $prof->delete();
         }
         ilUtil::sendInfo($lng->txt("msg_obj_modified"), true);
     }
     $ilCtrl->redirect($this, "listProfiles");
 }
 public function noProfileMatchingAssignedSkillExists($usrId, $availableSkillProfiles)
 {
     $noProfileMatchingSkills = $this->skillQuestionAssignmentList->getUniqueAssignedSkills();
     foreach ($availableSkillProfiles as $skillProfileId => $skillProfileTitle) {
         $profile = new ilSkillProfile($skillProfileId);
         $assignedSkillLevels = $profile->getSkillLevels();
         foreach ($assignedSkillLevels as $assignedSkillLevel) {
             $skillBaseId = $assignedSkillLevel['base_skill_id'];
             $skillTrefId = $assignedSkillLevel['tref_id'];
             if ($this->skillQuestionAssignmentList->isAssignedSkill($skillBaseId, $skillTrefId)) {
                 unset($noProfileMatchingSkills["{$skillBaseId}:{$skillTrefId}"]);
             }
         }
     }
     return count($noProfileMatchingSkills);
 }