From e8fee110f388cfa4c764dbddbc4dc816e67939ed Mon Sep 17 00:00:00 2001 From: cxdbz Date: Sat, 15 Jun 2019 09:12:41 +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=95=B0=E6=8D=AE=E6=A8=A1=E5=9E=8B?= 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 | 49 ++++++++++++++------ application/chengji/view/index/read_add.html | 1 + application/kaoshi/model/Kaohao.php | 2 +- 4 files changed, 38 insertions(+), 16 deletions(-) diff --git a/application/chengji/controller/Index.php b/application/chengji/controller/Index.php index bc8b8135..561cbf5f 100644 --- a/application/chengji/controller/Index.php +++ b/application/chengji/controller/Index.php @@ -625,7 +625,7 @@ class Index extends Base ->only([ 'page'=>'1', 'limit'=>'10', - 'field'=>'banji', + 'field'=>'subject_id', 'type'=>'desc', 'kaohao'=>'' ],'POST'); diff --git a/application/chengji/model/Tongji.php b/application/chengji/model/Tongji.php index 373baa07..dba349d9 100644 --- a/application/chengji/model/Tongji.php +++ b/application/chengji/model/Tongji.php @@ -82,7 +82,15 @@ class Tongji extends Model - // 统计成绩 + /** + * 统计全样本成绩 + * 包括:数量、合计、标准差、平均、优秀、及格、四分位 + * 全科及格率、全科平均分 + * @access public + * @param array $cj 成绩 + * @param number $kaoshi 考试ID + * @return array 返回类型 + */ public function tongji($cj=array(),$kaoshi) { @@ -92,20 +100,9 @@ class Tongji extends Model ->with('ksSubject') ->find(); $data = array(); - $allcj = array(); foreach ($ksinfo->ks_subject as $key => $value) { $cjcol = array_column($cj,$value->lieming); - $allcj = array_merge($allcj,$cjcol); - $temp = array(); - $temp['cnt'] = count($cjcol); - $temp['sum'] = array_sum($cjcol); - $temp['cnt']>0 ? $temp['avg'] = $temp['sum']/$temp['cnt'] : $temp['avg']=0; - $temp['biaozhuncha'] = round($this->getVariance($temp['avg'], $cjcol,true),2); - $temp['avg'] = round($temp['avg'],2); - $temp['youxiu'] = $this->rate($cjcol,$value->youxiu); - $temp['jige'] = $this->rate($cjcol,$value->jige); - $temp['sifenwei'] = $this->quartile($cjcol); - $data[$value->lieming] = $temp; + $data[$value->lieming] = $this->tj($cjcol,$value->youxiu,$value->jige); } $cjcol = array_column($cj,'sum'); $data['cnt'] = count($cjcol); @@ -121,6 +118,30 @@ class Tongji extends Model } + /** + * 统计给定一维数组的成绩 + * 包括:数量、合计、标准差、平均、优秀、及格、四分位 + * @access public + * @param array $cj 成绩 + * @param number $youxiu 优秀分数线 + * @param number $jige 优秀分数线 + * @return array 返回类型 + */ + public function tj($cj=array(),$youxiu,$jige) + { + $temp = array(); + $temp['cnt'] = count($cj); + $temp['sum'] = array_sum($cj); + $temp['cnt']>0 ? $temp['avg'] = $temp['sum']/$temp['cnt'] : $temp['avg']=0; + $temp['biaozhuncha'] = round($this->getVariance($temp['avg'], $cj,true),2); + $temp['avg'] = round($temp['avg'],2); + $temp['youxiu'] = $this->rate($cj,$youxiu); + $temp['jige'] = $this->rate($cj,$jige); + $temp['sifenwei'] = $this->quartile($cj); + return $temp; + } + + // 统计优秀、及格率 public function rate($cj = array(),$fenshuxian) { @@ -180,7 +201,7 @@ class Tongji extends Model * @param Array $list * @param Boolen $isSwatch * @return unknown type - */ + */ public static function getVariance($avg, $list, $isSwatch = FALSE) { $arrayCount = count($list); if($arrayCount == 1 && $isSwatch == TRUE){ diff --git a/application/chengji/view/index/read_add.html b/application/chengji/view/index/read_add.html index 6887c658..26dbd62a 100644 --- a/application/chengji/view/index/read_add.html +++ b/application/chengji/view/index/read_add.html @@ -58,6 +58,7 @@ } return str; }}, + {field: 'update_time', title: '更新时间 ', minWidth:100,sort: true}, {field: 'id', title: '操作',toolbar: '#barDemo',minWidth:140} ]]; options.url = "{:url('ajaxaddinfo')}"; diff --git a/application/kaoshi/model/Kaohao.php b/application/kaoshi/model/Kaohao.php index e505e513..e36807d8 100644 --- a/application/kaoshi/model/Kaohao.php +++ b/application/kaoshi/model/Kaohao.php @@ -166,7 +166,7 @@ class Kaohao extends Base $data[$key]['school'] = $value->cj_school->jiancheng; if($value->cj_student != Null){ $data[$key]['student'] = $value->cj_student->xingming; - $data[$key]['sex'] = $stuinfo->sex; + $data[$key]['sex'] = $value->cj_student->sex; }else{ $stuinfo = $stu::withTrashed() ->where('id',$value->student)