浏览代码

离线考试:查看时间、下载试卷

Michael Wang 7 年之前
父节点
当前提交
dc1377ef20

+ 5 - 0
.env.development

@@ -0,0 +1,5 @@
+VUE_APP_TK_SERVER_URL=http://ecs-dev.qmth.com.cn:8868
+VUE_APP_UPYUN_UPLOAD_URL=https://v0.api.upyun.com/exam-cloud-test
+VUE_APP_UPYUN_HEADER_AUTH=Basic ZXhhbWNsb3VkOmV4YW1jbG91ZDEyMzQ1Ng==
+VUE_APP_FACEPP_KEY=kEz_MSSjkNuHL3fHhCvv62fXkAo-vobE
+VUE_APP_FACEPP_SECRET=aQMioMGUDShMnQmfM1_H_kPTP2pJva6J

+ 5 - 0
.env.production

@@ -0,0 +1,5 @@
+VUE_APP_TK_SERVER_URL=http://ecs.qmth.com.cn:8868
+VUE_APP_UPYUN_UPLOAD_URL=https://v0.api.upyun.com/exam-cloud
+VUE_APP_UPYUN_HEADER_AUTH=Basic ZXhhbWNsb3VkOmV4YW1jbG91ZDEyMzQ1Ng==
+VUE_APP_FACEPP_KEY=VOlRKNlCSAYIOcSLDKOaZukkqpmi-Pwo
+VUE_APP_FACEPP_SECRET=bzMjy-JfwtVUxVDMzagFh7ggbQBC71f1

+ 5 - 0
.env.staging

@@ -0,0 +1,5 @@
+VUE_APP_TK_SERVER_URL=http://ecs-dev.qmth.com.cn:8868
+VUE_APP_UPYUN_UPLOAD_URL=https://v0.api.upyun.com/exam-cloud-test
+VUE_APP_UPYUN_HEADER_AUTH=Basic ZXhhbWNsb3VkOmV4YW1jbG91ZDEyMzQ1Ng==
+VUE_APP_FACEPP_KEY=kEz_MSSjkNuHL3fHhCvv62fXkAo-vobE
+VUE_APP_FACEPP_SECRET=aQMioMGUDShMnQmfM1_H_kPTP2pJva6J

+ 2 - 1
package.json

@@ -5,7 +5,8 @@
   "scripts": {
     "start": "vue-cli-service serve",
     "serve": "vue-cli-service serve",
-    "build": "vue-cli-service build",
+    "build:staging": "vue-cli-service build --mode staging",
+    "build:prod": "vue-cli-service build",
     "lint": "vue-cli-service lint",
     "test:unit": "vue-cli-service test:unit"
   },

+ 8 - 0
src/constants/constants.js

@@ -0,0 +1,8 @@
+export const FACEPP_API = "facepp_api";
+export const FACEID_LINENESS_URL =
+  "https://api.megvii.com/faceid/liveness/v2/do?token=";
+export const TK_SERVER_URL = process.env.VUE_APP_TK_SERVER_URL;
+export const UPYUN_UPLOAD_URL = process.env.VUE_APP_UPYUN_UPLOAD_URL;
+export const UPYUN_HEADER_AUTH = process.env.VUE_APP_UPYUN_HEADER_AUTH;
+export const FACEPP_KEY = process.env.VUE_APP_FACEPP_KEY;
+export const FACEPP_SECRET = process.env.VUE_APP_FACEPP_SECRET;

+ 20 - 11
src/features/OfflineExam/OfflineExamHome.vue

@@ -22,18 +22,27 @@ export default {
     };
   },
   async mounted() {
-    const res = await this.$http.get("/api/offline_exam/getOfflineCourse");
+    await this.fetchData();
+  },
+  methods: {
+    async fetchData() {
+      const res = await this.$http.get("/api/offline_exam/getOfflineCourse");
 
-    this.courses = res.data.map(c => ({
-      examRecordId: c.examRecordId,
-      courseName: c.courseName,
-      specialtyName: c.specialtyName,
-      startTime: c.startTime,
-      endTime: c.endTime,
-      fileUrl: c.studentSubjectiveHtml,
-      paperId: c.paperId,
-      operations: ""
-    }));
+      this.courses = res.data.map(c => ({
+        examRecordId: c.examRecordId,
+        courseName: c.courseName,
+        specialtyName: c.specialtyName,
+        orgName: c.orgName,
+        examStudentId: c.examStudentId,
+        startTime: c.startTime,
+        endTime: c.endTime,
+        fileUrl: c.studentSubjectiveHtml,
+        paperId: c.paperId
+      }));
+    },
+    async reloadList() {
+      await this.fetchData();
+    }
   },
   components: {
     "ecs-offline-list": EcsOfflineList

+ 56 - 27
src/features/OfflineExam/OfflineExamList.vue

@@ -17,7 +17,7 @@
           <td>{{ course.startTime }} <br> ~ <br> {{ course.endTime }}</td>
           <td>
             <div v-if="course.fileUrl">
-              <a :href="course.fileUrl">
+              <a :href="course.fileUrl" download>
                 <i-icon type="ios-cloud-download"></i-icon>下载作答</a>
             </div>
             <div v-else>
@@ -25,23 +25,37 @@
             </div>
           </td>
           <td style="min-width: 180px">
-            <div v-if="course.paperId" style="display: grid; grid-gap: 10px">
-              <i-button class="qm-primary-button">查看试卷</i-button>
-              <i-button class="qm-primary-button">下载试卷</i-button>
-              <i-button class="qm-primary-button">下载答题卡</i-button>
-              <div>
-                <Upload :headers="headers" :data="{fileType: fileType}" :before-upload="handleBeforeUpload" :action="'/api/offline_exam/'+course.examRecordId+'/submit'" :max-size="1024*30" :format="['pdf','zip']" :on-format-error="handleFormatError" :on-exceeded-size="handleMaxSize" :on-success="handleSuccess" :on-error="handleError" :show-upload-list="false">
-                  <Button type="ghost" icon="ios-cloud-upload-outline" class="qm-primary-button" style="width: 100%;">上传作答</Button>
-                </Upload>
-                <div v-if="file !== null">待上传文件: {{ file.name }}
-                  <Button type="text" @click="upload" :loading="loadingStatus">{{ loadingStatus ? '上传中...' : '上传' }}</Button>
+            <template v-if="!course.isvalid">
+              <div v-if="course.paperId" style="display: grid; grid-gap: 10px">
+                <i-button class="qm-primary-button" @click="previewPaper(course)">查看试卷</i-button>
+                <i-button class="qm-primary-button">
+                  <a class="qm-primary-button" :href="tk_server_url+'/api/ecs_ques/paper/export/'+course.paperId+'/PAPER/'+course.orgName+'/'+course.paperId + '/offLine'" download>下载试卷</a>
+                </i-button>
+                <i-button class="qm-primary-button">
+                  <a class="qm-primary-button" href="https://ecs-static.qmth.com.cn/offline-exam/答题卡.zip" download>下载答题卡</a>
+                </i-button>
+                <div>
+                  <Upload :headers="headers" :data="{fileType: fileType}" :before-upload="handleBeforeUpload" :action="'/api/offline_exam/'+course.examRecordId+'/submit'" :max-size="1024*30" :format="['pdf','zip']" :on-format-error="handleFormatError" :on-exceeded-size="handleMaxSize" :on-success="handleSuccess" :on-error="handleError" :show-upload-list="false">
+                    <Button type="ghost" icon="ios-cloud-upload-outline" class="qm-primary-button" style="width: 100%;">上传作答</Button>
+                  </Upload>
+                  <div v-if="file !== null">待上传文件: {{ file.name }}
+                    <Button type="text" @click="upload" :loading="loadingStatus">{{ loadingStatus ? '上传中...' : '上传' }}</Button>
+                  </div>
                 </div>
               </div>
-            </div>
 
-            <div v-else style="display: grid; grid-gap: 10px">
-              <i-button class="qm-primary-button">抽取试卷</i-button>
-            </div>
+              <div v-else style="display: grid; grid-gap: 10px">
+                <div v-if="new Date(course.startTime) - Date.now() > 0">
+                  未开始
+                </div>
+                <div v-else-if="new Date(course.endTime) - Date.now() < 0">
+                  已结束
+                </div>
+                <div v-else>
+                  <i-button class="qm-primary-button" @click="enterExam(course)">抽取试卷</i-button>
+                </div>
+              </div>
+            </template>
 
           </td>
         </tr>
@@ -51,10 +65,13 @@
 </template>
 
 <script>
+import { TK_SERVER_URL } from "@/constants/constants.js";
+
 export default {
   name: "EcsOfflineList",
   data() {
     return {
+      tk_server_url: TK_SERVER_URL,
       headers: {
         token: window.localStorage.getItem("token"),
         key: window.localStorage.getItem("key")
@@ -65,7 +82,8 @@ export default {
     };
   },
   props: {
-    courses: Array
+    courses: Array,
+    reloadList: Function
   },
   methods: {
     fileFormatCheck(file, resolve, reject) {
@@ -105,11 +123,10 @@ export default {
             binaryFileType: getMimetype(hex),
             hex: hex
           });
-          // console.log(uploads);
+
           if (
             ["application/zip", "application/pdf"].includes(getMimetype(hex))
           ) {
-            // console.log("true");
             resolve();
           } else {
             console.log("binary file type check: not zip or pdf");
@@ -131,12 +148,12 @@ export default {
       this.file = file;
       return false;
     },
-    handleSuccess(res, file) {
+    handleSuccess() {
       this.file = null;
       this.loadingStatus = false;
       this.$Message.success("上传成功");
     },
-    handleError(res, file) {
+    handleError() {
       this.file = null;
       this.loadingStatus = false;
       this.$Message.error("上传失败");
@@ -161,16 +178,28 @@ export default {
       }
       this.file = file;
       this.loadingStatus = true;
-      // const check = this.uploadList.length < 5;
-      // if (!check) {
-      //   this.$Notice.warning({
-      //     title: "Up to five pictures can be uploaded."
-      //   });
-      // }
       return new Promise((resolve, reject) =>
         this.fileFormatCheck(file, resolve, reject)
       );
-      // return true;
+    },
+    async enterExam(course) {
+      await this.$http.get("/api/offline_exam/start", {
+        params: { examStudentId: course.examStudentId }
+      });
+      this.$emit("reloadList");
+    },
+    previewPaper(course) {
+      var user = {
+        loginName: course.examStudentId,
+        backUrl: window.document.location.href,
+        isOnlineExam: true
+      };
+      window.name = JSON.stringify(user);
+      window.location.href =
+        this.tk_server_url +
+        "/#/preview_paper/" +
+        course.paperId +
+        "?isback=true";
     }
   }
 };

+ 3 - 3
vue.config.js

@@ -1,6 +1,6 @@
 let proxy = {
   "/api/ecs_core": {
-    target: " http://ecs-dev.qmth.com.cn:8000", //代理跨域转地址,基础信息
+    target: "http://ecs-dev.qmth.com.cn:8000", //代理跨域转地址,基础信息
     changeOrigin: true
   },
   // "/api/logic/portal": {
@@ -8,7 +8,7 @@ let proxy = {
   //   changeOrigin: true
   // },
   "/api/ecs_exam_work": {
-    target: " http://ecs-dev.qmth.com.cn:8001", // 考务 王伟
+    target: "http://ecs-dev.qmth.com.cn:8001", // 考务 王伟
     changeOrigin: true
   },
   // "/api/ecs_outlet": {
@@ -16,7 +16,7 @@ let proxy = {
   //   changeOrigin: true
   // },
   "/facepp_api": {
-    target: " http://ecs-dev.qmth.com.cn:8898", // 陈恳
+    target: "http://ecs-dev.qmth.com.cn:8898", // 陈恳
     changeOrigin: true
   }
 };