Selaa lähdekoodia

试卷导出展示修改

zhangjie 2 vuotta sitten
vanhempi
commit
6ea24681d5
1 muutettua tiedostoa jossa 24 lisäystä ja 6 poistoa
  1. 24 6
      src/modules/paper-export/views/PaperTemplateBuild.vue

+ 24 - 6
src/modules/paper-export/views/PaperTemplateBuild.vue

@@ -186,6 +186,7 @@ export default {
         seqMode: this.seqMode,
       });
       this.paperJson = res.data;
+      this.resetClozeSerialNo(this.paperJson);
       this.fieldData = {
         paperName: res.data.name,
         courseName: `${res.data.course.name}(${res.data.course.code})`,
@@ -200,6 +201,21 @@ export default {
         };
       });
     },
+    resetClozeSerialNo(paperData) {
+      const clozeQuestionTypes = ["CLOZE", "BANKED_CLOZE"];
+      paperData.paperDetails.forEach((detail) => {
+        detail.paperDetailUnits.forEach((question) => {
+          if (!clozeQuestionTypes.includes(question.questionType)) return;
+          question.question.quesBody.sections.forEach((section) => {
+            section.blocks.forEach((block) => {
+              if (block.type !== "cloze") return;
+              block.value =
+                question.question.subQuestions[block.value - 1].questionSeq;
+            });
+          });
+        });
+      });
+    },
     async seqModeChange() {
       await this.getPaperJson();
       this.$nextTick(() => {
@@ -388,14 +404,16 @@ export default {
         `${question.questionSeq}、`
       );
       contents.push(...tbodys);
+      const hasNobody = !tbodys.length;
 
       if (question.quesOptions && question.quesOptions.length) {
-        question.quesOptions.forEach((op) => {
-          const obodys = this.parseTitleOption(
-            op.optionBody,
-            `${numberToUpperCase(op.number)}、`,
-            "option"
-          );
+        question.quesOptions.forEach((op, oIndex) => {
+          let noVal = `${numberToUpperCase(op.number)}、`;
+          if (hasNobody && !oIndex) {
+            // 针对如完形填空的小题做的特殊处理
+            noVal = `${question.questionSeq}、${noVal}`;
+          }
+          const obodys = this.parseTitleOption(op.optionBody, noVal, "option");
           contents.push(...obodys);
         });
       }