Selaa lähdekoodia

可配置表格 多句 填空

natasha 2 vuotta sitten
vanhempi
commit
9ab136cc4e

+ 1 - 0
src/components/Adult/inputModules/ConfigurableTable/components/CellEdit.vue

@@ -270,6 +270,7 @@ export default {
                 wordPadding: [],
                 conAlign: 'center'
               },
+              input_Isexample: false
             },
           ],
           fn_check_list: {

+ 1 - 0
src/components/Adult/inputModules/ConfigurableTable/index.vue

@@ -205,6 +205,7 @@ export default {
                             completeInput: ""
                         },
                         detail: [],
+                        input_Isexample: false,
                     }
                   },
                 ],

+ 4 - 0
src/components/Adult/inputModules/HeaderSeparate/components/CellEdit.vue

@@ -111,6 +111,10 @@ export default {
           label: "前后缀 + 拼音",
           value: "prePinyin",
         },
+        {
+          label: "多行文本/句子填空",
+          value: "mulText",
+        },
       ],
     };
   },

+ 292 - 3
src/components/Adult/preview/ConfigurableTable.vue

@@ -230,7 +230,62 @@
                     </span>
                   </div>
                 </div>
-
+                
+                <div class="stem-content" v-else-if="col.type === 'mulText'">
+                    <div
+                        :class="[
+                            'sent-main',
+                        ]"
+                        v-for="(sdItem, sdIndex) in col.mulText.detail"
+                        :key="'sent-option-items' + j + sdIndex"
+                        >
+                        <div class="sent-que-box">
+                            <div
+                            class="sent-que"
+                            v-for="(sddItem, sddIndex) in sdItem.detail"
+                            :key="'sent-option-items' + j + sdIndex + sddIndex"
+                            :style="{
+                                paddingLeft:
+                                sddItem.config.wordPadding.indexOf('left') > -1
+                                    ? '4px'
+                                    : '0px',
+                                paddingRight:
+                                sddItem.config.wordPadding.indexOf('right') > -1
+                                    ? '4px'
+                                    : '0px',
+                            }"
+                            >
+                            <!-- 补全句子 -->
+                            <OneSentenceTemp
+                                :detail="sddItem"
+                                :pyPosition="curQue.pinyinPosition"
+                                :TaskModel="TaskModel"
+                                :Bookanswer="curQue.Bookanswer[i].content[j]"
+                                :judgeAnswer="judgeAnswer"
+                                :correctAnswer="col.mulText.correct.complateArr"
+                                :isInput="true"
+                                :fn_check_list="[]"
+                                :pyNumber="col.pyNumber && col.pyNumber[sdIndex]"
+                                :hengLeg="sdItem.hengLeg"
+                                :maxFontsize="sdItem.maxFontsize"
+                            />
+                            <template
+                                v-if="
+                                sddItem.img_list &&
+                                sddItem.img_list.length > 0 &&
+                                sddItem.img_list[0].id
+                                "
+                            >
+                                <img
+                                :src="sddItem.img_list[0].id"
+                                class="sddItem_img_list"
+                                :style="[imgStyle(sddItem)]"
+                                />
+                            </template>
+                            </div>
+                        </div>
+                    </div>
+                </div>
                 <CrossTick
                   v-if="col.isCross"
                   :index="i"
@@ -255,9 +310,10 @@
 <script>
 import CrossTick from "./HeaderSparate/CrossTick.vue";
 import AnswerTitle from "../preview/components/AnswerTitle.vue";
+import OneSentenceTemp from "./components/OneSentenceTemp.vue";
 
 export default {
-  components: { CrossTick, AnswerTitle },
+  components: { CrossTick, AnswerTitle, OneSentenceTemp },
   props: {
     curQue: {
       type: Object,
@@ -270,11 +326,19 @@ export default {
     judgeAnswer: {
       type: String,
     },
+    TaskModel: {
+      type: String,
+    }
   },
   data() {
     return {
       isAnswerMode: false,
       userError: false,
+      userAnswer: {
+        completeInput: []
+      },
+      userBookanswer:[],
+      chsFhList: [",", "。", "”", ":", "》", "?", "!", ";"],
     };
   },
   computed: {
@@ -311,11 +375,15 @@ export default {
     }
     if (!this.curQue.Bookanswer) {
       let arr = [];
+      let flag = false // 是否含有多个句子类型
       this.curQue.tableData.body.forEach((item, i) => {
         arr.push({
           content: [],
         });
         item.content.forEach((items) => {
+            if(items.type === 'mulText'){
+                flag = true
+            }
           arr[i].content.push({
             answer: "",
             CrossAnswer: "",
@@ -324,7 +392,9 @@ export default {
           });
         });
       });
-      this.$set(this.curQue, "Bookanswer", arr);
+      if(!flag){
+        this.$set(this.curQue, "Bookanswer", arr);
+      }
     } else {
       this.curQue.Bookanswer.forEach((item) => {
         item.content.forEach((item) => {
@@ -336,6 +406,9 @@ export default {
       });
     }
   },
+  mounted() {
+    this.handleData();
+  },
   methods: {
     enterAnswer(i, j, type) {
       if (type == "input") {
@@ -445,6 +518,180 @@ export default {
       });
       return colIndex === -1 && rowIndex === -1;
     },
+    handleData() {
+      let Bookanswer = [];
+      let itemLeg = 0;
+      this.totalHasPy = false;
+      let option = JSON.parse(JSON.stringify(this.curQue.tableData.body));
+      let completeImage = [];
+      option.forEach((item, index) => {
+        Bookanswer.push({content: []});
+        completeImage = [];
+        itemLeg = item.length > itemLeg ? item.length : itemLeg;
+        item.content.forEach((items, indexs) => {
+            if(items.mulText){
+                let userAnswer = JSON.parse(JSON.stringify(this.userAnswer));
+                let correct = JSON.parse(JSON.stringify(items.mulText.correct));
+                let complateArr = correct.completeInput.split("\n");
+                complateArr.forEach((itemI, indexI) => {
+                    if (itemI == "??" || itemI == "??") {
+                    complateArr[indexI] = "";
+                    }
+                });
+                items.mulText.correct.complateArr = complateArr;
+                this.curQue.tableData.body[index].content[indexs].mulText.correct.complateArr = complateArr;
+                Bookanswer[index].content.push(userAnswer);
+                let hengIndex = 0;
+                items.pyNumber = [];
+
+                items.mulText.detail.forEach((sdItem, sdIndex) => {
+                    let isHasPY = 0;
+                    let maxFontsize = 0;
+                    sdItem.detail.forEach((sddItem) => {
+                    if (sddItem.wordsList.length > 0) {
+                        sddItem.wordsList.forEach((sItem, sIndex) => {
+                        let reg = /_{2,}/g;
+                        if (reg.test(sItem.chs)) {
+                            sItem.index = sIndex;
+                            sItem.isHeng = true;
+                            sItem.hengIndex = hengIndex;
+                            hengIndex++;
+                        }
+                        //补全句子
+                        if (
+                            !this.curQue.Bookanswer 
+                        ) {
+                            let reg = /_{2,}/g;
+                            if (reg.test(sItem.chs)) {
+                            let bool = false;
+                            if (sddItem.hasOwnProperty("input_Isexample")) {
+                                bool = sddItem.input_Isexample;
+                            } else {
+                                bool = items.Isexample;
+                            }
+                            let obj = null;
+                            if (!sddItem.input_tian) {
+                                obj = {
+                                answer:
+                                    bool && complateArr[sItem.hengIndex]
+                                    ? complateArr[sItem.hengIndex]
+                                    : "",
+                                userAnswerJudge:
+                                    bool || !complateArr[sItem.hengIndex]
+                                    ? ""
+                                    : "[JUDGE##F##JUDGE]",
+                                input_Isexample: bool ? true : false,
+                                };
+                                Bookanswer[index].content[indexs].completeInput.push(
+                                JSON.parse(JSON.stringify(obj))
+                                );
+                            } else {
+                                if (sddItem.hengLeg == "-1") {
+                                completeImage.push(obj);
+                                } else {
+                                for (let i = 0; i < Number(sddItem.hengLeg); i++) {
+                                    completeImage.push(obj);
+                                }
+                                }
+                                Bookanswer[index].content[indexs].completeInput.push(
+                                JSON.parse(JSON.stringify(completeImage))
+                                );
+                            }
+                            }
+                        }
+
+                        this.mergeWordSymbol(sItem);
+                        if (sItem.pinyin) {
+                            isHasPY++;
+                            this.totalHasPy = true;
+                        }
+                        let fontSize = JSON.parse(JSON.stringify(sItem.fontSize));
+                        fontSize = Number(fontSize.replace("px", ""));
+                        maxFontsize = fontSize > maxFontsize ? fontSize : maxFontsize;
+                        });
+                    } else {
+                        if (sddItem.sentence) {
+                        let fontSize = JSON.parse(
+                            JSON.stringify(sddItem.config.fontSize)
+                        );
+                        fontSize = Number(fontSize.replace("px", ""));
+                        maxFontsize = fontSize > maxFontsize ? fontSize : maxFontsize;
+                        }
+                    }
+                    });
+                    sdItem.maxFontsize = maxFontsize;
+                    items.pyNumber.push(isHasPY);
+                });
+            }
+          
+        });
+      });
+      if (!this.curQue.Bookanswer) {
+        this.$set(
+          this.curQue,
+          "Bookanswer",
+          JSON.parse(JSON.stringify(Bookanswer))
+        );
+      } else {
+        let BookanswerStr = JSON.stringify(this.curQue.Bookanswer);
+        let errReg = /\[JUDGE##F##JUDGE\]/g;
+        if (errReg.test(BookanswerStr)) {
+          let errorArr = BookanswerStr.match(/\[JUDGE##F##JUDGE\]/g);
+          this.userErrorNumberTotal = errorArr.length;
+        }
+      }
+
+      this.$set(this.curQue.tableData, "body", option);
+      let contentWidth = 780;
+      if (this.curQue.img_list && this.curQue.img_list.length > 0) {
+        contentWidth = 780 - this.curQue.img_size;
+      }
+      if(itemLeg==1){
+        this.itemsWidth = 780
+      }else{
+        this.itemsWidth = Math.floor(contentWidth / itemLeg) - 16;
+      }
+      
+
+      // 把答错的挑出来
+      if (this.judgeAnswer == "standardAnswer") {
+        this.userErrorList = [];
+        this.userBookanswer = [];
+        this.curQue.tableData.body.forEach((item, index) => {
+            item.content.forEach((items, indexs) => {
+            if(items.mulText){
+                let flag = false;
+                // 句子填空
+                items.mulText.correct.complateArr.forEach((itemI, indexI) => {
+                if (
+                    itemI &&
+                    itemI !=
+                    this.curQue.Bookanswer[index].content[indexs].completeInput[indexI]
+                ) {
+                    flag = true;
+                }
+                });
+
+                if (flag) {
+                    this.userErrorList.push(items);
+                    this.userBookanswer.push(this.curQue.Bookanswer[index][indexs]);
+                    this.userError = true;
+                }
+            }
+            
+          });
+        });
+      }
+      console.log(this.curQue)
+    },
+    //词和标点合一起
+    mergeWordSymbol(sItem) {
+      if (this.chsFhList.indexOf(sItem.chs) > -1) {
+        sItem.isShow = false;
+      } else {
+        sItem.isShow = true;
+      }
+    },
   },
 };
 </script>
@@ -564,6 +811,48 @@ export default {
           display: grid;
         }
       }
+      .stem-content {
+        flex: 1;
+      }
+      .number-box {
+        // &-hasPY {
+        //   margin-top: 19px;
+        // }
+      }
+      .sent-main {
+        position: relative;
+        width: 100%;
+        display: flex;
+        flex-wrap: wrap;
+
+        box-sizing: border-box;
+        &-138 {
+          padding-right: 138px;
+        }
+        &-bottom {
+          margin-bottom: 9px;
+        }
+      }
+      .sent-que-box {
+        display: flex;
+        flex-wrap: wrap;
+        padding: 4px 0;
+      }
+      .sent-que {
+        // font-size: 0;
+        &-flex {
+          flex: 1;
+          display: flex;
+          justify-content: space-between;
+          align-items: stretch;
+        }
+        .sentence-part {
+          flex: 1;
+        }
+        .sddItem_img_list {
+          height: 32px;
+        }
+      }
     }
   }
 }