Преглед на файлове

新增全部道题正确率功能

zengyicheng преди 2 години
родител
ревизия
d919663741
променени са 1 файла, в които са добавени 70 реда и са изтрити 43 реда
  1. 70 43
      src/components/pages/components/worksDetail2.vue

+ 70 - 43
src/components/pages/components/worksDetail2.vue

@@ -800,6 +800,10 @@
                             </div>
                           </div>
                         </div>
+                        <div class="allRightBox">
+                          <span>全部道题的正确率:</span
+                          ><span>{{ checkJson[sIndex].allRight + "%" }}</span>
+                        </div>
                       </div>
                       <div v-else>
                         <div class="ech" style="margin-left: 23px">
@@ -1297,7 +1301,7 @@ export default {
               stagetask: "",
               time: "",
             });
-            this.checkJson[k] = [];
+            this.checkJson[k] = {};
             eList =
               chapters[0][res.data[0][k].stage].chapterInfo[0].taskJson[
                 res.data[0][k].task
@@ -1399,13 +1403,19 @@ export default {
                 }
                 t.radio = e;
                 workJson[k].chooseInfo.push(t);
+                this.checkJson[k].allRight = 0;
+                var isCount = 0;
                 for (var p = 0; p < t.radio.length; p++) {
                   if (!this.checkJson[k][p]) {
-                    this.checkJson[k].push({
+                    this.checkJson[k][p] = {
                       checkCount: [],
                       checkPerson: [],
-                      rightPerson: [],
-                    });
+                    };
+                    // this.checkJson[k].push({
+                    //   checkCount: [],
+                    //   checkPerson: [],
+                    //   rightPerson: [],
+                    // });
                   }
                   if (!this.checkJson[k][p].checkCount.length) {
                     this.checkJson[k][p].checkCount = [];
@@ -1420,11 +1430,15 @@ export default {
                         .sort()
                         .join(",") == t.radio[p].sort().join(",")
                     ) {
-                      this.checkJson[k][p].rightPerson.push(
-                        res.data[0][k].sName
-                      );
+                      // this.checkJson[k][p].rightPerson.push(
+                      //   res.data[0][k].sName
+                      // );
+                      this.checkJson[k][p].right = 100;
+                      isCount += this.checkJson[k][p].right;
+                    } else {
+                      this.checkJson[k][p].right = 0;
+                      isCount += 0;
                     }
-                    console.log(this.checkJson[k][p].rightPerson);
                     for (var q = 0; q < t.radio[p].length; q++) {
                       this.checkJson[k][p].checkPerson[parseInt(t.radio[p][q])]
                         ? this.checkJson[k][p].checkPerson[
@@ -1445,11 +1459,15 @@ export default {
                     if (
                       workJson[k].chooseInfo[0].testJson[p].answer == t.radio[p]
                     ) {
-                      this.checkJson[k][p].rightPerson.push(
-                        res.data[0][k].sName
-                      );
+                      // this.checkJson[k][p].rightPerson.push(
+                      //   res.data[0][k].sName
+                      // );
+                      this.checkJson[k][p].right = 100;
+                      isCount += this.checkJson[k][p].right;
+                    } else {
+                      this.checkJson[k][p].right = 0;
+                      isCount += 0;
                     }
-                    console.log(this.checkJson[k][p].rightPerson);
                     if (parseInt(t.radio[p]) || parseInt(t.radio[p]) == 0) {
                       this.checkJson[k][p].checkPerson[parseInt(t.radio[p])]
                         ? this.checkJson[k][p].checkPerson[
@@ -1468,6 +1486,7 @@ export default {
                     }
                   }
                 }
+                this.checkJson[k].allRight = isCount / t.radio.length;
               }
             }
 
@@ -1514,33 +1533,40 @@ export default {
               }
             }
           }
-          for (var k = 0; k < res.data[0].length; k++) {
-            for (var i = 0; i < chooseInfo.length; i++) {
-              if (chooseInfo[i].type == 8) {
-                for (var z = 0; z < this.checkJson[k].length; z++) {
-                  this.checkJson[k][z].checkPerent = [];
-                  this.checkJson[k][z].right = Math.round(
-                    (this.checkJson[k][z].rightPerson.length /
-                      parseInt(workJson[k].chooseInfo.length)) *
-                      100
-                  );
-                  for (
-                    var w = 0;
-                    w < this.checkJson[k][z].checkCount.length;
-                    w++
-                  ) {
-                    this.checkJson[k][z].checkPerent.push(
-                      Math.round(
-                        (this.checkJson[k][z].checkCount[w] /
-                          parseInt(workJson[k].chooseInfo.length)) *
-                          100
-                      )
-                    );
-                  }
-                }
-              }
-            }
-          }
+          // debugger
+          // for(var i = 0; i < chooseInfo.length; i++){
+          //   if (chooseInfo[i].type == 8) {
+          //     console.log(this.checkJson)
+          //   }
+          // }
+          // for (var k = 0; k < res.data[0].length; k++) {
+          //   console.log(workJson[k].chooseInfo);
+          //   for (var i = 0; i < chooseInfo.length; i++) {
+          //     if (chooseInfo[i].type == 8) {
+          //       for (var z = 0; z < this.checkJson[k].length; z++) {
+          //         this.checkJson[k][z].checkPerent = [];
+          //         this.checkJson[k][z].right = Math.round(
+          //           (this.checkJson[k][z].rightPerson.length /
+          //             parseInt(workJson[k].chooseInfo.length)) *
+          //             100
+          //         );
+          //         for (
+          //           var w = 0;
+          //           w < this.checkJson[k][z].checkCount.length;
+          //           w++
+          //         ) {
+          //           this.checkJson[k][z].checkPerent.push(
+          //             Math.round(
+          //               (this.checkJson[k][z].checkCount[w] /
+          //                 parseInt(workJson[k].chooseInfo.length)) *
+          //                 100
+          //             )
+          //           );
+          //         }
+          //       }
+          //     }
+          //   }
+          // }
 
           this.worksDetail = workJson;
 
@@ -1695,7 +1721,6 @@ export default {
           //     _option.radar.indicator.push({ name: _ooption[i].name, max: 5 });
           //     _option.series[0].data[0].value.push(_ooption[i].value);
           //   }
-          //   console.log(_option);
           //   this.setChart(_option);
 
           // }, 0);
@@ -1832,7 +1857,6 @@ export default {
     //     background: "rgba(255, 255, 255, 0.7)",
     //     target: document.querySelector(".student_table"),
     //   });
-    //   console.log(this.id);
     //   let params = {
     //     courseId: this.id,
     //   };
@@ -1850,7 +1874,6 @@ export default {
     //           dyList[i].taskList.push({ name: a[j].task, id: j });
     //         }
     //       }
-    //       console.log(dyList);
     //       this.dyList = dyList;
     //       // var dyJSON = JSON.parse()
     //     })
@@ -3521,11 +3544,15 @@ export default {
 .tool_right_box + .tool_right_box {
   margin-top: 10px;
 }
-.right_box_xuan {
+.right_box_xuan,
+.allRightBox > span:nth-child(2) {
   background: rgb(0 123 255);
   color: #fff;
   border-radius: 5px;
   padding: 5px;
   margin-left: 10px;
 }
+.allRightBox {
+  padding: 10px 12px;
+}
 </style>