Kaynağa Gözat

20250210 优化调整

贾小兵 2 hafta önce
ebeveyn
işleme
ddc00f99f3

+ 25 - 1
application/admin/controller/student/Collection.php

@@ -28,7 +28,7 @@ class Collection extends Backend
 
     protected $whereExtend = null;
 
-    protected $noNeedLogin = ['addreport','editreport','delreport'];
+    protected $noNeedLogin = ['addreport','editreport','delreport','countdown'];
 
     public function _initialize()
     {
@@ -457,6 +457,10 @@ class Collection extends Backend
         }else{
             $timer = $row->limit_duration*60 - abs(time() - $row->starttime);
         }
+        if(empty($row->countdown_time)){
+            $duration = 10+$row->limit_duration;
+            $this->exam_model->where('exam_id',$ids)->update(['countdown_time'=>strtotime(date('Y-m-d H:i:s', strtotime('+'.$duration.' minute',$row->starttime)))]);
+        }
 
         $row->replace_list =Db::name('real_exam_comp_request')->where(['exam_id'=>$ids])->select();
         $this->assignConfig('ids',$ids);
@@ -713,6 +717,26 @@ class Collection extends Backend
             }
             $this->success();
         }
+    }  
+
+    public function countdown($ids = null){
+        $row = $this->exam_model->get($ids);
+        if(!$row){
+            $this->error('未找到记录');
+        }
+        // 计算差值
+        $time = strtotime(date('Y-m-d H:i:s', strtotime('+10 minute',$row->countdown_time)));
+        $diff = $time-time();
+        // 将差值转换为秒
+        $seconds = $diff;
+        $minutes = floor($seconds / 60);
+        $seconds = $seconds % 60;
+        if($minutes==0 && $seconds==0){
+            $a = 0;
+        }else{
+            $a = '已经超时,'.$minutes.'分'.$seconds.'秒后系统自动交卷。';
+        }
+        $this->success($a);
     }
 
     public function analysis($ids = null)

+ 4 - 1
application/admin/controller/student/Exercise.php

@@ -428,7 +428,10 @@ class Exercise extends Backend
         }else{
             $timer = $row->limit_duration*60 - abs(time() - $row->starttime);
         }
-
+        if(empty($row->countdown_time)){
+            $duration = 10+$row->limit_duration;
+            $this->exam_model->where('exam_id',$ids)->update(['countdown_time'=>strtotime(date('Y-m-d H:i:s', strtotime('+'.$duration.' minute',$row->starttime)))]);
+        }
 
         $departmentdata = [];
         $departmentdata = Fault::where(['replace_part'=>1,'sim_type'=>$row->sim_type])->order('fault_id asc')->select();

+ 5 - 0
application/admin/controller/student/Practice.php

@@ -473,6 +473,11 @@ class Practice extends Backend
             $timer = $row->limit_duration*60 - abs(time() - $row->starttime);
         }
 
+        if(empty($row->countdown_time)){
+            $duration = 10+$row->limit_duration;
+            $this->exam_model->where('exam_id',$ids)->update(['countdown_time'=>strtotime(date('Y-m-d H:i:s', strtotime('+'.$duration.' minute',$row->starttime)))]);
+        }
+
         $departmentdata = [];
         $departmentdata = Fault::where(['replace_part'=>1,'sim_type'=>$row->sim_type])->order('fault_id asc')->select();
         $this->view->assign('departmentdata', $departmentdata);

+ 3 - 3
application/admin/view/teacher/exams/index.html

@@ -40,7 +40,7 @@
         </table>
 
         <div class="tableTitle success" style="font-size: 16px;margin: 10px 0">错误率统计</div>
-        <table style="width: 33%;float: left;border: 2px solid #ebd6d6;" class="table table-striped table-bordered table-hover table-nowrap panel-success">
+        <table style="width: 33%;float: left;border: 2px solid #bfb8b8;" class="table table-striped table-bordered table-hover table-nowrap panel-success">
             <thead>
             <tr style="text-align: center">
                 <td colspan="2">FZD04B型侦毒器</td>
@@ -54,7 +54,7 @@
 
             </tbody>
         </table>
-        <table style="width: 33%;float: left;border: 2px solid #ebd6d6;" class="table table-striped table-bordered table-hover table-nowrap panel-success">
+        <table style="width: 33%;float: left;border: 2px solid #bfb8b8;" class="table table-striped table-bordered table-hover table-nowrap panel-success">
             <thead>
             <tr style="text-align: center">
                 <td colspan="2">FZB006型毒剂报警器</td>
@@ -68,7 +68,7 @@
 
             </tbody>
         </table>
-        <table style="width: 33%;border: 2px solid #ebd6d6;" class="table table-striped table-bordered table-hover table-nowrap panel-success">
+        <table style="width: 33%;border: 2px solid #bfb8b8;" class="table table-striped table-bordered table-hover table-nowrap panel-success">
             <thead>
             <tr style="text-align: center">
                 <td colspan="2">防化兵用毒剂报警器</td>

+ 46 - 18
public/assets/js/backend/student/collection.js

@@ -102,39 +102,67 @@ define(['jquery', 'bootstrap', 'backend', 'table', 'form'], function ($, undefin
         examing: function () {
             $(document).ready(function() {
                 var countdownTime = Config.timer; // 倒计时时间,单位为秒
+                var countdownTime1 = 600; // 10分钟倒计时时间,单位为秒
                 var display = $('#timer');
                 var fenzhong = 0;
                 var timer = setInterval(function() {
                     var minutes = parseInt(countdownTime / 60, 10);
                     var seconds = parseInt(countdownTime % 60, 10);
-
-                    minutes = minutes < 10 ? "0" + minutes : minutes;
-                    seconds = seconds < 10 ? "0" + seconds : seconds;
-
+                    // minutes = minutes < 10 ? "0" + minutes : minutes;
+                    // seconds = seconds < 10 ? "0" + seconds : seconds;
                     display.text(minutes + "分" + seconds+'秒');
-
                     // console.log(minutes.replace("0-",''));
                     // console.log(parseInt(minutes.replace("0-",'')));
                     if (--countdownTime < 0) {
-                        // clearInterval(timer);
-                        $(".djs").html('已到考试结束时间,10分钟内系统自动交卷。')
-                        // display.text("时间到!");
-                    }
-                    if(minutes<1){
-                        fenzhong = parseInt(minutes.replace("0-",''));
-                        console.log(fenzhong);
-                        if(fenzhong==7){
-                            $('#update-form').submit();
-                            clearInterval(timer);
-                        }
+                        // $(".djs").html('已经超时,10分钟00秒后系统自动交卷。');
+                        $.ajax({
+                            url: "student/collection/countdown/ids/"+Config.ids,
+                            type: 'post',
+                            data: {},
+                            success: function (data) {
+                                if(data.code==1){
+                                    console.log(data.msg);
+                                    $(".djs").html(data.msg);
+                                    if(data.msg==0){
+                                        $('#update-form').submit();
+                                        clearInterval(timer);
+                                    }
+                                }
+                                if(data.code==0){
+                                    Layer.alert(data.msg);
+                                }
+                            }
+                        });
+                        // setTimeout(function() {
+                        //     var minutes1 = parseInt(countdownTime1 / 60, 10);
+                        //     var seconds1 = parseInt(countdownTime1 % 60, 10);
+                        //     $(".djs").html('已经超时,'+minutes1 + "分" + seconds1 +'秒后系统自动交卷。');
+                        //     if (--countdownTime1>0) {
+                        //         var minutes2 = parseInt(countdownTime1 / 60, 10);
+                        //         var seconds2 = parseInt(countdownTime1 % 60, 10);
+                        //         $(".djs").html('已经超时,'+minutes2 + "分" + seconds2 +'秒后系统自动交卷。');
+                        //         console.log(minutes2+'@@@@'+seconds2);
+                        //         if(minutes2==0 && seconds2==1){
+                        //             $('#update-form').submit();
+                        //             clearInterval(timer);
+                        //         }
+                        //     }
+                        // }, 1000); // 第二个定时器2秒后执行
                     }
-
+                    // if(minutes<1){
+                    //     fenzhong = parseInt(minutes.replace("0-",''));
+                    //     console.log(fenzhong);
+                    //     if(fenzhong==7){
+                    //         $('#update-form').submit();
+                    //         clearInterval(timer);
+                    //     }
+                    // }
                 }, 1000);
 
                 //五秒刷新,同步更换件列表数据
                  if(Config.isloading==1 && countdownTime>0){
                      setInterval(function() {
-                         window.location.reload();
+                        window.location.reload();
                      }, 30000);
                  }
 

+ 42 - 3
public/assets/js/backend/student/exercise.js

@@ -12,7 +12,7 @@ define(['jquery', 'bootstrap', 'backend', 'table', 'form'], function ($, undefin
             $(document).ready(function() {
                 var countdownTime = Config.timer; // 倒计时时间,单位为秒
                 var display = $('#timer');
-
+                var countdownTime1 = 600; // 10分钟倒计时时间,单位为秒
                 var timer = setInterval(function() {
                     var minutes = parseInt(countdownTime / 60, 10);
                     var seconds = parseInt(countdownTime % 60, 10);
@@ -23,10 +23,49 @@ define(['jquery', 'bootstrap', 'backend', 'table', 'form'], function ($, undefin
                     display.text(minutes + "分" + seconds+'秒');
 
                     if (--countdownTime < 0) {
-                        clearInterval(timer);
-                        display.text("时间到!");
+                        $.ajax({
+                            url: "student/collection/countdown/ids/"+Config.ids,
+                            type: 'post',
+                            data: {},
+                            success: function (data) {
+                                if(data.code==1){
+                                    console.log(data.msg);
+                                    $(".djs").html(data.msg);
+                                    if(data.msg==0){
+                                        $('#update-form').submit();
+                                        clearInterval(timer);
+                                    }
+                                }
+                                if(data.code==0){
+                                    Layer.alert(data.msg);
+                                }
+                            }
+                        });
+                        // $(".djs").html('已经超时,10分钟00秒后系统自动交卷。');
+                        // setTimeout(function() {
+                        //     var minutes1 = parseInt(countdownTime1 / 60, 10);
+                        //     var seconds1 = parseInt(countdownTime1 % 60, 10);
+                        //     $(".djs").html('已经超时,'+minutes1 + "分" + seconds1 +'秒后系统自动交卷。');
+                        //     if (--countdownTime1>0) {
+                        //         var minutes2 = parseInt(countdownTime1 / 60, 10);
+                        //         var seconds2 = parseInt(countdownTime1 % 60, 10);
+                        //         $(".djs").html('已经超时,'+minutes2 + "分" + seconds2 +'秒后系统自动交卷。');
+                        //         console.log(minutes2+'@@@@'+seconds2);
+                        //         if(minutes2==0 && seconds2==1){
+                        //             $('#update-form').submit();
+                        //             clearInterval(timer);
+                        //         }
+                        //     }
+                        // }, 1000); // 第二个定时器2秒后执行
                     }
                 }, 1000);
+
+                //五秒刷新,同步更换件列表数据
+                if(Config.isloading==1 && countdownTime>0){
+                    setInterval(function() {
+                        window.location.reload();
+                    }, 30000);
+                }
             });
 
             $(document).on('click', '.btn-replace', function () {

+ 45 - 12
public/assets/js/backend/student/practice.js

@@ -119,32 +119,65 @@ define(['jquery', 'bootstrap', 'backend', 'table', 'form'], function ($, undefin
         examing: function () {
             $(document).ready(function() {
                 var countdownTime = Config.timer; // 倒计时时间,单位为秒
+                var countdownTime1 = 600; // 10分钟倒计时时间,单位为秒
                 var display = $('#timer');
                 var fenzhong = 0;
                 var timer = setInterval(function() {
                     var minutes = parseInt(countdownTime / 60, 10);
                     var seconds = parseInt(countdownTime % 60, 10);
 
-                    minutes = minutes < 10 ? "0" + minutes : minutes;
-                    seconds = seconds < 10 ? "0" + seconds : seconds;
+                    // minutes = minutes < 10 ? "0" + minutes : minutes;
+                    // seconds = seconds < 10 ? "0" + seconds : seconds;
 
                     display.text(minutes + "分" + seconds+'秒');
 
                     // console.log(minutes.replace("0-",''));
                     // console.log(parseInt(minutes.replace("0-",'')));
                     if (--countdownTime < 0) {
+                        $.ajax({
+                            url: "student/collection/countdown/ids/"+Config.ids,
+                            type: 'post',
+                            data: {},
+                            success: function (data) {
+                                if(data.code==1){
+                                    console.log(data.msg);
+                                    $(".djs").html(data.msg);
+                                    if(data.msg==0){
+                                        $('#update-form').submit();
+                                        clearInterval(timer);
+                                    }
+                                }
+                                if(data.code==0){
+                                    Layer.alert(data.msg);
+                                }
+                            }
+                        });
                         // clearInterval(timer);
-                        $(".djs").html('已到练习结束时间,10分钟内系统自动交卷。')
-                        // display.text("时间到!");
-                    }
-                    if(minutes<1){
-                        fenzhong = parseInt(minutes.replace("0-",''));
-                        console.log(fenzhong);
-                        if(fenzhong==7){
-                            $('#update-form').submit();
-                            clearInterval(timer);
-                        }
+                        // $(".djs").html('已经超时,10分钟00秒后系统自动交卷。');
+                        // setTimeout(function() {
+                        //     var minutes1 = parseInt(countdownTime1 / 60, 10);
+                        //     var seconds1 = parseInt(countdownTime1 % 60, 10);
+                        //     $(".djs").html('已经超时,'+minutes1 + "分" + seconds1 +'秒后系统自动交卷。');
+                        //     if (--countdownTime1>0) {
+                        //         var minutes2 = parseInt(countdownTime1 / 60, 10);
+                        //         var seconds2 = parseInt(countdownTime1 % 60, 10);
+                        //         $(".djs").html('已经超时,'+minutes2 + "分" + seconds2 +'秒后系统自动交卷。');
+                        //         console.log(minutes2+'@@@@'+seconds2);
+                        //         if(minutes2==0 && seconds2==1){
+                        //             $('#update-form').submit();
+                        //             clearInterval(timer);
+                        //         }
+                        //     }
+                        // }, 1000); // 第二个定时器2秒后执行
                     }
+                    // if(minutes<1){
+                    //     fenzhong = parseInt(minutes.replace("0-",''));
+                    //     console.log(fenzhong);
+                    //     if(fenzhong==7){
+                    //         $('#update-form').submit();
+                    //         clearInterval(timer);
+                    //     }
+                    // }
 
                 }, 1000);