Beispiel #1
0
 public static function getLevel($examinee_id)
 {
     $index_ans = IndexAns::find(array('examinee_id' => 1, 'bind' => array(1 => $examinee_id)));
     $score = 0;
     $count = 0;
     foreach ($index_ans as $index) {
         $score += $index->score;
         $count++;
     }
     if ($count == 0) {
         $score_avg = 0;
     } else {
         $score_avg = $score / $count;
     }
     if ($score_avg > 5.8) {
         $level = 1;
     } else {
         if ($score_avg > 5.3) {
             $level = 2;
         } else {
             if ($score_avg > 5.0) {
                 $level = 3;
             } else {
                 $level = 4;
             }
         }
     }
     return $level;
 }
 public function getSystemComprehensive($examinee_id)
 {
     $project_id = $this->self_check($examinee_id);
     $result = IndexAns::find(array('examinee_id = ?1', 'bind' => array(1 => $examinee_id)));
     $result = $result->toArray();
     //指标总数
     $count_all = count($result);
     if ($count_all <= 0) {
         throw new Exception('指标数量为0,请确认');
     }
     //优秀(X>5.8)、良好(5.8≥X>5.3)、一般(5.3≥X>5.0)、较差(X≤5.0)
     $rate = array(0 => 0, 1 => 0, 2 => 0, 3 => 0);
     $sum = 0;
     foreach ($result as $value) {
         $sum += $value['score'];
         if ($value['score'] > 5.8) {
             $rate[0]++;
         } else {
             if ($value['score'] > 5.3) {
                 $rate[1]++;
             } else {
                 if ($value['score'] > 5.0) {
                     $rate[2]++;
                 } else {
                     $rate[3]++;
                 }
             }
         }
     }
     foreach ($rate as &$value) {
         $value = sprintf("%.2f", $value / $count_all) * 100;
     }
     $rt['value'] = $rate;
     //计算个人的指标平均成绩,得到评价等级
     $average = $sum / $count_all;
     if ($average > 5.8) {
         $rt['level'] = 1;
     } else {
         if ($average > 5.3) {
             $rt['level'] = 2;
         } else {
             if ($average > 5.0) {
                 $rt['level'] = 3;
             } else {
                 $rt['level'] = 4;
             }
         }
     }
     return $rt;
 }