|  | @@ -60,13 +60,65 @@ class Exams extends Backend
 | 
	
		
			
				|  |  |              ->paginate($limit);
 | 
	
		
			
				|  |  |          //最高分 最低分 平均分
 | 
	
		
			
				|  |  |          $select = $this->model->where($where)->where($this->whereExtend)->field('count(*) as count,sum(total_score) as totalscore,min(total_score) as min,max(total_score) as max')->select();
 | 
	
		
			
				|  |  | -        $pingfen  = 0;
 | 
	
		
			
				|  |  | +        $pingfen  = '';
 | 
	
		
			
				|  |  |          if(!empty($select[0]['totalscore']) && !empty($select[0]['count'])){
 | 
	
		
			
				|  |  |              $pingfen  = bcdiv($select[0]['totalscore'],$select[0]['count']);
 | 
	
		
			
				|  |  |          }
 | 
	
		
			
				|  |  | -
 | 
	
		
			
				|  |  |          $defen = ['max'=>$select[0]['max'],'min'=>$select[0]['min'],'pingfen'=>$pingfen];
 | 
	
		
			
				|  |  | -        $result = ['total' => $list->total(), 'rows' => $list->items(),'defen'=>$defen];
 | 
	
		
			
				|  |  | +        $one_static = [];
 | 
	
		
			
				|  |  | +        $two_static = [];
 | 
	
		
			
				|  |  | +        $three_static = [];
 | 
	
		
			
				|  |  | +        $where_falut = ['fault_type' => 3,'fault_state'=>0];
 | 
	
		
			
				|  |  | +        $exam_ids = $this->model->where($where)->where($this->whereExtend)->column('exam_id');
 | 
	
		
			
				|  |  | +        foreach ($list as $k => $val){
 | 
	
		
			
				|  |  | +            $one = Fault::where(['sim_type'=>'0001'])->where($where_falut)->field('fault_id,name')->select();
 | 
	
		
			
				|  |  | +            if($val['sim_type']=='0001'){
 | 
	
		
			
				|  |  | +                foreach ($one as $k1 => $val1){
 | 
	
		
			
				|  |  | +                    //先查分配次数,在查错误率
 | 
	
		
			
				|  |  | +                    $one_total = Db::name('real_exam_fault')->where(['flag'=>1,'exam_id'=>['in',$exam_ids],'fault_id'=>$val1['fault_id']])->count();
 | 
	
		
			
				|  |  | +                    $error_total = Db::name('real_exam_fault')->where(['flag'=>1,'exam_id'=>['in',$exam_ids],'fault_id'=>$val1['fault_id'],'answer_right'=>2])->count();
 | 
	
		
			
				|  |  | +                    $one[$k1]['epercent'] = '';
 | 
	
		
			
				|  |  | +                    if($one_total>0){
 | 
	
		
			
				|  |  | +                        $bili = bcmul(bcdiv($error_total,$one_total,2),100);
 | 
	
		
			
				|  |  | +                        $one[$k1]['epercent'] = $bili>0 ? $bili.'%' : '';
 | 
	
		
			
				|  |  | +                    }
 | 
	
		
			
				|  |  | +                }
 | 
	
		
			
				|  |  | +                $one_static = $one;
 | 
	
		
			
				|  |  | +            }
 | 
	
		
			
				|  |  | +            $two = Fault::where(['sim_type'=>'0002'])->where($where_falut)->field('fault_id,name')->select();
 | 
	
		
			
				|  |  | +            if($val['sim_type']=='0002'){
 | 
	
		
			
				|  |  | +                foreach ($two as $k2 => $val2){
 | 
	
		
			
				|  |  | +                    $two_total = Db::name('real_exam_fault')->where(['flag'=>1,'exam_id'=>['in',$exam_ids],'fault_id'=>$val2['fault_id']])->count();
 | 
	
		
			
				|  |  | +                    $error_total = Db::name('real_exam_fault')->where(['flag'=>1,'exam_id'=>['in',$exam_ids],'fault_id'=>$val2['fault_id'],'answer_right'=>2])->count();
 | 
	
		
			
				|  |  | +                    $two[$k2]['epercent'] = '';
 | 
	
		
			
				|  |  | +                    if($two_total>0){
 | 
	
		
			
				|  |  | +                        $bili = bcmul(bcdiv($error_total,$two_total,2),100);
 | 
	
		
			
				|  |  | +                        $two[$k2]['epercent'] = $bili>0 ? $bili.'%' : '';
 | 
	
		
			
				|  |  | +                    }
 | 
	
		
			
				|  |  | +                }
 | 
	
		
			
				|  |  | +            }
 | 
	
		
			
				|  |  | +            $two_static = $two;
 | 
	
		
			
				|  |  | +            $three = Fault::where(['sim_type'=>'0003'])->where($where_falut)->field('fault_id,name')->select();
 | 
	
		
			
				|  |  | +            if($val['sim_type']=='0003'){
 | 
	
		
			
				|  |  | +                foreach ($three as $k3 => $val3){
 | 
	
		
			
				|  |  | +                    $three_total = Db::name('real_exam_fault')->where(['flag'=>1,'exam_id'=>['in',$exam_ids],'fault_id'=>$val3['fault_id']])->count();
 | 
	
		
			
				|  |  | +                    $error_total = Db::name('real_exam_fault')->where(['flag'=>1,'exam_id'=>['in',$exam_ids],'fault_id'=>$val3['fault_id'],'answer_right'=>2])->count();
 | 
	
		
			
				|  |  | +                    $three[$k3]['epercent'] = '';
 | 
	
		
			
				|  |  | +                    if($three_total>0){
 | 
	
		
			
				|  |  | +                        $bili = bcmul(bcdiv($error_total,$three_total,2),100);
 | 
	
		
			
				|  |  | +                        $three[$k3]['epercent'] = $bili>0 ? $bili.'%' : '';
 | 
	
		
			
				|  |  | +                    }
 | 
	
		
			
				|  |  | +                }
 | 
	
		
			
				|  |  | +            }
 | 
	
		
			
				|  |  | +            $three_static = $three;
 | 
	
		
			
				|  |  | +        }
 | 
	
		
			
				|  |  | +        //统计错误率
 | 
	
		
			
				|  |  | +        $statistics = [
 | 
	
		
			
				|  |  | +            'one_static' => $one_static,
 | 
	
		
			
				|  |  | +            'two_static' => $two_static,
 | 
	
		
			
				|  |  | +            'three_static' => $three_static,
 | 
	
		
			
				|  |  | +        ];
 | 
	
		
			
				|  |  | +        $result = ['total' => $list->total(), 'rows' => $list->items(),'defen'=>$defen,'tongji'=>$statistics];
 | 
	
		
			
				|  |  |          return json($result);
 | 
	
		
			
				|  |  |      }
 | 
	
		
			
				|  |  |  
 | 
	
	
		
			
				|  | @@ -135,22 +187,28 @@ class Exams extends Backend
 | 
	
		
			
				|  |  |          $row['start_time'] = $rows->start_time;
 | 
	
		
			
				|  |  |          $row['end_time'] = $rows->end_time;
 | 
	
		
			
				|  |  |  
 | 
	
		
			
				|  |  | +        $fault_list = Db::name('real_exam_fault')->where(['exam_id'=>$ids,'flag'=>1])->select();
 | 
	
		
			
				|  |  | +        $row['fault_name_one'] = Fault::where('fault_id',$fault_list[0]['fault_id'])->value('name');
 | 
	
		
			
				|  |  | +        $row['fault_name_two'] = Fault::where('fault_id',$fault_list[1]['fault_id'])->value('name');
 | 
	
		
			
				|  |  | +        $row['fault_name_three'] = Fault::where('fault_id',$fault_list[2]['fault_id'])->value('name');
 | 
	
		
			
				|  |  | +
 | 
	
		
			
				|  |  |          $this->view->assign('row', $row);
 | 
	
		
			
				|  |  |          return $this->view->fetch();
 | 
	
		
			
				|  |  |      }
 | 
	
		
			
				|  |  |  
 | 
	
		
			
				|  |  |      //正在考试
 | 
	
		
			
				|  |  | -    public function persent()
 | 
	
		
			
				|  |  | +    public function persent($ids = null)
 | 
	
		
			
				|  |  |      {
 | 
	
		
			
				|  |  |          //设置过滤方法
 | 
	
		
			
				|  |  |          $this->request->filter(['strip_tags', 'trim']);
 | 
	
		
			
				|  |  |          if (false === $this->request->isAjax()) {
 | 
	
		
			
				|  |  |  
 | 
	
		
			
				|  |  | -            $examlist = $this->model->select();
 | 
	
		
			
				|  |  | -            foreach ($examlist as $k => $v){
 | 
	
		
			
				|  |  | -                $examlist[$k]['score'] = Db::name('real_exam_score')->where('exam_id',$v['exam_id'])->find();
 | 
	
		
			
				|  |  | -            }
 | 
	
		
			
				|  |  | -            $this->view->assign('examlist', $examlist);
 | 
	
		
			
				|  |  | +//            $examlist = $this->model->select();
 | 
	
		
			
				|  |  | +//            foreach ($examlist as $k => $v){
 | 
	
		
			
				|  |  | +//                $examlist[$k]['score'] = Db::name('real_exam_score')->where('exam_id',$v['exam_id'])->find();
 | 
	
		
			
				|  |  | +//            }
 | 
	
		
			
				|  |  | +//            $this->view->assign('examlist', $examlist);
 | 
	
		
			
				|  |  | +            $this->assignConfig('ids', $ids);
 | 
	
		
			
				|  |  |              return $this->view->fetch();
 | 
	
		
			
				|  |  |          }
 | 
	
		
			
				|  |  |          //如果发送的来源是 Selectpage,则转发到 Selectpage
 |