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['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):[]; $this->view->assign('other_report', $other_report); $this->view->assign('row', $row); return $this->view->fetch(); } }