Эх сурвалжийг харах

试卷预览时,5个答案选项场景的排版要求处理

刘洋 9 сар өмнө
parent
commit
793e587615

+ 35 - 5
src/modules/paper-export/views/paperTemplateBuildMixins.js

@@ -141,13 +141,17 @@ export default {
         const IS_NOUNS = questionType === "NOUNS";
 
         // 构建选项元素信息
+        console.log("options.length", options.length);
         const opitonList = options.map((optionIds) => {
           const elements = getElementsByIds(optionIds);
           const width = maxNum(elements.map((elem) => elem.w));
+          console.log(width, this.maxColumnWidth, this.TEXT_INDENT_SIZE);
           const percent = this.getSizePercent(
             width,
-            this.maxColumnWidth - this.TEXT_INDENT_SIZE
+            this.maxColumnWidth - this.TEXT_INDENT_SIZE,
+            options.length
           );
+          console.log("percent", percent);
           return {
             percent,
             resetPercent: null,
@@ -159,13 +163,16 @@ export default {
         let resetPercent = 1;
         // 奇数选项,段落匹配,全部一行
         if (
-          (optionCount % 2 > 0 && !IS_BANKED_CLOZE && !IS_NOUNS) ||
+          (optionCount % 2 > 0 &&
+            !IS_BANKED_CLOZE &&
+            !IS_NOUNS &&
+            optionCount !== 5) ||
           IS_PARAGRAPH_MATCHING
         ) {
           resetPercent = 1;
         } else {
           const maxPercent = maxNum(opitonList.map((item) => item.percent));
-          resetPercent = this.getResetPercent(maxPercent);
+          resetPercent = this.getResetPercent(maxPercent, optionCount);
         }
         opitonList.forEach((item) => {
           item.resetPercent = resetPercent;
@@ -441,15 +448,38 @@ export default {
         textIndent: `-${this.TEXT_INDENT_SIZE}px`,
       };
     },
-    getSizePercent(size, fullSize) {
+    getSizePercent(size, fullSize, optionLength) {
       const rate = size / fullSize;
+      if (optionLength == 5) {
+        if (rate <= 0.2) {
+          return 0.2;
+        } else if (rate <= 0.33) {
+          return 0.33;
+        } else if (rate <= 0.5) {
+          return 0.5;
+        } else {
+          return 1;
+        }
+      }
       if (rate <= 0.25) return 0.25;
       if (rate <= 0.5) return 0.5;
       return 1;
     },
-    getResetPercent(maxPercent) {
+    getResetPercent(maxPercent, optionCount) {
+      if (optionCount == 5) {
+        if (maxPercent > 0.5) {
+          return 1;
+        } else if (maxPercent > 0.33) {
+          return 0.5;
+        } else if (maxPercent > 0.2) {
+          return 0.33;
+        } else {
+          return 0.2;
+        }
+      }
       if (maxPercent > 0.5) return 1;
       if (maxPercent > 0.25) return 0.5;
+
       return 0.25;
     },
     calcInitColumnHeight(column) {