From 7ab859aa76a7a72402e3ed2bead06dce7b261aa1 Mon Sep 17 00:00:00 2001 From: cxdbz Date: Mon, 16 Dec 2019 20:12:34 +0800 Subject: [PATCH] =?UTF-8?q?=E4=BF=AE=E6=94=B9=E6=95=B0=E6=8D=AE=E7=BB=9F?= =?UTF-8?q?=E8=AE=A1=E7=8F=AD=E7=BA=A7=E6=A8=A1=E5=9E=8B?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/chengji/controller/Bjtongji.php | 2 + app/chengji/model/Bjtongji.php | 16 +-- app/chengji/model/Tongji.php | 145 ++++++++++++++-------------- app/kaoshi/controller/Kaohao.php | 5 + 4 files changed, 90 insertions(+), 78 deletions(-) diff --git a/app/chengji/controller/Bjtongji.php b/app/chengji/controller/Bjtongji.php index f39375b0..4f93cf55 100644 --- a/app/chengji/controller/Bjtongji.php +++ b/app/chengji/controller/Bjtongji.php @@ -75,6 +75,8 @@ class Bjtongji extends BaseController 'paixu'=>$src['paixu'], ]; + is_array($src['school']) ? $srcfrom['school'] = $src['school'] : $srcfrom['school'] = explode(',', $src['school']); + $data = $btj->tjBanji($srcfrom); diff --git a/app/chengji/model/Bjtongji.php b/app/chengji/model/Bjtongji.php index 9b445a55..c2a974dc 100644 --- a/app/chengji/model/Bjtongji.php +++ b/app/chengji/model/Bjtongji.php @@ -6,6 +6,7 @@ namespace app\chengji\model; use app\common\model\Base; // 引用学生成绩统计类 use app\chengji\model\Tongji as TJ; +use app\chengji\model\Chengji; class Bjtongji extends Base { @@ -19,9 +20,9 @@ class Bjtongji extends Base */ public function tjBanji($srcfrom) { + // 查询要统计成绩的班级 $kh = new \app\kaoshi\model\Kaohao; - $bj = $kh->cyBanji($srcfrom); $srcfrom['nianji'] = $srcfrom['ruxuenian']; @@ -29,6 +30,7 @@ class Bjtongji extends Base unset($srcfrom['ruxuenian'],$srcfrom['paixu']); + $data = array(); if($bj->isEmpty()){ return $data; @@ -36,6 +38,7 @@ class Bjtongji extends Base // 实例化学生成绩统计类 $tj = new TJ; + $cj = new Chengji; // 获取并统计各班级成绩 $data = array(); @@ -43,8 +46,8 @@ class Bjtongji extends Base foreach ($bj as $key => $value) { $bjs[] = $value->banji; $banji=[$value->banji]; - $temp = $tj->srcChengji($srcfrom); - $temp = $tj->tongji($temp,$kaoshi); + $temp = $cj->search($srcfrom); + $temp = $tj->tongji($temp,$srcfrom['kaoshi']); $data[] = [ 'banji'=>$value->bjtitle, 'school'=>$value->cj_school->jiancheng, @@ -53,10 +56,11 @@ class Bjtongji extends Base } - + $srcfrom['banji'] = $bjs; // 获取年级成绩 - $allcj = $tj->srcChengji($kaoshi=$kaoshi,$banji=$bjs,$nianji=$nianji,$school=array()); - $temp = $tj->tongji($allcj,$kaoshi); + // $allcj = $tj->srcChengji($kaoshi=$kaoshi,$banji=$bjs,$nianji=$nianji,$school=array()); + $allcj = $cj->search($srcfrom); + $temp = $tj->tongji($allcj,$srcfrom['kaoshi']); $data[] = [ 'banji'=>'合计', 'school'=>'', diff --git a/app/chengji/model/Tongji.php b/app/chengji/model/Tongji.php index fbb3ddb0..f6b9562d 100644 --- a/app/chengji/model/Tongji.php +++ b/app/chengji/model/Tongji.php @@ -18,84 +18,84 @@ class Tongji extends Base * @param array $school 学校 * @return array 返回类型 */ - public function srcChengji1($srcfrom) - { + // public function srcChengji1($srcfrom) + // { - // 初始化参数 - $src = array( - 'kaoshi'=>'', - 'banji'=>array('0'), - 'nianji'=>'', - 'school'=>array(), - ); + // // 初始化参数 + // $src = array( + // 'kaoshi'=>'', + // 'banji'=>array('0'), + // 'nianji'=>'', + // 'school'=>array(), + // ); - // 用新值替换初始值 - $src = array_cover( $srcfrom , $src ) ; - $banji = $src['banji']; - $school = $src['school']; - $nianji = $src['nianji']; + // // 用新值替换初始值 + // $src = array_cover( $srcfrom , $src ) ; + // $banji = $src['banji']; + // $school = $src['school']; + // $nianji = $src['nianji']; - $kh = new \app\kaoshi\model\Kaohao; + // $kh = new \app\kaoshi\model\Kaohao; - $khlist = $kh->where('kaoshi',$src['kaoshi']) - ->field('id,nianji,banji') - ->when(count($school)>0,function($query) use($school){ - $query->where('school','in',$school); - }) - ->when(strlen($nianji)>0,function($query) use($nianji){ - $query->where('ruxuenian',$nianji); - }) - ->when(count($banji)>0,function($query) use($banji){ - $query->where('banji','in',$banji); - }) - ->with([ - 'ksChengji'=>function($query){ - $query->field('kaohao_id,subject_id,defen'); - } - ]) - ->select(); - if($khlist->isEmpty()) - { - return $data = array(); - } + // $khlist = $kh->where('kaoshi',$src['kaoshi']) + // ->field('id,nianji,banji') + // ->when(count($school)>0,function($query) use($school){ + // $query->where('school','in',$school); + // }) + // ->when(strlen($nianji)>0,function($query) use($nianji){ + // $query->where('ruxuenian',$nianji); + // }) + // ->when(count($banji)>0,function($query) use($banji){ + // $query->where('banji','in',$banji); + // }) + // ->with([ + // 'ksChengji'=>function($query){ + // $query->field('kaohao_id,subject_id,defen'); + // } + // ]) + // ->select(); + // if($khlist->isEmpty()) + // { + // return $data = array(); + // } - // 获取参考学科 - $ks = new \app\kaoshi\model\Kaoshi; - $ksinfo = $ks->where('id',$kaoshi) - ->with([ - 'ksSubject'=>function($query){ - $query->field('kaoshiid,subjectid,lieming'); - } - ]) - ->find(); - if($ksinfo->ks_subject->isEmpty()) - { - return $data = array(); - } - $xk = array(); - foreach ($ksinfo->ks_subject as $key => $value) { - $xk[$value->subjectid] = $value->lieming; - } + // // 获取参考学科 + // $ks = new \app\kaoshi\model\Kaoshi; + // $ksinfo = $ks->where('id',$kaoshi) + // ->with([ + // 'ksSubject'=>function($query){ + // $query->field('kaoshiid,subjectid,lieming'); + // } + // ]) + // ->find(); + // if($ksinfo->ks_subject->isEmpty()) + // { + // return $data = array(); + // } + // $xk = array(); + // foreach ($ksinfo->ks_subject as $key => $value) { + // $xk[$value->subjectid] = $value->lieming; + // } - // 整理数据 - $data = array(); - foreach ($khlist as $key => $value) { - if(count($value->ks_chengji)== 0) - { - continue; - } - $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; - } + // // 整理数据 + // $data = array(); + // foreach ($khlist as $key => $value) { + // if(count($value->ks_chengji)== 0) + // { + // continue; + // } + // $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; - } + // return $data; + // } @@ -112,12 +112,13 @@ class Tongji extends Base // $allcj = array(); foreach ($ksinfo->ks_subject as $key => $value) { $cjcol = array_column($cj,$value->lieming); + // $allcj = array_merge($allcj,$cjcol); $temp = array(); $temp['xkcnt'] = count($cjcol); $temp['sum'] = array_sum($cjcol); $temp['xkcnt']>0 ? $temp['avg'] = $temp['sum']/$temp['xkcnt'] : $temp['avg']=0; - $temp['biaozhuncha'] = round($this->getVariance($temp['avg'], $cjcol,true),2); + // $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); diff --git a/app/kaoshi/controller/Kaohao.php b/app/kaoshi/controller/Kaohao.php index b3cf7fa9..6b1f4890 100644 --- a/app/kaoshi/controller/Kaohao.php +++ b/app/kaoshi/controller/Kaohao.php @@ -480,6 +480,11 @@ class Kaohao extends BaseController $banji = $list['banjiids']; $subject = $list['subject']; + if(kaoshiDate($kaoshi,'enddate')) + { + $this->error('考试已经结束,不能下载','/kaoshi/kaohao/biaoqian/'.$kaoshi); + } + // 验证表单数据 $result = $validate->check($list); $msg = $validate->getError();