/**
  * Fill table row
  */
 protected function fillRow($a_set)
 {
     global $lng, $ilCtrl;
     $ilCtrl->setParameter($this->parent_obj, "sk_id", $a_set["base_skill"]);
     $ilCtrl->setParameter($this->parent_obj, "tref_id", $a_set["tref_id"]);
     $this->tpl->setVariable("COMPETENCE", $a_set["title"]);
     $this->tpl->setVariable("NR_OF_QUESTIONS", $a_set["nr_of_q"]);
     $this->tpl->setVariable("MAX_SCALE_POINTS", $a_set["scale_sum"]);
     $this->tpl->setVariable("CMD", $ilCtrl->getLinkTarget($this->parent_obj, "listSkillThresholds"));
     $this->tpl->setVariable("ACTION", $lng->txt("edit"));
     include_once "./Services/Skill/classes/class.ilBasicSkill.php";
     $bs = new ilBasicSkill($a_set["base_skill"]);
     $ld = $bs->getLevelData();
     foreach ($ld as $l) {
         $this->tpl->setCurrentBlock("points");
         $this->tpl->setVariable("LEV", $l["title"]);
         $tr = $this->thresholds[$l["id"]][$a_set["tref_id"]];
         if ((int) $tr != 0) {
             $this->tpl->setVariable("THRESHOLD", (int) $tr);
         } else {
             $this->tpl->setVariable("THRESHOLD", "");
         }
         $this->tpl->parseCurrentBlock();
     }
 }
 /**
  * Get gap analysis html
  *
  * @param
  * @return
  */
 function getGapAnalysisHTML($a_user_id = 0, $a_skills = null)
 {
     global $ilUser, $lng;
     //		$this->setTabs("list_skills");
     if ($a_user_id == 0) {
         $user_id = $ilUser->getId();
     } else {
         $user_id = $a_user_id;
     }
     $skills = array();
     if ($this->getProfileId() > 0) {
         $profile = new ilSkillProfile($this->getProfileId());
         $this->profile_levels = $profile->getSkillLevels();
         foreach ($this->profile_levels as $l) {
             $skills[] = array("base_skill_id" => $l["base_skill_id"], "tref_id" => $l["tref_id"], "level_id" => $l["level_id"]);
         }
     } else {
         if (is_array($a_skills)) {
             $skills = $a_skills;
         }
     }
     // get actual levels for gap analysis
     $this->actual_levels = array();
     include_once "./Services/Skill/classes/class.ilBasicSkill.php";
     foreach ($skills as $sk) {
         $bs = new ilBasicSkill($sk["base_skill_id"]);
         if ($this->gap_mode == "max_per_type") {
             $max = $bs->getMaxLevelPerType($sk["tref_id"], $this->gap_mode_type, $user_id);
             $this->actual_levels[$sk["base_skill_id"]][$sk["tref_id"]] = $max;
         } else {
             if ($this->gap_mode == "max_per_object") {
                 $max = $bs->getMaxLevelPerObject($sk["tref_id"], $this->gap_mode_obj_id, $user_id);
                 $this->actual_levels[$sk["base_skill_id"]][$sk["tref_id"]] = $max;
             }
         }
     }
     $incl_self_eval = false;
     if (count($this->getGapAnalysisSelfEvalLevels() > 0)) {
         $incl_self_eval = true;
         $self_vals = $this->getGapAnalysisSelfEvalLevels();
     }
     // output spider stuff
     if (count($skills) >= 3) {
         $max_cnt = 0;
         $leg_labels = array();
         //var_dump($this->profile_levels);
         //foreach ($this->profile_levels as $k => $l)
         // write target, actual and self counter to skill array
         foreach ($skills as $k => $l) {
             //$bs = new ilBasicSkill($l["base_skill_id"]);
             $bs = new ilBasicSkill($l["base_skill_id"]);
             $leg_labels[] = $bs->getTitle();
             $levels = $bs->getLevelData();
             $cnt = 0;
             foreach ($levels as $lv) {
                 $cnt++;
                 if ($l["level_id"] == $lv["id"]) {
                     $skills[$k]["target_cnt"] = $cnt;
                 }
                 if ($this->actual_levels[$l["base_skill_id"]][$l["tref_id"]] == $lv["id"]) {
                     $skills[$k]["actual_cnt"] = $cnt;
                 }
                 if ($incl_self_eval) {
                     if ($self_vals[$l["base_skill_id"]][$l["tref_id"]] == $lv["id"]) {
                         $skills[$k]["self_cnt"] = $cnt;
                     }
                 }
                 $max_cnt = max($max_cnt, $cnt);
             }
         }
         //			$leg_labels = array("AAAAA", "BBBBB", "CCCCC");
         //var_dump($this->profile_levels);
         //var_dump($this->actual_levels);
         include_once "./Services/Chart/classes/class.ilChart.php";
         $chart = new ilChart("gap_chart", 600, 300);
         $chart->setYAxisMax($max_cnt);
         $chart->setLegLabels($leg_labels);
         // target level
         $cd = new ilChartData("spider");
         $cd->setLabel($lng->txt("skmg_target_level"));
         $cd->setFill("true", "#A0A0A0");
         // other users
         $cd2 = new ilChartData("spider");
         if ($this->gap_cat_title != "") {
             $cd2->setLabel($this->gap_cat_title);
         } else {
             if ($this->gap_mode == "max_per_type") {
                 $cd2->setLabel($lng->txt("objs_" . $this->gap_mode_type));
             } else {
                 if ($this->gap_mode == "max_per_object") {
                     $cd2->setLabel(ilObject::_lookupTitle($this->gap_mode_obj_id));
                 }
             }
         }
         $cd2->setFill("true", "#8080FF");
         // self evaluation
         if ($incl_self_eval) {
             $cd3 = new ilChartData("spider");
             $cd3->setLabel($lng->txt("skmg_self_evaluation"));
             $cd3->setFill("true", "#FF8080");
         }
         // fill in data
         $cnt = 0;
         foreach ($skills as $pl) {
             $cd->addPoint($cnt, (int) $pl["target_cnt"]);
             $cd2->addPoint($cnt, (int) $pl["actual_cnt"]);
             if ($incl_self_eval) {
                 $cd3->addPoint($cnt, (int) $pl["self_cnt"]);
             }
             $cnt++;
         }
         // add data to chart
         if ($this->getProfileId() > 0) {
             $chart->addData($cd);
         }
         $chart->addData($cd2);
         if ($incl_self_eval && count($this->getGapAnalysisSelfEvalLevels()) > 0) {
             $chart->addData($cd3);
         }
         $lg = new ilChartLegend();
         $chart->setLegend($lg);
         $chart_html = $chart->getHTML();
     }
     $stree = new ilSkillTree();
     $html = "";
     foreach ($skills as $s) {
         $path = $stree->getSkillTreePath($s["base_skill_id"]);
         // check draft
         foreach ($path as $p) {
             if ($p["draft"]) {
                 continue 2;
             }
         }
         $html .= $this->getSkillHTML($s["base_skill_id"], $user_id, false, $s["tref_id"]);
     }
     // list skills
     //		include_once("./Services/Skill/classes/class.ilPersonalSkillTableGUI.php");
     //		$sktab = new ilPersonalSkillTableGUI($this, "listSkills");
     return $chart_html . $html;
 }
 /**
  * Get average level of user self evaluation
  *
  * Note: this method does not make much sense in general, since it
  * assumes that all basic skills have the same level
  */
 static function getAverageLevel($a_se_id, $a_user_id, $a_top_skill_id)
 {
     global $lng;
     $lng->loadLanguageModule("skmg");
     include_once "./Services/Skill/classes/class.ilSkillTree.php";
     include_once "./Services/Skill/classes/class.ilBasicSkill.php";
     $stree = new ilSkillTree();
     $cnt = 0;
     $sum = 0;
     if ($stree->isInTree($a_top_skill_id)) {
         $se = new ilSkillSelfEvaluation($a_se_id);
         $levels = $se->getLevels();
         $cnode = $stree->getNodeData($a_top_skill_id);
         $childs = $stree->getSubTree($cnode);
         foreach ($childs as $child) {
             if ($child["type"] == "skll") {
                 $sk = new ilBasicSkill($child["child"]);
                 $ls = $sk->getLevelData();
                 $ord = array();
                 foreach ($ls as $k => $l) {
                     $ord[$l["id"]] = $k + 1;
                 }
                 reset($ls);
                 foreach ($ls as $ld) {
                     if ($ld["id"] == $levels[$child["child"]]) {
                         $sum += $ord[$ld["id"]];
                     }
                 }
                 $cnt += 1;
             }
         }
     }
     if ($cnt > 0) {
         $avg = round($sum / $cnt);
         if ($avg > 0) {
             return array("skill_title" => $cnode["title"], "ord" => $avg, "avg_title" => $ls[$avg - 1]["title"]);
         } else {
             return array("skill_title" => $cnode["title"], "ord" => $avg, "avg_title" => $lng->txt("skmg_no_skills"));
         }
     }
     return null;
 }
示例#4
0
 /**
  * Determine skill levels for appraisee
  *
  * @param $a_appraisee_id int user id of appraisee
  * @return array array with lots of information
  */
 function determineSkillLevelsForAppraisee($a_appraisee_id, $a_self_eval = false)
 {
     $skills = array();
     // get all skills
     $opts = $this->getAllAssignedSkillsAsOptions();
     foreach ($opts as $k => $title) {
         $k = explode(":", $k);
         $bs = new ilBasicSkill((int) $k[0]);
         $ld = $bs->getLevelData();
         $skills[] = array("base_skill_id" => (int) $k[0], "tref_id" => (int) $k[1], "skill_title" => $title, "level_data" => $ld);
     }
     if (!$a_self_eval) {
         $finished_ids = $this->survey->getFinishedIdsForAppraiseeId($a_appraisee_id, true);
     } else {
         $finished_id = $this->survey->getFinishedIdForAppraiseeIdAndRaterId($a_appraisee_id, $a_appraisee_id);
         if ($finished_id > 0) {
             $finished_ids = array($finished_id);
         }
     }
     if (!sizeof($finished_ids)) {
         $finished_ids = array(-1);
     }
     $results = $this->survey->getUserSpecificResults($finished_ids);
     foreach ($skills as $k => $s) {
         $q_ids = $this->getQuestionsForSkill($s["base_skill_id"], $s["tref_id"]);
         $mean_sum = 0;
         foreach ($q_ids as $q_id) {
             $qmean = 0;
             if (is_array($results[$q_id])) {
                 $cnt = 0;
                 $sum = 0;
                 foreach ($results[$q_id] as $r) {
                     // this is a workaround, since we only get arrays from
                     // getUserSpecificResults()
                     $r = explode(" - ", $r);
                     $sum += (int) $r[0];
                     $cnt++;
                 }
                 if ($cnt > 0) {
                     $qmean = $sum / $cnt;
                 }
             }
             $mean_sum += $qmean;
         }
         $skills[$k]["mean_sum"] = $mean_sum;
         include_once "./Modules/Survey/classes/class.ilSurveySkillThresholds.php";
         $skthr = new ilSurveySkillThresholds($this->survey);
         $thresholds = $skthr->getThresholds();
         foreach ($skills[$k]["level_data"] as $l) {
             $t = $thresholds[$l["id"]][$s["tref_id"]];
             if ($t > 0 && $mean_sum >= $t) {
                 $skills[$k]["new_level"] = $l["title"];
                 $skills[$k]["new_level_id"] = $l["id"];
             }
         }
     }
     return $skills;
 }
 /**
  * Get levels
  *
  * @param
  * @return
  */
 function getLevels()
 {
     include_once "./Services/Skill/classes/class.ilBasicSkill.php";
     $bs = new ilBasicSkill($this->base_skill_id);
     return $bs->getLevelData();
 }
 private function evaluateSkillPointAccounts($userId)
 {
     foreach ($this->skillPointAccounts as $skillKey => $skillPoints) {
         list($skillBaseId, $skillTrefId) = explode(':', $skillKey);
         $skill = new ilBasicSkill($skillBaseId);
         $levels = $skill->getLevelData();
         $reachedLevelId = null;
         foreach ($levels as $level) {
             $threshold = $this->skillLevelThresholdList->getThreshold($skillBaseId, $skillTrefId, $level['id']);
             if (!$threshold instanceof ilTestSkillLevelThreshold || !$threshold->getThreshold()) {
                 continue;
             }
             $reachedLevelId = $level['id'];
             if ($skillPoints <= $threshold->getThreshold()) {
                 break;
             }
         }
         if ($reachedLevelId) {
             $this->reachedSkillLevels[] = array('usrId' => $userId, 'sklBaseId' => $skillBaseId, 'sklTrefId' => $skillTrefId, 'sklLevelId' => $reachedLevelId);
         }
     }
 }