Ver código fonte

选择声调 乱序问题

natasha 11 meses atrás
pai
commit
80347aa33b

+ 10 - 1
src/views/exercise_questions/answer/components/AnswerReport.vue

@@ -31,7 +31,11 @@
         :key="question_id"
         :class="[
           'answer-list-item',
-          { subjectivity: is_objective === 'false', error: answer_status === 2 || answer_status === 0 },
+          {
+            subjectivity: is_objective === 'false',
+            error: answer_status === 2 || answer_status === 0,
+            right: answer_status === 1,
+          },
           { remarked: is_remarked === 'true' },
         ]"
         @click="selectQuestion(i)"
@@ -128,6 +132,11 @@ export default {
         background-color: $error-color;
       }
 
+      &.right {
+        color: #fff;
+        background-color: #3acb85;
+      }
+
       &.subjectivity {
         color: $font-color;
         background-color: #fef2a4;

+ 52 - 29
src/views/exercise_questions/preview/ChooseTonePreview.vue

@@ -189,26 +189,54 @@ export default {
     chooseTone(item, value, i) {
       if (this.disabled) return;
       if ((!this.active_letter || this.select_item_index !== i) && this.data.property.answer_mode === 'label') return;
-      item.user_answer[item.item_active_index].select_tone = value;
-      if (this.data.property.answer_mode === 'label') {
-        item.user_answer[item.item_active_index].select_letter = this.active_letter;
-        this.active_index_str = `${i}-${item.item_active_index}-${this.active_letter_index}`;
-        this.handleReplaceTone(this.active_letter + value);
+      if (
+        item.user_answer[item.item_active_index].select_tone &&
+        item.user_answer[item.item_active_index].select_tone === value &&
+        this.data.property.answer_mode === 'label' &&
+        item.user_answer[item.item_active_index].select_letter === this.active_letter
+      ) {
+        item.user_answer[item.item_active_index].select_tone = '';
+        this.handleReplaceTone(this.active_letter + 0);
         setTimeout(() => {
           let new_con = item.item_con_yuan[item.item_active_index].split(this.active_letter);
           item.item_con[item.item_active_index] = new_con[0] + this.final_con + new_con[1];
           this.$forceUpdate();
-          this.answer.answer_list[i].value[item.item_active_index] =
-            new_con[0] + this.active_letter + value + new_con[1];
+          this.answer.answer_list[i].value[item.item_active_index] = new_con[0] + this.active_letter + 0 + new_con[1];
         }, 100);
-      } else {
-        this.active_index_str = `${i}-${item.item_active_index}`;
-        this.handleReplaceTone(item.item_con_yuan[item.item_active_index] + value);
+      } else if (
+        item.user_answer[item.item_active_index].select_tone &&
+        item.user_answer[item.item_active_index].select_tone === value &&
+        this.data.property.answer_mode === 'select'
+      ) {
+        item.user_answer[item.item_active_index].select_tone = '';
+        this.handleReplaceTone(item.item_con_yuan[item.item_active_index] + 0);
         setTimeout(() => {
           item.item_con[item.item_active_index] = this.final_con;
           this.$forceUpdate();
         }, 100);
-        this.answer.answer_list[i].value[item.item_active_index] = value;
+        this.answer.answer_list[i].value[item.item_active_index] = '';
+      } else {
+        item.user_answer[item.item_active_index].select_tone = value;
+        if (this.data.property.answer_mode === 'label') {
+          item.user_answer[item.item_active_index].select_letter = this.active_letter;
+          this.active_index_str = `${i}-${item.item_active_index}-${this.active_letter_index}`;
+          this.handleReplaceTone(this.active_letter + value);
+          setTimeout(() => {
+            let new_con = item.item_con_yuan[item.item_active_index].split(this.active_letter);
+            item.item_con[item.item_active_index] = new_con[0] + this.final_con + new_con[1];
+            this.$forceUpdate();
+            this.answer.answer_list[i].value[item.item_active_index] =
+              new_con[0] + this.active_letter + value + new_con[1];
+          }, 100);
+        } else {
+          this.active_index_str = `${i}-${item.item_active_index}`;
+          this.handleReplaceTone(item.item_con_yuan[item.item_active_index] + value);
+          setTimeout(() => {
+            item.item_con[item.item_active_index] = this.final_con;
+            this.$forceUpdate();
+          }, 100);
+          this.answer.answer_list[i].value[item.item_active_index] = value;
+        }
       }
     },
     // 处理数据
@@ -390,32 +418,28 @@ export default {
         let user_answer = [];
         let user_select = [];
         let user_res_arr = [];
+
+        let answer_list_item = this.answer.answer_list.filter((items) => item.mark === items.mark);
         con_arr.forEach((items, indexs) => {
           user_answer.push({
-            select_tone: this.answer.answer_list[index].value[indexs],
+            select_tone: answer_list_item[0].value[indexs],
             select_letter: '',
             select_index: '',
-            is_right:
-              this.answer.answer_list[index].value[indexs] === this.data.answer.answer_list[index].value[indexs],
+            is_right: answer_list_item[0].value[indexs] === this.data.answer.answer_list[index].value[indexs],
             right_answer: this.data.answer.answer_list[index].value[indexs],
           });
           user_res_arr.push([]);
           user_select.push('');
           if (this.data.property.answer_mode === 'label') {
-            this.handleReplaceTone(
-              this.answer.answer_list[index].value[indexs],
-              user_select,
-              indexs,
-              user_res_arr[indexs],
-            );
+            this.handleReplaceTone(answer_list_item[0].value[indexs], user_select, indexs, user_res_arr[indexs]);
             if (
-              this.answer.answer_list[index].value[indexs].match(/\d+/g) &&
-              this.answer.answer_list[index].value[indexs].match(/\d+/g).length > 0
+              answer_list_item[0].value[indexs].match(/\d+/g) &&
+              answer_list_item[0].value[indexs].match(/\d+/g).length > 0
             ) {
-              user_answer[indexs].select_tone = this.answer.answer_list[index].value[indexs].match(/\d+/g)[0];
-              let letter_number = this.answer.answer_list[index].value[indexs].match(/\d+/g)[0];
-              let letter_index = this.answer.answer_list[index].value[indexs].indexOf(letter_number) - 1;
-              user_answer[indexs].select_letter = this.answer.answer_list[index].value[indexs].substring(
+              user_answer[indexs].select_tone = answer_list_item[0].value[indexs].match(/\d+/g)[0];
+              let letter_number = answer_list_item[0].value[indexs].match(/\d+/g)[0];
+              let letter_index = answer_list_item[0].value[indexs].indexOf(letter_number) - 1;
+              user_answer[indexs].select_letter = answer_list_item[0].value[indexs].substring(
                 letter_index,
                 letter_index + 1,
               );
@@ -429,7 +453,7 @@ export default {
             user_answer[indexs].right_index = this.data.answer.answer_list[index].value[indexs].search(/0|1|2|3|4/) - 1;
           } else {
             this.handleReplaceTone(
-              items + this.answer.answer_list[index].value[indexs],
+              items + answer_list_item[0].value[indexs],
               user_select,
               indexs,
               user_res_arr[indexs],
@@ -445,8 +469,7 @@ export default {
           active_letter: '',
           user_res_arr,
           all_right:
-            JSON.stringify(this.answer.answer_list[index].value) ===
-            JSON.stringify(this.data.answer.answer_list[index].value),
+            JSON.stringify(answer_list_item[0].value) === JSON.stringify(this.data.answer.answer_list[index].value),
         };
         this.con_preview.push(obj);
       });