Forráskód Böngészése

替换练习 智能识别

natasha 1 éve
szülő
commit
97f2a227b4

+ 19 - 1
src/views/exercise_questions/create/components/exercises/ReplaceAnswerQuestion.vue

@@ -120,7 +120,25 @@ export default {
 
       if (arr.length > 0) {
         this.data.stem = arr[0];
-        this.data.option_list = arr.slice(1).map((content) => getOption(content));
+        let option_list = arr.slice(1);
+        this.data.option_list = [];
+        this.data.property.row_count = option_list.length;
+        let column_count = 0;
+        option_list.forEach((item) => {
+          let item_arr = item.split(' ');
+          if (item_arr.length > column_count) {
+            column_count = item_arr.length;
+          }
+        });
+        this.data.property.column_count = column_count;
+        for (let i = 0; i < option_list.length; i++) {
+          let table_item = [];
+          let item_arr = option_list[i].split(' ');
+          for (let j = 0; j < column_count; j++) {
+            table_item.push({ content: item_arr[j] ? item_arr[j] : '', mark: getRandomNumber() });
+          }
+          this.data.option_list.push(table_item);
+        }
       }
     },
     addOption() {