d01c5799
梁保满
随堂问 报表开发
|
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
|
<template>
<el-table :data="resultData" border style="width: 100%">
<el-table-column prop="studentCode" label="学号" align="center"></el-table-column>
<el-table-column prop="studentName" label="姓名" align="center"></el-table-column>
<template v-if="types == 1">
<el-table-column prop="answerTimes" label="答题次数" align="center"></el-table-column>
<el-table-column prop="consumingDuration" label="答题耗时" align="center"><template slot-scope="scoped">{{
setDuration(scoped.row.consumingDuration)
}}</template></el-table-column>
<el-table-column prop="correctAnswerTimes" label="答对次数" align="center"></el-table-column>
<el-table-column prop="participationRate" label="参与度" sortable align="center"><template slot-scope="scoped">{{
scoped.row.participationRate }}%</template></el-table-column>
<el-table-column prop="correctRate" label="正确率" sortable align="center"><template slot-scope="scoped">{{
scoped.row.correctRate }}%</template></el-table-column>
<el-table-column prop="answerCorrectRate" label="已答正确率" sortable align="center"><template slot-scope="scoped">{{
scoped.row.answerCorrectRate }}%</template></el-table-column>
<el-table-column v-for="(item, index) in optionsList" :key="index" :label="'Q' + (index + 1)"
align="center"><template slot-scope="scoped">
<span :class="scoped.row['isRight' + index] ? '' : 'red'">{{
scoped.row["answer" + index]
}}</span>
</template>
</el-table-column>
</template>
<template v-if="types == 2">
<el-table-column prop="answerTimes" label="累计答题次数" align="center"></el-table-column>
<el-table-column prop="correctAnswerTimes" label="累计答对次数" align="center"></el-table-column>
<el-table-column prop="participationRate" label="总参与度" align="center"><template slot-scope="scoped">{{
scoped.row.participationRate }}%</template></el-table-column>
<el-table-column prop="participationRateRank" label="总参与度班名" align="center"></el-table-column>
<el-table-column prop="correctRate" label="总正确率" align="center"><template slot-scope="scoped">{{
scoped.row.correctRate }}%</template></el-table-column>
<el-table-column prop="correctRateRank" label="总正确率班名" sortable align="center"></el-table-column>
<el-table-column prop="answerCorrectRate" label="已答正确率" align="center"><template slot-scope="scoped">{{
scoped.row.answerCorrectRate }}%</template></el-table-column>
<el-table-column label="查看折线图" align="center">
<template slot-scope="scoped"><el-button icon="el-icon-right" type="primary" circle></el-button></template>
</el-table-column>
</template>
<template v-if="types == 3">
<el-table-column v-for="(item, index) in phaseOption" :key="index" :label="item" align="center">
<el-table-column align="center" :label="index == 0 ? '总课时数' : '课时数'" :prop="'periodCount' + item">
</el-table-column>
<el-table-column align="center" :label="index == 0 ? '总出题数' : '出题数'" :prop="'questionNum' + item">
</el-table-column>
<el-table-column align="center" :label="index == 0 ? '总参与度' : '参与度'" :prop="'participationRate' + item"><template
slot-scope="scoped">{{ scoped.row["participationRate" + item] }}%</template>
</el-table-column>
<el-table-column align="center" :label="index == 0 ? '总正确率' : '正确率'" :prop="'correctRate' + item"><template
slot-scope="scoped">{{ scoped.row["correctRate" + item] }}%</template>
</el-table-column>
</el-table-column>
</template>
</el-table>
</template>
<script>
export default {
props: {
tableData: Array,
types: Number,
},
data() {
return {
optionsList: [],
phaseOption: [], //问答补充数据
};
},
computed: {
resultData: function () {
let resultData = []
if (this.tableData.length) {
let optionsList = [];
let subjectName = [];
let rank = {}
resultData = this.tableData.map((item) => {
let params = {};
if (this.types == 1) {
const detail = JSON.parse(item.detail);
if (detail.length > optionsList.length) {
optionsList = [...detail];
}
detail.map((items, index) => {
params["isRight" + index] = items.isRight;
params["answer" + index] =
items.answer == 1
? "✓"
: items.answer == 2
? "✗"
: items.answer;
});
} else if (this.types == 3) {
item.dataList.map((items, index) => {
if (!subjectName.includes(items.subjectName)) {
subjectName.push(items.subjectName);
}
params["answerCorrectRate" + items.subjectName] =
items.answerCorrectRate;
params["correctRate" + items.subjectName] = items.correctRate;
params["participationRate" + items.subjectName] =
items.participationRate;
params["periodCount" + items.subjectName] = items.periodCount;
params["questionNum" + items.subjectName] = items.questionNum;
});
}
if (this.types != 3) {
let participationRateArr = []
let correctRateArr = []
this.tableData.map(item => {
participationRateArr.push(item.participationRate)
correctRateArr.push(item.correctRate)
})
participationRateArr = [...new Set(participationRateArr)]
participationRateArr = participationRateArr.sort((a, b) => {
return b - a
})
correctRateArr = [...new Set(correctRateArr)]
correctRateArr = correctRateArr.sort((a, b) => {
return b - a
})
let participationRateRank = participationRateArr.findIndex(value => {
return item.participationRate == value
})
let correctRateRank = correctRateArr.findIndex(value => {
return item.correctRate == value
})
rank = {
participationRateRank: participationRateRank + 1,
correctRateRank: correctRateRank + 1
}
}
return {
...item,
...params,
...rank
};
});
this.phaseOption = [...subjectName];
this.optionsList = [...optionsList];
} else {
resultData = []
this.optionsList = []
}
return resultData
}
},
methods: {
setDuration(times) {
let m = parseInt(times / 1000 / 60);
let s = parseInt((times / 1000) % 60);
let ms = times;
let aTime;
if (times == 0) {
aTime = `0`;
} else {
if (m == 0 && s == 0) {
aTime = `${ms}毫秒`;
} else if (m == 0 && s != 0) {
aTime = `${s}秒`;
} else if (m != 0 && s != 0) {
aTime = `${m}分${s}秒`;
}
}
return aTime;
},
}
};
</script>
<style>
.red {
color: #f30;
}
</style>
|