|
@@ -6,6 +6,7 @@ use app\admin\model\AdminLog;
|
|
use app\common\controller\Backend;
|
|
use app\common\controller\Backend;
|
|
use think\Config;
|
|
use think\Config;
|
|
use think\Hook;
|
|
use think\Hook;
|
|
|
|
+use think\Db;
|
|
use think\Session;
|
|
use think\Session;
|
|
use think\Validate;
|
|
use think\Validate;
|
|
|
|
|
|
@@ -16,7 +17,7 @@ use think\Validate;
|
|
class Index extends Backend
|
|
class Index extends Backend
|
|
{
|
|
{
|
|
|
|
|
|
- protected $noNeedLogin = ['login'];
|
|
|
|
|
|
+ protected $noNeedLogin = ['login','timeout'];
|
|
protected $noNeedRight = ['index', 'logout'];
|
|
protected $noNeedRight = ['index', 'logout'];
|
|
protected $layout = '';
|
|
protected $layout = '';
|
|
|
|
|
|
@@ -138,4 +139,116 @@ class Index extends Backend
|
|
return $html;
|
|
return $html;
|
|
}
|
|
}
|
|
|
|
|
|
|
|
+ /**
|
|
|
|
+ * 超时异常数据处理
|
|
|
|
+ * 已开始考试,且 未主动交卷。。。。 关闭浏览器,断电时间超过考试时间。
|
|
|
|
+ * @return void
|
|
|
|
+ */
|
|
|
|
+ public function timeout()
|
|
|
|
+ {
|
|
|
|
+ $where = ['exam_status'=>4,'countdown_time'=>['>',0],'exam_collection_type'=>3,'endtime'=>0];
|
|
|
|
+ $list = Db::name('real_exam')->where($where)->select();
|
|
|
|
+ foreach ($list as $k => $v) {
|
|
|
|
+ $score = 100;
|
|
|
|
+ $fault_one_score = 25;
|
|
|
|
+ $fault_two_score = 25;
|
|
|
|
+ $fault_three_score = 25;
|
|
|
|
+ $overtime_score = 10;//超时
|
|
|
|
+
|
|
|
|
+ //故障现象
|
|
|
|
+ $xianxian_score = 15;
|
|
|
|
+ $other_jielun = [];
|
|
|
|
+ $other_replace = '[{"fault_id":"","request_status":"0"}]';
|
|
|
|
+
|
|
|
|
+ //故障表查找得分
|
|
|
|
+ //特殊判断结果 故障部位
|
|
|
|
+ // 002型 薄膜开关FPC排线 蜂鸣器出声口 检测剂 干燥管 维护管
|
|
|
|
+ // 003型 检测剂 干燥管 维护管
|
|
|
|
+ $question_arr = ['0002GZBW0001','0002GZBW0003','0002GZBW0005','0002GZBW0009','0002GZBW0010','0003GZBW0006','0003GZBW0007','0003GZBW0008'];
|
|
|
|
+ //更新故障是否正确
|
|
|
|
+ $fault_list = Db::name('real_exam_fault')->where(['exam_id'=>$v['exam_id'],'flag'=>1])->select();
|
|
|
|
+ if(!empty($fault_list)){
|
|
|
|
+ foreach ($fault_list as $k1 =>$t){
|
|
|
|
+ $answer_right = 2;
|
|
|
|
+ //真实故障id 故障部位在 特殊故障部位里面
|
|
|
|
+ if(in_array($t['fault_id'],$question_arr)){
|
|
|
|
+ if(!empty($t['sim_fault_answer_value']) && substr($t['sim_fault_answer_value'], -1,1)==0){
|
|
|
|
+ $answer_right=1;
|
|
|
|
+ }
|
|
|
|
+ }else{
|
|
|
|
+ if(!empty($t['sim_fault_question_value']) && !empty($t['sim_fault_answer_value'])){
|
|
|
|
+ if($t['sim_fault_question_value']!=$t['sim_fault_answer_value'] ){
|
|
|
|
+ $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'=>$v['exam_id'],'flag'=>1,'answer_right'=>['>',0]])->select();
|
|
|
|
+ if(!empty($fault_right_list)){
|
|
|
|
+ if($fault_right_list[0]['answer_right']==1){
|
|
|
|
+ $fault_one_score = 0;
|
|
|
|
+ }
|
|
|
|
+ if(!empty($fault_right_list[1]['answer_right']) && $fault_right_list[1]['answer_right']==1){
|
|
|
|
+ $fault_two_score = 0;
|
|
|
|
+ }
|
|
|
|
+ if(!empty($fault_right_list[2]['answer_right']) && $fault_right_list[2]['answer_right']==1){
|
|
|
|
+ $fault_three_score = 0;
|
|
|
|
+ }
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ $total = $score-$fault_one_score-$fault_two_score-$fault_three_score-$xianxian_score-$overtime_score;
|
|
|
|
+
|
|
|
|
+ //追加考试记录数据
|
|
|
|
+ $add = [
|
|
|
|
+ 'exam_id' => $v['exam_id'],
|
|
|
|
+ 'total' => $total,
|
|
|
|
+ 'fault_one_score' => $fault_one_score,
|
|
|
|
+ 'fault_two_score' => $fault_two_score,
|
|
|
|
+ 'fault_three_score' => $fault_three_score,
|
|
|
|
+ 'xianxian_score' => $xianxian_score,
|
|
|
|
+ 'other_replace' => $other_replace,
|
|
|
|
+ 'other_jielun' => $other_jielun,
|
|
|
|
+ 'overtime_score' => $overtime_score,
|
|
|
|
+ ];
|
|
|
|
+ Db::name('real_exam_score')->insert($add);
|
|
|
|
+
|
|
|
|
+ //计算用时
|
|
|
|
+ $endtime = time();
|
|
|
|
+ $timediff = $endtime-$v['starttime'];
|
|
|
|
+ $remain = $timediff%86400;
|
|
|
|
+ //计算分钟数
|
|
|
|
+ $remain = $remain%3600;
|
|
|
|
+ $mins = intval($remain/60);
|
|
|
|
+ //计算秒数
|
|
|
|
+ $secs = $remain%60;
|
|
|
|
+
|
|
|
|
+ $diffInSeconds = $endtime-$v['starttime']; // 两个时间戳之间的差异(秒)
|
|
|
|
+ $minutes = floor($diffInSeconds / 60); // 计算分钟数
|
|
|
|
+ $seconds = $diffInSeconds % 60; // 计算剩余的秒数
|
|
|
|
+
|
|
|
|
+
|
|
|
|
+ $exam_duration = $mins*60+$secs;
|
|
|
|
+ $exam_duration_text = $minutes.'分'.$seconds.'秒';
|
|
|
|
+ $endtime = $endtime;
|
|
|
|
+ $end_time = date('Y-m-d H:i:s',$endtime);
|
|
|
|
+ $update = [
|
|
|
|
+ 'total_score'=>$total,
|
|
|
|
+ 'exam_duration'=>$exam_duration,
|
|
|
|
+ 'exam_duration_text'=>$exam_duration_text,
|
|
|
|
+ 'exam_status'=>5,
|
|
|
|
+ 'endtime'=>$endtime,
|
|
|
|
+ 'end_time'=>$end_time,
|
|
|
|
+ ];
|
|
|
|
+ //同步更新成绩
|
|
|
|
+ Db::name('real_exam')->where(['exam_id'=>$v['exam_id']])->update($update);
|
|
|
|
+
|
|
|
|
+
|
|
|
|
+ }
|
|
|
|
+ unset($v);
|
|
|
|
+ die('完成');
|
|
|
|
+ }
|
|
}
|
|
}
|