Browse Source

重新计算答对个数

liuhaidi123 1 week ago
parent
commit
a377cb8b9c
2 changed files with 20 additions and 3 deletions
  1. 1 1
      package.json
  2. 19 2
      src/views/courseWare.vue

+ 1 - 1
package.json

@@ -17,7 +17,7 @@
     "@tinymce/tinymce-vue": "^3.2.8",
     "awe-dnd": "^0.3.4",
     "axios": "0.18.1",
-    "book-ui": "file:../GCLS-Book-UI/book-ui-0.4.22.tgz",
+    "book-ui": "file:../GCLS-Book-UI/book-ui-0.4.23.tgz",
     "cnchar": "^3.0.1",
     "cnchar-all": "^3.0.1",
     "cnchar-order": "^3.0.1",

+ 19 - 2
src/views/courseWare.vue

@@ -495,8 +495,25 @@ export default {
               if (!exam_answer) return;
               this.bookAnswerContent = exam_answer.content;
               this.duration = exam_answer.duration;
-              this.rightNumber = exam_answer.count_right;
-              this.errorNumber = exam_answer.count_error;
+              // this.rightNumber = exam_answer.count_right;
+              // this.errorNumber = exam_answer.count_error;
+              let userErrorNumberTotal = 0;
+              let userRightNumberTotal = 0;
+              let errReg = /\[JUDGE##F##JUDGE\]/g;
+              let rightReg = /\[JUDGE##T##JUDGE\]/g;
+              if (errReg.test(this.bookAnswerContent)) {
+                let errorArr =
+                  this.bookAnswerContent.match(/\[JUDGE##F##JUDGE\]/g);
+                userErrorNumberTotal = errorArr.length;
+              }
+
+              if (rightReg.test(this.bookAnswerContent)) {
+                let rightArr =
+                  this.bookAnswerContent.match(/\[JUDGE##T##JUDGE\]/g);
+                userRightNumberTotal = rightArr.length;
+              }
+              this.rightNumber = userRightNumberTotal;
+              this.errorNumber = userErrorNumberTotal;
             } else {
               this.loading = false;
             }