Przeglądaj źródła

fix: 客观题输入给分

zhangjie 8 miesięcy temu
rodzic
commit
0015a0da5f

+ 13 - 7
src/modules/mark/components/markParam/MarkParamObjectiveAnswer.vue

@@ -139,6 +139,7 @@
                 <div class="el-form-item__content">
                   <el-input-number
                     v-model="scope.row.objectivePolicyScore"
+                    :disabled="scope.row.answer.length <= 1"
                     style="width: 110px; margin-left: 5px"
                     size="small"
                     :min="0"
@@ -147,7 +148,7 @@
                     step-strictly
                     :controls="false"
                     placeholder="每个选项得分"
-                    @change="validateObjectivePolicy(scope.row)"
+                    @change="objectivePolicyScoreChange(scope.row)"
                   ></el-input-number>
                   <div
                     v-if="scope.row.objectivePolicyError"
@@ -375,8 +376,8 @@ export default {
         }
 
         if (
-          row.optionCount &&
-          row.objectivePolicyScore * row.optionCount > row.totalScore
+          row.answer.length > 1 &&
+          row.objectivePolicyScore * row.answer.length > row.totalScore
         ) {
           row.objectivePolicyError = "分值过大";
           return;
@@ -395,14 +396,19 @@ export default {
         (item) => item.answerError || item.objectivePolicyError
       );
     },
+    objectivePolicyScoreChange(row) {
+      this.$nextTick(() => {
+        this.objectivePolicyChange(row);
+      });
+    },
     objectivePolicyChange(row) {
-      const { totalScore, optionCount, objectivePolicy } = row;
+      const { totalScore, answer, objectivePolicy } = row;
       if (objectivePolicy === "LEAK") {
-        if (optionCount) {
-          const pickScore = Math.floor((totalScore * 2) / optionCount) / 2;
+        if (answer.length > 1) {
+          const pickScore = Math.floor((totalScore * 2) / answer.length) / 2;
           row.objectivePolicyScore = pickScore;
         } else {
-          row.objectivePolicyScore = undefined;
+          row.objectivePolicyScore = 0;
         }
       } else {
         row.objectivePolicyScore = null;

+ 3 - 49
src/modules/target/components/course-examine/CourseExamineWeight.vue

@@ -19,7 +19,6 @@
             <template slot-scope="scope">
               <el-input-number
                 v-model="scope.row.evaluationList[cindex].weight"
-                :disabled="scope.row.evaluationList[cindex].disabled"
                 class="width-80"
                 size="small"
                 :min="0"
@@ -106,32 +105,10 @@ export default {
       );
 
       this.columns.forEach((column, cindex) => {
-        if (cindex === 0) {
-          dataList.forEach((item, eindex) => {
-            const node = item.evaluationList[cindex];
-            node.disabled = false;
-            node.enable = !!node.weight;
-            node.weight = node.weight || undefined;
-          });
-          return;
-        }
-
-        const rowIndex = dataList.findIndex((item, eindex) => {
-          return !!item.evaluationList[cindex].weight;
+        dataList.forEach((item, eindex) => {
+          const node = item.evaluationList[cindex];
+          node.weight = node.weight || undefined;
         });
-        if (rowIndex !== -1) {
-          dataList.forEach((item, eindex) => {
-            const node = item.evaluationList[cindex];
-            node.disabled = eindex !== rowIndex;
-            node.weight = node.weight || undefined;
-          });
-        } else {
-          dataList.forEach((item, eindex) => {
-            const node = item.evaluationList[cindex];
-            node.disabled = false;
-            node.weight = node.weight || undefined;
-          });
-        }
       });
 
       this.dataList = dataList;
@@ -142,29 +119,6 @@ export default {
           item.evaluationList.map((elem) => elem.weight || 0)
         );
       });
-
-      if (cindex === 0) {
-        this.dataList.forEach((item, eindex) => {
-          const node = item.evaluationList[cindex];
-          node.enable = !!node.weight;
-        });
-        return;
-      }
-
-      const val = this.dataList[rowIndex].evaluationList[cindex].weight;
-      if (val) {
-        this.dataList.forEach((item, eindex) => {
-          const node = item.evaluationList[cindex];
-          node.disabled = eindex !== rowIndex;
-          node.enable = eindex === rowIndex;
-        });
-      } else {
-        this.dataList.forEach((item, eindex) => {
-          const node = item.evaluationList[cindex];
-          node.disabled = false;
-          node.enable = false;
-        });
-      }
     },
     checkDataList() {
       if (!this.dataList.length) return;