model = new \app\admin\model\teacher\Collection; $this->exam_model = new \app\admin\model\teacher\Exams; $this->assignConfig('sim_sim_type', ConfigModel::getSimTypeList()); $this->assignConfig('sim_question_setting_method', ConfigModel::getSimQuestionList()); $this->whereExtend['exam_collection_type'] = 3; $this->whereExtend['exam_collection_state'] = 2; } /** * 默认生成的控制器所继承的父类中有index/add/edit/del/multi五个基础方法、destroy/restore/recyclebin三个回收站方法 * 因此在当前控制器中可不用编写增删改查的代码,除非需要自己控制这部分逻辑 * 需要将application/admin/library/traits/Backend.php中对应的方法复制到当前控制器,然后进行修改 */ //进入考试 public function into($ids = null) { $row = $this->model->get($ids); if(!$row){ $this->error('未找到记录'); } $info = $this->exam_model->where(['user_id'=>$this->auth->id,'exam_collection_id'=>$ids])->find(); if(empty($info)){ $arr = [ 'exam_collection_id' => $ids, 'user_id' => $this->auth->id, 'seat_id' => 1, 'sim_id' => 12, ]; $this->exam_model->save($arr); } if ($this->request->isPost()) { $exam_collection_id = $this->request->post('exam_collection_id'); $info->start_time = date('Y-m-d H:i:s'); $info->save(); $this->success('开始成功','/ZQOtIMLKud.php/student/collection/examing/ids/'.$info['exam_id']); } $this->view->assign('row', $row); return $this->view->fetch(); } public function examing($ids = null) { $row = $this->exam_model->get($ids); if(!$row){ $this->error('未找到记录'); } $this->assignConfig('timer', 60*$this->model->where(['exam_collection_id'=>$row['exam_collection_id']])->value('limit_duration')); $this->view->assign('row', $row); $departmentdata = []; $departmentdata = Report::where(['level'=>4,'is_replace'=>1])->select(); // foreach ($result as $k => $v) { // $departmentdata[$v['report_id']] = $v['name']; // } // halt($departmentdata); if ($this->request->isPost()) { $params = $this->request->post('row/a'); $this->success('交卷成功','/ZQOtIMLKud.php/student/collection/analysis/ids/'.$row['exam_id']); } $this->view->assign('departmentdata', $departmentdata); return $this->view->fetch(); } public function analysis($ids = null) { $row = $this->exam_model->get($ids); if(!$row){ $this->error('未找到记录'); } if ($this->request->isPost()) { $params = $this->request->post('row/a'); $this->success('操作成功','/ZQOtIMLKud.php/student/collection/index'); } return $this->view->fetch(); } }