ソースを参照

20250112 调整

贾小兵 3 ヶ月 前
コミット
8c7e5134b2

+ 2 - 0
application/admin/controller/department/Admin.php

@@ -182,6 +182,7 @@ class Admin extends Backend
                     if (!Validate::is($params['password'], '\S{6,16}')) {
                         exception(__("Please input correct password"));
                     }
+                    $params['depart_id'] = $department_id[0]??0;
                     $params['salt'] = Random::alnum();
                     $params['password'] = md5(md5($params['password']) . $params['salt']);
                     $params['avatar'] = '/assets/img/avatar.png'; //设置新管理员默认头像。
@@ -290,6 +291,7 @@ class Admin extends Backend
                     if (!$this->auth->isSuperAdmin()&&isset($params['data_scope'])){
                         unset($params['data_scope']);//超级管理人才能赋予全部数据权限
                     }
+                    $params['depart_id'] = $department_id[0]??0;
                     //这里需要针对username和email做唯一验证
                     $adminValidate = \think\Loader::validate('Admin');
                     $adminValidate->rule([

+ 20 - 13
application/admin/controller/student/Collection.php

@@ -11,6 +11,7 @@ use think\exception\PDOException;
 use think\exception\ValidateException;
 use think\response\Json;
 use think\Db;
+use think\Env;
 /**
  * sim-考试集合管理
  *
@@ -122,7 +123,7 @@ class Collection extends Backend
 //        }
         $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]);
+            $this->exam_model->where('exam_id',$info['exam_id'])->update(['seat_id'=>$this->auth->seat_id]);
             $info['seat_id'] = $this->auth->seat_id;
             $sim = Db::name('sim')->where('seat_id',$this->auth->seat_id)->find();
             $sim_text = '';
@@ -161,6 +162,7 @@ class Collection extends Backend
         $this->view->assign('row', $row);
         $this->assignConfig('exam_id', $info['exam_id']);
         $this->assignConfig('url_type', config('site.url_type'));
+        $this->assignConfig('is_fault', Env::get('app.is_fault'));
         return $this->view->fetch();
     }
 
@@ -172,10 +174,14 @@ class Collection extends Backend
         }
         if ($this->request->isPost()) {
             //先请求接口判断,再进行处理
-            $url = config('site.url_type').'/sim/real-exam-collection/teacher/exam/open/'.$ids;
-            $ret = json_decode(send_get($url),true);
-            if($ret['code']!=200){
-                $this->error($ret['msg']);
+            if(Env::get('app.is_fault')){
+                $url = config('site.url_type').'/sim/real-exam/student/exam/submit/'.$ids;
+                // /dev-api/sim/real-exam/student/exam/submit/{examId}
+                $ret = json_decode(send_get($url),true);
+                // halt($ret);
+                if($ret['code']!=200){
+                    $this->error($ret['msg']);
+                }
             }
 
             //计算分数,保存记录
@@ -218,7 +224,7 @@ class Collection extends Backend
                     foreach ($fault_list as $k =>$t){
                         $answer_right = 0;
                         if(!empty($t['sim_fault_question_value']) && !empty($t['sim_fault_answer_value'])){
-                            if($t['sim_fault_question_value']==$t['sim_fault_answer_value']){
+                            if($t['sim_fault_question_value']!=$t['sim_fault_answer_value']){
                                 $answer_right=1;
                             }else{
                                 $answer_right=2;
@@ -249,9 +255,14 @@ class Collection extends Backend
                     //故障保存的是部位,需要查找故障现象
                     $other_report = json_decode($params['other_report'],true);
                     if(count($other_report)<3){
-                        $xianxian_score = 5;
-                    }else{
-                        foreach ($other_report as $key => $em){
+                        $xianxian_score = 15-5*count($other_report)+$xianxian_score;
+                    //}else{
+                        
+//                        echo '部位:'.$buwei_score.'<br/>';
+//                        echo '原因:'.$yuanyin_socre.'<br/>';
+//                        echo '方法:'.$fangfa_score.'<br/>';
+                    }
+					foreach ($other_report as $key => $em){
                            //故障现象
                             if(!in_array($em['xx_id'],$partent_fault_id)){
                                 $xianxian_score = 5+$xianxian_score;
@@ -361,10 +372,6 @@ class Collection extends Backend
 //                                echo "这里为空扣了+1分<br/>";
                             }
                         }
-//                        echo '部位:'.$buwei_score.'<br/>';
-//                        echo '原因:'.$yuanyin_socre.'<br/>';
-//                        echo '方法:'.$fangfa_score.'<br/>';
-                    }
                 }
 //                echo "<pre>";
 //                print_r($buwei_arr);

+ 69 - 60
application/admin/controller/teacher/Collection.php

@@ -10,6 +10,7 @@ use think\exception\ValidateException;
 use app\admin\model\department\Department as DepartmentModel;
 use app\admin\model\teacher\Task;
 use app\admin\model\Fault;
+use think\Env;
 
 /**
  * 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 考试表  总分
             $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'],
-                    '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'),
-                        '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();
         } catch (ValidateException|PDOException|Exception $e) {
@@ -299,16 +303,19 @@ class Collection extends Backend
         if(!empty($values['exam_collection_state'])){
             //开始考试集合
             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端后台的接口数据,
                 //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;
             }
@@ -316,10 +323,12 @@ class Collection extends Backend
             if($values['exam_collection_state']==3){
                 //触发Java端后台的接口数据,
                 //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;
             }

+ 21 - 17
public/assets/js/backend/student/collection.js

@@ -72,19 +72,23 @@ define(['jquery', 'bootstrap', 'backend', 'table', 'form'], function ($, undefin
         },
         into: function () {
             $(document).on('click', '.btn-startexam', function () {
-                $.ajax({
-                    url: Config.url_type+"/sim/real-exam/student/exam/start/"+Config.exam_id,
-                    type: 'get',
-                    success: function (data) {
-                        console.log(data);
-                        if(data.code==200){
-                            window.location.href = '/ZQOtIMLKud.php/student/collection/examing/ids/'+Config.exam_id;
-                        }else{
-                            Layer.alert(data.msg);
-                            return;
+                if(Config.is_fault){
+                    $.ajax({
+                        url: Config.url_type+"/sim/real-exam/student/exam/start/"+Config.exam_id,
+                        type: 'get',
+                        success: function (data) {
+                            console.log(data);
+                            if(data.code==200){
+                                window.location.href = '/ZQOtIMLKud.php/student/collection/examing/ids/'+Config.exam_id;
+                            }else{
+                                Layer.alert(data.msg);
+                                return;
+                            }
                         }
-                    }
-                });
+                    });
+                }else{
+                    window.location.href = '/ZQOtIMLKud.php/student/collection/examing/ids/'+Config.exam_id;
+                }
             });
             // Controller.api.bindevent();
             // Form.api.bindevent($("form[role=form]"), function(data, ret) {
@@ -127,11 +131,11 @@ define(['jquery', 'bootstrap', 'backend', 'table', 'form'], function ($, undefin
                 }, 1000);
 
                 //五秒刷新,同步更换件列表数据
-                if(Config.isloading==1 && countdownTime>0){
-                    setInterval(function() {
-                        window.location.reload();
-                    }, 30000);
-                }
+                // if(Config.isloading==1 && countdownTime>0){
+                //     setInterval(function() {
+                //         window.location.reload();
+                //     }, 30000);
+                // }
 
             });
 

+ 1 - 1
public/assets/js/backend/student/exam.js

@@ -24,7 +24,7 @@ define(['jquery', 'bootstrap', 'backend', 'table', 'form'], function ($, undefin
                 columns: [
                     [
                         {checkbox: true},
-                        {field: 'exam_id', title: __('Exam_id')},
+                        // {field: 'exam_id', title: __('Exam_id')},
                         {field: 'exam_collection_name', title: __('考试名称')},
                         {field: 'sim_type', title: __('Sim_type'),searchList:{"0001":"FZD04B型侦毒器","0002":"FZB006型毒剂报警器","0003":"防化兵用毒剂报警器"},formatter: Table.api.formatter.simtype},
                         {field: 'user_username', title: __('学员学号')},

+ 1 - 1
public/assets/js/backend/teacher/info.js

@@ -31,7 +31,7 @@ define(['jquery', 'bootstrap', 'backend', 'table', 'form'], function ($, undefin
                 columns: [
                     [
                         {field: 'state', checkbox: true, },
-                        {field: 'id', title: '编号'},
+                        // {field: 'id', title: '编号'},
                         {field: 'username', title: __('Username')},
                         {field: 'nickname', title: __('Nickname')},
                         // {field: 'groups_text', title: __('Group'), operate:false, formatter: Table.api.formatter.label},