/**
  * Save Thresholds
  *
  * @param
  * @return
  */
 function saveThresholds()
 {
     global $ilCtrl, $lng;
     include_once "./Modules/Survey/classes/class.ilSurveySkillThresholds.php";
     $thres = new ilSurveySkillThresholds($this->survey);
     if (is_array($_POST["threshold"])) {
         foreach ($_POST["threshold"] as $l => $t) {
             $thres->writeThreshold((int) $_GET["sk_id"], (int) $_GET["tref_id"], (int) $l, (int) $t);
         }
         ilUtil::sendSuccess($lng->txt("msg_obj_modified"), 1);
     }
     $ilCtrl->redirect($this, "listSkillThresholds");
 }
示例#2
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;
 }