diff --git a/app/chengji/controller/Bjtongji.php b/app/chengji/controller/Bjtongji.php index 790ffaf4..50309871 100644 --- a/app/chengji/controller/Bjtongji.php +++ b/app/chengji/controller/Bjtongji.php @@ -292,6 +292,12 @@ class Bjtongji extends AdminBase // 统计各班级成绩 public function tongji() { + $tj = new \app\chengji\model\Tongji; + $arr = [1,7,3,4,5,6,2,8]; + $zw = $tj->zhongweishu($arr); + + halt('zw=' . $zw); + // 获取变量 $kaoshi_id = input('post.kaoshi_id'); // 判断考试状态 diff --git a/app/chengji/model/Tongji.php b/app/chengji/model/Tongji.php index a1d6c18e..52430861 100644 --- a/app/chengji/model/Tongji.php +++ b/app/chengji/model/Tongji.php @@ -246,15 +246,15 @@ class Tongji extends BaseModel $zws = 0; $cnt = count($arr); - if ($cnt = 1) { + if ($cnt === 1) { $zws = $arr[0]; }elseif ($cnt > 1) { $mod = $cnt % 2; if ($mod == 0) { $i = $cnt / 2; - $zws = ($arr[$i] + $arr[$i + 1]) / 2; + $zws = ($arr[$i - 1] + $arr[$i]) / 2; }else{ - $i = ($cnt + 1) / 2; + $i = ($cnt - 1) / 2; $zws = $arr[$i]; } }else{