|
@@ -165,16 +165,25 @@ class Practice extends Backend
|
|
$fault_two_score = 25;
|
|
$fault_two_score = 25;
|
|
$fault_three_score = 25;
|
|
$fault_three_score = 25;
|
|
|
|
|
|
|
|
+ //故障现象
|
|
$xianxian_score = 0;
|
|
$xianxian_score = 0;
|
|
- $yuanyin_socre= 0;
|
|
|
|
|
|
+ $xianxian_arr = [];
|
|
|
|
+ $xianxian_content = [];
|
|
|
|
+
|
|
|
|
+ //故障部位
|
|
$buwei_score= 0;
|
|
$buwei_score= 0;
|
|
- $fangfa_score= 0;
|
|
|
|
|
|
+ $buwei_arr = [];
|
|
|
|
+ $buwei_content = [];
|
|
|
|
|
|
- $xianxian_arr = [];
|
|
|
|
|
|
+ //可能原因
|
|
|
|
+ $yuanyin_socre= 0;
|
|
$yuanyin_arr = [];
|
|
$yuanyin_arr = [];
|
|
- $buwei_arr = [];
|
|
|
|
|
|
+ $yuanyin_content = [];
|
|
|
|
+
|
|
|
|
+ //排除方法
|
|
|
|
+ $fangfa_score= 0;
|
|
$fangfa_arr = [];
|
|
$fangfa_arr = [];
|
|
- $jielun_score = 0;
|
|
|
|
|
|
+ $fangfa_content = [];
|
|
|
|
|
|
|
|
|
|
Db::startTrans();
|
|
Db::startTrans();
|
|
@@ -205,7 +214,6 @@ class Practice extends Backend
|
|
}
|
|
}
|
|
}
|
|
}
|
|
|
|
|
|
-
|
|
|
|
//计算得分,故障是否有扣分 扣分制
|
|
//计算得分,故障是否有扣分 扣分制
|
|
$fault_right_list = Db::name('real_exam_fault')->where(['exam_id'=>$ids,'flag'=>1,'answer_right'=>['>',0]])->select();
|
|
$fault_right_list = Db::name('real_exam_fault')->where(['exam_id'=>$ids,'flag'=>1,'answer_right'=>['>',0]])->select();
|
|
if(!empty($fault_right_list)){
|
|
if(!empty($fault_right_list)){
|
|
@@ -218,93 +226,137 @@ class Practice extends Backend
|
|
if($fault_right_list[2]['answer_right']==1){
|
|
if($fault_right_list[2]['answer_right']==1){
|
|
$fault_three_score = 0;
|
|
$fault_three_score = 0;
|
|
}
|
|
}
|
|
|
|
+ }
|
|
|
|
+ $fault_right_list = Db::name('real_exam_fault')->where(['exam_id'=>$ids,'flag'=>1])->select();
|
|
|
|
|
|
- //根据故障部位,查找故障现象
|
|
|
|
- $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;
|
|
|
|
- }
|
|
|
|
|
|
+ //根据故障部位,查找故障现象
|
|
|
|
+ $fault_arr = [$fault_right_list[0]['fault_id'],$fault_right_list[1]['fault_id'],$fault_right_list[2]['fault_id']];
|
|
|
|
+
|
|
|
|
+ //根据故障部位查找,匹配的排除方法
|
|
|
|
+ $paichu_arr = Report::where(['bw_id'=>['in',$fault_arr]])->column('pc_id');
|
|
|
|
+ //根据故障部位查找,匹配可能原因
|
|
|
|
+ $yy_arr = Report::where(['bw_id'=>['in',$fault_arr]])->column('yy_id');
|
|
|
|
+
|
|
|
|
+ $partent_fault_id = Fault::where(['fault_id'=>['in',$fault_arr]])->column('parent_fault_id');
|
|
|
|
|
|
|
|
+ //获取数组
|
|
|
|
+ $other_report = json_decode($params['other_report'],true);
|
|
|
|
+ if(!empty($other_report)){
|
|
foreach ($other_report as $key => $em){
|
|
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'];
|
|
|
|
- }
|
|
|
|
-
|
|
|
|
|
|
+ $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;
|
|
|
|
- }
|
|
|
|
-
|
|
|
|
-
|
|
|
|
|
|
+ $buwei_arr[] = $em['bw_id'];
|
|
//可能原因
|
|
//可能原因
|
|
- 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;
|
|
|
|
- }
|
|
|
|
-
|
|
|
|
|
|
+ $yuanyin_arr[] = $em['yy_id'];
|
|
//排除方法
|
|
//排除方法
|
|
- 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;
|
|
|
|
- }
|
|
|
|
|
|
+ $fangfa_arr[] = $em['pc_id'];
|
|
|
|
+ }
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ //故障现象 分数 start
|
|
|
|
+ foreach ($partent_fault_id as $k1 =>$t){
|
|
|
|
+ if(!in_array($t,$xianxian_arr)){
|
|
|
|
+ $xianxian_score = 1+$xianxian_score;
|
|
|
|
+ $xianxian_content[] = [
|
|
|
|
+ 'cx_id'=>$t,
|
|
|
|
+ 'cx_type'=>'少写',
|
|
|
|
+ 'cx_name'=>Fault::where(['fault_id'=>$t])->value('name'),
|
|
|
|
+ ];
|
|
|
|
+ }
|
|
|
|
+ }
|
|
|
|
+ foreach ($xianxian_arr as $k2 =>$t2){
|
|
|
|
+ if(!in_array($t2,$partent_fault_id)){
|
|
|
|
+ $xianxian_score = 1+$xianxian_score;
|
|
|
|
+ $xianxian_content[] = [
|
|
|
|
+ 'cx_id'=>$t2,
|
|
|
|
+ 'cx_type'=>'错写',
|
|
|
|
+ 'cx_name'=>Fault::where(['fault_id'=>$t2])->value('name'),
|
|
|
|
+ ];
|
|
|
|
+ }
|
|
|
|
+ }
|
|
|
|
+ //故障现象 end
|
|
|
|
+
|
|
|
|
+
|
|
|
|
+ //故障部位 start
|
|
|
|
+ foreach ($fault_arr as $k11 =>$t11){
|
|
|
|
+ if(!in_array($t11,$buwei_arr)){
|
|
|
|
+ $buwei_score = 1+$buwei_score;
|
|
|
|
+ $buwei_content[] = [
|
|
|
|
+ 'cx_id'=>$t11,
|
|
|
|
+ 'cx_type'=>'少写',
|
|
|
|
+ 'cx_name'=>Fault::where(['fault_id'=>$t11])->value('name'),
|
|
|
|
+ ];
|
|
|
|
+ }
|
|
|
|
+ }
|
|
|
|
+ foreach ($buwei_arr as $k12 =>$t12){
|
|
|
|
+ if(!empty($t12) && !in_array($t12,$fault_arr)){
|
|
|
|
+ //错写
|
|
|
|
+ $buwei_score = 1+$buwei_score;
|
|
|
|
+ $buwei_content[] = [
|
|
|
|
+ 'cx_id'=>$t12,
|
|
|
|
+ 'cx_type'=>'错写',
|
|
|
|
+ 'cx_name'=>Fault::where(['fault_id'=>$t12])->value('name'),
|
|
|
|
+ ];
|
|
|
|
+ }
|
|
|
|
+ }
|
|
|
|
+ //故障部位 end
|
|
|
|
+
|
|
|
|
+ //排除方法 start
|
|
|
|
+ //循环固定的排除方法,匹配作答的排除方法
|
|
|
|
+ foreach ($paichu_arr as $k21 =>$t21){
|
|
|
|
+ if(!in_array($t21,$fangfa_arr)){
|
|
|
|
+ $fangfa_score = 1+$fangfa_score;
|
|
|
|
+ $fangfa_content[] = [
|
|
|
|
+ 'cx_id'=>$t21,
|
|
|
|
+ 'cx_type'=>'少写',
|
|
|
|
+ 'cx_name'=>Fault::where(['fault_id'=>$t21])->value('name'),
|
|
|
|
+ ];
|
|
|
|
+ }
|
|
|
|
+ }
|
|
|
|
+ //循环作答的排除方法,,匹配固定的排除方法
|
|
|
|
+ foreach ($fangfa_arr as $k22 =>$t22){
|
|
|
|
+ if(!empty($t22) && !in_array($t22,$paichu_arr)){
|
|
|
|
+ $fangfa_score = 1+$fangfa_score;
|
|
|
|
+ $fangfa_content[] = [
|
|
|
|
+ 'cx_id'=>$t22,
|
|
|
|
+ 'cx_type'=>'错写',
|
|
|
|
+ 'cx_name'=>Fault::where(['fault_id'=>$t22])->value('name'),
|
|
|
|
+ ];
|
|
|
|
+ }
|
|
|
|
+ }
|
|
|
|
+ //排除方法 end
|
|
|
|
+
|
|
|
|
+ //可能原因 start
|
|
|
|
+ //循环固定的可能原因,匹配作答的可能原因
|
|
|
|
+ foreach ($yy_arr as $k31 =>$t31){
|
|
|
|
+ if(!in_array($t31,$yuanyin_arr)){
|
|
|
|
+ $yuanyin_socre = 1+$yuanyin_socre;
|
|
|
|
+ $yuanyin_content[] = [
|
|
|
|
+ 'cx_id'=>$t31,
|
|
|
|
+ 'cx_type'=>'少写',
|
|
|
|
+ 'cx_name'=>Fault::where(['fault_id'=>$t31])->value('name'),
|
|
|
|
+ ];
|
|
}
|
|
}
|
|
}
|
|
}
|
|
-// echo "<pre>";
|
|
|
|
-// print_r($buwei_arr);
|
|
|
|
-// echo '原因:'.$yuanyin_socre.'<br/>';
|
|
|
|
-// echo '部位:'.$buwei_score.'<br/>';
|
|
|
|
-// echo '现象:'.$xianxian_score;
|
|
|
|
-// die();
|
|
|
|
|
|
+ //循环作答的排除方法,,匹配固定的排除方法
|
|
|
|
+ foreach ($yuanyin_arr as $k32 =>$t32){
|
|
|
|
+ if(!empty($t32) && !in_array($t32,$yy_arr)){
|
|
|
|
+ $yuanyin_socre = 1+$yuanyin_socre;
|
|
|
|
+ $yuanyin_content[] = [
|
|
|
|
+ 'cx_id'=>$t32,
|
|
|
|
+ 'cx_type'=>'错写',
|
|
|
|
+ 'cx_name'=>Fault::where(['fault_id'=>$t32])->value('name'),
|
|
|
|
+ ];
|
|
|
|
+ }
|
|
|
|
+ }
|
|
|
|
+ //可能原因 end
|
|
|
|
+
|
|
$weixiu_score = $xianxian_score+$yuanyin_socre+$buwei_score+$fangfa_score;
|
|
$weixiu_score = $xianxian_score+$yuanyin_socre+$buwei_score+$fangfa_score;
|
|
if($weixiu_score>15){
|
|
if($weixiu_score>15){
|
|
$weixiu_score = 15;
|
|
$weixiu_score = 15;
|
|
}
|
|
}
|
|
-// $xianxian_score = rand(1,3);
|
|
|
|
-// $yuanyin_socre= rand(1,3);
|
|
|
|
-// $buwei_score= rand(1,3);
|
|
|
|
-// $fangfa_score= rand(1,3);
|
|
|
|
-// if(empty($params['other_jielun'])){
|
|
|
|
-// $jielun_score = rand(1,3);
|
|
|
|
-// }
|
|
|
|
|
|
+
|
|
//是否超时
|
|
//是否超时
|
|
$overtime_fen = intval((time()-$info['endtime']) / 60);
|
|
$overtime_fen = intval((time()-$info['endtime']) / 60);
|
|
if($overtime_fen>=10){
|
|
if($overtime_fen>=10){
|
|
@@ -324,14 +376,18 @@ class Practice extends Backend
|
|
$params['fault_three_score'] = $fault_three_score;//得分;
|
|
$params['fault_three_score'] = $fault_three_score;//得分;
|
|
|
|
|
|
$params['xianxian_score'] = $xianxian_score;//得分;
|
|
$params['xianxian_score'] = $xianxian_score;//得分;
|
|
- $params['xianxian_content'] = !empty($xianxian_arr) ? json_encode($xianxian_arr):'';//错题;
|
|
|
|
|
|
+ $params['xianxian_content'] = json_encode($xianxian_content);//错题;
|
|
|
|
+
|
|
$params['yuanyin_socre'] = $yuanyin_socre;//得分;
|
|
$params['yuanyin_socre'] = $yuanyin_socre;//得分;
|
|
- $params['yuanyin_content'] = !empty($yuanyin_arr) ? json_encode($yuanyin_arr) : '';//错题;
|
|
|
|
|
|
+ $params['yuanyin_content'] = json_encode($yuanyin_content);//错题;
|
|
|
|
+
|
|
$params['buwei_score'] = $buwei_score;//得分;
|
|
$params['buwei_score'] = $buwei_score;//得分;
|
|
- $params['buwei_content'] = !empty($buwei_arr) ? json_encode($buwei_arr) :'';//错题;
|
|
|
|
|
|
+ $params['buwei_content'] = json_encode($buwei_content);//错题;
|
|
|
|
+
|
|
$params['fangfa_score'] = $fangfa_score;//得分;
|
|
$params['fangfa_score'] = $fangfa_score;//得分;
|
|
- $params['fangfa_content'] = !empty($fangfa_arr) ? json_encode($fangfa_arr):'';//错题;
|
|
|
|
-// $params['jielun_score'] = $jielun_score;//得分;
|
|
|
|
|
|
+ $params['fangfa_content'] = json_encode($fangfa_content);//错题;
|
|
|
|
+
|
|
|
|
+
|
|
$params['overtime_score'] = $overtime_score;//得分;
|
|
$params['overtime_score'] = $overtime_score;//得分;
|
|
Db::name('real_exam_score')->insert($params);
|
|
Db::name('real_exam_score')->insert($params);
|
|
|
|
|
|
@@ -417,34 +473,25 @@ class Practice extends Backend
|
|
$row['fault_name_two'] = !empty($fault_list[1]['fault_id']) ? Fault::where('fault_id',$fault_list[1]['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'):'';
|
|
$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'] = '';
|
|
|
|
+ if(!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) :'不存在或未选择';
|
|
|
|
|
|
+ $row['xianxian_content_name'] = json_decode($row['xianxian_content'],true);
|
|
}
|
|
}
|
|
- if($row['yuanyin_socre']>0 && empty($row['yuanyin_content']))
|
|
|
|
|
|
+ $row['yuanyin_content_name'] = '';
|
|
|
|
+ if(!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) :'不存在或未选择';
|
|
|
|
|
|
+ $row['yuanyin_content_name'] = json_decode($row['yuanyin_content'],true);
|
|
}
|
|
}
|
|
-
|
|
|
|
- if($row['buwei_score']>0 &&empty($row['buwei_content']))
|
|
|
|
|
|
+ $row['buwei_content_name'] = '';
|
|
|
|
+ if(!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) :'不存在或未选择';
|
|
|
|
|
|
+ $row['buwei_content_name'] = json_decode($row['buwei_content'],true);
|
|
}
|
|
}
|
|
- if($row['fangfa_score']>0 && empty($row['fangfa_content']))
|
|
|
|
|
|
+ $row['fangfa_content_name'] = '';
|
|
|
|
+ if(!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) :'不存在或未选择';
|
|
|
|
|
|
+ $row['fangfa_content_name'] = json_decode($row['fangfa_content'],true);
|
|
}
|
|
}
|
|
|
|
|
|
|
|
|