Browse Source

智能识别

natasha 1 year ago
parent
commit
e168cbfd65

+ 20 - 2
src/views/exercise_questions/create/components/exercises/AnswerQuestion.vue

@@ -110,8 +110,26 @@ export default {
         .filter((item) => item);
 
       if (arr.length > 0) {
-        this.data.stem = arr[0];
-        this.data.reference_answer = arr[1] ? arr[1] : '';
+        let sliceLength = 0;
+        if (arr[0].substring(0, 3) === '题干:') {
+          this.data.stem = arr[0].substring(3);
+          sliceLength += 1;
+        }
+        if (arr.slice(sliceLength)[0] && arr.slice(sliceLength)[0].substring(0, 3) === '提示:') {
+          this.data.description = arr.slice(sliceLength)[0].substring(3);
+          this.data.property.is_enable_description = 'true';
+          sliceLength += 1;
+        } else {
+          this.data.description = '';
+          this.data.property.is_enable_description = 'false';
+        }
+        if (arr.slice(sliceLength)[0] && arr.slice(sliceLength)[0].substring(0, 5) === '参考答案:') {
+          this.data.reference_answer = arr.slice(sliceLength)[0].substring(5);
+          this.data.property.is_enable_reference_answer = 'true';
+        } else {
+          this.data.reference_answer = '';
+          this.data.property.is_enable_reference_answer = 'false';
+        }
       }
     },
   },

+ 16 - 3
src/views/exercise_questions/create/components/exercises/ChineseQuestion.vue

@@ -361,10 +361,23 @@ export default {
         .filter((item) => item);
 
       if (arr.length > 0) {
-        this.data.stem = arr[0];
+        let sliceLength = 0;
+        if (arr[0].substring(0, 3) === '题干:') {
+          this.data.stem = arr[0].substring(3);
+          sliceLength += 1;
+        }
+        if (arr.slice(sliceLength)[0] && arr.slice(sliceLength)[0].substring(0, 3) === '提示:') {
+          this.data.description = arr.slice(sliceLength)[0].substring(3);
+          this.data.property.is_enable_description = 'true';
+          sliceLength += 1;
+        } else {
+          this.data.description = '';
+          this.data.property.is_enable_description = 'false';
+        }
+        let option_list = arr.slice(sliceLength);
         this.data.option_list = [];
-        arr.slice(1).map((content, index) => {
-          let content_item = content.split('&&');
+        option_list.map((content, index) => {
+          let content_item = content.split('/');
           this.data.option_list.push({
             content: content_item[0] ? content_item[0] : '',
             mark: getRandomNumber(),

+ 15 - 2
src/views/exercise_questions/create/components/exercises/ChooseToneQuestion.vue

@@ -343,8 +343,21 @@ export default {
         .filter((item) => item);
 
       if (arr.length > 0) {
-        this.data.stem = arr[0];
-        this.data.option_list = arr.slice(1).map((content) => getOption(content));
+        let sliceLength = 0;
+        if (arr[0].substring(0, 3) === '题干:') {
+          this.data.stem = arr[0].substring(3);
+          sliceLength += 1;
+        }
+        if (arr.slice(sliceLength)[0] && arr.slice(sliceLength)[0].substring(0, 3) === '提示:') {
+          this.data.description = arr.slice(sliceLength)[0].substring(3);
+          this.data.property.is_enable_description = 'true';
+          sliceLength += 1;
+        } else {
+          this.data.description = '';
+          this.data.property.is_enable_description = 'false';
+        }
+        let option_list = arr.slice(sliceLength);
+        this.data.option_list = option_list.map((content) => getOption(content));
         this.data.option_list.forEach((item) => {
           this.handleItemAnswer(item);
         });

+ 20 - 2
src/views/exercise_questions/create/components/exercises/EssayQuestion.vue

@@ -107,8 +107,26 @@ export default {
         .filter((item) => item);
 
       if (arr.length > 0) {
-        this.data.stem = arr[0];
-        this.data.reference_answer = arr[1] ? arr[1] : '';
+        let sliceLength = 0;
+        if (arr[0].substring(0, 3) === '题干:') {
+          this.data.stem = arr[0].substring(3);
+          sliceLength += 1;
+        }
+        if (arr.slice(sliceLength)[0] && arr.slice(sliceLength)[0].substring(0, 3) === '提示:') {
+          this.data.description = arr.slice(sliceLength)[0].substring(3);
+          this.data.property.is_enable_description = 'true';
+          sliceLength += 1;
+        } else {
+          this.data.description = '';
+          this.data.property.is_enable_description = 'false';
+        }
+        if (arr.slice(sliceLength)[0] && arr.slice(sliceLength)[0].substring(0, 5) === '参考答案:') {
+          this.data.reference_answer = arr.slice(sliceLength)[0].substring(5);
+          this.data.property.is_enable_reference_answer = 'true';
+        } else {
+          this.data.reference_answer = '';
+          this.data.property.is_enable_reference_answer = 'false';
+        }
       }
     },
   },

+ 15 - 2
src/views/exercise_questions/create/components/exercises/RepeatQuestion.vue

@@ -184,8 +184,21 @@ export default {
         .filter((item) => item);
 
       if (arr.length > 0) {
-        this.data.stem = arr[0];
-        this.data.option_list = arr.slice(1).map((content) => getOption(content));
+        let sliceLength = 0;
+        if (arr[0].substring(0, 3) === '题干:') {
+          this.data.stem = arr[0].substring(3);
+          sliceLength += 1;
+        }
+        if (arr.slice(sliceLength)[0] && arr.slice(sliceLength)[0].substring(0, 3) === '提示:') {
+          this.data.description = arr.slice(sliceLength)[0].substring(3);
+          this.data.property.is_enable_description = 'true';
+          sliceLength += 1;
+        } else {
+          this.data.description = '';
+          this.data.property.is_enable_description = 'false';
+        }
+        let option_list = arr.slice(sliceLength);
+        this.data.option_list = option_list.map((content) => getOption(content));
       }
     },
     addOption() {

+ 14 - 2
src/views/exercise_questions/create/components/exercises/ReplaceAnswerQuestion.vue

@@ -125,8 +125,20 @@ export default {
         .filter((item) => item);
 
       if (arr.length > 0) {
-        this.data.stem = arr[0];
-        let option_list = arr.slice(1);
+        let sliceLength = 0;
+        if (arr[0].substring(0, 3) === '题干:') {
+          this.data.stem = arr[0].substring(3);
+          sliceLength += 1;
+        }
+        if (arr.slice(sliceLength)[0] && arr.slice(sliceLength)[0].substring(0, 3) === '提示:') {
+          this.data.description = arr.slice(sliceLength)[0].substring(3);
+          this.data.property.is_enable_description = 'true';
+          sliceLength += 1;
+        } else {
+          this.data.description = '';
+          this.data.property.is_enable_description = 'false';
+        }
+        let option_list = arr.slice(sliceLength);
         this.data.option_list = [];
         this.data.property.row_count = option_list.length;
         let column_count = 0;

+ 14 - 2
src/views/exercise_questions/create/components/exercises/SortQuestion.vue

@@ -187,8 +187,20 @@ export default {
         .filter((item) => item);
 
       if (arr.length > 0) {
-        this.data.stem = arr[0];
-        let option_list = arr.slice(1);
+        let sliceLength = 0;
+        if (arr[0].substring(0, 3) === '题干:') {
+          this.data.stem = arr[0].substring(3);
+          sliceLength += 1;
+        }
+        if (arr.slice(sliceLength)[0] && arr.slice(sliceLength)[0].substring(0, 3) === '提示:') {
+          this.data.description = arr.slice(sliceLength)[0].substring(3);
+          this.data.property.is_enable_description = 'true';
+          sliceLength += 1;
+        } else {
+          this.data.description = '';
+          this.data.property.is_enable_description = 'false';
+        }
+        let option_list = arr.slice(sliceLength);
         this.data.option_list = option_list.map((item) => {
           let data_list = item.split(' ').map((content) => getOption(content));
           let item_obj = {

+ 13 - 1
src/views/exercise_questions/create/components/exercises/TalkPictureQuestion.vue

@@ -191,7 +191,19 @@ export default {
         .filter((item) => item);
 
       if (arr.length > 0) {
-        this.data.stem = arr[0];
+        let sliceLength = 0;
+        if (arr[0].substring(0, 3) === '题干:') {
+          this.data.stem = arr[0].substring(3);
+          sliceLength += 1;
+        }
+        if (arr.slice(sliceLength)[0] && arr.slice(sliceLength)[0].substring(0, 3) === '提示:') {
+          this.data.description = arr.slice(sliceLength)[0].substring(3);
+          this.data.property.is_enable_description = 'true';
+          sliceLength += 1;
+        } else {
+          this.data.description = '';
+          this.data.property.is_enable_description = 'false';
+        }
       }
     },
   },

+ 37 - 1
src/views/exercise_questions/create/components/exercises/WordCardQuestion.vue

@@ -155,6 +155,7 @@ import SoundRecord from '../common/SoundRecord.vue';
 import { GetStaticResources, GetFileStoreInfo } from '@/api/app';
 import { changeOptionType, handleInputNumber, addTone } from '@/views/exercise_questions/data/common';
 import UploadDrag from '../common/UploadDrag.vue';
+import { getRandomNumber } from '@/utils/index';
 
 import {
   wordCardData,
@@ -412,7 +413,42 @@ export default {
         .filter((item) => item);
 
       if (arr.length > 0) {
-        this.data.stem = arr[0];
+        let sliceLength = 0;
+        if (arr[0].substring(0, 3) === '题干:') {
+          this.data.stem = arr[0].substring(3);
+          sliceLength += 1;
+        }
+        if (arr.slice(sliceLength)[0] && arr.slice(sliceLength)[0].substring(0, 3) === '提示:') {
+          this.data.description = arr.slice(sliceLength)[0].substring(3);
+          this.data.property.is_enable_description = 'true';
+          sliceLength += 1;
+        } else {
+          this.data.description = '';
+          this.data.property.is_enable_description = 'false';
+        }
+        let option_list = arr.slice(sliceLength);
+        this.data.option_list = [];
+        option_list.map((content, index) => {
+          let content_item = content.split('/');
+          this.data.option_list.push({
+            content: content_item[0] ? content_item[0] : '',
+            mark: getRandomNumber(),
+            audio_file_id: '',
+            pinyin: content_item[1] ? content_item[1] : '',
+            definition: content_item[2] ? content_item[2] : '',
+            collocation: content_item[3] ? content_item[3] : '',
+            example_sentence: content_item.length > 3 ? content_item.slice(4) : [''],
+            picture_file_id: '',
+            hz_strokes_list: [],
+          });
+          let obj = {
+            loading: false,
+            loadings: false,
+          };
+          this.loading_list.push(obj);
+          this.handleChineseStrokes(this.data.option_list[index], index);
+          this.changePinyin(this.data.option_list[index]);
+        });
       }
     },
   },

+ 16 - 3
src/views/exercise_questions/create/components/exercises/WordDictationQuestion.vue

@@ -299,10 +299,23 @@ export default {
         .filter((item) => item);
 
       if (arr.length > 0) {
-        this.data.stem = arr[0];
+        let sliceLength = 0;
+        if (arr[0].substring(0, 3) === '题干:') {
+          this.data.stem = arr[0].substring(3);
+          sliceLength += 1;
+        }
+        if (arr.slice(sliceLength)[0] && arr.slice(sliceLength)[0].substring(0, 3) === '提示:') {
+          this.data.description = arr.slice(sliceLength)[0].substring(3);
+          this.data.property.is_enable_description = 'true';
+          sliceLength += 1;
+        } else {
+          this.data.description = '';
+          this.data.property.is_enable_description = 'false';
+        }
+        let option_list = arr.slice(sliceLength);
         this.data.option_list = [];
-        arr.slice(1).map((content, index) => {
-          let content_item = content.split('&&');
+        option_list.map((content, index) => {
+          let content_item = content.split('/');
           this.data.option_list.push({
             content: content_item[0] ? content_item[0] : '',
             mark: getRandomNumber(),

+ 13 - 4
src/views/exercise_questions/create/components/exercises/WritePictureQuestion.vue

@@ -195,10 +195,19 @@ export default {
         .filter((item) => item);
 
       if (arr.length > 0) {
-        this.data.stem = arr[0];
-        this.data.description = arr[2] ? arr[2] : '';
-        this.data.article = arr[1] ? arr[1] : '';
-        this.data.sample_text = arr[3] ? arr[3] : '';
+        let sliceLength = 0;
+        if (arr[0].substring(0, 3) === '题干:') {
+          this.data.stem = arr[0].substring(3);
+          sliceLength += 1;
+        }
+        if (arr.slice(sliceLength)[0] && arr.slice(sliceLength)[0].substring(0, 3) === '提示:') {
+          this.data.description = arr.slice(sliceLength)[0].substring(3);
+          this.data.property.is_enable_description = 'true';
+          sliceLength += 1;
+        } else {
+          this.data.description = '';
+          this.data.property.is_enable_description = 'false';
+        }
       }
     },
   },

+ 20 - 4
src/views/exercise_questions/create/components/exercises/WriteQuestion.vue

@@ -120,10 +120,26 @@ export default {
         .filter((item) => item);
 
       if (arr.length > 0) {
-        this.data.stem = arr[0];
-        this.data.description = arr[2] ? arr[2] : '';
-        this.data.article = arr[1] ? arr[1] : '';
-        this.data.sample_text = arr[3] ? arr[3] : '';
+        let sliceLength = 0;
+        if (arr[0].substring(0, 3) === '题干:') {
+          this.data.stem = arr[0].substring(3);
+          sliceLength += 1;
+        }
+        if (arr.slice(sliceLength)[0] && arr.slice(sliceLength)[0].substring(0, 3) === '提示:') {
+          this.data.description = arr.slice(sliceLength)[0].substring(3);
+          this.data.property.is_enable_description = 'true';
+          sliceLength += 1;
+        } else {
+          this.data.description = '';
+          this.data.property.is_enable_description = 'false';
+        }
+        if (arr.slice(sliceLength)[0] && arr.slice(sliceLength)[0].substring(0, 3) === '范文:') {
+          this.data.sample_text = arr.slice(sliceLength)[0].substring(3);
+          this.data.property.is_enable_sample_text = 'true';
+        } else {
+          this.data.sample_text = '';
+          this.data.property.is_enable_sample_text = 'false';
+        }
       }
     },
   },