lsc 1 rok temu
rodzic
commit
bad07c5a25

+ 2 - 2
src/components/pages/test/add/edit/check/index.vue

@@ -1,7 +1,7 @@
 <template>
   <div class="c_box">
     <div class="c_box_title">{{ title }}</div>
-    <div class="c_box_score">总分:{{ score }}</div>
+    <div class="c_box_score">总分:{{ score }}</div>
     <div class="c_body">
       <div v-if="type == 3">
         <div v-for="(item, index) in checkArray[page].array" :key="index" class="check_box">
@@ -110,7 +110,7 @@ export default {
           score += el.json.score ? parseFloat(el.json.score) : 0
         }
       })
-      return score > 0 ? score : '未设置分数'
+      return score > 0 ? score + '分' : '未设置分数'
     }
   },
   watch: {

+ 14 - 18
src/components/pages/test/check/check.vue

@@ -45,9 +45,11 @@
         </div>
         <div class="step_box">
           <div class="edit_top">
-            <div class="op_btn"></div>
+            <div class="op_btn">
+              <el-button type="primary" size="small" @click="publish">确定批改</el-button>
+            </div>
           </div>
-          <topicVue :cJson="cJson" :title="title" :checktype="2" :see="see" :isTeacher="2" :name="name"></topicVue>
+          <topicVue :cJson="cJson" :title="title" :checktype="2" :see="see" :isTeacher="1" :name="name" ref="topicVue"></topicVue>
         </div>
       </div>
     </div>
@@ -70,6 +72,7 @@ export default {
       cid: this.$route.query.cid,
       steps: 1,
       title: "",
+      id:"",
       testType: [],
       see: true,
       cJson: [],
@@ -117,6 +120,7 @@ export default {
           console.log(this.testType);
           this.look = res.data[0][0].look;
 
+          this.id = res.data[2][0].id
           this.cJson = JSON.parse(res.data[2][0].courseJson);
           this.name = res.data[2][0].username;
           this.loading = false;
@@ -126,28 +130,20 @@ export default {
         });
     },
     publish() {
+      let cjson = this.$refs['topicVue'].checkArray
       let params = [
         {
-          uid: this.userid,
-          cid: this.cid,
-          cjson: JSON.stringify(this.cJson),
-          type: "2",
+          id: this.id,
+          cjson: JSON.stringify(cjson),
+          type: "3",
+          uid:this.userid
         },
       ];
       this.ajax
-        .post(this.$store.state.api + "addTestWorks", params)
+        .post(this.$store.state.api + "addTestWorksTeacher", params)
         .then((res) => {
-          this.$message.success("提交成功");
-          this.goTo(
-            "/testStudent?userid=" +
-              this.userid +
-              "&oid=" +
-              this.oid +
-              "&org=" +
-              this.org +
-              "&role=" +
-              this.role
-          );
+          this.$message.success("批改成功");
+          this.retrunCourse();
         })
         .catch((err) => {
           this.$message.error("网络不佳");

+ 10 - 0
src/components/pages/test/check/index.vue

@@ -54,6 +54,16 @@
                   align="center"
                 >
                 </el-table-column>
+                <el-table-column
+                  prop="time"
+                  label="是否批改"
+                  min-width="15"
+                  align="center"
+                >
+                  <template slot-scope="scope">
+                    <div>{{ scope.row.type == 3 ? '是' : '否' }}</div>
+                  </template>
+                </el-table-column>
                 <el-table-column label="操作" width="200px">
                   <template slot-scope="scope">
                     <el-button

+ 26 - 3
src/components/pages/testStudent/view/component/choice.vue

@@ -5,7 +5,9 @@
         <div v-else class="choice_box">
             <div class="c_title">
                 <div class="title">{{ `(${option[checkJson.type].name})` + checkJson.title }}<span style="color: #efa030;" v-if="checkJson.score">({{ '分值:'+checkJson.score+'分' }})</span></div>
-                <div class="p_box" v-if="isTeacher == 1">1</div>
+                <div class="p_box" v-if="isTeacher == 1 && checkJson.score">
+                    <el-input v-model="score2" class="c_input" disabled></el-input><span style="margin: 0 10px;">/</span><span>{{ checkJson.score }}分</span>
+                </div>
             </div>
             <div class="choices">
                 <div class="choice" v-for="(item, index) in checkJson.array" :key="index">
@@ -51,6 +53,15 @@ export default {
             checkJson: undefined
         }
     },
+    computed: {
+        score2() {
+            let answer2 = this.checkJson.answer2 ? this.checkJson.answer2.sort().join(',') : ''
+            let answer = this.checkJson.answer ? this.checkJson.answer.sort().join(',') : ''
+            this.checkJson.score2 = (answer2 == answer ? this.checkJson.score : 0)
+            this.$forceUpdate();
+            return answer2 == answer ? this.checkJson.score : 0
+        }
+    },
     watch: {
         checkJson: {
             handler(newValue) {
@@ -113,7 +124,9 @@ export default {
 
 .choice_box> .c_title .p_box{
     margin-left: 5px;
-    width: fit-content;
+    min-width: fit-content;
+    display: flex;
+    align-items: center;
 }
 
 .choice_box>.choices {
@@ -180,4 +193,14 @@ export default {
 
 .choice_box>.choices>.choice>>>.el-radio__input.is-disabled.is-checked .el-radio__inner::after {
     background-color: #fff !important;
-}</style>
+}
+
+.c_input {
+    width: 90px;
+}
+
+.c_input >>> .el-input__inner{
+    padding: 0 5px;
+    text-align: right;
+}
+</style>

+ 26 - 2
src/components/pages/testStudent/view/component/gap.vue

@@ -10,7 +10,9 @@
                     <span style="color: #efa030;" v-if="checkJson.score && !see">({{ '分值:'+checkJson.score+'分' }})</span>
                     <!-- </div><div v-html="checkJson.title"></div> -->
                 </div>
-                <div class="p_box" v-if="isTeacher == 1">1</div>
+                <div class="p_box" v-if="isTeacher == 1 && checkJson.score">
+                    <el-input v-model="checkJson.score2" class="c_input" @change="numberPan" placeholder="请输入得分"></el-input><span style="margin: 0 10px;">/</span><span>{{ checkJson.score }}分</span>
+                </div>
             </div>
             <div class="choices">
                 <textarea  :readonly="checktype == 2" rows="2" v-autoHeight="68" class="binfo_input binfo_textarea" cols v-model="checkJson.answer2"
@@ -74,6 +76,17 @@ export default {
         depthCopy(s) {
             return JSON.parse(JSON.stringify(s));
         },
+        numberPan() {
+            if (/[^\d]/.test(this.checkJson.score2) || this.checkJson.score2 < 0) {
+                this.$message.error('请输入大于0的数字')
+                this.checkJson.score2 = ''
+            }
+
+            if(this.checkJson.score2 > this.checkJson.score){
+                this.$message.error('不能输入大于得分的数字')
+                this.checkJson.score2 = this.checkJson.score
+            }
+        },
     },
     mounted() {
         this.checkJson = this.cJson ? this.depthCopy(this.cJson) : undefined
@@ -115,7 +128,9 @@ export default {
 
 .choice_box> .c_title .p_box{
     margin-left: 5px;
-    width: fit-content;
+    min-width: fit-content;
+    display: flex;
+    align-items: center;
 }
 
 .choice_box>.choices {
@@ -153,4 +168,13 @@ export default {
 .binfo_input:focus-visible {
     border: 1.5px solid #3681FC !important;
 }
+
+.c_input {
+    width: 90px;
+}
+
+.c_input >>> .el-input__inner{
+    padding: 0 5px;
+    text-align: right;
+}
 </style>

+ 29 - 3
src/components/pages/testStudent/view/component/topic.vue

@@ -1,7 +1,11 @@
 <template>
   <div class="c_box">
     <div class="c_box_title">{{ title }}</div>
-    <div class="c_box_score">总分:{{ score }}分<span v-if="name" style="margin-left: 10px;">答题人:{{ name }}</span></div>
+    <div class="c_box_score">
+      <span>总分:{{ score }}</span>
+      <span v-if="name" style="margin-left: 10px;">答题人:{{ name }}</span>
+      <span style="margin-left: 10px;">得分:{{ score2 }}</span>
+    </div>
     <div class="c_body">
       <div v-if="type == 3">
         <div v-for="(item, index) in checkArray[page].array" :key="index" class="check_box">
@@ -110,7 +114,7 @@ export default {
     },
     score() {
       let score = 0
-      this.cJson.forEach(el => {
+      this.checkArray.forEach(el => {
         if ((el.ttype == 3 || el.ttype == 2) && el.array.length > 0) {
           el.array.forEach(item => {
             if (item.ttype == 2 && item.array.length > 0) {
@@ -127,7 +131,29 @@ export default {
           score += el.json.score ? parseFloat(el.json.score) : 0
         }
       })
-      return score > 0 ? score : '未设置分数'
+      return score > 0 ? score + '分' : '未设置分数'
+    },
+    score2() {
+      let score = 0
+      // let type = 1
+      this.checkArray.forEach(el => {
+        if ((el.ttype == 3 || el.ttype == 2) && el.array.length > 0) {
+          el.array.forEach(item => {
+            if (item.ttype == 2 && item.array.length > 0) {
+              item.array.forEach(item2 => {
+                if (item2.ttype == 1 && item2.json) {
+                  score += item2.json.score2 ? parseFloat(item2.json.score2) : 0
+                }
+              })
+            } else if (item.ttype == 1 && item.json) {
+              score += item.json.score2 ? parseFloat(item.json.score2) : 0
+            }
+          })
+        } else if (el.ttype == 1 && el.json) {
+          score += el.json.score2 ? parseFloat(el.json.score2) : 0
+        }
+      })
+      return score + '分'
     }
   },
   watch: {