diff --git a/application/chengji/controller/Index.php b/application/chengji/controller/Index.php index 136fb1ff..f18febd2 100644 --- a/application/chengji/controller/Index.php +++ b/application/chengji/controller/Index.php @@ -239,7 +239,6 @@ class Index extends Base $list['subject'] = $ksinfo->ks_subject; $list['kaoshi'] = $kaoshi; - // 模板赋值 $this->assign('list',$list); diff --git a/application/chengji/controller/Tongji.php b/application/chengji/controller/Tongji.php index 922e0a4b..5eb7856e 100644 --- a/application/chengji/controller/Tongji.php +++ b/application/chengji/controller/Tongji.php @@ -38,6 +38,7 @@ class Tongji extends Base $list['webtitle'] = '各年级的班级成绩列表'; $list['kaoshi'] = $kaoshi; + // 模板赋值 $this->assign('list',$list); @@ -97,7 +98,6 @@ class Tongji extends Base 'data'=>array(), //获取到的数据结果 ]; - return json($data); } @@ -106,10 +106,12 @@ class Tongji extends Base // 获取并统计各班级成绩 $tj = new TJ; $data = array(); + $allcj = array(); foreach ($bj as $key => $value) { $banji=[$value->banji]; $nianji = array(); $temp = $tj->srcChengji($src['kaoshi'],$banji,$nianji); + $allcj = array_merge($allcj, $temp);; $temp = $tj->tongji($temp,$src['kaoshi']); $data[] = [ 'banji'=>$value->cj_banji->banjiTitle, @@ -117,7 +119,7 @@ class Tongji extends Base 'chengji'=>$temp ]; } - + $cnt = count($data); // 重组返回内容 diff --git a/application/chengji/model/Tongji.php b/application/chengji/model/Tongji.php index bdbe0740..d2f1f486 100644 --- a/application/chengji/model/Tongji.php +++ b/application/chengji/model/Tongji.php @@ -111,21 +111,45 @@ 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'],1); + $temp['youxiu'] = $this->rate($cjcol,$value->youxiu); + $temp['jige'] = $this->rate($cjcol,$value->jige); $temp['sifenwei'] = $this->quartile($cjcol); $data[$value->lieming] = $temp; } + $data['cnt'] = count($allcj); + $data['sum'] = array_sum($allcj); + $data['cnt']>0 ? $data['avg'] = $data['sum']/$data['cnt'] : $data['avg']=0; + + return $data; } + // 统计优秀、及格率 + public function rate($cj = array(),$fenshuxian) + { + $cnt = 0; + foreach ($cj as $key => $value) { + if($value>=$fenshuxian) + { + $cnt++; + } + } + + return round($cnt/count($cj)*100); + } + + diff --git a/application/chengji/view/index/index.html b/application/chengji/view/index/index.html index 39b1843b..53f819cc 100644 --- a/application/chengji/view/index/index.html +++ b/application/chengji/view/index/index.html @@ -54,7 +54,7 @@ {/for} - + {/block} {block name="table"} @@ -100,6 +100,11 @@ options.cols[0].push({field: 'cnt', title: '总分',sort: true}); options.cols[0].push({field: 'id', title: '操作',toolbar: '#barDemo',minWidth:125}); + // 设置查询条件 + options.where = { + kaoshi:"{$list.kaoshi}" + } + // 提交搜索条件后重载表格 layui.use(['table','cjgl'],function(){ diff --git a/application/chengji/view/tongji/tj_banji.html b/application/chengji/view/tongji/tj_banji.html index 266412a5..54bbb637 100644 --- a/application/chengji/view/tongji/tj_banji.html +++ b/application/chengji/view/tongji/tj_banji.html @@ -80,7 +80,7 @@ // 获取学科 var xk = ''; xk = eval(decodeURIComponent(xk)); - var xiangmu = {cnt:'人数',sum:'总分',avg:'平均分'}; // 要显示哪些统计结果 + var xiangmu = {cnt:'人数',avg:'平均分',youxiu:'优秀率',jige:'及格率'}; // 要显示哪些统计结果 $.each(xk,function(index,value){ $.each(xiangmu,function(i,val){ @@ -90,9 +90,7 @@ title:val ,sort:true ,templet:function(d){ - // console.log(x + ' - ' + y); var str = d.chengji[colname][i]; - // console.log(colname + ' ' + i); return str; } }; @@ -100,32 +98,12 @@ options.cols[0].push(colinfo); }); }); + options.cols[0].push({ title: '总平均分',sort: true,templet:function(d){ + var str = d.chengji.avg; + return str; + }}); - - - // for(x in xk) - // { - // for(var y=0; ywhere('kaoshi',$src['kaoshi']) ->field('id,school,student,nianji,banji') ->when(count($school)>0,function($query) use($school){ @@ -112,6 +113,8 @@ class Kaohao extends Base } ]) ->select(); + + // 获取参考学科 $kaoshi = new \app\kaoshi\model\Kaoshi; $ksinfo = $kaoshi->where('id',$src['kaoshi']) @@ -126,6 +129,7 @@ class Kaohao extends Base $xk[$value->subjectid] = $value->lieming; } + // 整理数据 $data = array(); foreach ($khlist as $key => $value) {