auth->getGroupIds(); $this->model = new \app\admin\model\teacher\Exams; $this->departmodel = new \app\admin\model\department\Department; $this->adminmodel = new \app\admin\model\Admin; $this->faultmodel = new \app\admin\model\Fault; //已交卷 $this->whereExtend['endtime'] = ['>', 0]; //考试 $this->whereExtend['exam_collection_type'] = 3; $ids = $this->request->get('ids', ''); if(!empty($ids)){ // $this->whereExtend['exam_collection_id'] = ['in', $ids]; $this->whereExtend['user_depart_id'] = ['in', $ids]; } $departmentdata = []; // $collectionlist = Db::name('real_exam')->where('exam_collection_type',3) // ->whereTime('starttime','year') // ->group('exam_collection_id') // ->field('exam_collection_id,exam_collection_name') // ->order('exam_collection_id desc')->select(); // foreach ($collectionlist as $k => $v) { // $departmentdata[$v['exam_collection_id']] = $v['exam_collection_name']; // } $departlist = $this->departmodel->where('level',5)->select(); foreach ($departlist as $k => $v) { $departmentdata[$v['id']] = $v['name']; } unset($v); $this->view->assign('departmentdata', $departmentdata); $this->view->assign('ids', $ids); } /** * 数字大屏接口 */ public function index() { //区队总数 $where_depart['level'] = 5; $qudui_total = $this->departmodel->where($where_depart)->count(); $this->assign('qudui_total', $qudui_total); //学员总数 $where_xy['depart_id'] = ['>',0]; $xy_total = $this->adminmodel->where($where_xy)->count(); $this->assign('xy_total', $xy_total); //最高分 $max = $this->model->where($this->whereExtend)->order('endtime desc')->max('total_score'); $this->assignconfig('max', $max); //最低分 $min = $this->model->where($this->whereExtend)->order('endtime desc')->min('total_score'); $this->assignconfig('min',$min); //平均分 //考试人数 $exam_xueyuan_count = $this->model->where($this->whereExtend)->count(); //考试总分 $exam_xueyuan_total = $this->model->where($this->whereExtend)->sum('total_score'); //考试总分/考试人数 $exam_pjf = $exam_xueyuan_count>0?bcdiv($exam_xueyuan_total, $exam_xueyuan_count):0; $this->assignconfig('exam_pjf',$exam_pjf); //平均时长 //考试总时长 $exam_shichang = $this->model->where($this->whereExtend)->sum('exam_duration'); $exam_pjsc = $exam_xueyuan_count>0? bcdiv($exam_shichang, $exam_xueyuan_count):0; $this->assignconfig('exam_pjsc',bcdiv($exam_pjsc,60)); //学员成绩统计 $xueyuan_chengji_tongji = $this->model->where($this->whereExtend)->where('total_score>0')->order('endtime desc')->limit(50)->select(); $this->assign('xueyuan_chengji_tongji', $xueyuan_chengji_tongji); //各区队平均分分析 $qudui_list = $this->model->where($this->whereExtend)->group('user_depart_id')->select(); $qudui = []; foreach ($qudui_list as $k => $v) { $qudui_list[$k]['user_depart_name'] = $this->departmodel->where('id',$v['user_depart_id'])->value('name'); //每个区队的考试人数 $qudui_exam_count = $this->model->where('user_depart_id',$v['user_depart_id'])->count(); //每个区队的总分 $qudui_exam_total = $this->model->where('user_depart_id',$v['user_depart_id'])->sum('total_score'); //每个区队的平均分 $qudui_list[$k]['user_depart_pjf'] = bcdiv($qudui_exam_total,$qudui_exam_count); } unset($v); $this->assignconfig('qudui_list', $qudui_list); //区队平均分 年份 $this->assignconfig('qudui_list_year', date('Y')); //本年度考试成绩平均分统计 $collection_list = $this->model->where('exam_collection_type',3)->whereTime('starttime','year')->group('exam_collection_id')->order('exam_collection_id desc')->limit(6)->select(); foreach($collection_list as $k=>$v){ //每个考试的考试人数 $collection_exam_count = $this->model->where('exam_collection_id',$v['exam_collection_id'])->count(); //每个区队的总分 $collection_exam_total = $this->model->where('exam_collection_id',$v['exam_collection_id'])->sum('total_score'); //每个区队的平均分 $collection_list[$k]['collection_pjf'] = bcdiv($collection_exam_total,$collection_exam_count); } $this->assignconfig('collection_list', $collection_list); //FZD048型侦毒器维修难点统计 $fault_one = $this->faultmodel->where(['sim_type'=>'0001'])->field('fault_id,name')->select(); foreach ($fault_one as $k1 => $val1){ // if(strlen($val1['name'])>15){ // $name = mb_strcut($val1['name'],0,15,'utf8')."..."; // }else{ // $name = $val1['name']; // } // $fault_one[$k1]['name'] = $name; //先查分配次数,在查错误率 $error_total = Db::name('real_exam_fault')->where(['flag'=>1,'fault_id'=>$val1['fault_id'],'answer_right'=>2])->count(); $fault_one[$k1]['error_total'] = $error_total; } unset($val1); $vaccineCount = array_column($fault_one, 'error_total'); array_multisort($vaccineCount,SORT_DESC,$fault_one); $largestFour = array_slice($fault_one, 0, 5); // 获取最大的四个值 $one_static = $largestFour; $this->assignconfig('one_static', $one_static); //FZB006型毒剂报警器维修难点统计 $fault_two = $this->faultmodel->where(['sim_type'=>'0002'])->field('fault_id,name')->select(); foreach ($fault_two as $k1 => $val1){ // if(strlen($val1['name'])>15){ // $name = mb_strcut($val1['name'],0,15,'utf8')."..."; // }else{ // $name = $val1['name']; // } // $fault_two[$k1]['name'] = $name; //先查分配次数,在查错误率 $error_total = Db::name('real_exam_fault')->where(['flag'=>1,'fault_id'=>$val1['fault_id'],'answer_right'=>2])->count(); $fault_two[$k1]['error_total'] = $error_total; } unset($val1); $vaccineCount = array_column($fault_two, 'error_total'); array_multisort($vaccineCount,SORT_DESC,$fault_two); $largestFour = array_slice($fault_two, 0, 5); // 获取最大的四个值 $two_static = $largestFour; $this->assignconfig('two_static', $two_static); //防化兵用毒剂报警器维修难点统计 $fault_three = $this->faultmodel->where(['sim_type'=>'0003'])->field('fault_id,name')->select(); foreach ($fault_three as $k1 => $val1){ // if(strlen($val1['name'])>15){ // $name = mb_strcut($val1['name'],0,15,'utf8')."..."; // }else{ // $name = $val1['name']; // } // $fault_three[$k1]['name'] = $name; //先查分配次数,在查错误率 $error_total = Db::name('real_exam_fault')->where(['flag'=>1,'fault_id'=>$val1['fault_id'],'answer_right'=>2])->count(); $fault_three[$k1]['error_total'] = $error_total; } unset($val1); $vaccineCount = array_column($fault_three, 'error_total'); array_multisort($vaccineCount,SORT_DESC,$fault_three); $largestFour = array_slice($fault_three, 0, 5); // 获取最大的四个值 $three_static = $largestFour; $this->assignconfig('three_static', $three_static); return $this->view->fetch(); } }