From da9897bff98855684a577ddf023600f61d85cb44 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E5=B7=B4=E6=8E=8C?= Date: Wed, 5 Dec 2018 12:54:23 +0800 Subject: [PATCH] =?UTF-8?q?=E5=B9=B4=E7=BA=A7=E6=88=90=E7=BB=A9=E7=BB=9F?= =?UTF-8?q?=E8=AE=A1=E8=A1=A8=E3=80=81=E4=BF=AE=E6=94=B9=E5=AD=A6=E7=94=9F?= =?UTF-8?q?=E3=80=81=E5=88=86=E7=B1=BB=E7=AD=89?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- application/chengji/controller/Tongji.php | 95 +++++++--- application/chengji/model/Chengji.php | 11 +- application/chengji/model/Tongji.php | 62 ++++--- application/chengji/view/index/malu.html | 9 +- application/chengji/view/tongji/nianji.html | 163 ++++++++++++++++++ application/common.php | 10 +- application/common/view/list.html | 5 +- application/index/view/index/index.html | 2 +- .../kaoshi/view/more_action/index.html | 4 +- application/renshi/controller/Student.php | 1 + application/renshi/view/index/create.html | 4 +- application/renshi/view/index/edit.html | 4 +- application/renshi/view/student/edit.html | 4 +- application/system/controller/Category.php | 3 +- application/system/model/Category.php | 2 + application/system/view/category/create.html | 4 +- application/system/view/category/edit.html | 4 +- 17 files changed, 309 insertions(+), 78 deletions(-) create mode 100644 application/chengji/view/tongji/nianji.html diff --git a/application/chengji/controller/Tongji.php b/application/chengji/controller/Tongji.php index 6a759c69..2d8b2e7b 100644 --- a/application/chengji/controller/Tongji.php +++ b/application/chengji/controller/Tongji.php @@ -8,44 +8,83 @@ use app\common\controller\Base; class Tongji extends Base { // 年级成绩汇总 - public function nianji() + public function nianji($id) { - $id = input('param.id'); + + // 设置页面标题 + $list['title'] = '教师列表'; + $list['kaoshi'] = $id; + + // 模板赋值 + $this->assign('list', $list); + + // 渲染模板 + return $this->fetch(); + } + + + // 获取年级成绩统计结果 + public function ajaxNianji() + { + // 获取年级和班级列表名 + $njnames = nianjiList(); + + // 获取表单参数 + $getParam = request()->param(); + $school = $getParam['school']; + // 实例化成绩数据模型 $cj = new \app\chengji\model\Chengji; // 根据考试号和年级获取考试成绩 - $cjlist = $cj->searchNianji($id,'二年级'); - $cjlist = $cj->where('kaoshi',2)->select(); - if(!$cjlist) - { - return $this->error('没有找到成绩'); - } + $cjlist = $cj->searchNianji($getParam['kaoshiid'],$school,$getParam['ruxuenian']); - // 获取学科信息 - $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; - - $xkinfo = $kssub ->where('kaoshiid',$id)->append(['subject.title','subject.lieming'])->select(); - - // 循环取出优秀和及格分数线 - foreach ($xkinfo as $key => $value) { - $fenshuxian[$value['subjectid']]['youxiu']=$value['youxiu']; - $fenshuxian[$value['subjectid']]['jige']=$value['jige']; - $fenshuxian[$value['subjectid']]['title']=$value['subject']['title']; - $fenshuxian[$value['subjectid']]['lieming']=$value['subject']['lieming']; - } + // 根据年级获取一个有多少个班级 + $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']); - $a = $tj->tongji($cjlist,$fenshuxian); - dump($a); + + + // 循环获取各班级成绩 + $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/model/Chengji.php b/application/chengji/model/Chengji.php index 6cc4635d..80f0716a 100644 --- a/application/chengji/model/Chengji.php +++ b/application/chengji/model/Chengji.php @@ -181,12 +181,15 @@ class Chengji extends Base // 查询年级成绩 - public function searchNianji($kaoshiid,$nianji) + public function searchNianji($kaoshiid,$schoolid='',$nianji) { return $this->where('kaoshi',$kaoshiid) - ->where('nianji',$nianji) - ->field('id,kaoshi,yuwen,shuxue,waiyu') - ->cache('key',180) + ->where('ruxuenian',$nianji) + ->when(!empty($schoolid),function($query) use($schoolid){ + $query->where('school',$schoolid); + }) + ->field('id,kaoshi,banji,yuwen,shuxue,waiyu') + // ->cache('key',180) ->select(); } diff --git a/application/chengji/model/Tongji.php b/application/chengji/model/Tongji.php index ea411501..af37bf21 100644 --- a/application/chengji/model/Tongji.php +++ b/application/chengji/model/Tongji.php @@ -6,25 +6,12 @@ use think\Model; class Tongji extends Model { - var $avg = ''; - var $sum = ''; - var $youxiulv = '';#优秀率 - var $jigelv = '';#及格率 - - - //获取统计成绩 + //统计成绩 public function tongji($cjlist,$fenshuxian) { // 获取成绩总数 $cnt = $cjlist->count(); - // 如果没有成绩不计算 - if($cnt == 0) - { - $data = ['cnt'=>$cnt,'avg'=>$avg,'sum'=>$sum,'youxiu'=>$youxiulv,'jige'=>$jigelv]; - return $data; - } - // 循环计算各科成绩 foreach ($fenshuxian as $key => $value) { // 获取学科成绩 @@ -54,15 +41,48 @@ class Tongji extends Model // 统计学科成绩 public function tjxueke($xkchengji,$cnt,$youxiu,$jige) { - $sum = $sum = array_sum($xkchengji); - $avg = round($sum/$cnt,2); - $youxiulv = round($youxiu/$cnt*100,2); - $jigelv = round($jige/$cnt*100,2); - $max = max($xkchengji); - $min = min($xkchengji); - $data = ['cnt'=>$cnt,'sum'=>$sum,'avg'=>$avg,'youxiu'=>$youxiulv,'jige'=>$jigelv,'max'=>$max,'min'=>$min]; + $sum = array_sum($xkchengji); + if($sum != 0) + { + $avg = round($sum/$cnt,2); + $youxiulv = round($youxiu/$cnt*100,2); + $jigelv = round($jige/$cnt*100,2); + $max = max($xkchengji); + $min = min($xkchengji); + $data = ['cnt'=>$cnt,'sum'=>$sum,'avg'=>$avg,'youxiu'=>$youxiulv,'jige'=>$jigelv,'max'=>$max,'min'=>$min]; + }else{ + $data = ['cnt'=>0,'sum'=>'-','avg'=>'-','youxiu'=>'-','jige'=>'-','max'=>'-','min'=>'-']; + } + 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']; + } + + // 返回数据 + return $fsx; + } + + } diff --git a/application/chengji/view/index/malu.html b/application/chengji/view/index/malu.html index 57a3d174..9b7d1215 100644 --- a/application/chengji/view/index/malu.html +++ b/application/chengji/view/index/malu.html @@ -51,7 +51,7 @@ // 声明变量 var myinfo = []; var cnt = 1; - var myDate = new Date();//获取系统当前时间 + // var myDate = new Date();//获取系统当前时间 @@ -62,8 +62,7 @@ { return false; } - // 初始化数组 - // myinfo = array(); + // 获取扫码值并分割成数据 myinfo = $('#info').val().split(','); @@ -131,7 +130,7 @@ return false; } // 不能被0.5整除退出 - if(df%0.5) + if((df*10%5)) { return false; } @@ -154,7 +153,7 @@ var minute = date.getMinutes(); var second = date.getSeconds(); var addtime = hour + ':' + minute + ':' + second; - var str = ''+cnt+'' + myinfo['school'] +'' + myinfo['banji'] + ''+myinfo['student']+''+myinfo['zdname']+''+data['defen']+''+addtime+''; + var str = ''+cnt+'' + myinfo['cj_school']['jiancheng'] +'' + myinfo['cj_banji']['title'] + ''+myinfo['cj_student']['xingming']+''+myinfo['zdname']+''+data['defen']+''+addtime+''; cnt++; $('#addjg').prepend(str); } diff --git a/application/chengji/view/tongji/nianji.html b/application/chengji/view/tongji/nianji.html new file mode 100644 index 00000000..46c9e4c8 --- /dev/null +++ b/application/chengji/view/tongji/nianji.html @@ -0,0 +1,163 @@ +{extend name="common@list" /} +{block name="topnav"} + +{/block} +{block name="bouttons"} +
+
筛选
+
+
+ {php} + $school = new app\system\model\School; + $school = $school->searchMany('校级','校级'); + {/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/common.php b/application/common.php index 075bc13c..14591971 100644 --- a/application/common.php +++ b/application/common.php @@ -14,8 +14,9 @@ // 获取类别列表 function getCategory($id = '0') { + $category = new \app\system\model\Category; // 根据父级id查询类别列表 - $list = db('category') + $list = $category ->where('pid','in',$id) ->where('status',1) ->field('id,title') @@ -29,8 +30,9 @@ function getCategory($id = '0') // 获取类别名称 function getCategoryTitle($id) { + $category = new \app\system\model\Category; // 根据id查询类别名 - $value = db('category') + $value = $category ->where('id',$id) ->vlaue('title'); // 返回类别名 @@ -42,7 +44,7 @@ function nianjiList() { // 定义学年时间节点日期为每年的8月10日 // $yd = '8-10'; - $jiedian = strtotime(date('Y').'-8-10'); + $jiedian = strtotime(date('Y').'-8-1'); $time = new think\helper\Time(); @@ -95,6 +97,8 @@ function banjinamelist() } + + /** * $date是时间戳 * $type为1的时候是虚岁,2的时候是周岁 diff --git a/application/common/view/list.html b/application/common/view/list.html index e27d8114..e4c73038 100644 --- a/application/common/view/list.html +++ b/application/common/view/list.html @@ -85,12 +85,13 @@ //初始化表格 - $("#table1").DataTable({ + var mytable = $("#table1").DataTable({ language:lang, //提示信息 autoWidth: false, //禁用自动调整列宽 //stripeClasses: ["odd", "even"], //为奇偶行加上样式,兼容不支持CSS伪类的场合 processing: true, //隐藏加载提示,自行处理 serverSide: true, //启用服务器端分页 + stateSave: true, searching: true, //禁用原生搜索 orderMulti: false, //启用多列排序 //order: [], //取消默认排序查询,否则复选框一列会出现小箭头 @@ -101,7 +102,7 @@ ], destroy: true, //option显示数量 - aLengthMenu: [[20, 50, 100, 500], [20, 50, 100, 500]], + aLengthMenu: [[20, 60, 120], [20, 60, 120,]], iDisplayLength: 20, //默认显示20条 /*columnDefs: [{ "targets": 'nosort', //列的样式名 diff --git a/application/index/view/index/index.html b/application/index/view/index/index.html index 238b8938..25036533 100644 --- a/application/index/view/index/index.html +++ b/application/index/view/index/index.html @@ -32,7 +32,7 @@