浏览代码

修改选择题及导出问题

zengyicheng 2 年之前
父节点
当前提交
bec28992df
共有 2 个文件被更改,包括 400 次插入59 次删除
  1. 241 34
      src/components/pages/components/worksDetail2.vue
  2. 159 25
      src/components/pages/components/worksDetail3.vue

+ 241 - 34
src/components/pages/components/worksDetail2.vue

@@ -178,8 +178,8 @@
                   lookWork2(
                     scope.row.id,
                     scope.row.userid,
-                    scope.row.stage,
-                    scope.row.task
+                    '',
+                    '',
                   )
                 "
                 >导出报告</el-button
@@ -504,9 +504,7 @@
                       <div
                         class="left_top"
                         :style="{
-                          width: worksDetail[sIndex].eList.length
-                            ? '45%'
-                            : '95%',
+                          width: '95%',
                         }"
                         v-else-if="worksDetail[sIndex].chooseInfo.length > 0"
                       >
@@ -677,7 +675,13 @@
                       </div>
                       <div
                         class="right_top"
-                        v-show="worksDetail[sIndex].eList.length"
+                        v-show="
+                          worksDetail[sIndex].eList.length &&
+                          (worksDetail[sIndex].img.length > 0 ||
+                            worksDetail[sIndex].askInfo.length > 0 ||
+                            worksDetail[sIndex].answerInfo.length > 0 ||
+                            worksDetail[sIndex].wpptInfo.length > 0)
+                        "
                       >
                         <div class="ech">
                           <img src="../../../assets/icon/pj/ech.png" alt="" />
@@ -698,6 +702,57 @@
                     </div>
                   </div>
                   <div class="right_score" :class="{ rightScoreFullBox: full }">
+                    <!-- <div
+                      v-if="
+                        tType &&
+                        ((tType == 2 && sIsOpen == true) ||
+                          tType == 1 ||
+                          tType == 4) &&
+                        tool.tool.indexOf(45) != -1 &&
+                        (tool.testJson.testJson[0].answer ||
+                          tool.testJson.testJson[0].answer === 0) &&
+                        checkJson[toolIndex].length
+                      "
+                      class="xuan_right_box"
+                    >
+                      <div
+                        class="tool_right_box"
+                        v-for="(item, index) in tool.testJson.testJson"
+                        :key="index"
+                      >
+                        <div>
+                          <span>{{ index + 1 + "、" + item.teststitle }}</span>
+                        </div>
+                        <div class="right_box_xuan">
+                          <span>正确率</span>
+                          <span>{{
+                            (checkJson[toolIndex][index].right
+                              ? checkJson[toolIndex][index].right
+                              : 0) + "%"
+                          }}</span>
+                        </div>
+                      </div>
+                    </div>
+                    <div
+                      class="xuan_right_box"
+                      style="background: unset"
+                      v-if="
+                        tType &&
+                        ((tType == 2 && sIsOpen == true) ||
+                          tType == 1 ||
+                          tType == 4) &&
+                        tool.tool.indexOf(45) != -1
+                      "
+                    >
+                      <AskStatic2
+                        v-if="
+                          worksStudent.length &&
+                          worksStudent[toolIndex].length > 0
+                        "
+                        :askJSON="tool"
+                        :checkJson="checkJson[toolIndex]"
+                      ></AskStatic2>
+                    </div> -->
                     <div
                       class="sd_score"
                       style="
@@ -712,29 +767,66 @@
                           >{{ worksDetail[sIndex].time }}
                         </span>
                       </div>
-                      <div class="ech" style="margin-left: 23px">
-                        <img src="../../../assets/icon/pj/score.png" alt="" />
+                      <div
+                        v-if="
+                          worksDetail[sIndex].img.length == 0 &&
+                          worksDetail[sIndex].askInfo.length == 0 &&
+                          worksDetail[sIndex].answerInfo.length == 0 &&
+                          worksDetail[sIndex].wpptInfo.length == 0 &&
+                          worksDetail[sIndex].chooseInfo.length > 0
+                        "
+                      >
+                        <div style="font-size: 16px; color: #c7c7c7;margin-left: 15px;">
+                          题目统计
+                        </div>
+                        <div class="xuan_right_box">
+                          <div
+                            class="tool_right_box"
+                            v-for="(tItem, tIndex) in worksDetail[sIndex]
+                              .chooseInfo[0].testJson"
+                            :key="tIndex"
+                          >
+                            <div>
+                              <span>{{
+                                tIndex + 1 + "、" + tItem.teststitle
+                              }}</span>
+                            </div>
+                            <div class="right_box_xuan">
+                              <span>正确率</span>
+                              <span>{{
+                                (checkJson[sIndex][tIndex].right
+                                  ? checkJson[sIndex][tIndex].right
+                                  : 0) + "%"
+                              }}</span>
+                            </div>
+                          </div>
+                        </div>
                       </div>
-                      <div style="height: 80%; overflow: auto">
-                        <div
-                          class="score_box"
-                          v-for="(item, index) in worksDetail[sIndex].eList"
-                          :key="index"
-                        >
-                          <el-tooltip
-                            class="item"
-                            effect="dark"
-                            :content="item.value"
-                            placement="top-start"
+                      <div v-else>
+                        <div class="ech" style="margin-left: 23px">
+                          <img src="../../../assets/icon/pj/score.png" alt="" />
+                        </div>
+                        <div style="height: 80%; overflow: auto">
+                          <div
+                            class="score_box"
+                            v-for="(item, index) in worksDetail[sIndex].eList"
+                            :key="index"
                           >
-                            <span>{{ item.value }}</span>
-                          </el-tooltip>
-                          <el-rate
-                            class="rate_size"
-                            style="min-width: 120px"
-                            v-model="worksDetail[sIndex].rateList[item.value]"
-                            @change="getStar(sIndex)"
-                          ></el-rate>
+                            <el-tooltip
+                              class="item"
+                              effect="dark"
+                              :content="item.value"
+                              placement="top-start"
+                            >
+                              <span>{{ item.value }}</span>
+                            </el-tooltip>
+                            <el-rate
+                              class="rate_size"
+                              style="min-width: 120px"
+                              v-model="worksDetail[sIndex].rateList[item.value]"
+                              @change="getStar(sIndex)"
+                            ></el-rate>
+                          </div>
                         </div>
                       </div>
                     </div>
@@ -1095,6 +1187,7 @@ export default {
       userAarray: [],
       isPre: false,
       isNext: false,
+      checkJson: [],
     };
   },
   mounted() {
@@ -1205,7 +1298,7 @@ export default {
               stagetask: "",
               time: "",
             });
-
+            this.checkJson[k] = [];
             eList =
               chapters[0][res.data[0][k].stage].chapterInfo[0].taskJson[
                 res.data[0][k].task
@@ -1300,13 +1393,82 @@ export default {
                 let e = [];
                 for (var y = 0; y < t.testJson.length; y++) {
                   if (t.testJson[y].type == "2") {
-                    e.push(t.testJson[y].answer);
+                    e.push(JSON.parse(chooseInfo[i].content)[0].anwer[y]);
                   } else {
-                    e.push(t.testJson[y].answer);
+                    e.push(JSON.parse(chooseInfo[i].content)[0].anwer[y]);
                   }
                 }
                 t.radio = e;
                 workJson[k].chooseInfo.push(t);
+                for (var p = 0; p < t.radio.length; p++) {
+                  if (!this.checkJson[k][p]) {
+                    this.checkJson[k].push({
+                      checkCount: [],
+                      checkPerson: [],
+                      rightPerson: [],
+                    });
+                  }
+                  if (!this.checkJson[k][p].checkCount.length) {
+                    this.checkJson[k][p].checkCount = [];
+                    let _askItemCount = t.testJson[p].testItem;
+                    for (var aic = 0; aic < _askItemCount; aic++) {
+                      this.checkJson[k][p].checkCount.push(0);
+                    }
+                  }
+                  if (t.radio[p] instanceof Array) {
+                    if (
+                      workJson[k].chooseInfo[0].testJson[p].answer
+                        .sort()
+                        .join(",") == t.radio[p].sort().join(",")
+                    ) {
+                      this.checkJson[k][p].rightPerson.push(
+                        res.data[0][k].sName
+                      );
+                    }
+                    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[
+                            parseInt(t.radio[p][q])
+                          ].push(res.data[0][k].sName)
+                        : (this.checkJson[k][p].checkPerson[
+                            parseInt(t.radio[p][q])
+                          ] = [res.data[0][k].sName]);
+                      this.checkJson[k][p].checkCount[parseInt(t.radio[p][q])]
+                        ? this.checkJson[k][p].checkCount[
+                            parseInt(t.radio[p][q])
+                          ]++
+                        : (this.checkJson[k][p].checkCount[
+                            parseInt(t.radio[p][q])
+                          ] = 1);
+                    }
+                  } else {
+                    if (
+                      workJson[k].chooseInfo[0].testJson[p].answer == t.radio[p]
+                    ) {
+                      this.checkJson[k][p].rightPerson.push(
+                        res.data[0][k].sName
+                      );
+                    }
+                    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[
+                            parseInt(t.radio[p])
+                          ].push(res.data[0][k].sName)
+                        : (this.checkJson[k][p].checkPerson[
+                            parseInt(t.radio[p])
+                          ] = [res.data[0][k].sName]);
+                      this.checkJson[k][p].checkCount[parseInt(t.radio[p])]
+                        ? this.checkJson[k][p].checkCount[
+                            parseInt(t.radio[p])
+                          ]++
+                        : (this.checkJson[k][p].checkCount[
+                            parseInt(t.radio[p])
+                          ] = 1);
+                    }
+                  }
+                }
               }
             }
 
@@ -1353,6 +1515,33 @@ 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
+                      )
+                    );
+                  }
+                }
+              }
+            }
+          }
 
           this.worksDetail = workJson;
 
@@ -1781,11 +1970,9 @@ export default {
       let params = {
         uid: uid,
         cid: this.id,
-        stage: stage,
-        task: task,
       };
       this.ajax
-        .get(this.$store.state.api + "selectWorksDetail2", params)
+        .get(this.$store.state.api + "selectWorksDetail3", params)
         .then((res) => {
           this.sInfo = res.data[0][0];
           this.chapInfo = JSON.parse(res.data[0][0].chapters);
@@ -2441,7 +2628,7 @@ export default {
   font-size: 22px;
 }
 
-.sd_score span {
+.sd_score > span:nth-child(1) {
   width: 130px;
   text-align: justify;
   text-align-last: justify;
@@ -3314,4 +3501,24 @@ export default {
   height: 100%;
   object-fit: cover;
 }
+.xuan_right_box {
+  padding: 10px;
+  background: rgb(247, 247, 247);
+  margin: 10px 12px;
+  border-radius: 5px;
+}
+.tool_right_box {
+  display: flex;
+  align-items: center;
+}
+.tool_right_box + .tool_right_box {
+  margin-top: 10px;
+}
+.right_box_xuan {
+  background: rgb(0 123 255);
+  color: #fff;
+  border-radius: 5px;
+  padding: 5px;
+  margin-left: 10px;
+}
 </style>

+ 159 - 25
src/components/pages/components/worksDetail3.vue

@@ -253,7 +253,7 @@
                 <div
                   class="left_top"
                   :style="{
-                    width: worksDetail[sIndex].eList.length ? '45%' : '95%',
+                    width: '95%',
                   }"
                   v-else-if="worksDetail[sIndex].chooseInfo.length > 0"
                 >
@@ -417,7 +417,13 @@
                 </div>
                 <div
                   class="right_top"
-                  v-show="worksDetail[sIndex].eList.length"
+                  v-show="
+                    worksDetail[sIndex].eList.length &&
+                    (worksDetail[sIndex].img.length > 0 ||
+                      worksDetail[sIndex].askInfo.length > 0 ||
+                      worksDetail[sIndex].answerInfo.length > 0 ||
+                      worksDetail[sIndex].wpptInfo.length > 0)
+                  "
                 >
                   <div class="ech">
                     <img src="../../../assets/icon/pj/ech.png" alt="" />
@@ -448,29 +454,66 @@
                     >{{ worksDetail[sIndex].time }}
                   </span>
                 </div>
-                <div class="ech" style="margin-left: 23px">
-                  <img src="../../../assets/icon/pj/score.png" alt="" />
-                </div>
-                <div style="height: 80%; overflow: auto">
+                <div
+                  v-if="
+                    worksDetail[sIndex].img.length == 0 &&
+                    worksDetail[sIndex].askInfo.length == 0 &&
+                    worksDetail[sIndex].answerInfo.length == 0 &&
+                    worksDetail[sIndex].wpptInfo.length == 0 &&
+                    worksDetail[sIndex].chooseInfo.length > 0
+                  "
+                >
                   <div
-                    class="score_box"
-                    v-for="(item, index) in worksDetail[sIndex].eList"
-                    :key="index"
+                    style="font-size: 16px; color: #c7c7c7; margin-left: 15px"
                   >
-                    <el-tooltip
-                      class="item"
-                      effect="dark"
-                      :content="item.value"
-                      placement="top-start"
+                    题目统计
+                  </div>
+                  <div class="xuan_right_box">
+                    <div
+                      class="tool_right_box"
+                      v-for="(tItem, tIndex) in worksDetail[sIndex]
+                        .chooseInfo[0].testJson"
+                      :key="tIndex"
                     >
-                      <span>{{ item.value }}</span>
-                    </el-tooltip>
-                    <el-rate
-                      class="rate_size"
-                      style="min-width: 120px"
-                      v-model="worksDetail[sIndex].rateList[item.value]"
-                      disabled
-                    ></el-rate>
+                      <div>
+                        <span>{{ tIndex + 1 + "、" + tItem.teststitle }}</span>
+                      </div>
+                      <div class="right_box_xuan">
+                        <span>正确率</span>
+                        <span>{{
+                          (checkJson[sIndex][tIndex].right
+                            ? checkJson[sIndex][tIndex].right
+                            : 0) + "%"
+                        }}</span>
+                      </div>
+                    </div>
+                  </div>
+                </div>
+                <div v-else>
+                  <div class="ech" style="margin-left: 23px">
+                    <img src="../../../assets/icon/pj/score.png" alt="" />
+                  </div>
+                  <div style="height: 80%; overflow: auto">
+                    <div
+                      class="score_box"
+                      v-for="(item, index) in worksDetail[sIndex].eList"
+                      :key="index"
+                    >
+                      <el-tooltip
+                        class="item"
+                        effect="dark"
+                        :content="item.value"
+                        placement="top-start"
+                      >
+                        <span>{{ item.value }}</span>
+                      </el-tooltip>
+                      <el-rate
+                        class="rate_size"
+                        style="min-width: 120px"
+                        v-model="worksDetail[sIndex].rateList[item.value]"
+                        @change="getStar(sIndex)"
+                      ></el-rate>
+                    </div>
                   </div>
                 </div>
               </div>
@@ -809,6 +852,7 @@ export default {
       dyList: [],
       dyList2: [],
       userAarray: [],
+      checkJson: [],
     };
   },
   //   mounted() {
@@ -917,6 +961,7 @@ export default {
               stagetask: "",
               time: "",
             });
+            this.checkJson[k] = [];
             // this.allWorks = res.data[0][k];
             // this.chapInfo.push(JSON.parse(res.data[0][k].chapters));
             // chapters.push(JSON.parse(res.data[0][k].chapters));
@@ -1014,13 +1059,82 @@ export default {
                 let e = [];
                 for (var y = 0; y < t.testJson.length; y++) {
                   if (t.testJson[y].type == "2") {
-                    e.push(t.testJson[y].answer);
+                    e.push(JSON.parse(chooseInfo[i].content)[0].anwer[y]);
                   } else {
-                    e.push(t.testJson[y].answer);
+                    e.push(JSON.parse(chooseInfo[i].content)[0].anwer[y]);
                   }
                 }
                 t.radio = e;
                 workJson[k].chooseInfo.push(t);
+                for (var p = 0; p < t.radio.length; p++) {
+                  if (!this.checkJson[k][p]) {
+                    this.checkJson[k].push({
+                      checkCount: [],
+                      checkPerson: [],
+                      rightPerson: [],
+                    });
+                  }
+                  if (!this.checkJson[k][p].checkCount.length) {
+                    this.checkJson[k][p].checkCount = [];
+                    let _askItemCount = t.testJson[p].testItem;
+                    for (var aic = 0; aic < _askItemCount; aic++) {
+                      this.checkJson[k][p].checkCount.push(0);
+                    }
+                  }
+                  if (t.radio[p] instanceof Array) {
+                    if (
+                      workJson[k].chooseInfo[0].testJson[p].answer
+                        .sort()
+                        .join(",") == t.radio[p].sort().join(",")
+                    ) {
+                      this.checkJson[k][p].rightPerson.push(
+                        res.data[0][k].sName
+                      );
+                    }
+                    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[
+                            parseInt(t.radio[p][q])
+                          ].push(res.data[0][k].sName)
+                        : (this.checkJson[k][p].checkPerson[
+                            parseInt(t.radio[p][q])
+                          ] = [res.data[0][k].sName]);
+                      this.checkJson[k][p].checkCount[parseInt(t.radio[p][q])]
+                        ? this.checkJson[k][p].checkCount[
+                            parseInt(t.radio[p][q])
+                          ]++
+                        : (this.checkJson[k][p].checkCount[
+                            parseInt(t.radio[p][q])
+                          ] = 1);
+                    }
+                  } else {
+                    if (
+                      workJson[k].chooseInfo[0].testJson[p].answer == t.radio[p]
+                    ) {
+                      this.checkJson[k][p].rightPerson.push(
+                        res.data[0][k].sName
+                      );
+                    }
+                    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[
+                            parseInt(t.radio[p])
+                          ].push(res.data[0][k].sName)
+                        : (this.checkJson[k][p].checkPerson[
+                            parseInt(t.radio[p])
+                          ] = [res.data[0][k].sName]);
+                      this.checkJson[k][p].checkCount[parseInt(t.radio[p])]
+                        ? this.checkJson[k][p].checkCount[
+                            parseInt(t.radio[p])
+                          ]++
+                        : (this.checkJson[k][p].checkCount[
+                            parseInt(t.radio[p])
+                          ] = 1);
+                    }
+                  }
+                }
               }
             }
 
@@ -2108,7 +2222,7 @@ export default {
   font-size: 22px;
 }
 
-.sd_score span {
+.sd_score > span:nth-child(1)  {
   width: 130px;
   text-align: justify;
   text-align-last: justify;
@@ -2957,4 +3071,24 @@ export default {
   height: 100%;
   object-fit: cover;
 }
+.xuan_right_box {
+  padding: 10px;
+  background: rgb(247, 247, 247);
+  margin: 10px 12px;
+  border-radius: 5px;
+}
+.tool_right_box {
+  display: flex;
+  align-items: center;
+}
+.tool_right_box + .tool_right_box {
+  margin-top: 10px;
+}
+.right_box_xuan {
+  background: rgb(0 123 255);
+  color: #fff;
+  border-radius: 5px;
+  padding: 5px;
+  margin-left: 10px;
+}
 </style>