|
@@ -10,6 +10,7 @@ use think\exception\ValidateException;
|
|
use app\admin\model\department\Department as DepartmentModel;
|
|
use app\admin\model\department\Department as DepartmentModel;
|
|
use app\admin\model\teacher\Task;
|
|
use app\admin\model\teacher\Task;
|
|
use app\admin\model\Fault;
|
|
use app\admin\model\Fault;
|
|
|
|
+use think\Env;
|
|
|
|
|
|
/**
|
|
/**
|
|
* sim-考试集合管理
|
|
* sim-考试集合管理
|
|
@@ -205,60 +206,63 @@ class Collection extends Backend
|
|
}
|
|
}
|
|
}
|
|
}
|
|
|
|
|
|
- Db::name('real_exam')->where(['exam_collection_id'=>$row->exam_collection_id])->delete();
|
|
|
|
|
|
+ Db::name('real_exam')->where(['exam_collection_id'=>$row->exam_collection_id,'starttime'=>0])->delete();
|
|
//匹配的学员自动加入 mx_real_exam 考试表 总分
|
|
//匹配的学员自动加入 mx_real_exam 考试表 总分
|
|
$admin_list = Db::name('admin')->where('depart_id','in',$depart_ids)->select();
|
|
$admin_list = Db::name('admin')->where('depart_id','in',$depart_ids)->select();
|
|
foreach ($admin_list as $it){
|
|
foreach ($admin_list as $it){
|
|
- $arr1 = [
|
|
|
|
- 'exam_collection_id' => $row->exam_collection_id,
|
|
|
|
- 'exam_collection_name' => $params['exam_collection_name'],
|
|
|
|
- 'exam_collection_type' => $row['exam_collection_type'],
|
|
|
|
- 'sim_type' => $params['sim_type'],
|
|
|
|
- 'user_username' => $it['username'],
|
|
|
|
- 'user_nickname' => $it['nickname'],
|
|
|
|
- 'user_id' => $it['id'],
|
|
|
|
- 'user_depart_id' => $it['depart_id'],
|
|
|
|
- 'create_time'=>date('Y-m-d H:i:s'),
|
|
|
|
- 'update_time' => date('Y-m-d H:i:s'),
|
|
|
|
- ];
|
|
|
|
- $examid = Db::name('real_exam')->insertGetId($arr1);
|
|
|
|
- //匹配的学员自动加入 mx_real_exam_fault 考试故障关联表
|
|
|
|
- $fault_list = Fault::where(['sim_type' => $params['sim_type'], 'fault_state' => 0,'fault_type'=>3])->select();
|
|
|
|
- if($params['question_setting_method']==1){ //系统随机
|
|
|
|
- $fault_key = array_rand($fault_list, 3);
|
|
|
|
- }else if($params['question_setting_method']==2){//教师自选
|
|
|
|
- $question_ids = $params['question_ids'];
|
|
|
|
- }else if($params['question_setting_method']==3){ //任务自选
|
|
|
|
- $task_ids = Db::name('task_fault')->where(['task_id'=>['in',$params['task_id']]])->column('fault_id');
|
|
|
|
- }
|
|
|
|
- Db::name('real_exam_fault')->where(['exam_id'=>$examid])->delete();
|
|
|
|
-
|
|
|
|
- foreach ($fault_list as $key=> $item1){
|
|
|
|
- $flag = 0;
|
|
|
|
- if(!empty($fault_key) && in_array($key,$fault_key)){
|
|
|
|
- $flag = 1;
|
|
|
|
- }
|
|
|
|
- if(!empty($question_ids) && in_array($item1['fault_id'],explode(',',$question_ids))){
|
|
|
|
- $flag = 1;
|
|
|
|
- }
|
|
|
|
- if(!empty($task_ids) && in_array($item1['fault_id'],$task_ids)){
|
|
|
|
- $flag = 1;
|
|
|
|
- }
|
|
|
|
- $add= [
|
|
|
|
- 'exam_id'=>$examid,
|
|
|
|
- 'fault_id'=>$item1['fault_id'],
|
|
|
|
- 'ref_type'=>2,
|
|
|
|
- 'flag'=>$flag,
|
|
|
|
- 'ref_state'=>3,
|
|
|
|
-// 'sim_fault_question_value'=>'0000000'.rand(1,2),
|
|
|
|
- 'createtime'=>time(),
|
|
|
|
- 'updatetime'=>time(),
|
|
|
|
|
|
+ $real_exam = Db::name('real_exam')->where(['exam_collection_id'=>$row->exam_collection_id,'user_id'=>$it['id']])->find();
|
|
|
|
+ if(empty($real_exam)){
|
|
|
|
+ $arr1 = [
|
|
|
|
+ 'exam_collection_id' => $row->exam_collection_id,
|
|
|
|
+ 'exam_collection_name' => $params['exam_collection_name'],
|
|
|
|
+ 'exam_collection_type' => $row['exam_collection_type'],
|
|
|
|
+ 'sim_type' => $params['sim_type'],
|
|
|
|
+ 'user_username' => $it['username'],
|
|
|
|
+ 'user_nickname' => $it['nickname'],
|
|
|
|
+ 'user_id' => $it['id'],
|
|
|
|
+ 'user_depart_id' => $it['depart_id'],
|
|
'create_time'=>date('Y-m-d H:i:s'),
|
|
'create_time'=>date('Y-m-d H:i:s'),
|
|
- 'update_time'=>date('Y-m-d H:i:s'),
|
|
|
|
|
|
+ 'update_time' => date('Y-m-d H:i:s'),
|
|
];
|
|
];
|
|
- Db::name('real_exam_fault')->insert($add);
|
|
|
|
|
|
+ $examid = Db::name('real_exam')->insertGetId($arr1);
|
|
|
|
+ //匹配的学员自动加入 mx_real_exam_fault 考试故障关联表
|
|
|
|
+ $fault_list = Fault::where(['sim_type' => $params['sim_type'], 'fault_state' => 0,'fault_type'=>3])->select();
|
|
|
|
+ if($params['question_setting_method']==1){ //系统随机
|
|
|
|
+ $fault_key = array_rand($fault_list, 3);
|
|
|
|
+ }else if($params['question_setting_method']==2){//教师自选
|
|
|
|
+ $question_ids = $params['question_ids'];
|
|
|
|
+ }else if($params['question_setting_method']==3){ //任务自选
|
|
|
|
+ $task_ids = Db::name('task_fault')->where(['task_id'=>['in',$params['task_id']]])->column('fault_id');
|
|
|
|
+ }
|
|
|
|
+ Db::name('real_exam_fault')->where(['exam_id'=>$examid])->delete();
|
|
|
|
+
|
|
|
|
+ foreach ($fault_list as $key=> $item1){
|
|
|
|
+ $flag = 0;
|
|
|
|
+ if(!empty($fault_key) && in_array($key,$fault_key)){
|
|
|
|
+ $flag = 1;
|
|
|
|
+ }
|
|
|
|
+ if(!empty($question_ids) && in_array($item1['fault_id'],explode(',',$question_ids))){
|
|
|
|
+ $flag = 1;
|
|
|
|
+ }
|
|
|
|
+ if(!empty($task_ids) && in_array($item1['fault_id'],$task_ids)){
|
|
|
|
+ $flag = 1;
|
|
|
|
+ }
|
|
|
|
+ $add= [
|
|
|
|
+ 'exam_id'=>$examid,
|
|
|
|
+ 'fault_id'=>$item1['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);
|
|
|
|
+ }
|
|
|
|
+ unset($item1);
|
|
}
|
|
}
|
|
- unset($item1);
|
|
|
|
}
|
|
}
|
|
Db::commit();
|
|
Db::commit();
|
|
} catch (ValidateException|PDOException|Exception $e) {
|
|
} catch (ValidateException|PDOException|Exception $e) {
|
|
@@ -299,16 +303,19 @@ class Collection extends Backend
|
|
if(!empty($values['exam_collection_state'])){
|
|
if(!empty($values['exam_collection_state'])){
|
|
//开始考试集合
|
|
//开始考试集合
|
|
if($values['exam_collection_state']==2){
|
|
if($values['exam_collection_state']==2){
|
|
-// $state_count = $this->model->where(['exam_collection_state'=>$values['exam_collection_state'],'exam_collection_type'=>3])->count();
|
|
|
|
-// if($state_count>0){
|
|
|
|
-// $this->error('已有启用的考试,请先关闭原来的考试');
|
|
|
|
-// }
|
|
|
|
//触发Java端后台的接口数据,
|
|
//触发Java端后台的接口数据,
|
|
//dev-api/sim/real-exam-collection/teacher/exam/open/{examcollectionId} $ids put
|
|
//dev-api/sim/real-exam-collection/teacher/exam/open/{examcollectionId} $ids put
|
|
- $url = config('site.url_type').'/sim/real-exam-collection/teacher/exam/open/'.$ids;
|
|
|
|
- $ret = json_decode(send_post($url),true);
|
|
|
|
- if($ret['code']!=200){
|
|
|
|
- $this->error($ret['msg']);
|
|
|
|
|
|
+ if(Env::get('app.is_fault')){
|
|
|
|
+ $url = config('site.url_type').'/sim/real-exam-collection/teacher/exam/open/'.$ids;
|
|
|
|
+ $ret = json_decode(send_post($url),true);
|
|
|
|
+ if($ret['code']!=200){
|
|
|
|
+ $this->error($ret['msg']);
|
|
|
|
+ }
|
|
|
|
+ }else{
|
|
|
|
+ $state_count = $this->model->where(['exam_collection_state'=>$values['exam_collection_state'],'exam_collection_type'=>3])->count();
|
|
|
|
+ if($state_count>0){
|
|
|
|
+ $this->error('已有启用的考试,请先关闭原来的考试');
|
|
|
|
+ }
|
|
}
|
|
}
|
|
$count = 1;
|
|
$count = 1;
|
|
}
|
|
}
|
|
@@ -316,10 +323,12 @@ class Collection extends Backend
|
|
if($values['exam_collection_state']==3){
|
|
if($values['exam_collection_state']==3){
|
|
//触发Java端后台的接口数据,
|
|
//触发Java端后台的接口数据,
|
|
//dev-api/sim/real-exam-collection/teacher/exam/open/{examcollectionId} $ids put
|
|
//dev-api/sim/real-exam-collection/teacher/exam/open/{examcollectionId} $ids put
|
|
- $url = config('site.url_type').'/sim/real-exam-collection/teacher/exam/close/'.$ids;
|
|
|
|
- $ret = json_decode(send_post($url),true);
|
|
|
|
- if($ret['code']!=200){
|
|
|
|
- $this->error($ret['msg']);
|
|
|
|
|
|
+ if(Env::get('app.is_fault')){
|
|
|
|
+ $url = config('site.url_type').'/sim/real-exam-collection/teacher/exam/close/'.$ids;
|
|
|
|
+ $ret = json_decode(send_post($url),true);
|
|
|
|
+ if($ret['code']!=200){
|
|
|
|
+ $this->error($ret['msg']);
|
|
|
|
+ }
|
|
}
|
|
}
|
|
$count = 1;
|
|
$count = 1;
|
|
}
|
|
}
|