diff --git a/application/chengji/controller/Index.php b/application/chengji/controller/Index.php index 81e191b8..b3f20d98 100644 --- a/application/chengji/controller/Index.php +++ b/application/chengji/controller/Index.php @@ -377,12 +377,20 @@ class Index extends Base //生成学生表格 public function chengjixls() { + // 获取表单值 + $list = request()->post(); // 实例化验证模型 - $validate = new \app\teach\validate\Kaoshi; + $validate = new \app\chengji\validate\Cjdownload; // 验证表单数据 $result = $validate->check($list); $msg = $validate->getError(); + // 如果验证不通过则停止保存 + if(!$result){ + $this->error($msg); + } + + set_time_limit(0); @@ -464,11 +472,11 @@ class Index extends Base // 保存文件 - $filename = $ks.'学生成绩列表'.date('ymdHis').'.xls'; + $filename = $ks.'学生成绩列表'.date('ymdHis').'.xlsx'; header('Content-Type: application/vnd.openxmlformats-officedocument.spreadsheetml.sheet'); header('Content-Disposition: attachment;filename="' . $filename . '"'); header('Cache-Control: max-age=0'); - $writer = \PhpOffice\PhpSpreadsheet\IOFactory::createWriter($spreadsheet, 'Xls'); + $writer = \PhpOffice\PhpSpreadsheet\IOFactory::createWriter($spreadsheet, 'Xlsx'); $writer->save('php://output'); ob_flush(); flush(); diff --git a/application/chengji/controller/Tongji.php b/application/chengji/controller/Tongji.php index 69e0f993..7fa4406c 100644 --- a/application/chengji/controller/Tongji.php +++ b/application/chengji/controller/Tongji.php @@ -8,11 +8,11 @@ use app\common\controller\Base; class Tongji extends Base { // 年级成绩汇总 - public function nianji($id) + public function tjnianji($id) { // 设置页面标题 - $list['title'] = '教师列表'; + $list['title'] = '年级成绩统计'; $list['kaoshi'] = $id; // 模板赋值 @@ -83,18 +83,95 @@ class Tongji extends Base } - // 年级、班级学生成绩统计结果下载 - public function downloadnj() + // 年级、班级学生成绩统计结果下载界面 + public function downloadnj($id) { + dump('aa'); + + } + + + // 年级、班级学生成绩统计下载表格 + public function downloadxls($id) + { + dump('aa'); } // 获取各学校、各年级考试成绩 - public function schoolNianji() + public function tjschool($id) { + // 设置页面标题 + $list['title'] = '学校成绩统计'; + $list['kaoshi'] = $id; + + // 模板赋值 + $this->assign('list', $list); + + // 渲染模板 + return $this->fetch(); + } + + + // 获取年级成绩统计结果 + public function ajaxSchool() + { + // 获取年级和班级列表名 + $njnames = nianjiList(); + + // 获取表单参数 + $getParam = request()->param(); + $school = $getParam['school']; + + // 实例化成绩数据模型 + $cj = new \app\chengji\model\Chengji; + + // 根据考试号和年级获取考试成绩 + $cjlist = $cj->searchNianji($getParam['kaoshiid'],$school,$getParam['ruxuenian']); + + // 根据年级获取一个有多少个班级 + $bj = new \app\teach\model\Banji; + $bjids = $bj->where('ruxuenian',$getParam['ruxuenian']) + ->when(!empty($school),function($query) use($school){ + $query->where('school','in',$school); + }) + ->append(['title']) + ->select(); + $cnt = $bjids->count() + 1; + + + // 实例化成绩统计模型 + $tj = new \app\chengji\model\Tongji(); + // 获取统计成绩参数 + $canshu = $tj->getCanshu($getParam['kaoshiid']); + + + // 循环获取各班级成绩 + $i = 0; + foreach ($bjids as $key => $value) { + $data[$i]['id'] = $i+1; + $data[$i]['title'] = $value['title']; + $bjlist = $cjlist->where('banji',$value['id']); + $data[$i]['data'] = $tj->tongji($bjlist,$canshu); + + $i++; + } + + $data[$i]['id'] = $i+1; + $data[$i]['title'] = '合计'; + $data[$i]['data'] = $tj->tongji($cjlist,$canshu); + // 重组返回内容 + $data = [ + 'draw'=> $getParam["draw"] , // ajax请求次数,作为标识符 + 'recordsTotal'=>$cnt, // 获取到的结果数(每页显示数量) + 'recordsFiltered'=>$cnt, // 符合条件的总数据量 + 'data'=>$data, //获取到的数据结果 + ]; + + return json($data); } } diff --git a/application/chengji/view/index/download.html b/application/chengji/view/index/download.html index d81c344f..ffdfccf4 100644 --- a/application/chengji/view/index/download.html +++ b/application/chengji/view/index/download.html @@ -56,7 +56,7 @@
| 序号 | +班级 | +语文 | +数学 | +英语 | +|||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
| 人数 | +平均分 | +优秀率% | +及格率% | + +人数 | +平均分 | +优秀率% | +及格率% | + +人数 | +平均分 | +优秀率% | +及格率% | +||