|
@@ -2,12 +2,15 @@
|
|
|
|
|
|
namespace app\admin\controller\student;
|
|
namespace app\admin\controller\student;
|
|
|
|
|
|
|
|
+use app\admin\model\department\Department;
|
|
use app\admin\model\Fault;
|
|
use app\admin\model\Fault;
|
|
use app\admin\model\Report;
|
|
use app\admin\model\Report;
|
|
use app\common\controller\Backend;
|
|
use app\common\controller\Backend;
|
|
use app\common\model\Config as ConfigModel;
|
|
use app\common\model\Config as ConfigModel;
|
|
use think\Db;
|
|
use think\Db;
|
|
|
|
+use think\Env;
|
|
use think\exception\PDOException;
|
|
use think\exception\PDOException;
|
|
|
|
+use think\exception\ValidateException;
|
|
|
|
|
|
/**
|
|
/**
|
|
* sim-自主练习集合管理
|
|
* sim-自主练习集合管理
|
|
@@ -82,7 +85,33 @@ class Exercise extends Backend
|
|
'updatetime'=>time(),
|
|
'updatetime'=>time(),
|
|
];
|
|
];
|
|
$examid = $this->exam_model->insertGetId($data);
|
|
$examid = $this->exam_model->insertGetId($data);
|
|
|
|
+
|
|
|
|
+
|
|
|
|
+ //匹配的学员自动加入 mx_real_exam_fault 考试故障关联表
|
|
|
|
+ $fault_list = Fault::where(['sim_type' => $params['sim_type'], 'fault_state' => 0,'fault_type'=>3])->select();
|
|
|
|
+ foreach ($fault_list as $key=> $item1){
|
|
|
|
+ $fault_key = array_rand($fault_list, 3);
|
|
|
|
+ $flag = 0;
|
|
|
|
+ if(!empty($fault_key) && in_array($key,$fault_key)){
|
|
|
|
+ $flag = 1;
|
|
|
|
+ }
|
|
|
|
+ $add= [
|
|
|
|
+ 'exam_id'=>$examid,
|
|
|
|
+ 'fault_id'=>$item1['fault_id'],
|
|
|
|
+ 'ref_type'=>2,
|
|
|
|
+ 'flag'=>$flag,
|
|
|
|
+ 'ref_state'=>0,
|
|
|
|
+ '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);
|
|
|
|
+ }
|
|
|
|
+
|
|
$count = $examid;
|
|
$count = $examid;
|
|
|
|
+
|
|
|
|
+
|
|
Db::commit();
|
|
Db::commit();
|
|
} catch (PDOException|Exception $e) {
|
|
} catch (PDOException|Exception $e) {
|
|
Db::rollback();
|
|
Db::rollback();
|
|
@@ -102,20 +131,207 @@ class Exercise extends Backend
|
|
$this->error('未找到记录');
|
|
$this->error('未找到记录');
|
|
}
|
|
}
|
|
if ($this->request->isPost()) {
|
|
if ($this->request->isPost()) {
|
|
|
|
+
|
|
|
|
+ //先请求接口判断,再进行处理
|
|
|
|
+ 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']);
|
|
|
|
+ }
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ //计算分数,保存记录
|
|
$params = $this->request->post('row/a');
|
|
$params = $this->request->post('row/a');
|
|
- $row->end_time = date('Y-m-d H:i:s');
|
|
|
|
- $row->endtime = time();
|
|
|
|
- $row->exam_status = 5;
|
|
|
|
- $row->save();
|
|
|
|
|
|
+
|
|
|
|
+ $result = false;
|
|
|
|
+ $score = 100;
|
|
|
|
+ $fault_one_score = 25;
|
|
|
|
+ $fault_two_score = 25;
|
|
|
|
+ $fault_three_score = 25;
|
|
|
|
+
|
|
|
|
+ $xianxian_score = 0;
|
|
|
|
+ $yuanyin_socre= 0;
|
|
|
|
+ $buwei_score= 0;
|
|
|
|
+ $fangfa_score= 0;
|
|
|
|
+
|
|
|
|
+ $xianxian_arr = [];
|
|
|
|
+ $yuanyin_arr = [];
|
|
|
|
+ $buwei_arr = [];
|
|
|
|
+ $fangfa_arr = [];
|
|
|
|
+ $jielun_score = 0;
|
|
|
|
+
|
|
|
|
+
|
|
|
|
+ Db::startTrans();
|
|
|
|
+ try {
|
|
|
|
+
|
|
|
|
+ //更新考试结束时间
|
|
|
|
+ $row->end_time = date('Y-m-d H:i:s');
|
|
|
|
+ $row->endtime = time();
|
|
|
|
+ $row->exam_status = 5;
|
|
|
|
+ $row->other_report = $params['other_report'];
|
|
|
|
+ $result = $row->save();
|
|
|
|
+
|
|
|
|
+ $info = $this->exam_model->where(['exam_id'=>$ids])->find();
|
|
|
|
+
|
|
|
|
+
|
|
|
|
+ //更新故障是否正确
|
|
|
|
+ $fault_list = Db::name('real_exam_fault')->where(['exam_id'=>$ids,'flag'=>1])->select();
|
|
|
|
+ if(!empty($fault_list)){
|
|
|
|
+ foreach ($fault_list as $k =>$t){
|
|
|
|
+ $answer_right = 2;
|
|
|
|
+ if(!empty($t['sim_fault_question_value']) && !empty($t['sim_fault_answer_value'])){
|
|
|
|
+ if($t['sim_fault_question_value']!=$t['sim_fault_answer_value'] ){
|
|
|
|
+ //真实故障id 000200010001
|
|
|
|
+ if($t['sim_fault_answer_value']=='00000000' && $t['fault_id'] !='000200010001'){
|
|
|
|
+ $answer_right=2;
|
|
|
|
+ }
|
|
|
|
+ $answer_right=1;
|
|
|
|
+ }
|
|
|
|
+ }
|
|
|
|
+ Db::name('real_exam_fault')->where(['ref_id'=>$t['ref_id']])->update(['answer_right'=>$answer_right]);
|
|
|
|
+ }
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+
|
|
|
|
+ //计算得分,故障是否有扣分 扣分制
|
|
|
|
+ $fault_right_list = Db::name('real_exam_fault')->where(['exam_id'=>$ids,'flag'=>1,'answer_right'=>['>',0]])->select();
|
|
|
|
+ if(!empty($fault_right_list)){
|
|
|
|
+ if($fault_right_list[0]['answer_right']==1){
|
|
|
|
+ $fault_one_score = 0;
|
|
|
|
+ }
|
|
|
|
+ if($fault_right_list[1]['answer_right']==1){
|
|
|
|
+ $fault_two_score = 0;
|
|
|
|
+ }
|
|
|
|
+ if($fault_right_list[2]['answer_right']==1){
|
|
|
|
+ $fault_three_score = 0;
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ //根据故障部位,查找故障现象
|
|
|
|
+ $fault_arr = [$fault_right_list[0]['fault_id'],$fault_right_list[1]['fault_id'],$fault_right_list[2]['fault_id']];
|
|
|
|
+ $partent_fault_id = Fault::where(['fault_id'=>['in',$fault_arr]])->column('parent_fault_id');
|
|
|
|
+
|
|
|
|
+ //故障保存的是部位,需要查找故障现象
|
|
|
|
+ $other_report = json_decode($params['other_report'],true);
|
|
|
|
+ if(count($other_report)<3){
|
|
|
|
+ $xianxian_score = 15-5*count($other_report)+$xianxian_score;
|
|
|
|
+ $buwei_score = 3-1*count($other_report)+$buwei_score;
|
|
|
|
+ $yuanyin_socre = 3-1*count($other_report)+$yuanyin_socre;
|
|
|
|
+ $fangfa_score = 3-1*count($other_report)+$fangfa_score;
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ foreach ($other_report as $key => $em){
|
|
|
|
+ //故障现象
|
|
|
|
+ if(!in_array($em['xx_id'],$partent_fault_id)){
|
|
|
|
+ $xianxian_score = 5+$xianxian_score;
|
|
|
|
+ $xianxian_arr[] = $em['xx_id'];
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ //故障部位
|
|
|
|
+ if(!empty($em['bw_id'])){
|
|
|
|
+ $report_xx_id = Report::where(['bw_id'=>['in',$em['bw_id']]])->column('xx_id');
|
|
|
|
+ if(!in_array($em['xx_id'],$report_xx_id)){ //现象不对,直接扣分
|
|
|
|
+ $buwei_score = 1+$buwei_score;
|
|
|
|
+ $buwei_arr[] = $em['bw_id'];
|
|
|
|
+ }else{
|
|
|
|
+ //现象正确,判断是不是正确的选项
|
|
|
|
+ foreach (explode(',',$em['bw_id']) as $s => $bs){
|
|
|
|
+ if(!in_array($bs,$fault_arr)){
|
|
|
|
+ $buwei_score = 1+$buwei_score;
|
|
|
|
+ $buwei_arr[] = $bs;
|
|
|
|
+ }
|
|
|
|
+ }
|
|
|
|
+ }
|
|
|
|
+ }else{
|
|
|
|
+ //部位为空 +1
|
|
|
|
+ $buwei_score = 1+ $buwei_score;
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+
|
|
|
|
+ //可能原因
|
|
|
|
+ if(!empty($em['yy_id'])){
|
|
|
|
+ $report_bw_id = Report::where(['yy_id'=>['in',$em['yy_id']]])->column('bw_id');
|
|
|
|
+ if(!in_array($em['bw_id'],$report_bw_id)){ //现象不对,直接扣分
|
|
|
|
+ $yuanyin_socre = 1+$yuanyin_socre;
|
|
|
|
+ $yuanyin_arr[] = $em['yy_id'];
|
|
|
|
+ }else{
|
|
|
|
+
|
|
|
|
+ }
|
|
|
|
+ }else{
|
|
|
|
+ //部位为空 +1
|
|
|
|
+ $yuanyin_socre = 1+$yuanyin_socre;
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ //排除方法
|
|
|
|
+ if(!empty($em['pc_id'])){
|
|
|
|
+ $report_pc_id = Report::where(['pc_id'=>['in',$em['pc_id']]])->column('bw_id');
|
|
|
|
+ if(!in_array($em['bw_id'],$report_pc_id)){ //现象不对,直接扣分
|
|
|
|
+ $fangfa_score = 1+$fangfa_score;
|
|
|
|
+ $fangfa_arr[] = $em['pc_id'];
|
|
|
|
+ }else{
|
|
|
|
+
|
|
|
|
+ }
|
|
|
|
+ }else{
|
|
|
|
+ $fangfa_score = 1+$fangfa_score;
|
|
|
|
+ }
|
|
|
|
+ }
|
|
|
|
+ }
|
|
|
|
+// echo "<pre>";
|
|
|
|
+// print_r($buwei_arr);
|
|
|
|
+// echo '原因:'.$yuanyin_socre.'<br/>';
|
|
|
|
+// echo '部位:'.$buwei_score.'<br/>';
|
|
|
|
+// echo '现象:'.$xianxian_score;
|
|
|
|
+// die();
|
|
|
|
+ $weixiu_score = $xianxian_score+$yuanyin_socre+$buwei_score+$fangfa_score;
|
|
|
|
+ if($weixiu_score>15){
|
|
|
|
+ $weixiu_score = 15;
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ //是否超时
|
|
|
|
+ $overtime_fen = intval((time()-$info['endtime']) / 60);
|
|
|
|
+ if($overtime_fen>=10){
|
|
|
|
+ $overtime_score = 10;
|
|
|
|
+ }else if($overtime_fen>0 && $overtime_fen<10){
|
|
|
|
+ $overtime_score = $overtime_fen ;
|
|
|
|
+ }else{
|
|
|
|
+ $overtime_score =0;
|
|
|
|
+ }
|
|
|
|
+ $fault_score = $score-$fault_one_score-$fault_two_score-$fault_three_score-$weixiu_score-$overtime_score;
|
|
|
|
+
|
|
|
|
+ //更新考试结果表
|
|
|
|
+ $params['exam_id'] = $ids;
|
|
|
|
+ $params['total'] = $fault_score;//得分;
|
|
|
|
+ $params['fault_one_score'] = $fault_one_score;//得分;
|
|
|
|
+ $params['fault_two_score'] = $fault_two_score;//得分;
|
|
|
|
+ $params['fault_three_score'] = $fault_three_score;//得分;
|
|
|
|
+
|
|
|
|
+ $params['xianxian_score'] = $xianxian_score;//得分;
|
|
|
|
+ $params['xianxian_content'] = !empty($xianxian_arr) ? json_encode($xianxian_arr):'';//错题;
|
|
|
|
+ $params['yuanyin_socre'] = $yuanyin_socre;//得分;
|
|
|
|
+ $params['yuanyin_content'] = !empty($yuanyin_arr) ? json_encode($yuanyin_arr) : '';//错题;
|
|
|
|
+ $params['buwei_score'] = $buwei_score;//得分;
|
|
|
|
+ $params['buwei_content'] = !empty($buwei_arr) ? json_encode($buwei_arr) :'';//错题;
|
|
|
|
+ $params['fangfa_score'] = $fangfa_score;//得分;
|
|
|
|
+ $params['fangfa_content'] = !empty($fangfa_arr) ? json_encode($fangfa_arr):'';//错题;
|
|
|
|
+// $params['jielun_score'] = $jielun_score;//得分;
|
|
|
|
+ $params['overtime_score'] = $overtime_score;//得分;
|
|
|
|
+ Db::name('real_exam_score')->insert($params);
|
|
|
|
+
|
|
|
|
+ $this->exam_model->where(['exam_id'=>$ids])->update(['total_score'=>$fault_score]);
|
|
|
|
+
|
|
|
|
+ Db::commit();
|
|
|
|
+ } catch (ValidateException|PDOException|Exception $e) {
|
|
|
|
+ Db::rollback();
|
|
|
|
+ $this->error($e->getMessage());
|
|
|
|
+ }
|
|
|
|
+ if ($result === false) {
|
|
|
|
+ $this->error(__('No rows were inserted'));
|
|
|
|
+ }
|
|
|
|
+
|
|
$this->success('交卷成功','/ZQOtIMLKud.php/student/exercise/analysis/ids/'.$row['exam_id']);
|
|
$this->success('交卷成功','/ZQOtIMLKud.php/student/exercise/analysis/ids/'.$row['exam_id']);
|
|
}
|
|
}
|
|
-
|
|
|
|
-// if(empty($row->starttime)){
|
|
|
|
-// $row->start_time = date('Y-m-d H:i:s');
|
|
|
|
-// $row->starttime = time();
|
|
|
|
-// $row->exam_status = 4;
|
|
|
|
-// $row->save();
|
|
|
|
-// }
|
|
|
|
$isloading =1;
|
|
$isloading =1;
|
|
if(empty($row->other_replace)){
|
|
if(empty($row->other_replace)){
|
|
$isloading = 0;
|
|
$isloading = 0;
|
|
@@ -154,15 +370,62 @@ class Exercise extends Backend
|
|
|
|
|
|
public function analysis($ids = null)
|
|
public function analysis($ids = null)
|
|
{
|
|
{
|
|
- $row = $this->exam_model->get($ids);
|
|
|
|
- if(!$row){
|
|
|
|
- $this->error('未找到记录');
|
|
|
|
- }
|
|
|
|
if ($this->request->isPost()) {
|
|
if ($this->request->isPost()) {
|
|
$params = $this->request->post('row/a');
|
|
$params = $this->request->post('row/a');
|
|
//计算总分到学员考试表
|
|
//计算总分到学员考试表
|
|
$this->success('操作成功','/ZQOtIMLKud.php/student/exercise/index');
|
|
$this->success('操作成功','/ZQOtIMLKud.php/student/exercise/index');
|
|
}
|
|
}
|
|
|
|
+ $row = Db::name('real_exam_score')->where('exam_id', $ids)->find();
|
|
|
|
+ if (!$row) {
|
|
|
|
+ $this->error(__('No Results were found'));
|
|
|
|
+ }
|
|
|
|
+ $rows = $this->exam_model->get($ids);
|
|
|
|
+ $row['seat_id'] = $rows->seat_id;
|
|
|
|
+ $row['user_nickname'] = $rows->user_nickname;
|
|
|
|
+ $row['user_username'] = $rows->user_username;
|
|
|
|
+ $row['user_depart_id'] = $rows->user_depart_id;
|
|
|
|
+ $row['user_depart_name'] = Department::where('id',$rows->user_depart_id)->value('name');
|
|
|
|
+ $row['start_time'] = $rows->start_time;
|
|
|
|
+ $row['end_time'] = $rows->end_time;
|
|
|
|
+
|
|
|
|
+
|
|
|
|
+ $fault_list = Db::name('real_exam_fault')->where(['exam_id'=>$ids,'flag'=>1])->select();
|
|
|
|
+ $row['fault_name_one'] = !empty($fault_list[0]['fault_id']) ? Fault::where('fault_id',$fault_list[0]['fault_id'])->value('name'):'';
|
|
|
|
+ $row['fault_name_two'] = !empty($fault_list[1]['fault_id']) ? Fault::where('fault_id',$fault_list[1]['fault_id'])->value('name'):'';
|
|
|
|
+ $row['fault_name_three'] = !empty($fault_list[2]['fault_id']) ? Fault::where('fault_id',$fault_list[2]['fault_id'])->value('name'):'';
|
|
|
|
+
|
|
|
|
+ if($row['xianxian_score']>0 && empty($row['xianxian_content']))
|
|
|
|
+ {
|
|
|
|
+ $row['xianxian_content_name'] = '未选择';
|
|
|
|
+ }else{
|
|
|
|
+ $xianxian = Report::where(['xx_id'=>['in',json_decode($row['xianxian_content'],true)]])->group('xx_name')->column('xx_name');
|
|
|
|
+ $row['xianxian_content_name'] = !empty($xianxian) ? implode(',',$xianxian) :'不存在或未选择';
|
|
|
|
+ }
|
|
|
|
+ if($row['yuanyin_socre']>0 && empty($row['yuanyin_content']))
|
|
|
|
+ {
|
|
|
|
+ $row['yuanyin_content_name'] = '未选择';
|
|
|
|
+ }else{
|
|
|
|
+ $yuanyin = Report::where(['yy_id'=>['in',json_decode($row['yuanyin_content'],true)]])->group('yy_name')->column('yy_name');
|
|
|
|
+ $row['yuanyin_content_name'] = !empty($yuanyin) ? implode(',',$yuanyin) :'不存在或未选择';
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ if($row['buwei_score']>0 &&empty($row['buwei_content']))
|
|
|
|
+ {
|
|
|
|
+ $row['buwei_content_name'] = '未选择';
|
|
|
|
+ }else{
|
|
|
|
+ $buwei = Report::where(['bw_id'=>['in',json_decode($row['buwei_content'],true)]])->group('bw_name')->column('bw_name');
|
|
|
|
+ $row['buwei_content_name'] = !empty($buwei) ? implode(',',$buwei) :'不存在或未选择';
|
|
|
|
+ }
|
|
|
|
+ if($row['fangfa_score']>0 && empty($row['fangfa_content']))
|
|
|
|
+ {
|
|
|
|
+ $row['fangfa_content_name'] = '未选择';
|
|
|
|
+ }else{
|
|
|
|
+ $fangfa = Report::where(['pc_id'=>['in',json_decode($row['fangfa_content'],true)]])->group('pc_name')->column('pc_name');
|
|
|
|
+ $row['fangfa_content_name'] = !empty($fangfa) ? implode(',',$fangfa) :'不存在或未选择';
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+
|
|
|
|
+ $this->view->assign('row', $row);
|
|
return $this->view->fetch();
|
|
return $this->view->fetch();
|
|
}
|
|
}
|
|
|
|
|