Kaynağa Gözat

[修改]问题全部类型筛选,成绩管理

soleil 7 yıl önce
ebeveyn
işleme
2f5e156537

+ 1 - 1
src/views/login/Login.vue

@@ -36,7 +36,7 @@
         class="button login"
         @click="loginAction"
       >
-        登 
+        登 
       </button>
     </div>
     <div>

+ 1 - 1
src/views/login/Register.vue

@@ -82,7 +82,7 @@
       :class="{ 'is-text': true }"
       class="button login"
       type="submit"
-      >已有账户,登
+      >已有账户,登
     </router-link>
   </div>
 </template>

+ 2 - 2
src/views/teacher/Question/index.vue

@@ -479,7 +479,7 @@ export default {
   watch: {
     selectedType(val) {
       let type = val;
-      type == "全部类型" ? "" : type;
+      type = type == "全部类型" ? "" : type;
       this.getQuestionsByQType(type, 0, pageLimit);
     }
   },
@@ -526,7 +526,7 @@ export default {
         .catch(e => {
           this.$toast.open({
             message: e.message,
-            type: "is-link"
+            type: "is-danger"
           });
         });
     },

+ 54 - 26
src/views/teacher/Result/index.vue

@@ -189,6 +189,18 @@ import { required, numeric, between } from "vuelidate/lib/validators";
 import { getStudentFinaleResult } from "@/api/resultstatistics";
 import PageSectionLoading from "@/components/PageBody/PageSectionLoading/index";
 
+const RESULT_SECTION = [
+  "0分",
+  "1-29分",
+  "30-59分段",
+  "60-69分段",
+  "70-79分段",
+  "80-89分段",
+  "90-99分段",
+  "100分"
+];
+const RESULT_PARTITION = [0, 29, 59, 69, 79, 89, 99, 100];
+
 export default {
   components: {
     BInput,
@@ -208,16 +220,6 @@ export default {
       course: state => state.course.currentCourse
     })
   },
-  watch: {
-    course(val) {
-      //获取成绩信息
-      getStudentFinaleResult(val.id).then(res => {
-        console.log(res.data);
-        this.data = res.data;
-        this.isResultLoading = false;
-      });
-    }
-  },
   data() {
     return {
       name: "",
@@ -235,6 +237,32 @@ export default {
     };
   },
   methods: {
+    //统计学生成绩分段
+    studenResultStatistics(studentResults) {
+      let resultStatisticsData = [];
+      for (let i = 0; i < RESULT_PARTITION.length; i++) {
+        let count = 0;
+        if (i == 0) {
+          for (let result in studentResults) {
+            if (this.getFinalResult(result.row) == 0) count++;
+          }
+        } else if (i == RESULT_PARTITION.length - 1) {
+          for (let result in studentResults) {
+            if (this.getFinalResult(result.row) == 100) count++;
+          }
+        } else {
+          for (let result in studentResults) {
+            if (
+              this.getFinalResult(result.row) > RESULT_PARTITION[i - 1] &&
+              this.getFinalResult(result.row) <= RESULT_PARTITION[i]
+            )
+              count++;
+          }
+        }
+        resultStatisticsData.push(count);
+      }
+      return resultStatisticsData;
+    },
     type(value) {
       const number = parseFloat(value);
       if (number < 60) {
@@ -290,28 +318,28 @@ export default {
     let getResultIntervel = setInterval(() => {
       if (this.course.id) {
         clearInterval(getResultIntervel);
-        getStudentFinaleResult(this.course.id).then(res => {
-          this.data = res.data;
-          this.isResultLoading = false;
-        });
+        getStudentFinaleResult(this.course.id)
+          .then(res => {
+            this.data = res.data;
+            this.isResultLoading = false;
+          })
+          .catch(e => {
+            this.isResultLoading = false;
+            this.$toast.open({
+              message: e.message || "服务器错误,请稍后再试",
+              type: "is-danger"
+            });
+          });
       }
     }, 800);
-
+    //统计学生分数
+    let studentResultStatistics = this.studenResultStatistics(this.data);
     //绘制图表
     let resultChart = document.getElementById("result-chart");
     let myChart2 = new Chart(resultChart, {
       type: "bar",
       data: {
-        labels: [
-          "0分",
-          "1-29分",
-          "30-59分段",
-          "60-69分段",
-          "70-79分段",
-          "80-89分段",
-          "90-99分段",
-          "100分"
-        ],
+        labels: RESULT_SECTION,
         datasets: [
           {
             label: "人数",
@@ -320,7 +348,7 @@ export default {
             borderWidth: 1,
             pointStrokeColor: "#fff",
             pointStyle: "crossRot",
-            data: [2, 6, 10, 34, 50, 80, 30, 2],
+            data: studentResultStatistics,
             cubicInterpolationMode: "monotone",
             spanGaps: "false",
             fill: "false"