diff --git a/application/chengji/controller/Index.php b/application/chengji/controller/Index.php
index f18febd2..0ee6dd14 100644
--- a/application/chengji/controller/Index.php
+++ b/application/chengji/controller/Index.php
@@ -378,12 +378,20 @@ class Index extends Base
// 下载成绩表格
- public function dwChengji($id)
+ public function dwChengji($kaoshi)
{
- // 模板赋值
- $this->assign('id',$id);
- // 渲染模板
+ // 设置页面标题
+ $list['set'] = array(
+ 'webtitle'=>'成绩下载',
+ 'butname'=>'下载',
+ 'formpost'=>'POST',
+ 'url'=>'/chengji/dwChengji',
+ );
+
+ // 模板赋值
+ $this->assign('list',$list);
+ // 渲染
return $this->fetch();
}
diff --git a/application/chengji/controller/Tongji.php b/application/chengji/controller/Tongji.php
index eb910d43..31a01222 100644
--- a/application/chengji/controller/Tongji.php
+++ b/application/chengji/controller/Tongji.php
@@ -119,7 +119,15 @@ class Tongji extends Base
'chengji'=>$temp
];
}
-
+
+ // 获取年级成绩
+ $temp = $tj->tongji($allcj,$src['kaoshi']);
+ $data[] = [
+ 'banji'=>'',
+ 'school'=>'合计',
+ 'chengji'=>$temp
+ ];
+
$cnt = count($data);
// 重组返回内容
@@ -236,12 +244,36 @@ class Tongji extends Base
// 获取各学校、各年级考试成绩
public function tjNianji($kaoshi)
{
- // 设置页面标题
- $list['title'] = '各学校的年级成绩统计表';
+
+ $ks = new \app\kaoshi\model\Kaoshi;
+ $ksinfo = $ks->where('id',$kaoshi)
+ ->with([
+ 'KsNianji'
+ ,'ksSubject'=>function($query){
+ $query->field('kaoshiid,subjectid')
+ ->with(['subjectName'=>function($q){
+ $q->field('id,title,lieming');
+ }]
+ );
+ }
+ ])
+ ->field('id')
+ ->find();
+ if($ksinfo->ks_nianji[0])
+ {
+
+ $list['nianji'] = $ksinfo->ks_nianji[0]->nianjiname;
+ }else{
+ $list['nianji'] ='一年级';
+ }
+ $list['subject'] = $ksinfo->ks_subject;
+ // 设置要给模板赋值的信息
+ $list['webtitle'] = '各学校的年级成绩统计表';
$list['kaoshi'] = $kaoshi;
+
// 模板赋值
- $this->assign('list', $list);
+ $this->assign('list',$list);
// 渲染模板
return $this->fetch();
@@ -251,23 +283,89 @@ class Tongji extends Base
// 获取年级成绩统计结果
public function ajaxNianji()
{
- // 获取表单参数
- $getParam = request()->param();
+ // 获取参数
+ $src = $this->request
+ ->only([
+ 'page'=>'1',
+ 'limit'=>'10',
+ 'kaoshi'=>'',
+ 'nianji'=>'一年级',
+ 'paixu'=>array(),
+ ],'POST');
+
+ // 查询要统计成绩的班级
+ $kh = new \app\kaoshi\model\Kaohao;
+ $paixu = $src['paixu'];
+
+ $bj = $kh->where('nianji',$src['nianji'])
+ ->where('kaoshi',$src['kaoshi'])
+ ->when(count($paixu)>0,function($query) use($paixu){
+ $query->where('banji','in',function($q)use($paixu){
+ $q->name('banji')->where('paixu','in',$paixu)->field('id');
+ });
+ })
+ ->with([
+ 'cjBanji'=>function($query){
+ $query->field('id,paixu,ruxuenian')
+ ->append(['numTitle','banjiTitle']);
+ }
+ ,'cjSchool'=>function($query){
+ $query->field('id,jiancheng');
+ }
+ ])
+ ->group('school')
+ ->field('id,banji,school')
+ ->select();
+
+ if($bj->isEmpty()){
+ // 重组返回内容
+ $data = [
+ 'code'=> 0 , // ajax请求次数,作为标识符
+ 'msg'=>"", // 获取到的结果数(每页显示数量)
+ 'count'=>0, // 符合条件的总数据量
+ 'data'=>array(), //获取到的数据结果
+ ];
+
+ return json($data);
+ }
+
+
+
+ // 获取并统计各班级成绩
+ $tj = new TJ;
+ $data = array();
+ $allcj = array();
+ foreach ($bj as $key => $value) {
+ $school=array();
+ $nianji = [$src['nianji']];
+ $banji = array();
+ $temp = $tj->srcChengji($src['kaoshi'],$banji,$nianji,$school);
+ $allcj = array_merge($allcj, $temp);;
+ $temp = $tj->tongji($temp,$src['kaoshi']);
+ $data[] = [
+ 'school'=>$value->cj_school->jiancheng,
+ 'chengji'=>$temp
+ ];
+ }
+
+ // 获取年级成绩
+ $temp = $tj->tongji($allcj,$src['kaoshi']);
+ $data[] = [
+ 'school'=>'合计',
+ 'chengji'=>$temp
+ ];
- // 实例化统计成绩数据模型
- $tj = new \app\chengji\model\Tongji;
- $data = $tj->tjschool($getParam['kaoshiid'],$getParam['ruxuenian']);
$cnt = count($data);
-
// 重组返回内容
$data = [
- 'draw'=> $getParam["draw"] , // ajax请求次数,作为标识符
- 'recordsTotal'=>$cnt, // 获取到的结果数(每页显示数量)
- 'recordsFiltered'=>$cnt, // 符合条件的总数据量
+ 'code'=> 0 , // ajax请求次数,作为标识符
+ 'msg'=>"", // 获取到的结果数(每页显示数量)
+ 'count'=>$cnt, // 符合条件的总数据量
'data'=>$data, //获取到的数据结果
];
+
return json($data);
}
diff --git a/application/chengji/model/Tongji.php b/application/chengji/model/Tongji.php
index d2f1f486..d3679f93 100644
--- a/application/chengji/model/Tongji.php
+++ b/application/chengji/model/Tongji.php
@@ -6,61 +6,17 @@ use think\Model;
class Tongji extends Model
{
- // //统计成绩
- // public function tongji($cjlist,$fenshuxian)
- // {
- // // 循环计算各科成绩
- // foreach ($fenshuxian as $key => $value) {
- // // 获取列名
- // $lieming = $value['lieming'];
- // // 获取学科成绩
- // $xkchengji = $cjlist->column($value['lieming']);
-
- // // 过滤空元素
- // $xkchengji = array_filter($xkchengji);
- // // 获取成绩个数
- // $cnt = count($xkchengji);
-
-
- // // 获取优秀人数
- // $yx = $value['youxiu'];
- // $youxiu = array_filter($xkchengji,function($var) use($yx){
- // if( $var<$yx )
- // {
- // return false;
- // }else{
- // return true;
- // };
- // });
- // $youxiu = count($youxiu);
-
- // // 获取及格人数
- // $jg = $value['jige'];
- // $jg = array_filter($xkchengji,function($var) use($jg){
- // if( $var<$jg )
- // {
- // return false;
- // }else{
- // return true;
- // }
- // });
- // $jige = count($jg);
-
- // // 计算成绩
- // $data[$value['lieming']] = $this->tjxueke($xkchengji,$cnt,$youxiu,$jige);
- // }
-
- // return $data;
- // }
-
// 查询学生成绩
- public function srcChengji($kaoshi,$banji=array(),$nianji=array())
+ public function srcChengji($kaoshi,$banji=array(),$nianji=array(),$school=array())
{
$kh = new \app\kaoshi\model\Kaohao;
$khlist = $kh->where('kaoshi',$kaoshi)
->field('id,nianji,banji')
+ ->when(count($school)>0,function($query) use($school){
+ $query->where('school','in',$school);
+ })
->when(count($nianji)>0,function($query) use($nianji){
$query->where('nianji','in',$nianji);
})
@@ -128,7 +84,8 @@ class Tongji extends Model
}
$data['cnt'] = count($allcj);
$data['sum'] = array_sum($allcj);
- $data['cnt']>0 ? $data['avg'] = $data['sum']/$data['cnt'] : $data['avg']=0;
+ $data['cnt']>0 ? $data['avg'] = round($data['sum']/$data['cnt'],2) : $data['avg']=0;
+ $data['rate'] = $this->rateAll($cj,$ksinfo->ks_subject);
return $data;
@@ -150,112 +107,31 @@ class Tongji extends Model
}
+ // 全科及格率
+ public function rateAll($cj = array(), $sbj=array())
+ {
+ $jige = 0;
+ foreach ($cj as $key => $value) {
+ $tempcj = 0;
+ foreach ($sbj as $k => $val) {
+ $tempsbj = 0;
+ // if(isset($value[$val->lieming]))
+ // {
+ if($value[$val->lieming]>$val->jige)
+ {
+ $tempsbj++;
+ }
+ // }
+ }
+ $tempcj == $tempsbj ? $jige++ : $jige ;
+ }
+
+ return round($jige/count($cj)*100);
+ }
- // // 统计全区各学校的年级成绩
- // public function tjschool($kaoshiid,$ruxuenian)
- // {
- // // 实例化成绩数据模型
- // $cj = new \app\chengji\model\Chengji;
- // // 根据考试号和年级获取考试成绩
- // $cjlist = $cj->searchNianji($kaoshiid,'',$ruxuenian);
-
- // // 获取学校列表
- // $sch = schlist($low='校级',$high='校级');
-
-
- // // 获取统计成绩参数
- // $canshu = $this->getCanshu($kaoshiid);
-
-
-
- // // 循环获取各班级成绩
- // $i = 0;
- // foreach ($sch as $key => $value) {
- // $data[$i]['id'] = $i+1;
- // $data[$i]['title'] = $value['jiancheng'];
- // $bjlist = $cjlist->where('school',$value['id']);
- // $data[$i]['data'] = $this->tongji($bjlist,$canshu);
- // $i++;
- // }
-
- // $data[$i]['id'] = $i+1;
- // $data[$i]['title'] = '合计';
- // $data[$i]['data'] = $this->tongji($cjlist,$canshu);
-
- // return $data;
- // }
-
-
-
- // // 统计学科成绩
- // public function tjxueke($xkchengji,$cnt,$youxiu,$jige)
- // {
-
- // // 如果没有数据则返回空数组
- // if($cnt == 0)
- // {
- // $data = ['cnt'=>0,'sum'=>'-','avg'=>'-','youxiu'=>'-','jige'=>'-','max'=>'-','min'=>'-','biaozhuncha'=>'-','sifenwei'=>array()];
- // return $data;
- // }
-
- // // 计算数据
- // $sum = array_sum($xkchengji);
- // $avg = round($sum/$cnt,1);
- // $youxiulv = round($youxiu/$cnt*100,1);
- // $jigelv = round($jige/$cnt*100,1);
- // $max = max($xkchengji);
- // $min = min($xkchengji);
- // $biaozhuncha = round($this->getVariance($avg,$xkchengji,true),1);
- // $sifenwei = $this->quartile($xkchengji);
- // // 数组赋值
- // $data = [
- // 'cnt'=>$cnt,
- // 'sum'=>$sum,
- // 'avg'=>$avg,
- // 'youxiu'=>$youxiulv,
- // 'jige'=>$jigelv,
- // 'max'=>$max,
- // 'min'=>$min,
- // 'biaozhuncha'=>$biaozhuncha,
- // 'sifenwei'=>$sifenwei,
- // ];
-
- // // 返回计算结果
- // return $data;
- // }
-
-
- // // 获取统计成绩需要的参数
- // public function getCanshu($kaoshiid)
- // {
- // // 获取学科信息
- // $xk = new \app\teach\model\Subject;
- // $xk = $xk->where('id','<',4)->select();
- // $xkTitle = $xk->column('title','id');
- // $xkLieming = $xk->column('lieming','id');
-
- // // 获取参加考试学科满分
- // $kssub = new \app\kaoshi\model\KaoshiSubject;
-
- // $fenshuxian = $kssub ->where('kaoshiid',$kaoshiid)->append(['subject.title','subject.lieming'])->select();
-
- // // 循环取出优秀和及格分数线
- // foreach ($fenshuxian as $key => $value) {
- // $fsx[$value['subjectid']]['youxiu']=$value['youxiu'];
- // $fsx[$value['subjectid']]['jige']=$value['jige'];
- // $fsx[$value['subjectid']]['title']=$value['subject']['title'];
- // $fsx[$value['subjectid']]['lieming']=$value['subject']['lieming'];
- // $fsx[$value['subjectid']]['manfen']=$value['manfen'];
- // }
-
- // // 返回数据
- // return $fsx;
- // }
-
-
/**
* 得到数组的标准差
* @param unknown type $avg
diff --git a/application/chengji/view/index/index.html b/application/chengji/view/index/index.html
index 53f819cc..5edef580 100644
--- a/application/chengji/view/index/index.html
+++ b/application/chengji/view/index/index.html
@@ -70,6 +70,9 @@
+
@@ -120,6 +123,9 @@
case 'add':
cjgl.add('添加单位','/school/create','650','500');
break;
+ case 'download':
+ cjgl.add('下载成绩','/chengji/{$list.kaoshi}/dwChengji','650','500');
+ break;
};
});
diff --git a/application/chengji/view/tongji/tj_banji.html b/application/chengji/view/tongji/tj_banji.html
index bf0f68f6..8c1b21d7 100644
--- a/application/chengji/view/tongji/tj_banji.html
+++ b/application/chengji/view/tongji/tj_banji.html
@@ -82,7 +82,7 @@
// 获取学科
var xk = '';
xk = eval(decodeURIComponent(xk));
- var xiangmu = {cnt:'人数',avg:'平均分',youxiu:'优秀率',jige:'及格率'}; // 要显示哪些统计结果
+ var xiangmu = {cnt:'人数',avg:'平均分',youxiu:'优秀率%',jige:'及格率%'}; // 要显示哪些统计结果
$.each(xk,function(index,value){
options.cols[0].push({title: xk[index].subject_name.title,colspan:4,align:'center'});
@@ -91,7 +91,6 @@
// console.log(colname + ' ' + i);
var colinfo = {
title:val
- ,sort:true
,minWidth:100
,templet:function(d){
var str = d.chengji[colname][i];
@@ -102,11 +101,16 @@
options.cols[1].push(colinfo);
});
});
- options.cols[0].push({ title: '总平均分',sort: true,minWidth:100,rowspan:2,templet:function(d){
+ options.cols[0].push({title: '全科及格率',minWidth:100,rowspan:2,templet:function(d){
+ var str = d.chengji.rate;
+ return str;
+ }});
+ options.cols[0].push({ title: '总平均分',minWidth:100,rowspan:2,templet:function(d){
var str = d.chengji.avg;
return str;
}});
+
// 设置查询条件
options.where = {
diff --git a/application/chengji/view/tongji/tj_banji1.html b/application/chengji/view/tongji/tj_banji1.html
deleted file mode 100644
index b438a99b..00000000
--- a/application/chengji/view/tongji/tj_banji1.html
+++ /dev/null
@@ -1,161 +0,0 @@
-{extend name="common@list" /}
-{block name="topnav"}
-
-{/block}
-{block name="bouttons"}
-
-
-
-
- {php}
- $school = schlist('校级','校级');
- {/php}
-
-
-
- {foreach $school as $key=>$vo }
-
- {/foreach}
-
-
-
-
- {php}
- $njlist = nianjiList();
- {/php}
-
- {foreach $njlist as $key=>$vo }
-
-
-
-
- {/foreach}
-
-
-
-
-
-{/block}
-{block name="tables"}
-
-
-
- | 序号 |
- 班级 |
- 语文 |
- 数学 |
- 英语 |
-
-
- | 人数 |
- 平均分 |
- 优秀率% |
- 及格率% |
-
- 人数 |
- 平均分 |
- 优秀率% |
- 及格率% |
-
- 人数 |
- 平均分 |
- 优秀率% |
- 及格率% |
-
-
-
-
-
-
-
-{/block}
-{block name="myjs"}
-
-{/block}
\ No newline at end of file
diff --git a/application/chengji/view/tongji/tj_nianji.html b/application/chengji/view/tongji/tj_nianji.html
index 0bc9da3b..99e8ed54 100644
--- a/application/chengji/view/tongji/tj_nianji.html
+++ b/application/chengji/view/tongji/tj_nianji.html
@@ -1,135 +1,138 @@
+
{extend name="common@list" /}
-{block name="topnav"}
-
-{/block}
-{block name="bouttons"}
-
-
-
-
- {php}
- $njlist = nianjiList();
- {/php}
-
- {foreach $njlist as $key=>$vo }
-
-
-
-
- {/foreach}
+{block name="jsset"}
-
-
+{/block}
+{block name="nav"}
+
+ 考试管理
+ 成绩管理
+ 各年级成绩统计表
+
+{/block}
+{block name="search"}
+
-
+
{/block}
-{block name="tables"}
-
-
-
- | 序号 |
- 班级 |
- 语文 |
- 数学 |
- 英语 |
-
-
- | 人数 |
- 平均分 |
- 优秀率% |
- 及格率% |
-
- 人数 |
- 平均分 |
- 优秀率% |
- 及格率% |
-
- 人数 |
- 平均分 |
- 优秀率% |
- 及格率% |
-
-
-
-
-
-
-
+{block name="table"}
+
{/block}
{block name="myjs"}
-
+
+
+
+
{/block}
\ No newline at end of file
diff --git a/application/kaoshi/model/Kaohao.php b/application/kaoshi/model/Kaohao.php
index 76b844c5..a5c29709 100644
--- a/application/kaoshi/model/Kaohao.php
+++ b/application/kaoshi/model/Kaohao.php
@@ -147,7 +147,7 @@ class Kaohao extends Base
}
$data[$key]['cnt'] = $dfcnt;
if($sbjcnt>0){
- $data[$key]['avg'] = $dfcnt/$sbjcnt;
+ $data[$key]['avg'] = round($dfcnt/$sbjcnt,1);
}else{
$data[$key]['avg'] = 0;
}
diff --git a/route/chengji.php b/route/chengji.php
index b615de8b..4d4a0e75 100644
--- a/route/chengji.php
+++ b/route/chengji.php
@@ -25,7 +25,7 @@ Route::get('chengji/:kaoshi/stuChengjilist','chengji/Index/index');
Route::delete('chengji/:kaoshi/cj','chengji/Index/deletecj'); #只清空成绩
// 成绩统计表
Route::get('cjtongji/:kaoshi/banji','chengji/Tongji/tjBanji'); # 班级成绩统计列表
-Route::get('cjtongji/:id/nianji','chengji/Tongji/tjNianji'); # 年级成绩统计列表
+Route::get('cjtongji/:kaoshi/nianji','chengji/Tongji/tjNianji'); # 年级成绩统计列表
// 下载学生成绩
Route::get('chengji/:kaoshi/dwChengji','chengji/Index/dwChengji');