From e329268ead38c975e12ab93c2541c50cbda39833 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E5=B0=8F=E6=9D=BE=E6=A0=91?= Date: Mon, 20 May 2019 16:51:55 +0800 Subject: [PATCH] =?UTF-8?q?=E4=BF=AE=E6=94=B9=E6=88=90=E7=BB=A9=E7=BB=9F?= =?UTF-8?q?=E8=AE=A1=E6=96=B9=E5=BC=8F?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- application/chengji/controller/Index.php | 2 +- application/chengji/model/Tongji.php | 18 +++++++++++------- application/chengji/view/tongji/dw_banji.html | 6 +++--- application/kaoshi/view/kaohao/index.html | 1 + 4 files changed, 16 insertions(+), 11 deletions(-) diff --git a/application/chengji/controller/Index.php b/application/chengji/controller/Index.php index 0a86b4fa..412d2245 100644 --- a/application/chengji/controller/Index.php +++ b/application/chengji/controller/Index.php @@ -168,7 +168,7 @@ class Index extends Base // 重新组合成绩信息 foreach ($cjinfo as $key => $value) { foreach ($xk as $k => $val) { - if($value[$k+4] == null){ + if($value[$k+4] === null){ continue; } // 查询是否存在这个成绩 diff --git a/application/chengji/model/Tongji.php b/application/chengji/model/Tongji.php index c607e68a..e54201ee 100644 --- a/application/chengji/model/Tongji.php +++ b/application/chengji/model/Tongji.php @@ -55,11 +55,15 @@ class Tongji extends Model // 整理数据 $data = array(); foreach ($khlist as $key => $value) { + $data[$key]['sum'] = 0; + $sbjcnt = 0; foreach ($value->ks_chengji as $k => $val) { $data[$key][$xk[$val->subject_id]] = $val->defen*1; + $data[$key]['sum'] = ($data[$key]['sum'] + $val->defen) * 1; + $sbjcnt ++ ; } + $data[$key]['sum'] == 0 ? $data[$key]['avg'] = 0 : $data[$key]['sum'] / $sbjcnt; } - return $data; } @@ -90,12 +94,12 @@ class Tongji extends Model $temp['sifenwei'] = $this->quartile($cjcol); $data[$value->lieming] = $temp; } - $data['cnt'] = count($allcj); - $data['sum'] = array_sum($allcj); - $data['cnt']>0 ? $data['avg'] = round($data['sum']/$data['cnt'],2) : $data['avg']=0; + $cjcol = array_column($cj,'sum'); + $data['cnt'] = count($cjcol); + $data['sum'] = array_sum($cjcol); + $data['cnt']>0 ? $data['avg'] = round($data['sum']/$data['cnt'],1) : $data['avg']=0; $data['rate'] = $this->rateAll($cj,$ksinfo->ks_subject); #全科及格率 - return $data; } @@ -112,7 +116,7 @@ class Tongji extends Model } if(count($cj)>0) { - return round($cnt/count($cj)*100,2); + return round($cnt/count($cj)*100,1); }else{ return ''; } @@ -141,7 +145,7 @@ class Tongji extends Model if(count($cj)>0) { - return round($jige/count($cj)*100); + return round($jige/count($cj)*100,1); }else{ return ''; } diff --git a/application/chengji/view/tongji/dw_banji.html b/application/chengji/view/tongji/dw_banji.html index 9047e0bb..7e3c5ec8 100644 --- a/application/chengji/view/tongji/dw_banji.html +++ b/application/chengji/view/tongji/dw_banji.html @@ -23,15 +23,15 @@
-