|
@@ -110,16 +110,7 @@ class Collection extends Backend
|
|
|
//匹配的学员自动加入 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_key1 = array_rand($fault_list);
|
|
|
- $fault_key2 = array_rand($fault_list);
|
|
|
- $fault_key3 = array_rand($fault_list);
|
|
|
- if($fault_list[$fault_key1]['parent_fault_id']==$fault_list[$fault_key2]['parent_fault_id']){
|
|
|
- $fault_key2 = array_rand($fault_list);
|
|
|
- }
|
|
|
- if($fault_list[$fault_key2]['parent_fault_id']==$fault_list[$fault_key3]['parent_fault_id']){
|
|
|
- $fault_key3 = array_rand($fault_list);
|
|
|
- }
|
|
|
- $fault_key = [$fault_key1,$fault_key2,$fault_key3];
|
|
|
+ $fault_key = $this->rand_fault($fault_list);
|
|
|
}else if($params['question_setting_method']==2){//教师自选
|
|
|
$question_ids = $params['question_ids'];
|
|
|
}else if($params['question_setting_method']==3){ //任务自选
|
|
@@ -237,16 +228,7 @@ class Collection extends Backend
|
|
|
//匹配的学员自动加入 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_key1 = array_rand($fault_list);
|
|
|
- $fault_key2 = array_rand($fault_list);
|
|
|
- $fault_key3 = array_rand($fault_list);
|
|
|
- if($fault_list[$fault_key1]['parent_fault_id']==$fault_list[$fault_key2]['parent_fault_id']){
|
|
|
- $fault_key2 = array_rand($fault_list);
|
|
|
- }
|
|
|
- if($fault_list[$fault_key2]['parent_fault_id']==$fault_list[$fault_key3]['parent_fault_id']){
|
|
|
- $fault_key3 = array_rand($fault_list);
|
|
|
- }
|
|
|
- $fault_key = [$fault_key1,$fault_key2,$fault_key3];
|
|
|
+ $fault_key = $this->rand_fault($fault_list);
|
|
|
}else if($params['question_setting_method']==2){//教师自选
|
|
|
$question_ids = $params['question_ids'];
|
|
|
}else if($params['question_setting_method']==3){ //任务自选
|
|
@@ -491,4 +473,23 @@ class Collection extends Backend
|
|
|
}
|
|
|
$this->error(__('No rows were deleted'));
|
|
|
}
|
|
|
+
|
|
|
+
|
|
|
+ public function rand_fault($fault_list = null){
|
|
|
+
|
|
|
+ $fault_key = array_rand($fault_list,3);
|
|
|
+ $fault_key1 = array_rand($fault_list);
|
|
|
+ $fault_key2 = array_rand($fault_list);
|
|
|
+ $fault_key3 = array_rand($fault_list);
|
|
|
+ if($fault_list[$fault_key1]['parent_fault_id']==$fault_list[$fault_key2]['parent_fault_id']){
|
|
|
+ $fault_key2 = array_rand($fault_list);
|
|
|
+ }
|
|
|
+ if($fault_list[$fault_key2]['parent_fault_id']==$fault_list[$fault_key3]['parent_fault_id']){
|
|
|
+ $fault_key3 = array_rand($fault_list);
|
|
|
+ }
|
|
|
+ $arr = [$fault_key1,$fault_key2,$fault_key3];
|
|
|
+ return $arr;
|
|
|
+ }
|
|
|
+
|
|
|
+
|
|
|
}
|