From fcfb1874334f778c5450fd153c7accde124537e6 Mon Sep 17 00:00:00 2001 From: cxdbz Date: Sun, 1 Mar 2020 12:27:56 +0800 Subject: [PATCH] =?UTF-8?q?=E4=BF=AE=E6=94=B9=E5=AD=A6=E7=94=9F=E4=BF=A1?= =?UTF-8?q?=E6=81=AF?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .example.env | 2 +- README.md | 10 +- app/BaseController.php | 3 +- app/admin/model/AuthGroupAccess.php | 6 +- app/chengji/common.php | 18 + app/chengji/controller/Bjtongji.php | 23 +- app/chengji/controller/Index.php | 71 +- app/chengji/controller/Luru.php | 61 +- app/chengji/controller/Njtongji.php | 21 +- app/chengji/controller/Schtongji.php | 23 +- app/chengji/controller/Tongji.php | 32 + app/chengji/model/Chengji.php | 129 +- app/chengji/model/Tongji.php | 160 +- app/chengji/model/TongjiBj.php | 69 +- app/chengji/model/TongjiNj.php | 70 +- app/chengji/model/TongjiSch.php | 44 + app/chengji/route/chengji.php | 4 + app/chengji/view/bjtongji/biaoge.html | 50 +- app/chengji/view/index/index.html | 14 +- app/chengji/view/njtongji/biaoge.html | 31 +- app/event.php | 5 +- app/event/KaoshiStatus.php | 25 + app/kaoshi/controller/Index.php | 145 +- app/kaoshi/controller/Kaohao.php | 81 +- app/kaoshi/controller/KaoshiSet.php | 20 +- app/kaoshi/model/Kaohao.php | 224 +- app/kaoshi/model/Kaoshi.php | 69 +- app/kaoshi/view/index/index.html | 19 + app/kaoshi/view/index/more_action.html | 50 +- app/listener/KaoshiStatus.php | 21 + app/login/view/index/index.html | 2 +- app/login/view/index/myerror.html | 3 - app/login/view/index/shangma_log.html | 20 + app/middleware/Auth.php | 2 +- app/renshi/controller/Student.php | 186 +- app/renshi/model/Student.php | 7 +- app/renshi/view/student/read.html | 133 +- config/cache.php | 2 +- config/middleware.php | 10 +- config/shangma.php | 4 +- .../migrations/20181010035225_system_base.php | 12 +- .../migrations/20181010075304_auth_group.php | 8 +- .../20181010075517_auth_group_access.php | 2 + .../migrations/20181010075553_auth_rule.php | 8 +- database/migrations/20181012140355_member.php | 10 +- .../migrations/20181025041505_category.php | 6 +- database/migrations/20181026002455_school.php | 8 +- .../migrations/20181028023517_teacher.php | 12 +- database/migrations/20181028024920_xueqi.php | 14 +- database/migrations/20181028025648_kaoshi.php | 16 +- .../migrations/20181030024954_subject.php | 16 +- database/migrations/20181101040801_fields.php | 18 +- .../migrations/20181102003411_student.php | 14 +- database/migrations/20181102004156_banji.php | 11 +- database/migrations/20181114055804_kaohao.php | 18 +- .../migrations/20181218041034_dw_rongyu.php | 20 +- .../migrations/20181221041509_js_rongyu.php | 12 +- .../20181221041523_js_rongyu_info.php | 8 +- .../20181227061353_dw_rongyu_canyu.php | 7 +- .../20190214052203_js_rongyu_canyu.php | 7 +- database/migrations/20190218055858_keti.php | 12 +- .../migrations/20190222040223_keti_info.php | 4 +- .../migrations/20190222041040_keti_canyu.php | 7 +- .../migrations/20190430034853_chengji.php | 22 +- .../migrations/20200106012240_tongji_nj.php | 38 +- .../migrations/20200106013922_tongji_bj.php | 36 +- .../migrations/20200107045207_tongji_sch.php | 36 +- .../migrations/202001132733_kaoshi_set.php | 18 +- database/seeds/Category.php | 2 - database/seeds/Rule.php | 53 +- database/seeds/SystemBase.php | 4 +- public/static/echarts/dataTool.js | 872 - public/static/echarts/echarts-gl.js | 56990 --------- public/static/echarts/echarts.js | 97412 ++++++++++++++++ public/static/echarts/echarts.min.js | 16 - view/list.html | 23 +- 76 files changed, 98805 insertions(+), 58836 deletions(-) create mode 100644 app/event/KaoshiStatus.php create mode 100644 app/listener/KaoshiStatus.php delete mode 100644 public/static/echarts/dataTool.js delete mode 100644 public/static/echarts/echarts-gl.js create mode 100644 public/static/echarts/echarts.js delete mode 100644 public/static/echarts/echarts.min.js diff --git a/.example.env b/.example.env index 99e83162..c5f0e1f7 100644 --- a/.example.env +++ b/.example.env @@ -1 +1 @@ -APP_DEBUG = false [APP] DEFAULT_TIMEZONE = Asia/Shanghai [DATABASE] TYPE = mysql HOSTNAME = 127.0.0.1 DATABASE = chengji USERNAME = username PASSWORD = password HOSTPORT = 3306 CHARSET = utf8 DEBUG = false [LANG] default_lang = zh-cn \ No newline at end of file +APP_DEBUG = false [APP] DEFAULT_TIMEZONE = Asia/Shanghai [DATABASE] TYPE = mysql HOSTNAME = 127.0.0.1 DATABASE = mysql USERNAME = username PASSWORD = password HOSTPORT = 3306 CHARSET = utf8 PREFIX = cj_ DEBUG = false [LANG] default_lang = zh-cn \ No newline at end of file diff --git a/README.md b/README.md index 707fadc2..5cdbcb57 100644 --- a/README.md +++ b/README.md @@ -1,5 +1,5 @@  -# 尚码免费成绩管理系统 +# 码蚁免费成绩管理系统   坦率地讲,在不久的将来,这也许会是辽东半岛上第二好用的成绩统计系统。如果你觉得还可以,还不赶紧 Watch 、 Start 一下。如果觉得不好,何不给个改进意见再离开,反正已经来了,是吧? @@ -122,8 +122,7 @@ 更多更新日志(http://www.xiaoshongshu.cn/login/log) ## 升级提示 -  v1.2.3版升级到v1.3.1版本,请重新运行 php think migrate:run 命令,重新设置参加考试年级、学科,并重新统计成绩。 - 其它版本升级到v1.3.1版本,建议重新建表。 + v1.3.1升级到v1.3.2版本时,对 cj_chengji 、 cj_tongji_bj 、 cj_tongji_nj 、 cj_tongji_sch 几个做的字段作了调整,具体调整,请参考号 database/migrations 文件下对应的文件,如果已经存在数据的话,建议重新建表并执行结构同步。如果有没数据可以重新建表。 ## 更详细信息请查阅官方手册 @@ -133,4 +132,7 @@ https://www.kancloud.cn/llblax/abcd/789222 * 继续增加统计项目 * 以更多图表形式呈现统计结果 * 增加教师职务权限验证 -* 增加学生自助查询成绩 \ No newline at end of file +* 增加学生自助查询成绩 + +## 求助 +* 一直想给这个项目起个名字,想了几个都不合适,朋友们能给一个好名字的话兄弟会非常感谢! \ No newline at end of file diff --git a/app/BaseController.php b/app/BaseController.php index 2b6b7046..c4a5456b 100644 --- a/app/BaseController.php +++ b/app/BaseController.php @@ -40,8 +40,7 @@ abstract class BaseController * @var array */ protected $middleware = [ - UserLogin::class, - Auth::class, + 'userlogin','auth' ]; /** diff --git a/app/admin/model/AuthGroupAccess.php b/app/admin/model/AuthGroupAccess.php index b8cede76..3fc19d4c 100644 --- a/app/admin/model/AuthGroupAccess.php +++ b/app/admin/model/AuthGroupAccess.php @@ -2,10 +2,12 @@ namespace app\admin\model; +// // 引用用户数据模型 +// use think\model\Pivot; // 引用用户数据模型 -use think\model\Pivot; +use app\common\model\Base; -class AuthGroupAccess extends Pivot +class AuthGroupAccess extends Base { // } diff --git a/app/chengji/common.php b/app/chengji/common.php index 8169db1a..d4b4c7b1 100644 --- a/app/chengji/common.php +++ b/app/chengji/common.php @@ -144,4 +144,22 @@ function manfenvalidate($defen,$manfen) ]; return $data; + } + + /** + * 把给定的成绩进行排序 + * @access public + * @param array $arr 要计算的一维数组成绩 + * @return array $result 返回成绩排序结果 + */ + function tjOrder($cj,$type = 'desc') + { + if($type == 'desc') + { + arsort($cj); + }else{ + asort($cj); + } + + return $cj; } \ No newline at end of file diff --git a/app/chengji/controller/Bjtongji.php b/app/chengji/controller/Bjtongji.php index 08cca982..20814e35 100644 --- a/app/chengji/controller/Bjtongji.php +++ b/app/chengji/controller/Bjtongji.php @@ -290,7 +290,9 @@ class Bjtongji extends BaseController public function tongji() { // 获取变量 - $kaoshi = input('post.kaoshi'); + $kaoshi = input('post.kaoshi'); + // 判断考试状态 + event('ksstatus',$kaoshi); // 统计成绩 $btj = new BTJ; @@ -303,6 +305,25 @@ class Bjtongji extends BaseController + // 统计学生在班级名次 + public function bjOrder() + { + // 获取变量 + $kaoshi = input('post.kaoshi'); + // 判断考试状态 + event('ksstatus',$kaoshi); + + // 统计成绩 + $btj = new BTJ; + $data = $btj->bjOrder($kaoshi); + + $data == true ? $data=['msg'=>'学生成绩在班级位置统计完成。','val'=>1] : $data=['msg'=>'数据处理错误','val'=>0]; + + return json($data); + } + + + // 统计平均分优秀率及格率 diff --git a/app/chengji/controller/Index.php b/app/chengji/controller/Index.php index 190d9df3..4193ad83 100644 --- a/app/chengji/controller/Index.php +++ b/app/chengji/controller/Index.php @@ -50,31 +50,18 @@ class Index extends BaseController { // 获取参数 $src = $this->request - ->only(['page','limit','field','order','kaoshi','school','ruxuenian','banjiids'=>array(),'searchval' + ->only(['page','limit','field','order','kaoshi','school','ruxuenian','banji'=>array(),'searchval' ],'POST'); // 获取参与考试的班级 - if(count($src['banjiids'])==0){ + if(count($src['banji'])==0){ $kh = new \app\kaoshi\model\Kaohao; - $src['banjiids']= array_column($kh->cyBanji($src), 'id'); + $src['banji']= array_column($kh->cyBanji($src), 'id'); } - - $srcform = [ - // 'page'=>$src['page'], - // 'limit'=>$src['limit'], - // 'field'=>$src['field'], - // 'order'=>$src['order'], - 'kaoshi'=>$src['kaoshi'], - 'banji'=>$src['banjiids'], - ]; - - - // 实例化 + // 实例化并查询成绩 $cj = new Chengji; - - // 查询要显示的数据 - $data = $cj->search($srcform); + $data = $cj->search($src); // 获取符合条件记录总数 $cnt = count($data); @@ -100,13 +87,6 @@ class Index extends BaseController public function deletecjs($kaoshi) { - // 判断考试结束时间是否已过 - $enddate = kaoshiDate($kaoshi,'enddate'); - if($enddate === true) - { - $this->error('考试时间已过,不能删除成绩','/login/err'); - } - // 设置页面标题 $list['set'] = array( 'webtitle'=>'批量删除成绩', @@ -140,6 +120,9 @@ class Index extends BaseController $banji = $src['banjiids']; $subject = $src['subject']; + // 判断考试状态 + event('ksstatus',$src['kaoshi']); + // 获取要删除成绩的考号 $kaohao = new \app\kaoshi\model\Kaohao; $kaohaolist = $kaohao::where('kaoshi',$src['kaoshi']) @@ -183,12 +166,8 @@ class Index extends BaseController $khid = Chengji::where('id',$id['0'])->value('kaohao_id'); $kaoshiid = Kaohao:: where('id',$khid)->value('Kaoshi'); - // 判断考试结束时间是否已过 - $enddate = kaoshiDate($kaoshiid,'enddate'); - if($enddate === true) - { - $this->error('考试时间已过,不能删除成绩','/login/err'); - } + // 判断考试状态 + event('ksstatus',$kaoshiid); $data = Chengji::destroy($id); @@ -203,23 +182,23 @@ class Index extends BaseController - // 设置成绩状态 - public function setStatus() - { + // // 设置成绩状态 + // public function setStatus() + // { - // 获取id变量 - $id = request()->post('id'); - $value = request()->post('value'); + // // 获取id变量 + // $id = request()->post('id'); + // $value = request()->post('value'); - // 获取班级信息 - $data = Chengji::where('id',$id)->update(['status'=>$value]); + // // 获取班级信息 + // $data = Chengji::where('id',$id)->update(['status'=>$value]); - // 根据更新结果设置返回提示信息 - $data ? $data=['msg'=>'状态设置成功','val'=>1] : $data=['msg'=>'数据处理错误','val'=>0]; + // // 根据更新结果设置返回提示信息 + // $data ? $data=['msg'=>'状态设置成功','val'=>1] : $data=['msg'=>'数据处理错误','val'=>0]; - // 返回信息 - return json($data); - } + // // 返回信息 + // return json($data); + // } @@ -592,9 +571,9 @@ class Index extends BaseController $sheet->setCellValue('G'.$row, '优秀率%'); $sheet->setCellValue('H'.$row, '及格率%'); $sheet->setCellValue('I'.$row, '最高分'); - $sheet->setCellValue('J'.$row, '%75'); + $sheet->setCellValue('J'.$row, '%25'); $sheet->setCellValue('K'.$row, '%50'); - $sheet->setCellValue('L'.$row, '%25'); + $sheet->setCellValue('L'.$row, '%75'); $row = $row + 1 ; diff --git a/app/chengji/controller/Luru.php b/app/chengji/controller/Luru.php index 97f25f5e..e88000e8 100644 --- a/app/chengji/controller/Luru.php +++ b/app/chengji/controller/Luru.php @@ -28,7 +28,6 @@ class Luru extends BaseController ->field('id,title,jiancheng') ->select(); - // 模板赋值 $this->view->assign('list',$list); // 渲染 @@ -79,11 +78,6 @@ class Luru extends BaseController } - - - - - // 使用二维码录入成绩 public function malu() { @@ -107,22 +101,17 @@ class Luru extends BaseController { // 获取表单数据 $list = $this->request->only(['kaohao_id','subject_id','nianji','defen'],'post'); + $kaoshiid = Kaohao::where('id',$list['kaohao_id'])->value('kaoshi'); - // 判断考试结束时间是否已过 - $enddate = kaoshiDate($kaoshiid,'enddate'); - if($enddate === true) - { - $data=['msg'=>'考试时间已过,不能录入成绩','val'=>0]; - return json($data); - } - + // 判断考试状态 + event('ksstatus',$kaoshiid); + // // 根据考号获取学生年在年级及考试ID - // $kh = new \app\kaoshi\model\Kaohao; - // $khinfo = $kh->where('id',$list['k'])->find(); // 获取本学科满分 $ksset = new \app\kaoshi\model\KaoshiSet; $subject = $ksset->srcSubject($kaoshiid,$list['subject_id'],$list['nianji']); + if(count($subject)>0) { $manfen = $subject[0]['fenshuxian']['manfen']; @@ -148,7 +137,7 @@ class Luru extends BaseController if($cjone) { // 判断记录是否被删除 - if($cjone->delete_time > 1) + if($cjone->delete_time > 0) { $cjone->restore(); } @@ -160,6 +149,7 @@ class Luru extends BaseController } $cjone->defen = $list['defen']; + $cjone->defenlv = $list['defen'] / $manfen * 100; $data = $cjone->save(); }else{ @@ -167,7 +157,8 @@ class Luru extends BaseController 'kaohao_id'=>$list['kaohao_id'], 'subject_id'=>$list['subject_id'], 'user_id'=>session('userid'), - 'defen'=>$list['defen'] + 'defen'=>$list['defen'], + 'defenlv' => $list['defen'] / $manfen * 100, ]; $data = Chengji::create($data); } @@ -192,13 +183,8 @@ class Luru extends BaseController // 判断考试结束时间是否已过 $kaoshiid = Kaohao::where('id',$list['kaohao_id'])->value('kaoshi'); - $enddate = kaoshiDate($kaoshiid,'enddate'); - if($enddate === true) - { - $data=['msg'=>'考试时间已过,不能录入成绩','val'=>0]; - return json($data); - } - + // 判断考试状态 + event('ksstatus',$kaoshiid); // 获取学科id $subject = new \app\teach\model\Subject; @@ -249,6 +235,7 @@ class Luru extends BaseController } $cjone->defen = $list['newdefen']; + $cjone->defenlv = $list['newdefen'] / $manfen * 100; $data = $cjone->save(); }else{ @@ -256,7 +243,8 @@ class Luru extends BaseController 'kaohao_id'=>$list['kaohao_id'], 'subject_id'=>$subject_id, 'user_id'=>session('userid'), - 'defen'=>$list['newdefen'] + 'defen'=>$list['newdefen'], + 'defenlv'=>$list['newdefen'] / $manfen * 100, ]; $data = Chengji::create($data); } @@ -370,13 +358,8 @@ class Luru extends BaseController $data=['msg'=>'请使用模板上传','val'=>0]; return json($data); } - // 判断考试结束时间是否已过 - $enddate = kaoshiDate($kaoshiid,'enddate'); - if($enddate === true) - { - $data=['msg'=>'考试时间已过,不能录入成绩','val'=>0]; - return json($data); - } + // 判断考试状态 + event('ksstatus',$kaoshiid); // 删除空单元格得到学科列名数组 array_splice($cjinfo[1],0,4); @@ -412,8 +395,15 @@ class Luru extends BaseController if($defen === null){ continue; } + // 验证成绩格式,如果不对则跳过 - $mfyz = manfenvalidate($defen,$value['fenshuxian']['manfen']); + if(isset($value['fenshuxian']['manfen'])) + { + $manfen = $value['fenshuxian']['manfen']; + }else{ + $manfen = ""; + } + $mfyz = manfenvalidate($defen,$manfen); if($mfyz['val'] == 0) { continue; @@ -432,6 +422,7 @@ class Luru extends BaseController { $cjone->restore(); $cjone->defen = $defen; + $cjone->defenlv = $defen/$manfen*100; $cjone->save(); } }else{ @@ -440,7 +431,7 @@ class Luru extends BaseController 'kaohao_id'=>$val[1], 'subject_id'=>$value['id'], 'user_id'=>$user_id, - 'defen'=>$defen + 'defen'=>$defen/$manfen*100, ]; Chengji::create($data); } diff --git a/app/chengji/controller/Njtongji.php b/app/chengji/controller/Njtongji.php index 22415e47..a9a6915b 100644 --- a/app/chengji/controller/Njtongji.php +++ b/app/chengji/controller/Njtongji.php @@ -264,7 +264,8 @@ class Njtongji extends BaseController { // 获取变量 $kaoshi = input('post.kaoshi'); - + // 判断考试状态 + event('ksstatus',$kaoshi); // 统计成绩 $ntj = new NTJ; $data = $ntj->tjNianji($kaoshi); @@ -275,6 +276,24 @@ class Njtongji extends BaseController } + // 统计学生在班级名次 + public function njOrder() + { + // 获取变量 + $kaoshi = input('post.kaoshi'); + // 判断考试状态 + event('ksstatus',$kaoshi); + + // 统计成绩 + $ntj = new NTJ; + $data = $ntj->njOrder($kaoshi); + + $data == true ? $data=['msg'=>'学生成绩在班级位置统计完成。','val'=>1] : $data=['msg'=>'数据处理错误','val'=>0]; + + return json($data); + } + + // 统计平均分优秀率及格率 public function myAvg($kaoshi) { diff --git a/app/chengji/controller/Schtongji.php b/app/chengji/controller/Schtongji.php index 5cdd071b..478ccf3f 100644 --- a/app/chengji/controller/Schtongji.php +++ b/app/chengji/controller/Schtongji.php @@ -13,7 +13,8 @@ class Schtongji { // 获取变量 $kaoshi = input('post.kaoshi'); - + // 判断考试状态 + event('ksstatus',$kaoshi); // 统计成绩 $schtj = new SCHTJ; $data = $schtj->tjSchool($kaoshi); @@ -22,4 +23,24 @@ class Schtongji return json($data); } + + + // 统计学生在班级名次 + public function schOrder() + { + // 获取变量 + $kaoshi = input('post.kaoshi'); + // 判断考试状态 + event('ksstatus',$kaoshi); + + // 统计成绩 + $schtj = new SCHTJ; + $data = $schtj->schOrder($kaoshi); + + $data == true ? $data=['msg'=>'学生成绩在班级位置统计完成。','val'=>1] : $data=['msg'=>'数据处理错误','val'=>0]; + + return json($data); + } + + } diff --git a/app/chengji/controller/Tongji.php b/app/chengji/controller/Tongji.php index 03d06bdc..f718cd66 100644 --- a/app/chengji/controller/Tongji.php +++ b/app/chengji/controller/Tongji.php @@ -85,4 +85,36 @@ class Tongji extends BaseController } + public function newJieguo() + { + // 获取成绩最后修改时间 + $cj = new \app\chengji\model\Chengji; + $cj = $cj->order(['update_time'=>'desc'])->find(); + $cj = $cj->getData('update_time'); + + // 分别获取班级、年级、学校统计结果更新时间 + $bj = new \app\chengji\model\TongjiBj; + $bj = $bj->order(['update_time'=>'desc'])->find(); + $bj = $bj->getData('update_time'); + + $nj = new \app\chengji\model\TongjiNj; + $nj = $nj->order(['update_time'=>'desc'])->find(); + $nj = $nj->getData('update_time'); + + $sch = new \app\chengji\model\TongjiSch; + $sch = $sch->order(['update_time'=>'desc'])->find(); + $sch = $sch->getData('update_time'); + + if($cj>=$bj || $cj>=$nj || $cj>=$sch) + { + $data=['msg'=>'不是最新结果,重算一下!','val'=>0]; + }else{ + $data=['msg'=>'是最新结果,不用算啦~','val'=>1]; + } + + return json($data); + + } + + } diff --git a/app/chengji/model/Chengji.php b/app/chengji/model/Chengji.php index 657c094c..b6320729 100644 --- a/app/chengji/model/Chengji.php +++ b/app/chengji/model/Chengji.php @@ -51,12 +51,6 @@ class Chengji extends Base $kaoshi = $src['kaoshi']; $searchval = $src['searchval']; - // $ks = new \app\kaoshi\model\Kaoshi; - // $bfdate = $ks->where('id',$kaoshi) - // ->value('bfdate'); - // // $nj = nianjiList($bfdate); - // $ksset = new \app\kaoshi\model\KaoshiSet; - // $nianji = $ksset->srcNianji($src['kaoshi']); $stu = new \app\renshi\model\Student; $stuid = $stu ->when(strlen($searchval)>0,function($query)use($searchval){ @@ -160,6 +154,7 @@ class Chengji extends Base // 以考号为基础查询成绩 $chengjilist = $kh->srcChengji($src); + // 按条件排序 $src['order'] == 'desc' ? $src['order'] =SORT_DESC :$src['order'] = SORT_ASC; if(count($chengjilist)>0){ @@ -169,5 +164,127 @@ class Chengji extends Base return $chengjilist; } + + + + /** + * 把给定的成绩进行排序 + * @access public + * @param array $cj 要计算的一维数组成绩 + * @param array $col 0=>paixu,1=>weizhi + * @param int $xm 项目 0=>学科得分,1=>平均分,2=>总分 + * @param int $jibie 级别 1=>班级,2=>年级,3=>区 + * @return array $result 返回成绩排序结果 + */ + public function saveOrder($cj,$col) + { + $cnt = count($cj); # 获取元素数量 + if($cnt == 0) + { + return true; + } + + arsort($cj); + $khids = array_keys($cj); # 获取考号即键值 + $data = array(); # 新数据容器 + + foreach ($khids as $key => $value) { + $data[$key]['id'] = $value; + $data[$key][$col[0]] = $key +1 ; + if($key > 0 && $cj[$khids[$key-1]] == $cj[$value]) + { + $data[$key][$col[0]] = $data[$key-1][$col[0]]; + } + $data[$key][$col[1]] = 1 - ($data[$key][$col[0]]-1)/$cnt; + $data[$key][$col[1]] = round($data[$key][$col[1]] * 100 , 2) ; + } + + $temp = $this->saveAll($data); + + return true; + } + + + + /** + * 学生个人成绩列表 + * @access public + * @param array $cj 要计算的一维数组成绩 + * @param array $col 0=>paixu,1=>weizhi + * @param int $xm 项目 0=>学科得分,1=>平均分,2=>总分 + * @param int $jibie 级别 1=>班级,2=>年级,3=>区 + * @return array $result 返回成绩排序结果 + */ + public function oneChengji($srcfrom) + { + // 初始化参数 + $src = array( + 'student'=>'', + 'kaoshi'=>array(), + ); + + // 用新值替换初始值 + $src = array_cover( $srcfrom , $src ); + + $kh = new \app\kaoshi\model\Kaohao; + $stuCj = $kh->srcOneStudentChengji($src); + + + // 获取可以参加考试的学科 + $sbj = new \app\teach\model\Subject; + $sbjList = $sbj->where('kaoshi',1) + ->where('status',1) + ->field('id,lieming') + ->column('lieming','id'); + + // 整理数据 + $data = array(); + foreach ($stuCj as $key => $value) { + $data[$key] = [ + 'kaoshiId'=>$value->kaoshi, + 'kaoshiTitle'=>$value->cjKaoshi->title, + 'kaohaoId'=>$value->id, + 'banjiTitle'=>$value->banjiTitle, + 'zuzhi'=>$value->cjKaoshi->ksZuzhi->jiancheng, + 'category'=>$value->cjKaoshi->ksCategory->title, + 'bfdate'=>$value->cjKaoshi->bfdate, + 'enddate'=>$value->cjKaoshi->enddate, + ]; + + $cjcnt = count($value->ksChengji); + + if($cjcnt > 0) + { + $sbj = $value->ksChengji->column('subject_id'); + foreach ($sbjList as $sbj_k => $sbj_val) { + // 通过学科ID获取这个学科成绩对应的成绩下标。 + // 这个地方需要再核实。 + $xb = array_search($sbj_k, $sbj); # ksChengji下标 + if($xb === false) + { + $data[$key][$sbj_val] = ''; + }else{ + $data[$key][$sbj_val] = $value->ksChengji[$xb]->defen; + } + } + $defen = array_column($value->ksChengji->toArray(), 'defen'); + $sum = array_sum($defen ); + $avg = $sum / $cjcnt; + $data[$key]['sum'] = $sum; + $data[$key]['avg'] = round($avg,2); + }else{ + foreach ($sbjList as $sbj_k => $sbj_val) { + $data[$key][$sbj_val] = ''; + } + $data[$key]['sum'] = ''; + $data[$key]['avg'] = ''; + } + } + + return $data; + } + + + } diff --git a/app/chengji/model/Tongji.php b/app/chengji/model/Tongji.php index 2a70a6c4..ec682ee4 100644 --- a/app/chengji/model/Tongji.php +++ b/app/chengji/model/Tongji.php @@ -20,7 +20,6 @@ class Tongji extends Base $cjcol = array_filter($cjcol,function($item){ return $item != null; }); - $temp = array(); $temp['xkcnt'] = count($cjcol); $data[$value['lieming']] = $temp; @@ -54,68 +53,74 @@ class Tongji extends Base 'max'=>null, 'min'=>null, 'zhongshu'=>null, + 'defenlv'=>null, ]; + $data = array(); + $sbjdefencnt = 0; #记录试卷满分 // 循环统计各学科成绩 foreach ($subject as $key => $value) { + $sbjdefencnt = $sbjdefencnt + $value['fenshuxian']['manfen']; $cjcol = array_column($cj,$value['lieming']); $stucnt = count($cjcol); $cjcol = array_filter($cjcol,function($item){ return $item !== null; }); - $temp = array(); + $temp = $tempNull; + $temp['id'] = $value['id']; + $temp['stucnt'] = $stucnt; - if($cjcol==null) + if($cjcol!=null) { - $temp = $tempNull; - $temp['stucnt'] = $stucnt; - $temp['id'] = $value['id']; - }else{ $temp['xkcnt'] = count($cjcol); $temp['sum'] = array_sum($cjcol); - $temp['xkcnt']>0 ? $temp['avg'] = $temp['sum']/$temp['xkcnt'] : $temp['avg']=0; + if( $temp['xkcnt']>0) + { + $temp['avg'] = $temp['sum']/$temp['xkcnt']; + $temp['defenlv'] = $temp['avg'] / $value['fenshuxian']['manfen']; + } $temp['biaozhuncha'] = round($this->getVariance($temp['avg'], $cjcol,true),2); $temp['avg'] = round($temp['avg'],2); $temp['youxiu'] = $this->rate($cjcol,$value['fenshuxian']['youxiu']); $temp['jige'] = $this->rate($cjcol,$value['fenshuxian']['jige']); $temp['max'] = max($cjcol); $temp['min'] = min($cjcol); - $temp['sifenwei'] = $this->quartile($cjcol); + $temp['sifenwei'] = $this->myquartile($cjcol); $temp['zhongshu'] = ''; - $temp['stucnt'] = $stucnt; - $temp['id'] = $value['id']; + $temp['defenlv'] = round($temp['defenlv'] * 100,2); } $data['cj'][$value['lieming']] = $temp; } - $temp = array(); + $temp = $tempNull; $cjcol = array_column($cj,'sum'); - $$stucnt = count($cjcol); + $stucnt = count($cjcol); $cjcol = array_filter($cjcol,function($item){ return $item !== null; }); - if($cjcol==null){ - $temp = $tempNull; - $temp['stucnt'] = $stucnt; - $temp['id'] = 0; - }else{ + $temp['id'] = 0; + $temp['stucnt'] = $stucnt; + if($cjcol!=null){ $temp['xkcnt'] = count($cjcol); # 报名人数 $temp['sum'] = array_sum($cjcol); - $temp['xkcnt']>0 ? $temp['avg'] = $temp['sum']/$temp['xkcnt'] : $temp['avg']=0; + if( $temp['xkcnt']>0) + { + $temp['avg'] = $temp['sum']/$temp['xkcnt']; + $temp['defenlv'] = $temp['avg'] / $sbjdefencnt; + } $temp['biaozhuncha'] = round($this->getVariance($temp['avg'], $cjcol,true),2); $temp['avg'] = round($temp['avg'],2); $temp['max'] = max($cjcol); $temp['min'] = min($cjcol); $temp['youxiu'] = null; $temp['jige'] = $this->rateAll($cj,$subject); #全科及格率 - $temp['sifenwei'] = $this->quartile($cjcol); + $temp['sifenwei'] = $this->myquartile($cjcol); $temp['zhongshu'] = ''; - $temp['stucnt'] = $stucnt; - $temp['id'] = 0; + $temp['defenlv'] = round($temp['defenlv'] * 100,2); } $data['cj']['all'] = $temp; @@ -123,14 +128,6 @@ class Tongji extends Base } - - // 统计给定成绩 - public function tongjiArray($cj,$koashi) - { - - } - - // 统计优秀、及格率 public function rate($cj = array(),$fenshuxian) { @@ -210,88 +207,55 @@ class Tongji extends Base } - // 四分位 - public function quartile($items) { - // 获取数组长度 - $length = count($items); - if ($items == null || $length == 0) return $result = [0=>'',1=>'',2=>'']; - - if ($length < 5) return $result = [0=>'',1=>'',2=>'']; - $result = array(); - - sort($items); - - if ($length % 2 == 0) {//偶数 - $result[1] = ($items[$length/2 - 1] + $items[$length/2]) / 2; - } else {//奇数 - $result[1] = $items[($length + 1)/2 - 1]; - } - - if ($length % 4 == 0) { - $result[0] = ($items[$length/4 - 1] + $items[$length/4]) / 2; - $result[2] = ($items[3*$length/4 - 1] + $items[3*$length/4]) / 2; - } else { - $result[0] = $items[$length/4]; - $result[2] = $items[3*$length/4]; - } - - return $result; - } - - - // 自己写的四分位 + /** + * 计算四分位( Quartile ) Q1、Q2、Q3的值 + * @access public + * @param array $arr 要计算的一维数组 + * @return array $result 下标0-2 分别对应Q1、Q2、Q3 + */ public function myquartile($arr) { // 获取数组长度 $length = count($arr); + + // 如果数组为空或数组长度小于5时,返回空。 if ($arr == null || $length == 0) return $result = [0=>'',1=>'',2=>'']; - if ($length < 5) return $result = [0=>'',1=>'',2=>'']; - $result = array(); + // 数组排序 sort($arr); - if ($length % 2 == 0) {//偶数 - - // Q1 - $tempNum = ($length + 1 ) * 0.25; - $temp = intval($tempNum); - $tempNum = ceil($tempNum)-$tempNum; - $result[0] = $arr[$temp-1] * (1-$tempNum) + $arr[$temp] * $tempNum; + // 初始化变量 + $result = array(); #储存结果 + $q = array(); #储存位置 - // Q2 - $tempNum = ($length + 1 ) * 0.5; - $temp = intval($tempNum); - $tempNum = ceil($tempNum)-$tempNum; - $result[1] = $arr[$temp-1] * (1-$tempNum) + $arr[$temp] * $tempNum; - - // Q3 - $tempNum = ($length + 1 ) * 0.75; - $temp = intval($tempNum); - $tempNum = ceil($tempNum)-$tempNum; - $result[2] = $arr[$temp-1] * (1-$tempNum) + $arr[$temp] * $tempNum; - - - - } else {//奇数 - $tempNum = ($length + 1 ) * 0.25; - $result[0] = $arr[$tempNum-1]; - $tempNum = ($length + 1 ) * 0.5; - $result[1] = $arr[$tempNum-1]; - $tempNum = ($length + 1 ) * 0.75; - $result[2] = $arr[$tempNum-1]; + // 确定位置 + // 计算方法参考百度百科 + // 使用n-1方法。 + $q[0] = 1 + ($length - 1 ) * 0.25; + $q[1] = 1 + ($length - 1 ) * 0.5; + $q[2] = 1 + ($length - 1 ) * 0.75; + // n+1方法结果也对,但是与excel不相同 + // $q[0] = ($length + 1 ) * 0.25; + // $q[1] = ($length + 1 ) * 0.5; + // $q[2] = ($length + 1 ) * 0.75; + // 计算每个位置对应的值 + foreach ($q as $key => $value) { + if(is_int($value)) # 如果位置是整数,则直接取位置对应的值 + { + $result[$key] = $arr[$value-1]; + }else{ + # 如果位置不是整数。计算公式:大数*位置小数 + 小数*(1-位置小数) + $tempNum = $value; + $temp = intval($tempNum); + $tempNum = $tempNum - $temp; + $result[$key] = $arr[$temp] * $tempNum + $arr[$temp-1] * (1-$tempNum); + $result[$key] = round($result[$key],2); + } } return $result; } - - - // 分数段 - public function fenshuduan($cj=array(),$setp=10,$manfen=100) - { - - } - } diff --git a/app/chengji/model/TongjiBj.php b/app/chengji/model/TongjiBj.php index 0daca03b..32dbb845 100644 --- a/app/chengji/model/TongjiBj.php +++ b/app/chengji/model/TongjiBj.php @@ -32,6 +32,7 @@ class TongjiBj extends Base // 初始化统计结果 $data = array(); + // 循环年级 foreach ($nianji as $njkey => $value) { // 获取参加考试班级 @@ -48,21 +49,12 @@ class TongjiBj extends Base $temp = $kh->srcChengji($srcfrom); $temp = $tj->tongjiSubject($temp,$subject); - // halt($temp); - // 循环更新或写入成绩 foreach ($temp['cj'] as $cjkey => $cj) { - // if($cjkey == 'all') - // { - // continue; - // } - // 查询该班级该学科成绩是否存在 $tongjiJg = $this->where('kaoshi_id',$src['kaoshi']) ->where('banji_id',$val['id']) ->where('subject_id',$cj['id']) ->find(); - // halt('aa'); - if($tongjiJg) { $tongjiJg->kaoshi_id = $src['kaoshi']; @@ -81,6 +73,7 @@ class TongjiBj extends Base $tongjiJg->q2 = $cj['sifenwei'][1]; $tongjiJg->q3 = $cj['sifenwei'][2]; $tongjiJg->zhongshu = $cj['zhongshu']; + $tongjiJg->defenlv = $cj['defenlv']; $data = $tongjiJg->save(); }else{ // 重新组合统计结果 @@ -101,12 +94,14 @@ class TongjiBj extends Base 'q2'=>$cj['sifenwei'][1], 'q3'=>$cj['sifenwei'][2], 'zhongshu'=>$cj['zhongshu'], + 'defenlv'=>$cj['defenlv'], ]; $data = $this::create($tongjiJg); } } } } + return true; } @@ -234,7 +229,7 @@ class TongjiBj extends Base ->order(['subject_id']); } ]) - ->cache(true) + // ->cache(true) ->group('banji_id,kaoshi_id') ->append(['banjiTitle']) ->select(); @@ -258,18 +253,18 @@ class TongjiBj extends Base foreach ($value->bjJieguo as $k => $val) { if($val->subject_id>0){ $data[$value->banji_id]['chengji'][$val->bjSubject->lieming] = [ - 'avg'=>$val->avg, - 'youxiu'=>$val->youxiu, - 'jige'=>$val->jige, + 'avg'=>$val->avg*1, + 'youxiu'=>$val->youxiu*1, + 'jige'=>$val->jige*1, 'cjCnt'=>$val->chengji_cnt, 'title'=>$val->bjSubject->title, 'jiancheng'=>$val->bjSubject->jiancheng, - 'biaozhuncha'=>$val->biaozhuncha, + 'biaozhuncha'=>$val->biaozhuncha*1, 'sifenwei'=>[ 'min'=>$val->min, - 'q1'=>$val->q1, - 'q2'=>$val->q2, - 'q3'=>$val->q3, + 'q1'=>$val->q1*1, + 'q2'=>$val->q2*1, + 'q3'=>$val->q3*1, 'max'=>$val->max, ], ]; @@ -290,6 +285,46 @@ class TongjiBj extends Base } + // 成绩排序 + public function bjOrder($kaoshi) + { + $src = array('kaoshi'=>$kaoshi); + // 实例化学生成绩统计类 + $kh = new Kaohao; + $ksset = new \app\kaoshi\model\KaoshiSet; + $cj = new \app\chengji\model\Chengji; + $nianji = $ksset->srcNianji($kaoshi); + $col = ['bpaixu','bweizhi']; + + + // 初始化统计结果 + $data = array(); + + // 循环年级 + foreach ($nianji as $njkey => $value) { + // 获取参加考试班级 + $src['ruxuenian'] = $value['nianji']; + $banji = $kh->cyBanji($src); + $subject = $ksset->srcSubject($kaoshi,'',$value['nianji']); + + // 循环班级,获取并统计成绩 + foreach ($banji as $bjkey => $val) { + // 获取成绩 + $srcfrom = [ + 'kaoshi'=>$kaoshi, + 'banji'=>$val['id'], + ]; + $temp = $kh->srcChengjiSubject($srcfrom); + // 循环计算成绩排序 + foreach ($temp as $key => $value) { + $cj->saveOrder($value,$col); + } + } + } + return true; + } + + // 考试关联 public function bjKaoshi() diff --git a/app/chengji/model/TongjiNj.php b/app/chengji/model/TongjiNj.php index d2a651f5..2cb3bd07 100644 --- a/app/chengji/model/TongjiNj.php +++ b/app/chengji/model/TongjiNj.php @@ -72,6 +72,7 @@ class TongjiNj extends Base $tongjiJg->q2 = $cj['sifenwei'][1]; $tongjiJg->q3 = $cj['sifenwei'][2]; $tongjiJg->zhongshu = $cj['zhongshu']; + $tongjiJg->defenlv = $cj['defenlv']; $data = $tongjiJg->save(); }else{ // 重新组合统计结果 @@ -93,6 +94,7 @@ class TongjiNj extends Base 'q2'=>$cj['sifenwei'][1], 'q3'=>$cj['sifenwei'][2], 'zhongshu'=>$cj['zhongshu'], + 'defenlv'=>$cj['defenlv'], ]; $data = $this::create($tongjiJg); @@ -160,8 +162,6 @@ class TongjiNj extends Base }, 'njJieguo'=>function($query) use($ruxuenian,$kaoshi){ $query->field('subject_id,school_id,ruxuenian,stu_cnt,chengji_cnt,avg,youxiu,jige,biaozhuncha,max,min,q1,q2,q3') - ->where('ruxuenian',$ruxuenian) - ->where('kaoshi_id',$kaoshi) ->with([ 'njSubject'=>function($query){ $query->field('id,lieming,jiancheng,title'); @@ -191,18 +191,18 @@ class TongjiNj extends Base foreach ($value->njJieguo as $k => $val) { if($val->subject_id>0){ $data[$value->school_id]['chengji'][$val->njSubject->lieming] = [ - 'avg'=>$val->avg, - 'youxiu'=>$val->youxiu, - 'jige'=>$val->jige, + 'avg'=>$val->avg*1, + 'youxiu'=>$val->youxiu*1, + 'jige'=>$val->jige*1, 'cjCnt'=>$val->chengji_cnt, 'title'=>$val->njSubject->title, 'jiancheng'=>$val->njSubject->jiancheng, - 'biaozhuncha'=>$val->biaozhuncha, + 'biaozhuncha'=>$val->biaozhuncha*1, 'sifenwei'=>[ 'min'=>$val->min, - 'q1'=>$val->q1, - 'q2'=>$val->q2, - 'q3'=>$val->q3, + 'q1'=>$val->q1*1, + 'q2'=>$val->q2*1, + 'q3'=>$val->q3*1, 'max'=>$val->max, ], ]; @@ -222,6 +222,52 @@ class TongjiNj extends Base } + // 成绩排序 + public function njOrder($kaoshi) + { + $src = array('kaoshi'=>$kaoshi); + // 实例化学生成绩统计类 + $kh = new \app\kaoshi\model\Kaohao; + $ksset = new \app\kaoshi\model\KaoshiSet; + $cj = new \app\chengji\model\Chengji; + $nianji = $ksset->srcNianji($kaoshi); + $col = ['xpaixu','xweizhi']; + + + // 初始化统计结果 + $data = array(); + + // 循环年级 + foreach ($nianji as $njkey => $value) { + // 获取参加考试班级 + $src['ruxuenian'] = $value['nianji']; + + $school = $kh->cySchool($src); + $subject = $ksset->srcSubject($kaoshi,'',$value['nianji']); + + // 循环班级,获取并统计成绩 + foreach ($school as $schkey => $val) { + // 获取查询成绩参数 + $src['school'] = $val['id']; + $banji = $kh->cyBanji($src); + $srcfrom = [ + 'kaoshi'=>$kaoshi, + 'school'=>$val['id'], + 'banji'=>array_column($banji, 'id'), + ]; + $temp = $kh->srcChengjiSubject($srcfrom); + + // 循环计算成绩排序 + foreach ($temp as $key => $value) { + $cj->saveOrder($value,$col); + } + } + } + + return true; + } + + // 考试关联 public function njKaoshi() { @@ -243,7 +289,11 @@ class TongjiNj extends Base // 成绩统计结果关联 public function njJieguo() { - return $this->hasMany('\app\chengji\model\TongjiNj','school_id','school_id'); + $ruxuenian = $this->getAttr('ruxuenian'); + $kaoshi = $this->getAttr('kaoshi_id'); + return $this->hasMany('\app\chengji\model\TongjiNj','school_id','school_id') + ->where('ruxuenian',$ruxuenian) + ->where('kaoshi_id',$kaoshi); } } diff --git a/app/chengji/model/TongjiSch.php b/app/chengji/model/TongjiSch.php index 610a5347..da7b71f2 100644 --- a/app/chengji/model/TongjiSch.php +++ b/app/chengji/model/TongjiSch.php @@ -63,6 +63,7 @@ class TongjiSch extends Base $tongjiJg->q2 = $cj['sifenwei'][1]; $tongjiJg->q3 = $cj['sifenwei'][2]; $tongjiJg->zhongshu = $cj['zhongshu']; + $tongjiJg->defenlv = $cj['defenlv']; $data = $tongjiJg->save(); }else{ // 重新组合统计结果 @@ -83,6 +84,7 @@ class TongjiSch extends Base 'q2'=>$cj['sifenwei'][1], 'q3'=>$cj['sifenwei'][2], 'zhongshu'=>$cj['zhongshu'], + 'defenlv'=>$cj['defenlv'], ]; $data = $this::create($tongjiJg); @@ -172,6 +174,48 @@ class TongjiSch extends Base } + + // 成绩排序 + public function schOrder($kaoshi) + { + $src = array('kaoshi'=>$kaoshi); + // 实例化学生成绩统计类 + $kh = new \app\kaoshi\model\Kaohao; + $ksset = new \app\kaoshi\model\KaoshiSet; + $cj = new \app\chengji\model\Chengji; + $nianji = $ksset->srcNianji($kaoshi); + + + // 初始化统计结果 + $data = array(); + + // 循环年级 + foreach ($nianji as $njkey => $value) { + // 获取参加考试班级 + $src['ruxuenian'] = $value['nianji']; + $subject = $ksset->srcSubject($kaoshi,'',$value['nianji']); + $banji = $kh->cyBanji($src); + $col = ['qpaixu','qweizhi']; + + // 获取成绩 + $srcfrom = [ + 'kaoshi'=>$kaoshi, + 'ruxuenian'=>$value['nianji'], + 'banji'=>array_column($banji, 'id'), + ]; + $temp = $kh->srcChengjiSubject($srcfrom); + // 循环计算成绩排序 + foreach ($temp as $key => $value) { + $cj->saveOrder($value,$col); + } + } + + return true; + } + + + + // 学科关联 public function schSubject() { diff --git a/app/chengji/route/chengji.php b/app/chengji/route/chengji.php index f26270dd..0b6baf56 100644 --- a/app/chengji/route/chengji.php +++ b/app/chengji/route/chengji.php @@ -31,6 +31,7 @@ Route::group('index', function () { Route::group('tongji', function () { Route::rule('yilucnt/','Tongji/yiluCnt'); # 更新信息 Route::rule('data','Tongji/ajaxData','post'); # 扫码界面 + Route::rule('newjieguo','Tongji/newJieguo','post'); }); @@ -44,6 +45,7 @@ Route::group('bjtj', function () { Route::rule('myavg','Bjtongji/myAvg','post'); # 扫码界面 Route::rule('myxiangti','Bjtongji/myXiangti','post'); # 扫码界面 Route::rule('digui/','Bjtongji/digui','get'); # 扫码界面 + Route::rule('bjorder','Bjtongji/bjOrder','post'); # 统计各班级成绩 }); @@ -56,6 +58,7 @@ Route::group('njtj', function () { Route::rule('tongji','Njtongji/tongji','post'); # 统计各年级成绩 Route::rule('myavg','Njtongji/myAvg','post'); # 扫码界面 Route::rule('myxiangti','Njtongji/myXiangti','post'); # 扫码界面 + Route::rule('njorder','Njtongji/njOrder','post'); # 统计各班级成绩 }); // 全年级统计 @@ -63,6 +66,7 @@ Route::group('schtj', function () { Route::rule('biaoge/','Schtongji/biaoge','get'); # 班级表格 Route::rule('data','Schtongji/ajaxData','post'); # 扫码界面 Route::rule('tongji','Schtongji/tongji','post'); # 统计各年级成绩 + Route::rule('schorder','Schtongji/schOrder','post'); # 统计各班级成绩 }); // 录入 diff --git a/app/chengji/view/bjtongji/biaoge.html b/app/chengji/view/bjtongji/biaoge.html index d933da87..984d5909 100644 --- a/app/chengji/view/bjtongji/biaoge.html +++ b/app/chengji/view/bjtongji/biaoge.html @@ -1,8 +1,7 @@ {extend name=".././view/list.html" /} {block name="jsset"} - {load href="__STATIC__/echarts/echarts.min.js" /} - {load href="__STATIC__/echarts/dataTool.js" /} + {load href="__STATIC__/echarts/echarts.js" /} {/block} {block name="nav"} @@ -284,20 +283,31 @@ top: '10%', }, grid: { - // left: '10%', + left: '10%', top: '20%', - // right: '10%', - // bottom: '15%' + right: '10%', + bottom: '15%' }, tooltip: { - feature:{ - saveAsImage:{ - show:true, - type:'png', - title:title - }, - }, + show: true, + axisPointer: { + type: 'cross' + } }, + toolbox: { + id:id, + show:true, + orient:'horizontal', + showTitle:true, + feature: { + restore: { //重置 + show: true + }, + saveAsImage: { //保存文件 + show: true + }, + }, + }, dataset: { source:data.data }, @@ -369,9 +379,23 @@ tooltip: { trigger: 'item', axisPointer: { - type: 'shadow' + type: 'cross' } }, + toolbox: { + id:id, + show:true, + orient:'horizontal', + showTitle:true, + feature: { + restore: { //重置 + show: true + }, + saveAsImage: { //保存文件 + show: true + }, + }, + }, grid: { left: '10%', top: '20%', diff --git a/app/chengji/view/index/index.html b/app/chengji/view/index/index.html index 11abead5..60d63f29 100644 --- a/app/chengji/view/index/index.html +++ b/app/chengji/view/index/index.html @@ -92,12 +92,12 @@ var xk = ''; xk = eval(decodeURIComponent(xk)); for(x in xk) - { + { options.cols[0].push({field: xk[x].lieming, title: xk[x].title , minWidth:100,sort: true,edit:'text'}); - } - options.cols[0].push({field: 'avg', title: '平均分', minWidth:100,sort: true}); - options.cols[0].push({field: 'sum', title: '总分', minWidth:100,sort: true}); - options.cols[0].push({field: 'id', title: '操作',toolbar: '#barDemo',minWidth:125}); + } + options.cols[0].push({field: 'avg', title: '平均分', minWidth:100,sort: true}); + options.cols[0].push({field: 'sum', title: '总分', minWidth:100,sort: true}); + options.cols[0].push({field: 'id', title: '操作',toolbar: '#barDemo',minWidth:125}); // 设置查询条件 options.where = { @@ -171,7 +171,7 @@ "newdefen":newdefen }, success:function(result,obj){ - if(result.val == 0) + if(result.val == 0 || result.code==0) { layer.msg(result.msg,{icon:5}); }else{ @@ -194,7 +194,7 @@ function addBanji(){ // 获取参数 var formval = form.val('search'); - cjgl.createCheckbox('banji',formval,'/kaoshi/index/cybanji','banjiids','banTitle'); + cjgl.createCheckbox('banji',formval,'/kaoshi/index/cybanji','banji','banTitle'); } diff --git a/app/chengji/view/njtongji/biaoge.html b/app/chengji/view/njtongji/biaoge.html index 863602c0..4475e521 100644 --- a/app/chengji/view/njtongji/biaoge.html +++ b/app/chengji/view/njtongji/biaoge.html @@ -1,8 +1,7 @@ {extend name=".././view/list.html" /} {block name="jsset"} - {load href="__STATIC__/echarts/echarts.min.js" /} - {load href="__STATIC__/echarts/dataTool.js" /} + {load href="__STATIC__/echarts/echarts.js" /} {/block} {block name="nav"} @@ -254,6 +253,20 @@ }, }, }, + toolbox: { + id:id, + show:true, + orient:'horizontal', + showTitle:true, + feature: { + restore: { //重置 + show: true + }, + saveAsImage: { //保存文件 + show: true + }, + }, + }, dataset: { source:data.data }, @@ -328,6 +341,20 @@ type: 'shadow' } }, + toolbox: { + id:id, + show:true, + orient:'horizontal', + showTitle:true, + feature: { + restore: { //重置 + show: true + }, + saveAsImage: { //保存文件 + show: true + }, + }, + }, grid: { left: '10%', top: '20%', diff --git a/app/event.php b/app/event.php index e9851bb5..fa40e005 100644 --- a/app/event.php +++ b/app/event.php @@ -2,6 +2,7 @@ // 事件定义文件 return [ 'bind' => [ + 'kaoshistatus'=>'ksstatus', ], 'listen' => [ @@ -10,8 +11,10 @@ return [ 'HttpEnd' => [], 'LogLevel' => [], 'LogWrite' => [], + 'ksstatus' => [ + 'app\listener\KaoshiStatus' + ], ], - 'subscribe' => [ ], ]; diff --git a/app/event/KaoshiStatus.php b/app/event/KaoshiStatus.php new file mode 100644 index 00000000..fd59b20d --- /dev/null +++ b/app/event/KaoshiStatus.php @@ -0,0 +1,25 @@ +kaoshiInfo($kaoshiid); + if($ksinfo->status == 0) + { + return $this->error('考试状态为禁用,不允许操作!','/login/err'); + } + return $ksinfo; + } + +} diff --git a/app/kaoshi/controller/Index.php b/app/kaoshi/controller/Index.php index f99a840e..ad0c68c9 100644 --- a/app/kaoshi/controller/Index.php +++ b/app/kaoshi/controller/Index.php @@ -7,14 +7,16 @@ use app\BaseController; // 引用考试数据模型类 use app\kaoshi\model\Kaoshi as KS; +use app\middleware\KaoshiStatus; + class Index extends BaseController { + // 显示考试列表 public function index() { - // 设置要给模板赋值的信息 $list['webtitle'] = '考试列表'; $list['dataurl'] = 'index/data'; @@ -34,6 +36,8 @@ class Index extends BaseController // 获取参数 $src = $this->request ->only([ + 'xueqi'=>'', + 'category'=>'', 'page'=>'1', 'limit'=>'10', 'field'=>'id', @@ -91,10 +95,10 @@ class Index extends BaseController // 保存信息 public function save() { + // 实例化验证模型 $validate = new \app\kaoshi\validate\Kaoshi; - // 获取表单数据 $list = request()->only(['title','xueqi','category','bfdate','enddate','zuzhi'],'post'); @@ -164,11 +168,15 @@ class Index extends BaseController // 更新考试信息 public function update($id) { + event('ksstatus',$id); + $validate = new \app\kaoshi\validate\Kaoshi; // 获取表单数据 $list = request()->only(['title','xueqi','category','bfdate','enddate','zuzhi'],'post'); + + // 验证表单数据 $result = $validate->check($list); $msg = $validate->getError(); @@ -214,7 +222,6 @@ class Index extends BaseController ->field('id') ->find(); - // 重新整理年级和学科 $subject=array(); $subjectid=array(); @@ -225,13 +232,11 @@ class Index extends BaseController $subject[$value->lieming]['jige'] = $value['jige']; } - $nianji = array(); foreach ($data['ks_nianji'] as $key => $value) { $nianji[] = $value['nianji']; } - $list['data']['ks_subjectid'] = implode(',' , $subjectid); $list['data']['ks_nianjiid'] = implode(',' , $nianji); $list['data']['ks_subject'] = $subject; @@ -246,8 +251,6 @@ class Index extends BaseController 'kaoshi'=>$id, ); - - // 模板赋值 $this->view->assign('list',$list); // 渲染 @@ -259,77 +262,77 @@ class Index extends BaseController - // 更新考试信息 - public function updateSet($id) - { - $validate = new \app\kaoshi\validate\Kaoshiset; + // // 更新考试信息 + // public function updateSet($id) + // { - // 获取表单数据 - $list = request()->only(['nianji','subject','manfen','youxiu','jige','lieming','nianjiname'],'post'); + // $validate = new \app\kaoshi\validate\Kaoshiset; + + // // 获取表单数据 + // $list = request()->only(['nianji','subject','manfen','youxiu','jige','lieming','nianjiname'],'post'); - // 验证表单数据 - $result = $validate->check($list); - $msg = $validate->getError(); + // // 验证表单数据 + // $result = $validate->check($list); + // $msg = $validate->getError(); - // 如果验证不通过则停止保存 - if(!$result){ - return json(['msg'=>$msg,'val'=>0]);; - } + // // 如果验证不通过则停止保存 + // if(!$result){ + // return json(['msg'=>$msg,'val'=>0]);; + // } - $list['id'] = $id; + // $list['id'] = $id; - // 整理数据 - $data = array(); - $i = 0; - foreach ($list['subject'] as $key => $value) { - $data[$i]['subjectid'] = $key; - $data[$i]['manfen'] = $list['manfen'][$key]; - $data[$i]['youxiu'] = $list['youxiu'][$key]; - $data[$i]['jige'] = $list['jige'][$key]; - $data[$i]['lieming'] = $list['lieming'][$key]; - $data[$i]['kaoshiid'] = $id; - $i++; - } + // // 整理数据 + // $data = array(); + // $i = 0; + // foreach ($list['subject'] as $key => $value) { + // $data[$i]['subjectid'] = $key; + // $data[$i]['manfen'] = $list['manfen'][$key]; + // $data[$i]['youxiu'] = $list['youxiu'][$key]; + // $data[$i]['jige'] = $list['jige'][$key]; + // $data[$i]['lieming'] = $list['lieming'][$key]; + // $data[$i]['kaoshiid'] = $id; + // $i++; + // } - // 更新数据 + // // 更新数据 + // // 删除原来的数据 + // $subject = new \app\kaoshi\model\KaoshiSubject; - // 删除原来的数据 - $subject = new \app\kaoshi\model\KaoshiSubject; + // $subject::destroy(function($query) use ($id){ + // $query->where('kaoshiid',$id); + // }); - $subject::destroy(function($query) use ($id){ - $query->where('kaoshiid',$id); - }); + // // 添加新的数据 + // $subjectdata = $subject->saveAll($data); - // 添加新的数据 - $subjectdata = $subject->saveAll($data); + // // 整理数据 + // $data = array(); + // $i = 0; + // foreach ($list['nianji'] as $key => $value) { + // $data[$i]['nianji'] = $key; + // $data[$i]['nianjiname'] = $list['nianjiname'][$key]; + // $data[$i]['kaoshiid'] = $id; + // $i++; + // } - // 整理数据 - $data = array(); - $i = 0; - foreach ($list['nianji'] as $key => $value) { - $data[$i]['nianji'] = $key; - $data[$i]['nianjiname'] = $list['nianjiname'][$key]; - $data[$i]['kaoshiid'] = $id; - $i++; - } - - // 更新数据 - $nianji = new \app\kaoshi\model\KaoshiNianji; - $nianji::destroy(function($query) use ($id){ - $query->where('kaoshiid',$id); - }); - $nianjidata = $nianji->saveAll($data); + // // 更新数据 + // $nianji = new \app\kaoshi\model\KaoshiNianji; + // $nianji::destroy(function($query) use ($id){ + // $query->where('kaoshiid',$id); + // }); + // $nianjidata = $nianji->saveAll($data); - // 根据更新结果设置返回提示信息 - $subjectdata && $nianjidata ? $data=['msg'=>'设置成功','val'=>1] : $data=['msg'=>'数据处理错误','val'=>0]; + // // 根据更新结果设置返回提示信息 + // $subjectdata && $nianjidata ? $data=['msg'=>'设置成功','val'=>1] : $data=['msg'=>'数据处理错误','val'=>0]; - // 返回信息 - return json($data); - } + // // 返回信息 + // return json($data); + // } @@ -477,22 +480,4 @@ class Index extends BaseController return json($data); } - - // // 考试参加考试的学校、学科、年级、班级 - // public function kaoshiInfo($kaoshi=0) - // { - // $ks = new KS(); - // $data = $ks->kaoshiInfo($kaoshi); - - // if($data){ - // $data['msg'] = '查询成功'; - // $data['val'] = 1; - // }else{ - // $data['msg'] = '查询失败'; - // $data['val'] = 0; - // } - - - // return json($data); - // } } diff --git a/app/kaoshi/controller/Kaohao.php b/app/kaoshi/controller/Kaohao.php index 012c889c..ad1c2750 100644 --- a/app/kaoshi/controller/Kaohao.php +++ b/app/kaoshi/controller/Kaohao.php @@ -57,7 +57,7 @@ class Kaohao extends BaseController // 获取表单数据 $list = request()->only(['school','kaoshi','banjiids'],'post'); - + event('ksstatus',$list['kaoshi']); // 验证表单数据 $result = $validate->check($list); @@ -68,10 +68,6 @@ class Kaohao extends BaseController return ['msg'=>$msg,'val'=>0]; } - if(kaoshiDate($list['kaoshi'],'enddate')) - { - return ['msg'=>'考试已经结束,不能分配考号','val'=>0]; - } // 获取实例化学生数据模型 $stu = new \app\renshi\model\Student; @@ -180,30 +176,44 @@ class Kaohao extends BaseController $list['student'] = explode(' ', $list['student']); $list['student'] = $list['student'][1]; + event('ksstatus',$list['kaoshi']); + // 查询考号是否存在 - $ks = KH::where('kaoshi',$list['kaoshi']) + $ks = KH::withTrashed() + ->where('kaoshi',$list['kaoshi']) ->where('student',$list['student']) ->find(); + + // 如果存在成绩则更新,不存在则添加 if($ks) { - $data=['msg'=>'该学生考号已经存在','val'=>0]; - return json($data); + // 判断记录是否被删除 + if($ks->delete_time > 0) + { + $ks->restore(); + } + $data=['msg'=>'生成成功','val'=>1]; + }else{ + // 获取参加考试年级数组 + $bfdate = KS::where('id',$list['kaoshi'])->value('bfdate'); + $njlist = nianjiList($bfdate); + + + // 获取班级信息 + $bj = new \app\teach\model\Banji; + $bjinfo = $bj->where('id',$list['banji'])->find(); + $list['school'] = $bjinfo->school; + $list['ruxuenian'] = $bjinfo->ruxuenian; + $list['nianji'] = $njlist[$bjinfo->ruxuenian]; + $list['paixu'] = $bjinfo->paixu; + $data = KH::create($list); } - // 获取参加考试年级数组 - $bfdate = KS::where('id',$list['kaoshi'])->value('bfdate'); - $njlist = nianjiList($bfdate); - // 获取班级信息 - $bj = new \app\teach\model\Banji; - $bjinfo = $bj->where('id',$list['banji'])->find(); - $list['school'] = $bjinfo->school; - $list['ruxuenian'] = $bjinfo->ruxuenian; - $list['nianji'] = $njlist[$bjinfo->ruxuenian]; - $list['paixu'] = $bjinfo->paixu; - $data = KH::create($list); + + // 根据更新结果设置返回提示信息 $data ? $data=['msg'=>'生成成功','val'=>1] : $data=['msg'=>'数据处理错误','val'=>0]; @@ -317,7 +327,6 @@ class Kaohao extends BaseController // 标签下载 public function biaoqian($kaoshi) { - // 获取参考年级、学科 $ksset = new ksset; $list['data']['nianji'] = $ksset->srcNianji($kaoshi); @@ -352,16 +361,11 @@ class Kaohao extends BaseController // 获取表单数据 $list = request()->only(['banjiids'=>array(),'kaoshi','subject'=>array()],'post'); - + event('ksstatus',$list['kaoshi']); $kaoshi = $list['kaoshi']; $banji = $list['banjiids']; $subject = $list['subject']; - if(kaoshiDate($kaoshi,'enddate')) - { - $this->error('考试已经结束,不能下载','/kaoshi/kaohao/biaoqian/'.$kaoshi); - } - // 实例化验证模型 $validate = new \app\kaoshi\validate\Biaoqian; // 验证表单数据 @@ -386,7 +390,7 @@ class Kaohao extends BaseController $kh = new KH(); // 获取考试信息 - $kaohao = $kh->srcKaohao($kaoshi,$banji); + $kaohao = $kh->srcKaohaoBanji($kaoshi,$banji); $thistime = date("Y-m-d h:i:sa"); @@ -465,11 +469,6 @@ class Kaohao extends BaseController public function caiji($kaoshi) { - if(kaoshiDate($kaoshi,'enddate')) - { - $this->error('考试已经结束,不能下载','/kaoshi/kaohao/biaoqian/'.$kaoshi); - } - // 获取参考年级、学科 $ksset = new ksset; $list['data']['nianji'] = $ksset->srcNianji($kaoshi); @@ -510,6 +509,7 @@ class Kaohao extends BaseController // 获取表单数据 $list = request()->only(['banjiids'=>array(),'ruxuenian','kaoshi','subject'=>array()],'post'); + event('ksstatus',$list['kaoshi']); $kaoshi = $list['kaoshi']; $banji = $list['banjiids']; @@ -536,7 +536,7 @@ class Kaohao extends BaseController $kh = new KH(); // 获取考试信息 - $kaohao = $kh->srcKaohao($kaoshi,$banji); + $kaohao = $kh->srcKaohaoBanji($kaoshi,$banji); // 获取电子表格列名 @@ -647,18 +647,13 @@ class Kaohao extends BaseController // 判断考试结束时间是否已过 $ksid = KH::where('id',$id[0])->value('kaoshi'); - $enddate = kaoshiDate($ksid,'enddate'); + event('ksstatus',$ksid); - if( $enddate === true ) - { - $data=['msg'=>'考试时间已过,不能删除','val'=>0]; - }else{ - $data = KH::destroy($id); - // 根据更新结果设置返回提示信息 - $data ? $data=['msg'=>'删除成功','val'=>1] : $data=['msg'=>'数据处理错误','val'=>0]; - } - // 返回信息 + $data = KH::destroy($id); + // 根据更新结果设置返回提示信息 + $data ? $data=['msg'=>'删除成功','val'=>1] : $data=['msg'=>'数据处理错误','val'=>0]; + // 返回信息 return json($data); } diff --git a/app/kaoshi/controller/KaoshiSet.php b/app/kaoshi/controller/KaoshiSet.php index c61ca5a0..b49b830d 100644 --- a/app/kaoshi/controller/KaoshiSet.php +++ b/app/kaoshi/controller/KaoshiSet.php @@ -5,6 +5,8 @@ namespace app\kaoshi\controller; use app\BaseController; // 引用考号数据模型类 use app\kaoshi\model\KaoshiSet as ksset; +// 考试控制器 +use app\kaoshi\controller\Kaoshi as kscon; class KaoshiSet extends BaseController @@ -87,7 +89,7 @@ class KaoshiSet extends BaseController */ public function create($kaoshi) { - + // 设置页面标题 $list['set'] = array( 'webtitle'=>'设置考试', @@ -129,6 +131,8 @@ class KaoshiSet extends BaseController // 'lieming'=>array() ],'POST'); + event('ksstatus',$src['kaoshi']); + // 验证表单数据 $validate = new \app\kaoshi\validate\Kaoshiset; $result = $validate->check($src); @@ -229,17 +233,11 @@ class KaoshiSet extends BaseController // 判断考试结束时间是否已过 $ksset = new ksset; $ksid = $ksset::where('id',$id[0])->value('kaoshi_id'); - $enddate = kaoshiDate($ksid,'enddate'); + event('ksstatus',$ksid); - - if( $enddate === true ) - { - $data=['msg'=>'考试时间已过,不能删除','val'=>0]; - }else{ - $data = ksset::destroy($id,true); - // 根据更新结果设置返回提示信息 - $data ? $data=['msg'=>'删除成功','val'=>1] : $data=['msg'=>'数据处理错误','val'=>0]; - } + $data = ksset::destroy($id,true); + // 根据更新结果设置返回提示信息 + $data ? $data=['msg'=>'删除成功','val'=>1] : $data=['msg'=>'数据处理错误','val'=>0]; // 返回信息 return json($data); } diff --git a/app/kaoshi/model/Kaohao.php b/app/kaoshi/model/Kaohao.php index b40c167d..295f27ab 100644 --- a/app/kaoshi/model/Kaohao.php +++ b/app/kaoshi/model/Kaohao.php @@ -15,7 +15,7 @@ class Kaohao extends Base * @param array $banji 学生所在班级 * @return array 返回类型 */ - public function srcKaohao($kaoshi,$banji) + public function srcKaohaoBanji($kaoshi,$banji) { // 获取考试标签 $data = $this->where('kaoshi',$kaoshi) @@ -61,23 +61,19 @@ class Kaohao extends Base } } } - return $data; } /** - * 列出适合显示的学生成绩, + * 整理出适合显示的学生成绩, * 以考号为基础查询学生成绩信息并排序,计划在网页上显示成绩列表中使用 * 信息包括:学校、年级、班级、姓名、性别、各学科成绩、平均分、总分 * @access public * @param array $src 参数数组 - * @param number $src['school'] 学生所在学校 - * @param number $src['nianji'] 学生所在年级 - * @param number $src['paixu'] 班级标识 + * @param number $src['kaoshi'] 考试ID + * @param array $src['banji'] 班级数组 * @param number $src['searchval'] 关键字 - * @param number $src['field'] 排序字段 - * @param number $src['type'] 排序类型 * @return array 返回类型 */ public function srcChengji($srcfrom) @@ -85,8 +81,6 @@ class Kaohao extends Base // 初始化参数 $src = array( 'kaoshi'=>'0', - // 'school'=>array(), - // 'ruxuenian'=>array(), 'banji'=>array(), 'searchval'=>'' ); @@ -94,50 +88,7 @@ class Kaohao extends Base // 用新值替换初始值 $src = array_cover( $srcfrom , $src ) ; - - // 重新定义变量 - // $school = strToarray($src['school']); - // $ruxuenian = strToarray($src['ruxuenian']); - $banji = strToarray($src['banji']); - $seachval = $src['searchval']; - - - // 查询成绩 - $khlist = $this->where('kaoshi',$src['kaoshi']) - ->field('id,school,student,ruxuenian,paixu,kaoshi,nianji') - // ->when(count($school)>0,function($query) use($school){ - // $query->where('school','in',$school); - // }) - // ->when(count($ruxuenian)>0,function($query) use($ruxuenian){ - // $query->where('ruxuenian','in',$ruxuenian); - // }) - ->where('banji','in',$banji) - // ->when(count($banji)>0,function($query) use($banji){ - // $query->where('banji','in',$banji); - // }) - ->when(strlen($seachval)>0,function($query) use($seachval){ - $query->where(function($w) use ($seachval){ - $w - ->whereOr('student','in',function($q)use($seachval){ - $q->name('student')->where('xingming','like','%'.$seachval.'%')->field('id'); - }); - }); - }) - ->with([ - 'ksChengji'=>function($query){ - $query->field('kaohao_id,subject_id,defen'); - } - ,'cjSchool'=>function($query){ - $query->field('id,jiancheng'); - } - ,'cjStudent'=>function($query){ - $query->field('id,xingming,sex'); - } - ]) - ->append(['banjiTitle']) - ->select(); - - + $khlist = self::search($src); // 成绩整理 if($khlist->isEmpty()) @@ -145,7 +96,6 @@ class Kaohao extends Base return $data = array(); } - // 获取参考学科 $ksset = new \app\kaoshi\model\KaoshiSet; $ksSubject = $ksset->srcSubject($src['kaoshi'],'',''); @@ -160,14 +110,9 @@ class Kaohao extends Base $xk[$value['id']] = $value['lieming']; } - - $bjlist = banjinamelist(); - // 实例化学生数据模型 $stu = new \app\renshi\model\Student; - - // 整理数据 $data = array(); foreach ($khlist as $key => $value) { @@ -185,7 +130,6 @@ class Kaohao extends Base $data[$key]['student'] = $stuinfo->xingming; $data[$key]['sex'] = $stuinfo->sex; } - // $data[$key]['nianji'] = $value->nianji; $data[$key]['banji'] = $value->banjiTitle; $dfsum = 0; $sbjcnt = 0; @@ -201,13 +145,11 @@ class Kaohao extends Base { $data[$key][$val]=$cjarr[$k] * 1; $sbjcnt++; - // $dfsum = $dfsum + $data[$key][$val]; }else{ $data[$key][$val]= null; } } - if($sbjcnt>0){ $data[$key]['sum'] = array_sum($cjarr); $data[$key]['avg'] = round($data[$key]['sum']/$sbjcnt,1); @@ -216,12 +158,166 @@ class Kaohao extends Base $data[$key]['avg'] = null; } } + return $data; } - + /** + * 按考号查询学生成绩,整理出学生每个学科成绩 + * 计划在成绩排序中使用 + * 信息包括:成绩id,排序,位置 + * @access public + * @param array $src 参数数组 + * @param number $src['kaoshi'] 考试ID + * @param array $src['banji'] 班级数组 + * @param number $src['searchval'] 关键字 + * @return array 返回类型 + */ + + public function srcChengjiSubject($srcfrom) + { + // 初始化参数 + $src = array( + 'kaoshi'=>'0', + 'banji'=>array(), + 'searchval'=>'' + ); + + // 用新值替换初始值 + $src = array_cover( $srcfrom , $src ) ; + + $khlist = self::search($src); + + + // 成绩整理 + if($khlist->isEmpty()) + { + return $data = array(); + } + + // 整理成绩 + $data = array(); + foreach ($khlist as $kh_k => $kh_val) { + foreach ($kh_val->ksChengji as $cj_k => $cj_val) { + $data[$cj_val->subject_id][$cj_val->id] = $cj_val->defen; + } + } + + return $data; + + } + + + + /** + * 列出成绩原始数据,其它数据模型中的方法以此方法为基础进行数据整理 + * @access public + * @param array $src 参数数组 + * @param number $src['kaoshi'] 考试ID + * @param array $src['banji'] 班级数组 + * @param number $src['searchval'] 关键字 + * @return array 返回成绩对象 + */ + public function search($srcfrom) + { + // 初始化参数 + $src = array( + 'kaoshi'=>'0', + 'banji'=>array(), + 'searchval'=>'' + ); + + // 用新值替换初始值 + $src = array_cover( $srcfrom , $src ) ; + $src['banji'] = strToarray($src['banji']); + + // 查询成绩 + $data = $this->where('kaoshi',$src['kaoshi']) + ->field('id,school,student,ruxuenian,paixu,kaoshi,nianji') + ->where('banji','in',$src['banji']) + ->when(strlen($src['searchval'])>0,function($query) use($src){ + $query->where(function($w) use ($src){ + $w + ->whereOr('student','in',function($q)use($src){ + $q->name('student')->where('xingming','like','%'.$src['searchval'].'%')->field('id'); + }); + }); + }) + ->with([ + 'ksChengji'=>function($query){ + $query->field('id,kaohao_id,subject_id,defen'); + } + ,'cjSchool'=>function($query){ + $query->field('id,jiancheng'); + } + ,'cjStudent'=>function($query){ + $query->field('id,xingming,sex'); + } + ]) + ->append(['banjiTitle']) + ->select(); + + return $data; + } + + + + + + + // 获取单个学生考试成绩 + public function srcOneStudentChengji($srcfrom) + { + // 初始化参数 + $src = array( + 'student'=>'', + 'kaoshi'=>array(), + ); + + // 用新值替换初始值 + $src = array_cover( $srcfrom , $src ) ; + $src['kaoshi'] = strToarray($src['kaoshi']); + + $stuCj = $this->where('student',$src['student']) + ->when(count($src['kaoshi'])>0,function($query)use($src){ + $query->where('kaoshi_id','in',$src['kaoshi']) + ->field('id'); + }) + ->with([ + 'ksChengji'=>function($query){ + $query->field('id,kaohao_id,subject_id,defen,bweizhi,xweizhi,qweizhi'); + } + ,'cjSchool'=>function($query){ + $query->field('id,jiancheng'); + } + ,'cjKaoshi'=>function($query){ + $query->field('id,title,zuzhi,xueqi,category,bfdate,enddate') + ->with([ + 'ksCategory'=>function($q){ + $q->field('id,title'); + } + ,'ksZuzhi'=>function($q) + { + $q->field('id,title,jiancheng'); + } + ]); + } + ]) + ->field('id,kaoshi,student,ruxuenian,nianji,banji,paixu') + ->append(['banjiTitle']) + ->select(); + + return $stuCj; + } + + + + + + + // 满分 public function banjiKaohao() diff --git a/app/kaoshi/model/Kaoshi.php b/app/kaoshi/model/Kaoshi.php index 115bf5cd..2c2bda27 100644 --- a/app/kaoshi/model/Kaoshi.php +++ b/app/kaoshi/model/Kaoshi.php @@ -8,26 +8,41 @@ use app\common\model\Base; class Kaoshi extends Base { - // 查询所有单位 + // 查询所有考试 public function search($srcfrom) { $src = [ 'field'=>'id', 'order'=>'desc', + 'zuzhi'=>array(), + 'xueqi'=>'', + 'category'=>array(), 'searchval'=>'' ]; // 用新值替换初始值 $src = array_cover( $srcfrom , $src ) ; - - // 整理变量 - // $xingzhi = $src['xingzhi']; - $searchval = $src['searchval']; + $src['zuzhi'] = strToarray($src['zuzhi']); + $src['xueqi'] = strToarray($src['xueqi']); + $src['category'] = strToarray($src['category']); // 查询数据 $data = $this ->order([$src['field'] =>$src['order']]) - ->when(strlen($searchval)>0,function($query) use($searchval){ - $query->where('title','like','%'.$searchval.'%'); + ->when(strlen($src['searchval'])>0,function($query) use($src){ + $query->where('title','like','%'.$src['searchval'].'%'); + }) + ->when(count($src['zuzhi'])>0,function($query) use($src){ + $query->where('zuzhi','in',$src['zuzhi']); + }) + ->when(count($src['xueqi'])>0,function($query) use($src){ + $query->where('xueqi','in',function($q)use($src){ + $q->name('xueqi') + ->where('category','in',$src['xueqi']) + ->field('id'); + }); + }) + ->when(count($src['category'])>0,function($query) use($src){ + $query->where('category','in',$src['category']); }) ->with( [ @@ -50,33 +65,11 @@ class Kaoshi extends Base // 考试参加考试的学校、学科、年级、班级 public function kaoshiInfo($kaoshi=0) { - // 获取参考年级 $kaoshiList = $this->where('id',$kaoshi) - ->field('id,title') - // ->with([ - // 'ksNianji' - // ,'ksSubject'=>function($query){ - // $query->field('id,subjectid,kaoshiid') - // ->with(['subjectName'=>function($q){ - // $q->field('id,title'); - // }] - // ); - // } - // ]) - ->where('enddate','>=',time()) - ->find() - ->toArray(); - - // 获取参加考试信息 - $kh = new \app\kaoshi\model\Kaohao; - $list = array(); - $list['subject'] = $kaoshiList['ksSubject']; - $list['nianji'] = $kaoshiList['ksNianji']; - $nianji = array_column($list['nianji'], 'nianji'); - $list['school'] = $kh->cySchool(['kaoshi'=>$kaoshiList['id'],'ruxuenian'=>$nianji]); - - return $list; + ->field('id,title,status') + ->find(); + return $kaoshiList; } @@ -151,16 +144,8 @@ class Kaoshi extends Base { return $this->hasMany('KaoshiSet','kaoshi_id','id'); } - // // 考试设置关联表 - // public function ksSubject() - // { - // return $this->hasMany('KaoshiSet','kaoshi_id','id')->gooup('subject_id'); - // } - // // 考试设置关联表 - // public function ksNianji() - // { - // return $this->hasMany('KaoshiSet','kaoshi_id','id')->gooup('nianji'); - // } + + // 参考类别关联表 public function ksCategory() { diff --git a/app/kaoshi/view/index/index.html b/app/kaoshi/view/index/index.html index e9b45d2d..54cbef21 100644 --- a/app/kaoshi/view/index/index.html +++ b/app/kaoshi/view/index/index.html @@ -19,6 +19,25 @@ autocomplete="off" class="layui-input"> +
+ +
+ + {php} $category = getCategory('学期');{/php} + {volist name="category" id="vo"} + + {/volist} +
+
+
+ +
+ {php} $category = getCategory('考试');{/php} + {volist name="category" id="vo"} + + {/volist} +
+
{/block} {block name="table"}
diff --git a/app/kaoshi/view/index/more_action.html b/app/kaoshi/view/index/more_action.html index be405ee1..c7ab2468 100644 --- a/app/kaoshi/view/index/more_action.html +++ b/app/kaoshi/view/index/more_action.html @@ -27,20 +27,20 @@ - {php}$kaoshiid =$list['kaoshiid']; {/php}
  • 1、前期操作
  • -
  • 2、成绩录入
  • -
  • 3、成绩列表
  • +
  • 2、表格录入
  • +
  • 3、成绩统计
  • +
  • 4、统计结果
@@ -86,7 +86,14 @@
已录成绩数量
-
+
 
+
+
+ +
+ + @@ -114,6 +138,12 @@
+ +
+ +
检测统计结果是否是最新结果
+
+
@@ -178,5 +208,7 @@ }); } + + \ No newline at end of file diff --git a/app/listener/KaoshiStatus.php b/app/listener/KaoshiStatus.php new file mode 100644 index 00000000..f647db27 --- /dev/null +++ b/app/listener/KaoshiStatus.php @@ -0,0 +1,21 @@ +getKsStatus($kaoshiid); + } +} diff --git a/app/login/view/index/index.html b/app/login/view/index/index.html index 76afc917..c87e9cb6 100644 --- a/app/login/view/index/index.html +++ b/app/login/view/index/index.html @@ -6,7 +6,7 @@ - + diff --git a/app/login/view/index/myerror.html b/app/login/view/index/myerror.html index 9f327daf..b4611e2c 100644 --- a/app/login/view/index/myerror.html +++ b/app/login/view/index/myerror.html @@ -7,9 +7,6 @@ - - - {load href="__XADMIN__/css/font.css" /} {load href="__XADMIN__/css/xadmin.css" /} diff --git a/app/login/view/index/shangma_log.html b/app/login/view/index/shangma_log.html index c18b49d3..8d481fc0 100644 --- a/app/login/view/index/shangma_log.html +++ b/app/login/view/index/shangma_log.html @@ -44,6 +44,26 @@