Browse Source

给分间隔

xiatian 5 years ago
parent
commit
a2cdd9d29e

+ 102 - 3
src/modules/marking/views/MarkSettingMain.vue

@@ -169,16 +169,29 @@
               min-width="100"
               prop="markerCount"
             ></el-table-column>
-            <el-table-column :context="_self" label="操作">
+            <el-table-column
+              label="给分间隔"
+              min-width="100"
+              prop="scoreStep"
+            ></el-table-column>
+            <el-table-column :context="_self" width="250" label="操作">
               <template slot-scope="scope">
-                <div class="pull-left" v-if="scope.row.totalCount > 0">
+                <div class="pull-left">
                   <el-button
+                    v-if="scope.row.totalCount > 0"
                     @click="fastSetting(scope.$index, scope.row)"
                     type="primary"
                     size="mini"
                     plain
                     >快速设置</el-button
                   >
+                  <el-button
+                    @click="openStepModel(scope.row)"
+                    type="primary"
+                    size="mini"
+                    plain
+                    >给分间隔设置</el-button
+                  >
                 </div>
               </template>
             </el-table-column>
@@ -196,6 +209,44 @@
             ></el-pagination>
           </div>
         </div>
+        <el-dialog
+          title="设置给分间隔"
+          width="500px"
+          :visible.sync="stepModel"
+          :close-on-click-modal="false"
+          @close="closeStepModel"
+        >
+          <el-form
+            :inline="true"
+            :model="stepForm"
+            ref="stepForm"
+            :rules="stepRules"
+            label-width="90px"
+            :key="stepModelKey"
+          >
+            <el-row>
+              <el-form-item label="给分间隔" prop="step">
+                <el-input-number
+                  size="mini"
+                  v-model="stepForm.step"
+                  :precision="1"
+                  :step="0.1"
+                  :min="0.1"
+                  :max="100"
+                ></el-input-number>
+              </el-form-item>
+            </el-row>
+            <el-row class="pull-center">
+              <el-button
+                type="primary"
+                @click="subStep"
+                :loading="this.stepForm.loading"
+                >确定</el-button
+              >
+              <el-button @click="closeStepModel">取消</el-button>
+            </el-row>
+          </el-form>
+        </el-dialog>
       </div>
     </section>
   </div>
@@ -230,6 +281,14 @@ export default {
         userId: [],
         paperId: ""
       },
+      stepModel: false,
+      stepModelKey: Math.random(),
+      stepForm: {
+        workId: null,
+        courseCode: null,
+        step: null,
+        loading: false
+      },
       paperId: "",
       impDialog: false,
       uploadAction: DATA_PROCESS_API + "/markTasks/import",
@@ -238,13 +297,53 @@ export default {
       errMessages: [],
       errDialog: false,
       fileLoading: false,
-      fileList: []
+      fileList: [],
+      stepRules: {
+        step: [{ required: true, message: "请输入给分间隔", trigger: "change" }]
+      }
     };
   },
   components: {
     LinkTitlesCustom
   },
   methods: {
+    openStepModel(row) {
+      this.stepForm.step = row.scoreStep;
+      this.stepForm.workId = row.workId;
+      this.stepForm.courseCode = row.code;
+      this.stepModel = true;
+    },
+    closeStepModel() {
+      this.stepModel = false;
+      this.stepForm.step = null;
+      this.stepModelKey = Math.random();
+    },
+    async subStep() {
+      let res = await this.$refs.stepForm.validate();
+      if (!res) {
+        return;
+      }
+      this.stepForm.loading = true;
+      var url =
+        MARKING_API +
+        "/markCourses/score-step?workId=" +
+        this.stepForm.workId +
+        "&courseCode=" +
+        this.stepForm.courseCode +
+        "&scoreStep=" +
+        this.stepForm.step;
+      this.$httpWithMsg
+        .put(url)
+        .then(() => {
+          this.$notify({
+            type: "success",
+            message: "设置成功!"
+          });
+          this.closeStepModel();
+          this.initSetting();
+        })
+        .finally(() => (this.stepForm.loading = false));
+    },
     //查询课程
     getCourses() {
       this.$http

+ 1 - 0
src/modules/marking/views/Marking.vue

@@ -242,6 +242,7 @@
             :markedResult="markedResult"
             :resultItems="resultItems"
             :studentPaperId="studentPaper.id"
+            :scoreStep="studentPaper.scoreStep"
             :markTaskId="task.id"
           ></tpScoreboard>
         </div>

+ 40 - 18
src/modules/marking/views/TpScoreBoard.vue

@@ -95,7 +95,7 @@
                     <span>{{ resultItem.markItem.maxScore }}分</span>
                   </div>
                   <div class="pull-left item-number3">
-                    间隔:{{ resultItem.markItem.scoreInterval }}
+                    间隔:{{ itemScoreStep(resultItem.markItem.scoreInterval) }}
                   </div>
                 </div>
                 <div class="item-score">
@@ -259,7 +259,8 @@ export default {
     "markTaskId",
     "resultItems",
     "markedResult",
-    "paperMark"
+    "paperMark",
+    "scoreStep"
   ],
   methods: {
     ...mapActions([USER_SIGNOUT]),
@@ -367,7 +368,6 @@ export default {
     checkScore(resultItem) {
       var score = resultItem.score + "";
       var maxScore = resultItem.markItem.maxScore + "";
-      var scoreInterval = resultItem.markItem.scoreInterval + "";
       if (score.trim().length === 0) {
         this.$notify({
           message: "分数不能为空",
@@ -376,10 +376,10 @@ export default {
         });
         return false;
       } else {
-        let regex = scoreInterval == 1 ? "^\\d+$" : "^\\d+(\\.[5])?$";
+        let regex = "^\\d+(\\.[\\d])?$";
         if (!score.match(regex)) {
           this.$notify({
-            message: "分数必须为数字,且格式要正确(包括间隔分)",
+            message: "分数必须为数字",
             type: "error",
             duration: 1000
           });
@@ -539,10 +539,8 @@ export default {
       if (document.getElementById("remark")) {
         remarkValue = document.getElementById("remark").value;
       }
-      console.log("remarkValue: " + remarkValue);
       if (!this.markedResult.id) {
         //正常提交情况
-        console.log("提交resultItems", this.resultItems);
         this.$httpWithMsg
           .post(
             MARKING_API +
@@ -559,7 +557,6 @@ export default {
           .then(
             response => {
               this.saveMarkSign();
-              console.log(response);
               if (response.data.id) {
                 this.$notify({
                   message: "提交成功",
@@ -580,7 +577,6 @@ export default {
             },
             error => {
               // 响应错误回调
-              console.log(error);
               if (error.response.data.desc) {
                 var errorInfo = error.response.data.desc;
                 if (errorInfo.includes("超时")) {
@@ -592,7 +588,6 @@ export default {
                     {
                       confirmButtonText: "确定",
                       callback: () => {
-                        console.log("sessionStorage", sessionStorage);
                         this.$http
                           .post(CORE_API + "/auth/logout")
                           .then(() => {
@@ -647,15 +642,13 @@ export default {
             }
           );
       } else {
-        console.log("markedResult", this.markedResult);
         this.markedResult.resultItems = this.resultItems;
         this.markedResult.remark = remarkValue;
         this.$httpWithMsg
           .put(MARKING_API + "/markResults", this.markedResult)
           .then(
-            response => {
+            () => {
               this.saveMarkSign();
-              console.log(response);
               this.$notify({
                 message: "提交成功",
                 type: "success"
@@ -701,6 +694,27 @@ export default {
       } else {
         this.textareaflag = true;
       }
+    },
+    accAdd(num1, num2) {
+      let sq1, sq2, m;
+      try {
+        sq1 = num1.toString().split(".")[1].length;
+      } catch (e) {
+        sq1 = 0;
+      }
+      try {
+        sq2 = num2.toString().split(".")[1].length;
+      } catch (e) {
+        sq2 = 0;
+      }
+      m = Math.pow(10, Math.max(sq1, sq2));
+      return (num1 * m + num2 * m) / m;
+    },
+    itemScoreStep(scoreInterval) {
+      if (this.scoreStep != null) {
+        return this.scoreStep;
+      }
+      return scoreInterval;
     }
   },
   watch: {
@@ -774,12 +788,20 @@ export default {
     itemScores() {
       var itemScores = [];
       var scoreInterval = this.resultItem.markItem.scoreInterval;
-      for (
-        let i = 0, j = 0;
-        i <= this.resultItem.markItem.maxScore;
-        i += scoreInterval, j++
-      ) {
+      if (this.scoreStep != null) {
+        scoreInterval = this.scoreStep;
+      }
+      let i = 0;
+      let j = 0;
+      do {
         itemScores[j] = i;
+        i = this.accAdd(i, scoreInterval);
+        j++;
+      } while (i <= this.resultItem.markItem.maxScore);
+      if (
+        itemScores[itemScores.length - 1] < this.resultItem.markItem.maxScore
+      ) {
+        itemScores[itemScores.length] = this.resultItem.markItem.maxScore;
       }
       return itemScores;
     },