|
@@ -24,12 +24,15 @@ class Collection extends Backend
|
|
|
* @var \app\admin\model\teacher\Collection
|
|
|
*/
|
|
|
protected $model = null;
|
|
|
+
|
|
|
+ protected $exam_model = null;
|
|
|
protected $whereExtend = null;
|
|
|
|
|
|
public function _initialize()
|
|
|
{
|
|
|
parent::_initialize();
|
|
|
$this->model = new \app\admin\model\teacher\Collection;
|
|
|
+ $this->exam_model = new \app\admin\model\teacher\Exams;
|
|
|
$this->assignConfig('sim_sim_type', ConfigModel::getSimTypeList());
|
|
|
$this->assign('sim_sim_type', ConfigModel::getSimTypeList());
|
|
|
$this->assignConfig('sim_question_setting_method', ConfigModel::getSimQuestionList());
|
|
@@ -83,8 +86,54 @@ class Collection extends Backend
|
|
|
}
|
|
|
|
|
|
//匹配的学员自动加入 mx_real_exam 考试表 总分
|
|
|
+ $admin_list = Db::name('admin')->where('depart_id','in',$depart_ids)->select();
|
|
|
+ foreach ($admin_list as $it){
|
|
|
+ $arr1 = [
|
|
|
+ 'exam_collection_id' => $this->model->exam_collection_id,
|
|
|
+ 'exam_collection_name' => $params['exam_collection_name'],
|
|
|
+ 'exam_collection_type' => $params['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'],
|
|
|
+ 'seat_id'=>01,
|
|
|
+ 'sim_id'=>intval($params['sim_type']),
|
|
|
+ '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 考试故障关联表
|
|
|
+ if($params['question_setting_method']==1){ //系统随机
|
|
|
+ $fault_list = Fault::where(['sim_type' => $params['sim_type'], 'fault_state' => 0,'fault_type'=>3])->select();
|
|
|
+ }else if($params['question_setting_method']==2){//教师自选
|
|
|
+ $fault_list = Fault::where(['sim_type' => $params['sim_type'],'fault_id'=>['in',$params['question_ids']], 'fault_state' => 0,'fault_type'=>3])->select();
|
|
|
+ }else if($params['question_setting_method']==3){ //任务自选
|
|
|
+ $fault_list = Db::name('task_fault')->where(['task_id'=>['in',$params['question_ids']]])->select();
|
|
|
+ }
|
|
|
+ $fault_key = array_rand($fault_list, 3);
|
|
|
+ foreach ($fault_list as $key=> $item1){
|
|
|
+ $flag = 0;
|
|
|
+ if(in_array($key,$fault_key)){
|
|
|
+ $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);
|
|
|
|
|
|
- //匹配的学员自动加入 mx_real_exam_fault 考试故障关联表
|
|
|
+ }
|
|
|
|
|
|
Db::commit();
|
|
|
} catch (ValidateException|PDOException|Exception $e) {
|
|
@@ -104,6 +153,10 @@ class Collection extends Backend
|
|
|
$this->error(__('No Results were found'));
|
|
|
}
|
|
|
if (false === $this->request->isPost()) {
|
|
|
+ $examing_count = $this->exam_model->where(['exam_collection_id'=>$ids,'exam_status'=>4])->count();
|
|
|
+ if($examing_count>0){
|
|
|
+ $this->error('有学员考试中,无法修改');
|
|
|
+ }
|
|
|
$this->view->assign('row', $row);
|
|
|
$this->assignConfig('row_info', $row);
|
|
|
return $this->view->fetch();
|
|
@@ -124,13 +177,72 @@ class Collection extends Backend
|
|
|
$result = false;
|
|
|
Db::startTrans();
|
|
|
try {
|
|
|
- //是否采用模型验证
|
|
|
- if ($this->modelValidate) {
|
|
|
- $name = str_replace("\\model\\", "\\validate\\", get_class($this->model));
|
|
|
- $validate = is_bool($this->modelValidate) ? ($this->modelSceneValidate ? $name . '.edit' : $name) : $this->modelValidate;
|
|
|
- $row->validateFailException()->validate($validate);
|
|
|
- }
|
|
|
+ $depart_ids = $params['depart_ids'];
|
|
|
$result = $row->allowField(true)->save($params);
|
|
|
+
|
|
|
+
|
|
|
+ Db::name('real_exam_collection_dept')->where(['exam_collection_id'=>$row->exam_collection_id])->delete();
|
|
|
+ foreach(explode(',',$depart_ids) as $item){
|
|
|
+ if(!empty($item)){
|
|
|
+ $arr = [
|
|
|
+ 'exam_collection_id' => $row->exam_collection_id,
|
|
|
+ 'dept_id' => $item,
|
|
|
+ 'update_time' => date('Y-m-d H:i:s'),
|
|
|
+ ];
|
|
|
+ Db::name('real_exam_collection_dept')->insert($arr);
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ Db::name('real_exam')->where(['exam_collection_id'=>$row->exam_collection_id])->delete();
|
|
|
+ //匹配的学员自动加入 mx_real_exam 考试表 总分
|
|
|
+ $admin_list = Db::name('admin')->where('depart_id','in',$depart_ids)->select();
|
|
|
+ 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'],
|
|
|
+ 'seat_id'=>01,
|
|
|
+ 'sim_id'=>intval($params['sim_type']),
|
|
|
+ '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 考试故障关联表
|
|
|
+ if($params['question_setting_method']==1){ //系统随机
|
|
|
+ $fault_list = Fault::where(['sim_type' => $params['sim_type'], 'fault_state' => 0,'fault_type'=>3])->select();
|
|
|
+ }else if($params['question_setting_method']==2){//教师自选
|
|
|
+ $fault_list = Fault::where(['sim_type' => $params['sim_type'],'fault_id'=>['in',$params['question_ids']], 'fault_state' => 0,'fault_type'=>3])->select();
|
|
|
+ }else if($params['question_setting_method']==3){ //任务自选
|
|
|
+ $fault_list = Db::name('task_fault')->where(['task_id'=>['in',$params['question_ids']]])->select();
|
|
|
+ }
|
|
|
+ Db::name('real_exam_fault')->where(['exam_id'=>$examid])->delete();
|
|
|
+ $fault_key = array_rand($fault_list, 3);
|
|
|
+ foreach ($fault_list as $key=> $item1){
|
|
|
+ $flag = 0;
|
|
|
+ if(in_array($key,$fault_key)){
|
|
|
+ $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);
|
|
|
+ }
|
|
|
Db::commit();
|
|
|
} catch (ValidateException|PDOException|Exception $e) {
|
|
|
Db::rollback();
|
|
@@ -254,6 +366,12 @@ class Collection extends Backend
|
|
|
老师开启考试
|
|
|
*/
|
|
|
public function start($ids = null){
|
|
|
+// $row = $this->model->get($ids);
|
|
|
+// if (!$row) {
|
|
|
+// $this->error(__('No Results were found'));
|
|
|
+// }
|
|
|
+// $params['starttime'] = time();
|
|
|
+// $result = $row->allowField(true)->save($params);
|
|
|
$this->success('开始成功');
|
|
|
}
|
|
|
}
|