瀏覽代碼

增加在线练习。fix活体检测wss

Michael Wang 6 年之前
父節點
當前提交
6c9af0e762

+ 1 - 1
.env.staging

@@ -1,4 +1,4 @@
 VUE_APP_TK_SERVER_URL=http://192.168.10.39:8868
 VUE_APP_FACEPP_KEY=kEz_MSSjkNuHL3fHhCvv62fXkAo-vobE
 VUE_APP_FACEPP_SECRET=aQMioMGUDShMnQmfM1_H_kPTP2pJva6J
-VUE_APP_WK_SERVER_SOCKET=wss://ecs.qmth.com.cn:8878/oewebsocket/
+VUE_APP_WK_SERVER_SOCKET=wss://ecs-dev.qmth.com.cn:8878/oewebsocket/

+ 8 - 0
src/features/OnlineExam/Examing/ExamingHome.vue

@@ -129,6 +129,14 @@ export default {
       const exam = await this.$http.get(
         "/api/ecs_exam_work/exam/" + this.$route.params.examId
       );
+      if (exam.data.examType === "PRACTICE") {
+        const practiceType = (await this.$http.get(
+          "/api/ecs_exam_work/exam/examOrgProperty/" +
+            this.$route.params.examId +
+            `/PRACTICE_TYPE`
+        )).data;
+        this.practiceType = practiceType;
+      }
       const paperStruct = (await this.$http.get(
         "/api/ecs_oe_student/examRecordPaperStruct/getExamRecordPaperStruct?examRecordDataId=" +
           this.$route.params.examRecordDataId

+ 8 - 40
src/features/OnlinePractice/OnlinePracticeHome.vue

@@ -14,49 +14,21 @@
         </Select>
       </div>
 
-      <i-table border :columns="columns" :data="courses"></i-table>
+      <OnlinePracticeList :courses="courses"></OnlinePracticeList>
 
     </div>
   </main-layout>
 </template>
 
 <script>
+import OnlinePracticeList from "./OnlinePracticeList.vue";
+
 export default {
   name: "OnlinePracticeHome",
   data() {
     return {
       examId: null,
       examList: [],
-      columns: [
-        {
-          title: "课程",
-          key: "courseName"
-        },
-        {
-          title: "考试开放时间",
-          key: "start2end",
-          render: (h, params) => {
-            // return h("div", params.row.start2end);
-            return <div domPropsInnerHTML={params.row.start2end} />;
-          }
-        },
-        {
-          title: "练习次数",
-          key: "practiceCount"
-        },
-        {
-          title: "最近正确率",
-          key: "recentObjectiveAccuracy"
-        },
-        {
-          title: "平均正确率",
-          key: "aveObjectiveAccuracy"
-        },
-        {
-          title: "操作",
-          key: "operations"
-        }
-      ],
       courses: []
     };
   },
@@ -64,7 +36,7 @@ export default {
     const res = await this.$http.get(
       "/api/ecs_exam_work/exam/queryByNameLike?name=&examType=PRACTICE"
     );
-    this.examList = res.data;
+    this.examList = (res.data || []).filter(e => e.enable);
     if (this.examList[0]) {
       this.examId = this.examList[0].id;
       await this.fetchList(this.examId);
@@ -76,15 +48,11 @@ export default {
         "/api/ecs_oe_student/practice/queryPracticeCourseList?examId=" + examId
       );
 
-      this.courses = res.data.map(c => ({
-        courseName: c.courseName,
-        start2end: c.startTime + "<br> ~ <br>" + c.endTime,
-        practiceCount: c.practiceCount,
-        recentObjectiveAccuracy: c.recentObjectiveAccuracy + "%",
-        aveObjectiveAccuracy: c.aveObjectiveAccuracy + "%",
-        operations: ""
-      }));
+      this.courses = res.data;
     }
+  },
+  components: {
+    OnlinePracticeList
   }
 };
 </script>

+ 106 - 0
src/features/OnlinePractice/OnlinePracticeList.vue

@@ -0,0 +1,106 @@
+<template>
+  <div class="list">
+    <table>
+      <tbody class="list-row">
+        <tr class="list-header qm-primary-strong-text">
+          <td>课程</td>
+          <td>考试开放时间</td>
+          <td>练习次数</td>
+          <td>最近正确率</td>
+          <td>平均正确率</td>
+          <td>最高正确率</td>
+          <td style="max-width: 200px">操作</td>
+        </tr>
+
+        <tr v-for="course in courses" :key="course.examId">
+          <td>{{ course.courseName }}</td>
+          <td>{{ course.startTime }} <br> ~ <br> {{ course.endTime }}</td>
+          <td>{{ course.practiceCount }}</td>
+          <td>{{ course.recentObjectiveAccuracy }}%</td>
+          <td>{{ course.aveObjectiveAccuracy }}%</td>
+          <td>{{ course.maxObjectiveAccuracy }}%</td>
+          <td style="min-width: 180px">
+            <div style="display: grid; grid-template-columns: 1fr 1fr; grid-gap: 10px">
+              <i-button class="qm-primary-button" :disabled="!courseInBetween(course)" @click="enterPractice(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>
+              </i-poptip>
+            </div>
+          </td>
+        </tr>
+      </tbody>
+    </table>
+
+  </div>
+</template>
+
+<script>
+import { createNamespacedHelpers } from "vuex";
+import moment from "moment";
+import { mapState as globalMapState } from "vuex";
+const { mapState, mapMutations } = createNamespacedHelpers("examHomeModule");
+
+export default {
+  name: "OnlinePracticeList",
+  data() {
+    return { now: new Date(), selectedCourse: null };
+  },
+  props: {
+    courses: Array
+  },
+  created() {
+    this.getNow();
+    this.intervalID = setInterval(() => this.getNow(), 1000);
+  },
+  beforeDestroy() {
+    clearInterval(this.intervalID);
+  },
+  methods: {
+    ...mapMutations(["toggleFaceCheckModal"]),
+    getNow() {
+      this.now = new Date();
+    },
+    courseInBetween(course) {
+      return moment(this.now).isBetween(
+        moment(course.startTime),
+        moment(course.endTime)
+      );
+    },
+    async enterPractice(course) {
+      this.$router.push(
+        `/online-exam/exam/${course.examId}/overview?examStudentId=${
+          course.examStudentId
+        }`
+      );
+    }
+  },
+  computed: {
+    ...globalMapState(["user"])
+  }
+};
+</script>
+
+<style scoped>
+.list {
+  border: 1px solid #eeeeee;
+  border-radius: 6px;
+}
+
+.list table {
+  width: 100%;
+  border-collapse: collapse !important;
+  border-spacing: 0;
+}
+.list td {
+  border: 1px solid #eeeeee;
+  border-radius: 6px;
+  border-collapse: separate !important;
+  padding: 10px;
+}
+</style>
+
+<style>
+.online-exam-list-override-poptip .ivu-poptip-rel {
+  width: 100%;
+}
+</style>

+ 2 - 2
src/store.js

@@ -34,11 +34,11 @@ const examingHomeModule = {
     toggleSnapNow(state) {
       state.snapNow = !state.snapNow;
       if (state.snapNow) {
-        state.snapProcessingCount++;
+        state.snapProcessingCount = state.snapProcessingCount + 1;
       }
     },
     decreaseSnapCount(state) {
-      state.snapProcessingCount--;
+      state.snapProcessingCount = state.snapProcessingCount - 1;
     },
     updateExamState(state, payload) {
       state = Object.assign(state, payload);