|
|
@@ -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"
|