Explorar o código

简答题显示答题文字数量

Michael Wang %!s(int64=5) %!d(string=hai) anos
pai
achega
9e1d4e3ec0
Modificáronse 1 ficheiros con 14 adicións e 0 borrados
  1. 14 0
      src/features/OnlineExam/Examing/TextQuestionView.vue

+ 14 - 0
src/features/OnlineExam/Examing/TextQuestionView.vue

@@ -60,6 +60,9 @@
           @blur="$event => textInput($event)"
           class="stu-answer"
         ></div>
+        <div style="float: right; margin-top: -25px; margin-right: 10px;">
+          {{ answerWordCount }}
+        </div>
       </div>
       <div v-else>
         <div>
@@ -298,6 +301,17 @@ export default {
     rightAnswerTransform() {
       return this.question.rightAnswer.join("");
     },
+    answerWordCount() {
+      if (this.$refs.answerDiv) {
+        return this.$refs.answerDiv.innerText.length;
+      } else {
+        const ele = document.createElement("div");
+        ele.innerHTML = this.studentAnswer;
+        ele.innerText.length;
+
+        return ele.innerText.length;
+      }
+    },
     isAudioAnswerType() {
       return this.examQuestion.answerType === "SINGLE_AUDIO";
     },