From fad4067eba942a728945fc38faa286f819b9d38b Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E5=B7=B4=E6=8E=8C?= Date: Mon, 21 Dec 2020 13:08:16 +0800 Subject: [PATCH] 0 --- app/chengji/controller/Bjtongji.php | 1 + app/chengji/model/TongjiBj.php | 52 ++++-- app/chengji/model/TongjiNj.php | 39 +++-- app/chengji/view/bjtongji/biaoge.html | 14 +- app/common.php | 9 + app/index/controller/Index.php | 2 +- app/index/view/index/index.html | 4 +- app/kaoshi/controller/Index.php | 35 ++++ app/kaoshi/controller/TongjiXiangmu.php | 11 +- app/kaoshi/model/TongjiXiangmu.php | 27 +++ app/kaoshi/view/tongji_xiangmu/create.html | 9 + app/kaoshi/view/tongji_xiangmu/index.html | 3 +- app/system/controller/SystemBase.php | 4 +- app/system/model/SystemBase.php | 2 +- app/system/view/system_base/edit.html | 9 + app/tools/controller/KsCanyu.php | 4 +- config/shangma.php | 1 - .../migrations/20181010035225_system_base.php | 1 + .../20201217083453_tong_ji_xingmu.php | 9 +- database/seeds/SystemBase.php | 1 + database/seeds/TongjiXingmu.php | 155 ++++++++++-------- 21 files changed, 275 insertions(+), 117 deletions(-) diff --git a/app/chengji/controller/Bjtongji.php b/app/chengji/controller/Bjtongji.php index 33727a75..cd291340 100755 --- a/app/chengji/controller/Bjtongji.php +++ b/app/chengji/controller/Bjtongji.php @@ -31,6 +31,7 @@ class Bjtongji extends AdminBase $list['kaoshi_id'] = $kaoshi_id; $list['kaoshititle'] = $ksinfo->title; $list['dataurl'] = '/chengji/bjtj/data'; + $list['tjxm'] = srcTjxm(); // 模板赋值 $this->view->assign('list', $list); diff --git a/app/chengji/model/TongjiBj.php b/app/chengji/model/TongjiBj.php index cc1596c6..9efc0025 100755 --- a/app/chengji/model/TongjiBj.php +++ b/app/chengji/model/TongjiBj.php @@ -234,20 +234,26 @@ class TongjiBj extends BaseModel foreach ($value->bjJieguo as $k => $val) { if($val->subject_id > 0){ $data[$value->banji_id]['chengji'][$val->bjSubject->lieming] = [ - 'avg' => $val->avg * 1 + 'title' => $val->bjSubject->title + ,'jiancheng' => $val->bjSubject->jiancheng + ,'stu_cnt' => $val->stu_cnt + ,'chengji_cnt' => $val->chengji_cnt + ,'sum' => $val->sum + ,'avg' => $val->avg * 1 + ,'defenlv' => $val->defenlv + ,'biaozhuncha' => $val->biaozhuncha * 1 + ,'youxiu' => $val->youxiu + ,'jige' => $val->jige ,'youxiulv' => $val->youxiulv ,'jigelv' => $val->jigelv - ,'cjCnt' => $val->chengji_cnt - ,'title' => $val->bjSubject->title - ,'jiancheng' => $val->bjSubject->jiancheng - ,'biaozhuncha' => $val->biaozhuncha * 1 - ,'sifenwei' => [ - 'min' => $val->min - ,'q1' => $val->q1 * 1 - ,'q2' => $val->q2 * 1 - ,'q3' => $val->q3 * 1 - ,'max' => $val->max - ] + ,'max' => $val->max + ,'min' => $val->min + ,'q1' => $val->q1 * 1 + ,'q2' => $val->q2 * 1 + ,'q3' => $val->q3 * 1 + ,'zhongshu' => $val->zhongshu + ,'zhongweishu' => $val->zhongweishu + ,'chashenglv' => $val->chashenglv ]; }else{ $data[$value->banji_id]['quanke'] = [ @@ -298,9 +304,7 @@ class TongjiBj extends BaseModel }, 'bjJieguo' => function ($query) { - $query->field('id, teacher_id, subject_id, banji_id, stu_cnt, - chengji_cnt, avg, youxiu, jige, biaozhuncha, - max, min, q1, q2, q3') + $query ->with([ 'bjSubject' => function($q){ $q->field('id, lieming, jiancheng, title'); @@ -627,7 +631,7 @@ class TongjiBj extends BaseModel $ksid = $this->getAttr('kaoshi_id'); return $this->hasMany('\app\chengji\model\TongjiBj', 'banji_id', 'banji_id') ->where('kaoshi_id', $ksid) - ->append(['youxiulv', 'jigelv']); + ->append(['youxiulv', 'jigelv', 'chashenglv']); } @@ -696,7 +700,7 @@ class TongjiBj extends BaseModel } - // 获取优秀率 + // 获取及格率 public function getJigelvAttr() { $jige = 0; @@ -708,4 +712,18 @@ class TongjiBj extends BaseModel return $jige; } + + + // 差生率 + function getChashenglvAttr() + { + $cjCnt = $this->chengji_cnt; + $chaCnt = $cjCnt - $this->jige; + $chalv = 0; + if ($cjCnt > 0) { + $chalv = round($chaCnt / $cjCnt * 100, 2); + } + + return $chalv; + } } diff --git a/app/chengji/model/TongjiNj.php b/app/chengji/model/TongjiNj.php index 6915ae04..9c821528 100755 --- a/app/chengji/model/TongjiNj.php +++ b/app/chengji/model/TongjiNj.php @@ -76,21 +76,27 @@ class TongjiNj extends BaseModel 'school_id' => $school['id'], 'ruxuenian' => $nianji['ruxuenian'], 'subject_id' => $cj['id'], - 'stu_cnt' => $cj['stucnt'], - 'chengji_cnt' => $cj['xkcnt'], - 'sum' => $cj['sum'], - 'avg' => $cj['avg'], - 'biaozhuncha' => $cj['biaozhuncha'], - 'youxiu' => $cj['youxiu'], - 'jige' => $cj['jige'], - 'max' => $cj['max'], - 'min' => $cj['min'], - 'q1' => $cj['sifenwei'][0], - 'q2' => $cj['sifenwei'][1], - 'q3' => $cj['sifenwei'][2], - 'zhongshu' => $cj['zhongshu'], - 'zhongweihu' => $cj['zhongweishu'], - 'defenlv' => $cj['defenlv'], + + + 'title' => $val->bjSubject->title + ,'jiancheng' => $val->bjSubject->jiancheng + ,'stu_cnt' => $val->stu_cnt + ,'chengji_cnt' => $val->chengji_cnt + ,'sum' => $val->sum + ,'avg' => $val->avg * 1 + ,'defenlv' => $val->defenlv + ,'biaozhuncha' => $val->biaozhuncha * 1 + ,'youxiu' => $val->youxiu + ,'jige' => $val->jige + ,'youxiulv' => $val->youxiulv + ,'jigelv' => $val->jigelv + ,'max' => $val->max + ,'min' => $val->min + ,'q1' => $val->q1 * 1 + ,'q2' => $val->q2 * 1 + ,'q3' => $val->q3 * 1 + ,'zhongshu' => $val->zhongshu + ,'zhongweishu' => $val->zhongweishu ]; $data = $this::create($tongjiJg); @@ -139,8 +145,7 @@ class TongjiNj extends BaseModel $query->field('id, paixu, jiancheng'); }, 'njJieguo' => function ($query) { - $query->field('subject_id, school_id, ruxuenian, stu_cnt, chengji_cnt, - avg, youxiu, jige, biaozhuncha, max, min, q1, q2, q3, zhongshu, zhongweishu') + $query ->with([ 'njSubject' => function($query){ $query->field('id, lieming, jiancheng, title'); diff --git a/app/chengji/view/bjtongji/biaoge.html b/app/chengji/view/bjtongji/biaoge.html index 608258c8..8b3db9a4 100755 --- a/app/chengji/view/bjtongji/biaoge.html +++ b/app/chengji/view/bjtongji/biaoge.html @@ -82,22 +82,28 @@ // 获取学科 var xk = ''; xk = eval(decodeURIComponent(xk)); - var xiangmu = {cjCnt:'人数',avg:'平均分',jigelv:'及格率%',youxiulv:'优秀率%'}; // 要显示哪些统计结果 + + var xiangmu = ''; + xiangmu = eval(decodeURIComponent(xiangmu)); + xiangmuCnt = xiangmu.length; + + // var xiangmu = {cjCnt:'人数',avg:'平均分',jigelv:'及格率%',youxiulv:'优秀率%'}; // 要显示哪些统计结果 $.each(xk,function(index,value){ - options.cols[0].push({title: xk[index].title+'('+xk[index].fenshuxian.manfen+')',colspan:4,align:'center'}); + options.cols[0].push({title: xk[index].title+'('+xk[index].fenshuxian.manfen+')',colspan:xiangmuCnt,align:'center'}); $.each(xiangmu,function(i,val){ var colname = xk[index].lieming; var colinfo = { - title:val + title:val.title ,minWidth:100 ,templet:function(d){ var str = ""; + console.log(d); if(d.chengji) { if(d.chengji[colname]) { - str = d.chengji[colname][i]; + str = d.chengji[colname][val.biaoshi]; } } return str; diff --git a/app/common.php b/app/common.php index d9e16223..aeaa5d49 100755 --- a/app/common.php +++ b/app/common.php @@ -50,6 +50,15 @@ } + // 查询统计项目 + function srcTjxm() + { + $tjxm = new \app\kaoshi\model\TongjiXiangmu; + $data = $tjxm->srcTongji(); + return $data; + } + + // // 单位列表 // function schoolXueduan($low = '幼儿园', $high = '其它学段', $order = 'asc') // { diff --git a/app/index/controller/Index.php b/app/index/controller/Index.php index babc67fb..e3b16ea9 100755 --- a/app/index/controller/Index.php +++ b/app/index/controller/Index.php @@ -15,7 +15,7 @@ class Index extends AdminBase // 获取信息 $sysbasemod = new sysbasemod(); # 关键字 $list = $sysbasemod::sysInfo(); # 描述 - $list['webtitle'] = config('shangma.webtitle'); # 系统名称 + // $list['webtitle'] = config('shangma.webtitle'); # 系统名称 $list['version'] = config('shangma.version'); # 版本号 $ad = new \app\admin\model\Admin; # 获取用户姓名 $list->xingming = $ad->where('id', session('user_id'))->value('xingming'); diff --git a/app/index/view/index/index.html b/app/index/view/index/index.html index 68a5dcbf..0ff746d3 100755 --- a/app/index/view/index/index.html +++ b/app/index/view/index/index.html @@ -2,7 +2,7 @@ - {$list['webtitle']} {$list['version']} + {$list['sys_title']} {$list['version']} @@ -39,7 +39,7 @@
+ {$list['sys_title']}
diff --git a/app/kaoshi/controller/Index.php b/app/kaoshi/controller/Index.php index 3718a9df..8e557e86 100755 --- a/app/kaoshi/controller/Index.php +++ b/app/kaoshi/controller/Index.php @@ -191,6 +191,41 @@ class Index extends AdminBase } + // 删除考试 + public function delete($id) + { + // 整理数据 + $id = request()->delete('id'); + $id = explode(',', $id); + + $data = KS::destroy($id); + $data ? $data = ['msg' => '删除成功', 'val' => 1] + : $data = ['msg' => '数据处理错误', 'val' => 0]; + + // 返回信息 + return json($data); + } + + + // 设置考试状态 + public function setStatus() + { + // 获取id变量 + $id = request()->post('id'); + $value = request()->post('value'); + + // 获取考试信息 + $data = KS::where('id', $id)->update(['status' => $value]); + + // 根据更新结果设置返回提示信息 + $data ? $data = ['msg' => '状态设置成功', 'val' => 1] + : $data = ['msg' => '数据处理错误', 'val' => 0]; + + // 返回信息 + return json($data); + } + + // 考试更多操作页面 public function moreAction($kaoshi_id) { diff --git a/app/kaoshi/controller/TongjiXiangmu.php b/app/kaoshi/controller/TongjiXiangmu.php index ce257d88..7e535436 100755 --- a/app/kaoshi/controller/TongjiXiangmu.php +++ b/app/kaoshi/controller/TongjiXiangmu.php @@ -50,6 +50,7 @@ class TongjiXiangmu extends AdminBase ,'title' ,'biaoshi' ,'tongji' + ,'paixu' ,'status' ,'update_time' ]); @@ -93,6 +94,7 @@ class TongjiXiangmu extends AdminBase 'title' ,'biaoshi' ,'tongji' + ,'paixu' ], 'post'); // 验证表单数据 @@ -125,7 +127,7 @@ class TongjiXiangmu extends AdminBase { // 获取考试信息 $list['data'] = tjxm::where('id', $id) - ->field('id, title, biaoshi, tongji') + ->field('id, title, biaoshi, tongji, paixu') ->find(); // 设置页面标题 @@ -153,9 +155,10 @@ class TongjiXiangmu extends AdminBase { // 获取表单数据 $list = request()->only([ - 'title', - 'biaoshi', - 'tongji' + 'title' + ,'biaoshi' + ,'tongji' + ,'paixu' ], 'post'); $list['id'] = $id; diff --git a/app/kaoshi/model/TongjiXiangmu.php b/app/kaoshi/model/TongjiXiangmu.php index e8cf5f11..3954d4cf 100755 --- a/app/kaoshi/model/TongjiXiangmu.php +++ b/app/kaoshi/model/TongjiXiangmu.php @@ -29,4 +29,31 @@ class TongjiXiangmu extends BaseModel return $data; } + + + // 统计获取器 + public function getTongjiAttr($value) + { + $jg = 0; + if($value === 1) + { + $jg = '参与'; + }else{ + $jg = '不参与'; + } + return $jg; + } + + + // 查询统计 + public function srcTongji() + { + $data = $this->where('status', 1) + ->where('tongji', 1) + ->field('title, biaoshi') + ->order(['paixu']) + ->select() + ->toArray(); + return $data; + } } diff --git a/app/kaoshi/view/tongji_xiangmu/create.html b/app/kaoshi/view/tongji_xiangmu/create.html index 5c3a8dcc..bcc4a35e 100755 --- a/app/kaoshi/view/tongji_xiangmu/create.html +++ b/app/kaoshi/view/tongji_xiangmu/create.html @@ -20,6 +20,15 @@ autocomplete="off" class="layui-input " value="{$list.data.biaoshi|default=''}" placeholder="1-25个字符"> +
+ +
+ +
+
diff --git a/app/kaoshi/view/tongji_xiangmu/index.html b/app/kaoshi/view/tongji_xiangmu/index.html index 347aef6b..a043ccf9 100755 --- a/app/kaoshi/view/tongji_xiangmu/index.html +++ b/app/kaoshi/view/tongji_xiangmu/index.html @@ -42,7 +42,7 @@