Browse Source

Merge branch 'master' of http://60.205.254.193:3000/GCLS/GCLS_Page_Exercise

dusenyao 1 year ago
parent
commit
a3570cb816

+ 8 - 2
src/views/exercise_questions/create/components/exercises/ChineseQuestion.vue

@@ -305,8 +305,14 @@ export default {
       if (index > -1) {
         this.handleItemPinyin(item.pinyin, item.mark);
         setTimeout(() => {
-          item.pinyin = this.matically_pinyin_obj[item.mark];
-        }, 100);
+          if (this.matically_pinyin_obj[item.mark].indexOf(',') > -1) {
+            this.$message.warning('输入的拼音有误,请重新输入');
+            item.pinyin = '';
+            this.matically_pinyin_obj[item.mark] = '';
+          } else {
+            item.pinyin = this.matically_pinyin_obj[item.mark];
+          }
+        }, 10);
       }
       let pinyin_list = item.pinyin.trim().split(' ');
       item.pinyin_item_list = [];

+ 11 - 5
src/views/exercise_questions/create/components/exercises/ChooseToneQuestion.vue

@@ -272,7 +272,7 @@ export default {
           });
       }
     },
-    handleReplaceTone(value, mark) {
+    handleReplaceTone(value, mark, itemIndex) {
       if (!value) return;
       value.split(/\s+/).forEach((item) => {
         this.handleValue(item);
@@ -289,6 +289,12 @@ export default {
         )
         .filter((item) => item.length > 0)
         .join(' ');
+      if (this.matically_pinyin_str[mark].indexOf(',') > -1) {
+        this.$message.warning('输入的拼音有误,请重新输入');
+        this.matically_pinyin_obj[mark] = [];
+        this.matically_pinyin_str[mark] = '';
+        this.data.option_list[itemIndex].content = '';
+      }
     },
     handleValue(valItem) {
       let numList = [];
@@ -313,7 +319,7 @@ export default {
     },
     // 答案
     handleItemAnswer(item) {
-      const index = this.data.answer.answer_list.findIndex((items) => items.mark === item.mark);
+      const itemIndex = this.data.answer.answer_list.findIndex((items) => items.mark === item.mark);
       let content = item.content.trim();
       const regex = /[\u4e00-\u9fa5]/g;
       item.content_hz = content.match(regex) ? content.match(regex).join('') : '';
@@ -337,17 +343,17 @@ export default {
             select_item += `${items_trim}${index === content_arr.length - 1 ? '' : ' '}`;
           }
           content_preview += `${items_yuan} `;
-          this.handleReplaceTone(items_yuan + items_trim.substring(indexs, indexs + 1), item.mark);
+          this.handleReplaceTone(items_yuan + items_trim.substring(indexs, indexs + 1), item.mark, itemIndex);
         }
       });
-      if (index === -1) {
+      if (itemIndex === -1) {
         let obj = {
           mark: item.mark,
           value: select_item.split(' '),
         };
         this.data.answer.answer_list.push(obj);
       } else {
-        this.data.answer.answer_list[index].value = select_item.split(' ');
+        this.data.answer.answer_list[itemIndex].value = select_item.split(' ');
       }
       item.content_view = content_preview.trim().split(' ');
       // item.matically_pinyin = matically_pinyin.trim().split(' ').join(',');

+ 4 - 0
src/views/exercise_questions/create/components/exercises/RepeatQuestion.vue

@@ -280,6 +280,10 @@ export default {
           if (index > -1) {
             this.handleItemPinyin(content, this.data.option_list[i].mark);
             setTimeout(() => {
+              if (this.matically_pinyin_obj[this.data.option_list[i].mark].indexOf(',') > -1) {
+                this.$message.warning('输入的拼音有误,请重新输入');
+                this.matically_pinyin_obj[this.data.option_list[i].mark] = '';
+              }
               document.getElementsByClassName('repeat-richtext')[i].getElementsByClassName('rich-text')[0].innerText =
                 this.matically_pinyin_obj[this.data.option_list[i].mark];
               this.data.option_list[i].content = this.matically_pinyin_obj[this.data.option_list[i].mark];

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

@@ -421,8 +421,12 @@ export default {
       if (index > -1) {
         this.handleItemPinyin(item.pinyin, item.mark);
         setTimeout(() => {
+          if (this.matically_pinyin_obj[item.mark].indexOf(',') > -1) {
+            this.$message.warning('输入的拼音有误,请重新输入');
+            this.matically_pinyin_obj[item.mark] = '';
+          }
           item.pinyin = this.matically_pinyin_obj[item.mark];
-        }, 100);
+        }, 10);
       }
     },
     /**

+ 8 - 2
src/views/exercise_questions/create/components/exercises/WordDictationQuestion.vue

@@ -254,8 +254,14 @@ export default {
       if (index > -1) {
         this.handleItemPinyin(item.pinyin, item.mark);
         setTimeout(() => {
-          item.pinyin = this.matically_pinyin_obj[item.mark];
-        }, 100);
+          if (this.matically_pinyin_obj[item.mark].indexOf(',') > -1) {
+            this.$message.warning('输入的拼音有误,请重新输入');
+            item.pinyin = '';
+            this.matically_pinyin_obj[item.mark] = '';
+          } else {
+            item.pinyin = this.matically_pinyin_obj[item.mark];
+          }
+        }, 10);
       }
       let pinyin_list = item.pinyin.trim().split(' ');
       item.pinyin_item_list = [];

+ 3 - 2
src/views/exercise_questions/data/chinese.js

@@ -2,6 +2,7 @@ import { stemTypeList, scoreTypeList, questionNumberTypeList, switchOption, font
 import { getRandomNumber } from '@/utils/index';
 import { GetStaticResources } from '@/api/app';
 import { addTone } from '@/views/exercise_questions/data/common';
+let res_arr;
 
 export function getOption(content = '') {
   return {
@@ -60,7 +61,6 @@ export function handleValue(valItem) {
 
 function handleReplaceTone(value, mark, matically_pinyin_obj) {
   if (!value) return;
-  let res_arr = [];
   value.split(/\s+/).forEach((item) => {
     res_arr.push(handleValue(item));
   });
@@ -73,6 +73,7 @@ function handleReplaceTone(value, mark, matically_pinyin_obj) {
 export function handleItemPinyin(content, mark, matically_pinyin_obj) {
   let content_arr = content.trim().split(' ');
   matically_pinyin_obj[mark] = [];
+  res_arr = [];
   content_arr.forEach((items) => {
     let items_trim = items.trim();
     if (items_trim) {
@@ -89,7 +90,7 @@ export function handleSplitPy(item) {
     handleItemPinyin(item.pinyin, item.mark, matically_pinyin_obj);
     setTimeout(() => {
       item.pinyin = matically_pinyin_obj[item.mark];
-    }, 100);
+    }, 10);
   }
   let pinyin_list = item.pinyin.trim().split(' ');
   item.pinyin_item_list = [];