Просмотр исходного кода

修改“进入考试”按钮状态。代码风格修正。

Michael Wang 7 лет назад
Родитель
Сommit
e80a2b6032

+ 5 - 0
package-lock.json

@@ -10636,6 +10636,11 @@
         "minimist": "0.0.8"
       }
     },
+    "moment": {
+      "version": "2.22.2",
+      "resolved": "https://registry.npmjs.org/moment/-/moment-2.22.2.tgz",
+      "integrity": "sha1-PCV/mDn8DpP/UxSWMiOeuQeD/2Y="
+    },
     "move-concurrently": {
       "version": "1.0.1",
       "resolved": "https://registry.npmjs.org/move-concurrently/-/move-concurrently-1.0.1.tgz",

+ 1 - 0
package.json

@@ -13,6 +13,7 @@
   "dependencies": {
     "axios": "^0.18.0",
     "iview": "^2.14.3",
+    "moment": "^2.22.2",
     "register-service-worker": "^1.0.0",
     "vue": "^2.5.16",
     "vue-router": "^3.0.1",

+ 5 - 0
src/features/OnlineExam/OnlineExamHome.vue

@@ -22,6 +22,11 @@ export default {
     };
   },
   async mounted() {
+    // TODO: 断点续考
+    // check examRecord
+    // go to /online-exam/exam/:id/start
+    // Promise.all
+
     const res = await this.$http.get("/api/online_exam_course");
 
     this.courses = res.data.map(c => ({

+ 29 - 7
src/features/OnlineExam/OnlineExamList.vue

@@ -10,7 +10,7 @@
           <td style="max-width: 200px">操作</td>
         </tr>
 
-        <tr v-for="(course) in courses" :key="course.examId">
+        <tr v-for="course in courses" :key="course.examId">
           <td>{{ course.courseName }}</td>
           <td>{{ course.specialtyName }}</td>
           <td>{{ course.startTime }} <br> ~ <br> {{ course.endTime }}</td>
@@ -18,7 +18,7 @@
           <td style="min-width: 180px">
             <template v-if="!course.isvalid">
               <div style="display: grid; grid-template-columns: 1fr 1fr; grid-gap: 10px">
-                <i-button class="qm-primary-button" @click="previewPaper(course)">进入考试</i-button>
+                <i-button class="qm-primary-button" :disabled="!courseInBetween(course)" @click="enterExam(course)">进入考试</i-button>
 
                 <i-poptip trigger="hover" placement="left" class="online-exam-list-override-poptip">
                   <i-button class="qm-primary-button" style="width: 100%">客观分</i-button>
@@ -35,21 +35,43 @@
 
 <script>
 import OnlineExamResultList from "./OnlineExamResultList.vue";
+import moment from "moment";
 
 export default {
   name: "EcsOnlineList",
   data() {
-    return {};
+    return { now: new Date() };
   },
   props: {
     courses: Array
   },
+  created() {
+    this.getNow();
+    this.intervalID = setInterval(this.getNow, 1000);
+  },
+  destroyed() {
+    clearInterval(this.intervalID);
+  },
   methods: {
+    getNow() {
+      this.now = new Date();
+    },
+    courseInBetween(course) {
+      return moment(this.now).isBetween(
+        moment(course.startTime),
+        moment(course.endTime)
+      );
+    },
     async enterExam(course) {
-      await this.$http.get("/api/offline_exam/start", {
-        params: { examStudentId: course.examStudentId }
-      });
-      this.$emit("reloadList");
+      // TODO: 待确认. 前端控制展示“是否进入考试”。后端控制不在有效期内不准访问。
+      if (course.faceEnable) {
+        // open face check modal, then
+        // if 人脸识别失败 && 考试开启强制人脸识别 return
+        // if 人脸识别失败 && 考试未开启强制人脸识别
+        //    让学生手动确认进入考试,若取消,则返回
+      }
+
+      // this.$router.push("/online-exam/exam/:id/overview")
     },
     previewPaper(course) {
       var user = {

+ 4 - 4
src/features/login/Login.vue

@@ -1,11 +1,11 @@
 <template>
   <div class="home">
 
-    <div class="header">
-      <div class="school-logo"><img :src="this.logoPath" alt="school logo"></img>
+    <header class="header">
+      <div class="school-logo"><img :src="this.logoPath" alt="school logo" />
       </div>
       <a class="close" style="border-bottom-left-radius: 6px;">关闭</a>
-    </div>
+    </header>
 
     <div class="center">
 
@@ -42,7 +42,7 @@
       </div>
     </div>
 
-    <div class="footer"></div>
+    <footer class="footer"></footer>
 
   </div>
 </template>

+ 8 - 0
vue.config.js

@@ -45,6 +45,7 @@ for (const s of stu) {
   };
 }
 
+var webpack = require("webpack");
 module.exports = {
   devServer: {
     proxy
@@ -60,5 +61,12 @@ module.exports = {
         prefix: true
       })
       .end();
+  },
+  configureWebpack: {
+    plugins: [
+      // Ignore all locale files of moment.js
+      // TODO: use webpack stats to check if iview locale matters
+      new webpack.IgnorePlugin(/^\.\/locale$/, /moment|iview$/)
+    ]
   }
 };