diff --git a/application/chengji/controller/Index.php b/application/chengji/controller/Index.php index a891d58b..81e191b8 100644 --- a/application/chengji/controller/Index.php +++ b/application/chengji/controller/Index.php @@ -151,14 +151,12 @@ class Index extends Base $data = $cjmod->saveAll($cj); // 判断成绩更新结果 - empty($cj) ? $data = ['msg'=>'上传失败','val' => 0] : $data = ['msg'=>'上传成功','val' => 1,]; - ob_flush(); - flush(); + empty($cj) ? $data=['msg'=>'上传失败','val'=>0] : $data=['msg'=>'上传成功','val'=>1]; // 返回成绩结果 return json($data); - - + ob_flush(); + flush(); } @@ -379,18 +377,33 @@ class Index extends Base //生成学生表格 public function chengjixls() { + // 实例化验证模型 + $validate = new \app\teach\validate\Kaoshi; + // 验证表单数据 + $result = $validate->check($list); + $msg = $validate->getError(); + + + set_time_limit(0); $list = input(); $id = $list['id']; // 获取数据库信息 $chengjiinfo = Chengji::where('kaoshi',$id) ->where('banji','in',$list['banjiids']) - ->order(['ruxuenian','stuAvg'=>'desc']) + ->order(['stuAvg'=>'desc']) ->append(['cj_student.xingming','cj_banji.title']) ->select(); // 获取考试标题 $ks = Kaoshi::where('id',$id)->find('title'); + + // 实例化成绩统计模型 + $tj = new \app\chengji\model\Tongji(); + // 获取统计成绩参数 + $canshu = $tj->getCanshu($id); + $tj = $tj->tongji($chengjiinfo,$canshu); + // 创建表格 @@ -407,6 +420,16 @@ class Index extends Base $sheet->setCellValue('F2', '英语'); $sheet->setCellValue('G2', '平均分'); $sheet->setCellValue('H2', '总分'); + $sheet->setCellValue('J2', '项目'); + $sheet->setCellValue('K2', '语文'); + $sheet->setCellValue('L2', '数学'); + $sheet->setCellValue('M2', '英语'); + $sheet->setCellValue('J3', '人数'); + $sheet->setCellValue('J4', '平均分'); + $sheet->setCellValue('J5', '优秀率'); + $sheet->setCellValue('J6', '及格率'); + $sheet->setCellValue('J7', '标准差'); + // 循环写出信息 @@ -427,6 +450,18 @@ class Index extends Base } } + // 循环写出统计结果 + $x = 11; + $lieming = array(11=>'K',12=>'L',13=>'M'); + foreach ($tj as $key => $value) { + $sheet->setCellValue($lieming[$x].'3', $value['cnt']); + $sheet->setCellValue($lieming[$x].'4', $value['avg']); + $sheet->setCellValue($lieming[$x].'5', $value['youxiu']); + $sheet->setCellValue($lieming[$x].'6', $value['jige']); + $sheet->setCellValue($lieming[$x].'7', $value['biaozhuncha']); + $x++; + } + // 保存文件 $filename = $ks.'学生成绩列表'.date('ymdHis').'.xls'; diff --git a/application/chengji/controller/Tongji.php b/application/chengji/controller/Tongji.php index 5602fbfc..69e0f993 100644 --- a/application/chengji/controller/Tongji.php +++ b/application/chengji/controller/Tongji.php @@ -52,7 +52,7 @@ class Tongji extends Base // 实例化成绩统计模型 $tj = new \app\chengji\model\Tongji(); - + // 获取统计成绩参数 $canshu = $tj->getCanshu($getParam['kaoshiid']); @@ -82,4 +82,19 @@ class Tongji extends Base return json($data); } + + // 年级、班级学生成绩统计结果下载 + public function downloadnj() + { + + } + + + + // 获取各学校、各年级考试成绩 + public function schoolNianji() + { + + } + } diff --git a/application/chengji/validate/Cjdownload.php b/application/chengji/validate/Cjdownload.php new file mode 100644 index 00000000..14aca152 --- /dev/null +++ b/application/chengji/validate/Cjdownload.php @@ -0,0 +1,26 @@ + ['规则1','规则2'...] + * + * @var array + */ + protected $rule = [ + 'banjiids|参考班级' => 'require|array', + ]; + + /** + * 定义错误信息 + * 格式:'字段名.规则名' => '错误信息' + * + * @var array + */ + protected $message = []; +} diff --git a/application/chengji/view/index/download.html b/application/chengji/view/index/download.html index 22f2ab7f..d81c344f 100644 --- a/application/chengji/view/index/download.html +++ b/application/chengji/view/index/download.html @@ -28,13 +28,10 @@