xiatian 4 лет назад
Родитель
Сommit
ecbc062911
1 измененных файлов с 120 добавлено и 107 удалено
  1. 120 107
      src/modules/questions/views/EditPaper.vue

+ 120 - 107
src/modules/questions/views/EditPaper.vue

@@ -627,9 +627,9 @@
             <div
               v-if="
                 quesModel.questionType != 'NESTED_ANSWER_QUESTION' &&
-                  quesModel.questionType != 'SINGLE_ANSWER_QUESTION' &&
-                  quesModel.questionType != 'MULTIPLE_ANSWER_QUESTION' &&
-                  quesModel.questionType != 'BOOL_ANSWER_QUESTION'
+                quesModel.questionType != 'SINGLE_ANSWER_QUESTION' &&
+                quesModel.questionType != 'MULTIPLE_ANSWER_QUESTION' &&
+                quesModel.questionType != 'BOOL_ANSWER_QUESTION'
               "
             >
               <el-form-item label="答案">
@@ -640,7 +640,7 @@
             <div
               v-if="
                 quesModel.questionType == 'SINGLE_ANSWER_QUESTION' ||
-                  quesModel.questionType == 'MULTIPLE_ANSWER_QUESTION'
+                quesModel.questionType == 'MULTIPLE_ANSWER_QUESTION'
               "
             >
               <el-form-item label="答案">
@@ -678,7 +678,7 @@
                 paper.paperType == 'IMPORT' &&
                 (quesModel.questionType == 'SINGLE_ANSWER_QUESTION' ||
                   quesModel.questionType == 'MULTIPLE_ANSWER_QUESTION')
-              )
+              ),
             }"
           >
             <el-button
@@ -686,8 +686,8 @@
               @click="addQuesOption"
               v-if="
                 paper.paperType == 'IMPORT' &&
-                  (quesModel.questionType == 'SINGLE_ANSWER_QUESTION' ||
-                    quesModel.questionType == 'MULTIPLE_ANSWER_QUESTION')
+                (quesModel.questionType == 'SINGLE_ANSWER_QUESTION' ||
+                  quesModel.questionType == 'MULTIPLE_ANSWER_QUESTION')
               "
               ><i class="el-icon-plus"></i> 新增选项
             </el-button>
@@ -777,6 +777,9 @@
             value="上传答案文件"
             accept="application/vnd.openxmlformats-officedocument.spreadsheetml.sheet"
           />
+          <el-button @click="downAnswerTemplate" type="info">
+            <span>下载模板</span>
+          </el-button>
           <el-button
             @click="uploadAnswerFile"
             type="info"
@@ -809,7 +812,7 @@ export default {
   name: "editPaperApp",
   components: {
     reduplicate_mark,
-    ckeditor
+    ckeditor,
   },
   data() {
     return {
@@ -829,9 +832,9 @@ export default {
       paper: {
         course: {
           code: "",
-          name: ""
+          name: "",
         },
-        examRemark: ""
+        examRemark: "",
       },
       loading: false,
       dialogLoading: false,
@@ -878,7 +881,7 @@ export default {
         "SlateBlue",
         "SlateGray",
         "Tomato",
-        "VioletRed"
+        "VioletRed",
       ],
       difficultyDegreeList: [
         { label: 0.1, value: 0.1 },
@@ -890,15 +893,15 @@ export default {
         { label: 0.7, value: 0.7 },
         { label: 0.8, value: 0.8 },
         { label: 0.9, value: 0.9 },
-        { label: 1.0, value: 1.0 }
+        { label: 1.0, value: 1.0 },
       ],
       publicityList: [
         { label: "公开", value: true },
-        { label: "非公开", value: false }
+        { label: "非公开", value: false },
       ],
       answerTypes: [
         { label: "文本", value: "DIVERSIFIED_TEXT" },
-        { label: "音频", value: "SINGLE_AUDIO" }
+        { label: "音频", value: "SINGLE_AUDIO" },
       ],
       coursePropertyList: [],
       coursePropertyName: "", //课程属性名
@@ -908,10 +911,17 @@ export default {
       secondPropertyId: "", //二级属性id
       examRemark: "",
       showQuestions: [],
-      showButtons: []
+      showButtons: [],
     };
   },
   methods: {
+    downAnswerTemplate() {
+      var key = this.user.key;
+      var token = this.user.token;
+      window.open(
+        QUESTION_API + "/paper/answer/template?$key=" + key + "&$token=" + token
+      );
+    },
     openAnswerDialog() {
       this.checkResultAnswer = false;
       this.isUploadAnswer = true;
@@ -940,7 +950,7 @@ export default {
         param.append("dataFile", file, file.name);
       }
       let config = {
-        headers: { "Content-Type": "multipart/form-data" }
+        headers: { "Content-Type": "multipart/form-data" },
       };
       this.uploadAnswerLoading = true;
       this.$http
@@ -957,7 +967,7 @@ export default {
           document.getElementById("answerFile").value = "";
           this.initPaper();
         })
-        .catch(error => {
+        .catch((error) => {
           this.answerMessage = error.response.data.desc;
           document.getElementById("answerFile").value = "";
           this.uploadAnswerLoading = false;
@@ -996,7 +1006,7 @@ export default {
           "/" +
           this.paperDetailId +
           "/" +
-          this.parentView
+          this.parentView,
       });
     },
     //打开编辑大题题目弹窗
@@ -1018,7 +1028,7 @@ export default {
         .then(() => {
           this.$notify({
             message: "保存成功",
-            type: "success"
+            type: "success",
           });
           this.detailLoading = false;
           this.closePaperDatailDialog();
@@ -1033,60 +1043,63 @@ export default {
       this.paper = {
         course: {
           code: "",
-          name: ""
-        }
+          name: "",
+        },
       };
-      this.$http.get(QUESTION_API + "/paper/" + this.paperId).then(response => {
-        this.paper = response.data;
-        //查询所有课程属性名
-        this.initCourseProperty(this.paper.course.code);
-        //将所有小题分为公开和非公开
-        if (this.paper.paperDetails && this.paper.paperDetails.length > 0) {
-          for (let paperDetil of this.paper.paperDetails) {
-            this.showQuestions.push({ is_show: true });
-            this.showButtons.push({ up: true });
-            paperDetil.pubCount = 0;
-            paperDetil.noPubCount = 0;
-            if (
-              paperDetil.paperDetailUnits &&
-              paperDetil.paperDetailUnits.length > 0
-            ) {
-              for (let paperDetilUt of paperDetil.paperDetailUnits) {
-                if (
-                  paperDetilUt.question.questionType != "NESTED_ANSWER_QUESTION"
-                ) {
-                  //非套题
-                  if (paperDetilUt.question.publicity) {
-                    paperDetil.pubCount = paperDetil.pubCount + 1;
-                  } else {
-                    paperDetil.noPubCount = paperDetil.noPubCount + 1;
-                  }
-                } else {
-                  //循环所有子题
-                  for (let ques of paperDetilUt.question.subQuestions) {
-                    if (ques.publicity) {
+      this.$http
+        .get(QUESTION_API + "/paper/" + this.paperId)
+        .then((response) => {
+          this.paper = response.data;
+          //查询所有课程属性名
+          this.initCourseProperty(this.paper.course.code);
+          //将所有小题分为公开和非公开
+          if (this.paper.paperDetails && this.paper.paperDetails.length > 0) {
+            for (let paperDetil of this.paper.paperDetails) {
+              this.showQuestions.push({ is_show: true });
+              this.showButtons.push({ up: true });
+              paperDetil.pubCount = 0;
+              paperDetil.noPubCount = 0;
+              if (
+                paperDetil.paperDetailUnits &&
+                paperDetil.paperDetailUnits.length > 0
+              ) {
+                for (let paperDetilUt of paperDetil.paperDetailUnits) {
+                  if (
+                    paperDetilUt.question.questionType !=
+                    "NESTED_ANSWER_QUESTION"
+                  ) {
+                    //非套题
+                    if (paperDetilUt.question.publicity) {
                       paperDetil.pubCount = paperDetil.pubCount + 1;
                     } else {
                       paperDetil.noPubCount = paperDetil.noPubCount + 1;
                     }
+                  } else {
+                    //循环所有子题
+                    for (let ques of paperDetilUt.question.subQuestions) {
+                      if (ques.publicity) {
+                        paperDetil.pubCount = paperDetil.pubCount + 1;
+                      } else {
+                        paperDetil.noPubCount = paperDetil.noPubCount + 1;
+                      }
+                    }
                   }
                 }
               }
             }
           }
-        }
-        setTimeout(() => {
-          document.documentElement.scrollTop = document.body.scrollTop = scrollPosition;
-          console.log(scrollPosition);
-        }, 1000);
-        this.loading = false;
-      });
+          setTimeout(() => {
+            document.documentElement.scrollTop = document.body.scrollTop = scrollPosition;
+            console.log(scrollPosition);
+          }, 1000);
+          this.loading = false;
+        });
     },
     //查询所有课程属性名
     initCourseProperty(courseCode) {
       this.$http
         .get(QUESTION_API + "/courseProperty/enable/" + courseCode)
-        .then(response => {
+        .then((response) => {
           this.coursePropertyList = response.data;
         });
     },
@@ -1105,7 +1118,7 @@ export default {
       if (count == 0) {
         this.$alert("您确定删除吗?", "提示", {
           confirmButtonText: "确定",
-          callback: action => {
+          callback: (action) => {
             if (action == "confirm") {
               this.loading = true;
               this.$http
@@ -1115,17 +1128,17 @@ export default {
                   this.loading = true;
                   this.$notify({
                     message: "删除成功",
-                    type: "success"
+                    type: "success",
                   });
                   this.loading = false;
                 });
             }
-          }
+          },
         });
       } else {
         this.$alert("大题下还有小题,不可删除!", "提示", {
           confirmButtonText: "确定",
-          callback: () => {}
+          callback: () => {},
         });
       }
     },
@@ -1298,7 +1311,7 @@ export default {
           if (courseProperty.name == this.coursePropertyName) {
             this.$http
               .get(QUESTION_API + "/property/first/" + courseProperty.id)
-              .then(response => {
+              .then((response) => {
                 this.firstPropertyList = response.data;
               });
           }
@@ -1311,7 +1324,7 @@ export default {
       if (this.firstPropertyId) {
         this.$http
           .get(QUESTION_API + "/property/second/" + this.firstPropertyId)
-          .then(response => {
+          .then((response) => {
             this.secondPropertyList = response.data;
           });
       }
@@ -1325,7 +1338,7 @@ export default {
         id: "",
         coursePropertyName: "",
         firstProperty: {},
-        secondProperty: {}
+        secondProperty: {},
       };
       if (
         this.quesModel.quesProperties == null ||
@@ -1347,7 +1360,7 @@ export default {
         if (quesPro.id == quesProperty.id) {
           this.$notify({
             message: "该属性已存在,请重新选择",
-            type: "error"
+            type: "error",
           });
           return false;
         }
@@ -1367,7 +1380,7 @@ export default {
         if (!this.secondPropertyId) {
           this.$notify({
             message: "请选择二级属性",
-            type: "error"
+            type: "error",
           });
           return false;
         }
@@ -1392,14 +1405,14 @@ export default {
       if (!this.coursePropertyName) {
         this.$notify({
           message: "请选择属性",
-          type: "error"
+          type: "error",
         });
         return false;
       }
       if (!this.firstPropertyId) {
         this.$notify({
           message: "请选择一级属性",
-          type: "error"
+          type: "error",
         });
         return false;
       }
@@ -1434,7 +1447,7 @@ export default {
       this.quesModel.quesOptions.push({
         number: "",
         optionBody: "",
-        isCorrect: ""
+        isCorrect: "",
       });
       for (var i = 0; i < this.quesModel.quesOptions.length; i++) {
         this.quesModel.quesOptions[i]["number"] = i + 1;
@@ -1458,14 +1471,14 @@ export default {
       } else {
         this.$notify({
           message: "分数只能为正数",
-          type: "error"
+          type: "error",
         });
         return;
       }
       let paperDetailUnitExp = {
         id: this.editPaperDetailUnit.id,
         question: this.quesModel,
-        score: this.quesModel.score
+        score: this.quesModel.score,
       };
       if (
         this.quesModel.quesOptions &&
@@ -1474,12 +1487,12 @@ export default {
         this.$confirm("无选项将删除该试题, 是否继续?", "提示", {
           confirmButtonText: "确定",
           cancelButtonText: "取消",
-          type: "warning"
+          type: "warning",
         }).then(() => {
           this.dialogLoading = true;
           this.$http
             .delete(QUESTION_API + "/paper/deleteQuestion/" + this.quesModel.id)
-            .then(response => {
+            .then((response) => {
               if (response.data.length > 0) {
                 var deleteInfo =
                   "该试题被试卷:" +
@@ -1487,12 +1500,12 @@ export default {
                   "使用,不能删除";
                 this.$notify({
                   message: deleteInfo,
-                  type: "error"
+                  type: "error",
                 });
               } else {
                 this.$notify({
                   message: "保存成功",
-                  type: "success"
+                  type: "success",
                 });
               }
               this.dialogLoading = false;
@@ -1505,17 +1518,17 @@ export default {
           .then(() => {
             this.$notify({
               message: "保存成功",
-              type: "success"
+              type: "success",
             });
             this.dialogLoading = false;
             this.closeQuesDialog();
             this.initPaper();
           })
-          .catch(err => {
+          .catch((err) => {
             this.dialogLoading = false;
             this.$notify({
               type: "error",
-              message: err.response.data.desc
+              message: err.response.data.desc,
             });
           });
       }
@@ -1554,7 +1567,7 @@ export default {
     deleteQues01(paperDetailUnitId) {
       this.$alert("您确定删除吗?", "提示", {
         confirmButtonText: "确定",
-        callback: action => {
+        callback: (action) => {
           if (action == "confirm") {
             this.loading = true;
             this.$http
@@ -1566,23 +1579,23 @@ export default {
                 this.loading = true;
                 this.$notify({
                   message: "删除成功",
-                  type: "success"
+                  type: "success",
                 });
                 this.loading = false;
               });
           }
-        }
+        },
       });
     },
     deleteQues02(questionId) {
       this.$alert("您确定删除吗?", "提示", {
         confirmButtonText: "确定",
-        callback: action => {
+        callback: (action) => {
           if (action == "confirm") {
             this.loading = true;
             this.$http
               .delete(QUESTION_API + "/paper/deleteQuestion/" + questionId)
-              .then(response => {
+              .then((response) => {
                 if (response.data.length > 0) {
                   var deleteInfo =
                     "该试题被试卷:" +
@@ -1590,7 +1603,7 @@ export default {
                     "使用,不能删除";
                   this.$notify({
                     message: deleteInfo,
-                    type: "error"
+                    type: "error",
                   });
                 } else {
                   this.initPaper();
@@ -1599,13 +1612,13 @@ export default {
                   this.loading = true;
                   this.$notify({
                     message: "保存成功",
-                    type: "success"
+                    type: "success",
                   });
                 }
                 this.loading = false;
               });
           }
-        }
+        },
       });
     },
     //获取重复试题
@@ -1613,7 +1626,7 @@ export default {
       this.duplicateLoading = true;
       this.$http
         .get(QUESTION_API + "/paper/" + this.paperId + "/reduplicate-questions")
-        .then(response => {
+        .then((response) => {
           this.reduplicateQuestions = response.data;
           this.duplicateLoading = false;
           this.initReduplicateQuesColor();
@@ -1639,7 +1652,7 @@ export default {
       if (colorCount > 20) {
         this.reduplicateQuesColor = randomColor({
           luminosity: "bright",
-          count: colorCount
+          count: colorCount,
         });
       } else {
         this.reduplicateQuesColor = this.defaultColor;
@@ -1676,38 +1689,38 @@ export default {
         .then(() => {
           this.$notify({
             message: "保存成功",
-            type: "success"
+            type: "success",
           });
           this.loading = false;
           this.initPaper();
         })
-        .catch(error => {
+        .catch((error) => {
           this.loading = false;
           this.$notify({
             type: "error",
-            message: error.response.data.desc
+            message: error.response.data.desc,
           });
         });
     },
     //删除试卷
     deletePaper(id) {
       this.$confirm("确认删除试卷吗?", "提示", {
-        type: "warning"
+        type: "warning",
       }).then(() => {
         this.loading = true;
         this.$http.delete(QUESTION_API + "/paper/" + id).then(
           () => {
             this.$notify({
               message: "删除成功",
-              type: "success"
+              type: "success",
             });
             this.back();
           },
-          error => {
+          (error) => {
             this.$notify({
               message: error.response.data.desc,
               type: "error",
-              title: "错误"
+              title: "错误",
             });
             this.loading = false;
           }
@@ -1732,11 +1745,11 @@ export default {
     back() {
       if (sessionStorage.getItem("question_back") == "true") {
         this.$router.push({
-          path: "/questions/" + this.parentView + "/0"
+          path: "/questions/" + this.parentView + "/0",
         });
       } else {
         this.$router.push({
-          path: "/questions/" + this.parentView + "/1"
+          path: "/questions/" + this.parentView + "/1",
         });
       }
     },
@@ -1789,7 +1802,7 @@ export default {
           QUESTION_API + "/checkRadioFile/" + this.paperId,
           this.fileNameList
         )
-        .then(response => {
+        .then((response) => {
           console.log("response:", response);
           this.message = response.data.errorMsg;
           if (this.message == "OK") {
@@ -1799,7 +1812,7 @@ export default {
             this.isUpload = true;
           }
         })
-        .catch(error => {
+        .catch((error) => {
           console.log(error);
         });
     },
@@ -1813,7 +1826,7 @@ export default {
         param.append("files", file, file.name);
       }
       let config = {
-        headers: { "Content-Type": "multipart/form-data" }
+        headers: { "Content-Type": "multipart/form-data" },
       };
       this.$http
         .post(QUESTION_API + "/uploadRadio/" + this.paperId, param, config)
@@ -1825,15 +1838,15 @@ export default {
           document.getElementById("radioFile").value = "";
           this.initPaper();
         })
-        .catch(error => {
+        .catch((error) => {
           this.message = error.response.data.desc;
           this.uploadAudioLoading = false;
         });
-    }
+    },
   },
   computed: {
     ...mapState({
-      user: state => state.user
+      user: (state) => state.user,
     }),
     updatePorperty() {
       if (this.parentView === "gen_paper") {
@@ -1849,7 +1862,7 @@ export default {
         return obj.sort().toString();
       }
       return this.quesModel.quesAnswer;
-    }
+    },
   },
   watch: {},
   created() {
@@ -1862,10 +1875,10 @@ export default {
     this.uploadAction = QUESTION_API + "/uploadRadio/" + this.paperId;
     this.uploadHeaders = {
       key: this.user.key,
-      token: this.user.token
+      token: this.user.token,
     };
   },
-  mounted() {}
+  mounted() {},
 };
 </script>
 <style scoped src="../styles/EditPaper.css">