|
@@ -67,15 +67,17 @@ class Collection extends Backend
|
|
$isset = $this->model->alias('z')
|
|
$isset = $this->model->alias('z')
|
|
->join('real_exam r','z.exam_collection_id=r.exam_collection_id','left')
|
|
->join('real_exam r','z.exam_collection_id=r.exam_collection_id','left')
|
|
->where('z.exam_collection_type=3 and z.exam_collection_state=2 and r.endtime=0 and r.user_id='.$this->auth->id)->find();
|
|
->where('z.exam_collection_type=3 and z.exam_collection_state=2 and r.endtime=0 and r.user_id='.$this->auth->id)->find();
|
|
- if(empty($isset)){
|
|
|
|
|
|
+
|
|
|
|
+ if(empty($isset)){
|
|
//提示页面,没有开始的考试
|
|
//提示页面,没有开始的考试
|
|
return $this->view->fetch('tishi');
|
|
return $this->view->fetch('tishi');
|
|
- }else{
|
|
|
|
-// $this->redirect('/ZQOtIMLKud.php/student/collection/examing/ids/'.$isset['exam_id'].'?ref=addtabs');
|
|
|
|
- echo "<script>location.href='/ZQOtIMLKud.php/student/collection/examing/ids/".$isset['exam_id']."';</script>";
|
|
|
|
- //$this->redirect('/hotelmanage/room/displayindex/ids/1');
|
|
|
|
- exit();
|
|
|
|
- }
|
|
|
|
|
|
+ }else{
|
|
|
|
+//// $this->redirect('/ZQOtIMLKud.php/student/collection/examing/ids/'.$isset['exam_id'].'?ref=addtabs');
|
|
|
|
+// echo "<script>location.href='/ZQOtIMLKud.php/student/collection/examing/ids/".$isset['exam_id']."';</script>";
|
|
|
|
+// //$this->redirect('/hotelmanage/room/displayindex/ids/1');
|
|
|
|
+// exit();
|
|
|
|
+ echo "<script>location.href='/ZQOtIMLKud.php/student/collection/into/ids/".$isset['exam_collection_id']."'</script>";
|
|
|
|
+ }
|
|
die();
|
|
die();
|
|
//设置过滤方法
|
|
//设置过滤方法
|
|
$this->request->filter(['strip_tags', 'trim']);
|
|
$this->request->filter(['strip_tags', 'trim']);
|
|
@@ -112,58 +114,38 @@ class Collection extends Backend
|
|
if(!$row){
|
|
if(!$row){
|
|
$this->error('未找到记录');
|
|
$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,
|
|
|
|
- 'user_username' => $this->auth->username,
|
|
|
|
- 'user_nickname' => $this->auth->nickname,
|
|
|
|
- 'user_depart_id' => $this->auth->depart_id,
|
|
|
|
- 'exam_collection_name' => $row->exam_collection_name,
|
|
|
|
- 'exam_collection_type' => 3,
|
|
|
|
- 'sim_type' => $row->sim_type,
|
|
|
|
- 'seat_id' => 1,
|
|
|
|
- 'sim_id' => intval($row->sim_type),
|
|
|
|
- ];
|
|
|
|
- $this->exam_model->save($arr);
|
|
|
|
-
|
|
|
|
- //考试和故障关联表
|
|
|
|
- $fault_list = Fault::where(['sim_type' => $row->sim_type, 'fault_state' => 0,'fault_type'=>3])->select();
|
|
|
|
- $fault_key = array_rand($fault_list, 3);
|
|
|
|
- foreach ($fault_list as $key=> $item){
|
|
|
|
- $flag = 0;
|
|
|
|
- if(in_array($key,$fault_key)){
|
|
|
|
- $flag = 1;
|
|
|
|
- }
|
|
|
|
- $add= [
|
|
|
|
- 'exam_id'=>$this->exam_model->exam_id,
|
|
|
|
- 'fault_id'=>$item->fault_id,
|
|
|
|
- 'ref_type'=>2,
|
|
|
|
- 'flag'=>$flag,
|
|
|
|
- 'ref_state'=>3,
|
|
|
|
- 'sim_fault_question_value'=>'0000000'.rand(1,2),
|
|
|
|
- 'createtime'=>time(),
|
|
|
|
- 'updatetime'=>time(),
|
|
|
|
- 'create_time'=>date('Y-m-d H:i:s'),
|
|
|
|
- 'update_time'=>date('Y-m-d H:i:s'),
|
|
|
|
- ];
|
|
|
|
- Db::name('real_exam_fault')->insert($add);
|
|
|
|
|
|
+ $info = $this->exam_model->where(['user_id'=>$this->auth->id,'exam_collection_id'=>$ids,'exam_collection_type'=>3,'endtime'=>0])->find();
|
|
|
|
+ if(!empty($info)){
|
|
|
|
+ $this->exam_model->where('exam_id',$info['exam_id'])->update(['seat_id'=>$this->auth->seat_id,'sim_id'=>$this->auth->sim_id]);
|
|
|
|
+ $sim = Db::name('sim')->where('seat_id',$this->auth->seat_id)->find();
|
|
|
|
+ $sim_text = '';
|
|
|
|
+// 模拟器状态 0:可用初始化 1:在线 2:模拟器离线 3:网关离线 4:硬件故障异常 5:手动禁用
|
|
|
|
+ if($sim['sim_state']==1){
|
|
|
|
+ $sim_text = '在线';
|
|
|
|
+ }else if($sim['sim_state']==2){
|
|
|
|
+ $sim_text = '模拟器离线';
|
|
|
|
+ }else if($sim['sim_state']==3){
|
|
|
|
+ $sim_text = '网关离线';
|
|
|
|
+ }else if($sim['sim_state']==4){
|
|
|
|
+ $sim_text = '硬件故障异常';
|
|
|
|
+ }else if($sim['sim_state']==5){
|
|
|
|
+ $sim_text = '手动禁用';
|
|
}
|
|
}
|
|
- unset($item);
|
|
|
|
|
|
+ $info['sim_text'] = $sim_text;
|
|
}
|
|
}
|
|
if ($this->request->isPost()) {
|
|
if ($this->request->isPost()) {
|
|
- $exam_collection_id = $this->request->post('exam_collection_id');
|
|
|
|
- if(empty($info->starttime)){
|
|
|
|
- $info->start_time = date('Y-m-d H:i:s');
|
|
|
|
- $info->starttime = time();
|
|
|
|
- }
|
|
|
|
- $info->exam_status = 4;
|
|
|
|
- $info->save();
|
|
|
|
- $this->success('开始成功','/ZQOtIMLKud.php/student/collection/examing/ids/'.$info['exam_id']);
|
|
|
|
|
|
+// $exam_collection_id = $this->request->post('exam_collection_id');
|
|
|
|
+// if(empty($info->starttime)){
|
|
|
|
+// $info->start_time = date('Y-m-d H:i:s');
|
|
|
|
+// $info->starttime = time();
|
|
|
|
+// }
|
|
|
|
+// $info->exam_status = 4;
|
|
|
|
+// $info->save();
|
|
|
|
+// $this->success('开始成功','/ZQOtIMLKud.php/student/collection/examing/ids/'.$info['exam_id']);
|
|
}
|
|
}
|
|
|
|
+ $this->view->assign('info', $info);
|
|
$this->view->assign('row', $row);
|
|
$this->view->assign('row', $row);
|
|
|
|
+ $this->assignConfig('exam_id', $info['exam_id']);
|
|
return $this->view->fetch();
|
|
return $this->view->fetch();
|
|
}
|
|
}
|
|
|
|
|
|
@@ -174,6 +156,8 @@ class Collection extends Backend
|
|
$this->error('未找到记录');
|
|
$this->error('未找到记录');
|
|
}
|
|
}
|
|
if ($this->request->isPost()) {
|
|
if ($this->request->isPost()) {
|
|
|
|
+ //先请求接口判断,再进行处理
|
|
|
|
+
|
|
//计算分数,保存记录
|
|
//计算分数,保存记录
|
|
$params = $this->request->post('row/a');
|
|
$params = $this->request->post('row/a');
|
|
|
|
|
|
@@ -199,18 +183,18 @@ class Collection extends Backend
|
|
$info = $this->exam_model->where(['exam_id'=>$ids])->find();
|
|
$info = $this->exam_model->where(['exam_id'=>$ids])->find();
|
|
|
|
|
|
//更新考试关联表,计算得分 mx_real_exam_fault
|
|
//更新考试关联表,计算得分 mx_real_exam_fault
|
|
- $fault_list = Db::name('real_exam_fault')->where(['exam_id'=>$ids,'flag'=>1])->select();
|
|
|
|
- foreach ($fault_list as $it)
|
|
|
|
- {
|
|
|
|
- $update['sim_fault_answer_value'] ='0000000'.rand(1,2);
|
|
|
|
- if($update['sim_fault_answer_value']==$it['sim_fault_question_value']){
|
|
|
|
- $update['answer_right'] = 1;
|
|
|
|
- }else{
|
|
|
|
- $update['answer_right'] = 2;
|
|
|
|
- }
|
|
|
|
- Db::name('real_exam_fault')->where('ref_id',$it['ref_id'])->update($update);
|
|
|
|
- }
|
|
|
|
- unset($it);
|
|
|
|
|
|
+// $fault_list = Db::name('real_exam_fault')->where(['exam_id'=>$ids,'flag'=>1])->select();
|
|
|
|
+// foreach ($fault_list as $it)
|
|
|
|
+// {
|
|
|
|
+// $update['sim_fault_answer_value'] ='0000000'.rand(1,2);
|
|
|
|
+// if($update['sim_fault_answer_value']==$it['sim_fault_question_value']){
|
|
|
|
+// $update['answer_right'] = 1;
|
|
|
|
+// }else{
|
|
|
|
+// $update['answer_right'] = 2;
|
|
|
|
+// }
|
|
|
|
+// Db::name('real_exam_fault')->where('ref_id',$it['ref_id'])->update($update);
|
|
|
|
+// }
|
|
|
|
+// unset($it);
|
|
|
|
|
|
//计算得分,故障是否有扣分 扣分制
|
|
//计算得分,故障是否有扣分 扣分制
|
|
$fault_right_list = Db::name('real_exam_fault')->where(['exam_id'=>$ids,'flag'=>1,'answer_right'=>['>',0]])->select();
|
|
$fault_right_list = Db::name('real_exam_fault')->where(['exam_id'=>$ids,'flag'=>1,'answer_right'=>['>',0]])->select();
|