|
@@ -97,20 +97,47 @@ class Practice extends Backend
|
|
$this->error('未找到记录');
|
|
$this->error('未找到记录');
|
|
}
|
|
}
|
|
$info = $this->exam_model->where(['user_id'=>$this->auth->id,'exam_collection_id'=>$ids])->find();
|
|
$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' =>1,
|
|
|
|
- 'sim_type' => $row->sim_type,
|
|
|
|
- 'seat_id' => 1,
|
|
|
|
- 'sim_id' => 12,
|
|
|
|
- ];
|
|
|
|
- $this->exam_model->save($arr);
|
|
|
|
|
|
+ // 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' =>1,
|
|
|
|
+ // 'sim_type' => $row->sim_type,
|
|
|
|
+ // 'seat_id' => 1,
|
|
|
|
+ // 'sim_id' => 12,
|
|
|
|
+ // ];
|
|
|
|
+ // $this->exam_model->save($arr);
|
|
|
|
+ // }
|
|
|
|
+ if(!empty($info)){
|
|
|
|
+ if(!empty($this->auth->seat_id) && !empty($info['seat_id']) && $this->auth->seat_id!=$info['seat_id']){
|
|
|
|
+ $this->error('已在其他座号有开始的练习,不允许换座号');
|
|
|
|
+ }
|
|
|
|
+ $sim = Db::name('sim')->where('sim_type',$info['sim_type'])->where('seat_id',$this->auth->seat_id)->find();
|
|
|
|
+ if(empty($sim)){
|
|
|
|
+ $this->error('未找到模拟器,不可练习');
|
|
|
|
+ }
|
|
|
|
+ $this->exam_model->where('exam_id',$info['exam_id'])->update(['seat_id'=>$this->auth->seat_id,'sim_id'=>$sim['sim_id']]);
|
|
|
|
+ $info['seat_id'] = $this->auth->seat_id;
|
|
|
|
+ $sim_text = '';
|
|
|
|
+ if(!empty($sim)){
|
|
|
|
+ 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 = '手动禁用';
|
|
|
|
+ }
|
|
|
|
+ }
|
|
|
|
+// 模拟器状态 0:可用初始化 1:在线 2:模拟器离线 3:网关离线 4:硬件故障异常 5:手动禁用
|
|
|
|
+ $info['sim_text'] = $sim_text;
|
|
}
|
|
}
|
|
if(!empty($info['starttime']))
|
|
if(!empty($info['starttime']))
|
|
{
|
|
{
|