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; $other_jielun = !empty($row['other_jielun']) ? json_decode($row['other_jielun'],true):[]; $this->view->assign('other_jielun', $other_jielun); $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(); } }