| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107 | 
							- <?php
 
- namespace app\admin\controller\student;
 
- use app\admin\model\Fault;
 
- use app\admin\model\Report;
 
- use app\common\controller\Backend;
 
- use app\common\model\Config as ConfigModel;
 
- use think\Db;
 
- use app\admin\model\department\Department;
 
- /**
 
-  * sim-考试表/成绩总分
 
-  *
 
-  * @icon fa fa-circle-o
 
-  */
 
- class Exam extends Backend
 
- {
 
-     /**
 
-      * Exams模型对象
 
-      * @var \app\admin\model\teacher\Exams
 
-      */
 
-     protected $model = null;
 
-     protected $whereExtend = null;
 
-     public function _initialize()
 
-     {
 
-         parent::_initialize();
 
-         $this->model = new \app\admin\model\teacher\Exams;
 
-         $groupIds = $this->auth->getGroupIds();
 
-         //学员查看自己的
 
-         if(in_array(8, $groupIds)){
 
-             $this->whereExtend['user_id'] = $this->auth->id;
 
-         }
 
-         $this->assignconfig("groupIds", $groupIds[0]);
 
-         $this->whereExtend['exam_collection_type'] = 3;
 
-         $this->whereExtend['endtime'] = ['>',0];
 
-         $this->whereExtend['is_sure'] = 1;
 
-     }
 
-     /**
 
-      * 默认生成的控制器所继承的父类中有index/add/edit/del/multi五个基础方法、destroy/restore/recyclebin三个回收站方法
 
-      * 因此在当前控制器中可不用编写增删改查的代码,除非需要自己控制这部分逻辑
 
-      * 需要将application/admin/library/traits/Backend.php中对应的方法复制到当前控制器,然后进行修改
 
-      */
 
-     public function view($ids = null)
 
-     {
 
-         $row = Db::name('real_exam_score')->where('exam_id', $ids)->find();
 
-         if (!$row) {
 
-             $this->error(__('未交卷'));
 
-         }
 
-         $rows = $this->model->get($ids);
 
-         $row['seat_id'] = $rows->seat_id;
 
-         $row['user_nickname'] = $rows->user_nickname;
 
-         $row['user_username'] = $rows->user_username;
 
-         $row['user_depart_id'] = $rows->user_depart_id;
 
-         $row['user_depart_name'] = Department::where('id',$rows->user_depart_id)->value('name');
 
-         $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');
 
-         $row['fault_score'] = 75-$row['fault_one_score']-$row['fault_two_score']-$row['fault_three_score'];
 
-          
 
-         $row['weixiu_score'] = 10-$row['overtime_score']??0; 
 
-         $other_jielun = !empty($row['other_jielun']) ? json_decode($row['other_jielun'],true):[];
 
-         $koufen = 0;
 
-         $dt_count = 0;
 
-         foreach ($other_jielun as $key => $value) {
 
-             if(!empty($value['cx_score'])){
 
-                 $koufen = $koufen+abs($value['cx_score']);
 
-             }
 
-             if($value['cx_type']=='未作答'){
 
-                 $dt_count = $dt_count+1;
 
-             }
 
-         }
 
-         $report_score = 15-$koufen;
 
-         $row['report_score'] = $report_score>0?$report_score:0;
 
-         $total = $row['fault_score']+$row['report_score']+$row['weixiu_score'];
 
-         Db::name('real_exam_score')->where('exam_id', $ids)->update(['total'=>$total]);
 
-         Db::name('real_exam')->where('exam_id', $ids)->update(['total_score'=>$total]);
 
-         $row['total'] = $total;
 
-         $this->view->assign('other_jielun', $other_jielun);
 
-         $this->view->assign('dt_count', $dt_count);
 
-         $diffInSeconds = $rows['endtime'] - $rows['starttime']; // 两个时间戳之间的差异(秒)
 
-         $minutes = floor($diffInSeconds / 60); // 计算分钟数
 
-         $seconds = $diffInSeconds % 60; // 计算剩余的秒数
 
-         $row['shijian'] = $minutes.'分'.$seconds.'秒';
 
-         $this->view->assign('row', $row);
 
-         return $this->view->fetch();
 
-     }
 
- }
 
 
  |