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]; } /** * 默认生成的控制器所继承的父类中有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']; $report_score = 15-$row['xianxian_score']-$row['yuanyin_socre']-$row['buwei_score']-$row['fangfa_score']; $row['report_score'] = $report_score>0?$report_score:0; $row['weixiu_score'] = 10-$row['overtime_score']??0; $row['xianxian_content_name'] = ''; if(!empty($row['xianxian_content'])) { $row['xianxian_content_name'] = json_decode($row['xianxian_content'],true); } $row['yuanyin_content_name'] = ''; if(!empty($row['yuanyin_content'])) { $row['yuanyin_content_name'] = json_decode($row['yuanyin_content'],true); } $row['buwei_content_name'] = ''; if(!empty($row['buwei_content'])) { $row['buwei_content_name'] = json_decode($row['buwei_content'],true); } $row['fangfa_content_name'] = ''; if(!empty($row['fangfa_content'])) { $row['fangfa_content_name'] = json_decode($row['fangfa_content'],true); } $other_report = !empty($row['other_report']) ? json_decode($row['other_report'],true):[]; $other_jielun = !empty($row['other_jielun']) ? json_decode($row['other_jielun'],true):[]; $fault_right_list = Db::name('real_exam_fault')->where(['exam_id'=>$ids,'flag'=>1])->select(); //根据故障部位 数组 $fault_arr = [$fault_right_list[0]['fault_id'],$fault_right_list[1]['fault_id'],$fault_right_list[2]['fault_id']]; //查找故障现象 数组 $partent_fault_id = Fault::where(['fault_id'=>['in',$fault_arr],'sim_type'=>$rows['sim_type']])->column('parent_fault_id'); $arr1= []; foreach ($partent_fault_id as $key => $value) { $arr1[] = [ 'gzxz_id' => $value, 'xianxian_content' => $row['xianxian_content_name'], 'other_report' => $other_report, 'other_jielun' => $other_jielun, ]; } $this->view->assign('other_report', $other_report); $this->view->assign('partent_fault_id', $arr1); $this->view->assign('row', $row); return $this->view->fetch(); } }