Explorar el Código

解决试卷大图不分页问题

zhangjie hace 3 años
padre
commit
a64b88d1f8

+ 35 - 9
src/features/examwork/StudentExamDetail/PreviewPaperDialog.vue

@@ -46,6 +46,7 @@ import { numberToChinese, numberToUpperCase } from "./spins/renderJSON";
 import ContItem from "./spins/ContItem.vue";
 import previewTem from "./spins/previewTem";
 import { randomCode } from "@/utils/utils";
+import { STRUCT_TYPES } from "./spins/paperSetting";
 
 export default {
   name: "preview-paper-dialog",
@@ -238,15 +239,40 @@ export default {
       }
 
       if (question.studentAnswer) {
-        contents.push({
-          cls: "topic-answer std-answer",
-          type: "json",
-          content: {
-            answerType: "student",
-            structType: question.structType,
-            body: question.studentAnswer,
-          },
-        });
+        // 简答题的特殊处理,解决上传的大图无法分页问题。文字内容不受影响。
+        if (question.structType === STRUCT_TYPES.TEXT) {
+          // console.log(question.studentAnswer);
+          let aindex = 0;
+          question.studentAnswer.forEach((answer) => {
+            answer.sections.forEach((section) => {
+              contents.push({
+                cls: "topic-answer std-answer",
+                type: "json",
+                content: {
+                  answerType: "student",
+                  structType: question.structType,
+                  hideTitle: aindex !== 0,
+                  body: [
+                    {
+                      sections: [section],
+                    },
+                  ],
+                },
+              });
+              aindex++;
+            });
+          });
+        } else {
+          contents.push({
+            cls: "topic-answer std-answer",
+            type: "json",
+            content: {
+              answerType: "student",
+              structType: question.structType,
+              body: question.studentAnswer,
+            },
+          });
+        }
       }
 
       contents.push({

+ 4 - 11
src/features/examwork/StudentExamDetail/spins/TopicAnswer.vue

@@ -1,8 +1,9 @@
 <template>
   <div class="cont-item-detail">
-    <h4 class="cont-part-title">
+    <h4 v-if="!data.hideTitle" class="cont-part-title">
       {{ data.answerType === "student" ? "学生答案" : "标准答案" }}
     </h4>
+    <h4 v-else class="cont-part-title"></h4>
     <div
       v-if="data.structType === STRUCT_TYPES.BOOLEAN_CHOICE"
       class="cont-part-body"
@@ -33,6 +34,7 @@
 
 <script>
 import RichText from "./RichText.vue";
+import { STRUCT_TYPES } from "./paperSetting";
 
 export default {
   name: "topic-answer",
@@ -47,16 +49,7 @@ export default {
   },
   data() {
     return {
-      STRUCT_TYPES: {
-        SINGLE_CHOICE: 1,
-        MULTIPLE_CHOICE: 2,
-        BOOLEAN_CHOICE: 3,
-        FILL_BLANK: 4,
-        TEXT: 5,
-        NESTED: 6,
-        LISTENING: 7,
-        MATCHES: 8,
-      },
+      STRUCT_TYPES,
       optionNames: "ABCDEFGHIJKLMNOPQRSTUVWXYZ",
     };
   },

+ 10 - 0
src/features/examwork/StudentExamDetail/spins/paperSetting.js

@@ -0,0 +1,10 @@
+export const STRUCT_TYPES = {
+  SINGLE_CHOICE: 1,
+  MULTIPLE_CHOICE: 2,
+  BOOLEAN_CHOICE: 3,
+  FILL_BLANK: 4,
+  TEXT: 5,
+  NESTED: 6,
+  LISTENING: 7,
+  MATCHES: 8,
+};