Blame view

src/views/basic/ask/components/answerQustion.vue 12.9 KB
d01c5799   梁保满   随堂问 报表开发
1
  <template>
22095aba   梁保满   接口联调
2
3
    <div>
      <el-table :data="resultData" border style="width: 100%">
ce278878   梁保满   2-2 bugfix
4
5
6
7
8
9
10
11
12
13
        <el-table-column
          prop="studentCode"
          label="学号"
          align="center"
        ></el-table-column>
        <el-table-column
          prop="studentName"
          label="姓名"
          align="center"
        ></el-table-column>
22095aba   梁保满   接口联调
14
        <template v-if="types == 1">
ce278878   梁保满   2-2 bugfix
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
          <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"
2e5b8dea   梁保满   分数设置修改,
38
39
40
41
42
            ><template slot-scope="scoped">{{
              `${scoped.row.participationRate}${
                scoped.row.participationRate ? "%" : ""
              }`
            }}</template></el-table-column
ce278878   梁保满   2-2 bugfix
43
44
45
46
47
48
          >
          <el-table-column
            prop="correctRate"
            label="正确率"
            sortable
            align="center"
2e5b8dea   梁保满   分数设置修改,
49
50
51
            ><template slot-scope="scoped">{{
              `${scoped.row.correctRate}${scoped.row.correctRate ? "%" : ""}`
            }}</template></el-table-column
ce278878   梁保满   2-2 bugfix
52
53
54
55
56
57
          >
          <el-table-column
            prop="answerCorrectRate"
            label="已答正确率"
            sortable
            align="center"
2e5b8dea   梁保满   分数设置修改,
58
59
60
61
62
            ><template slot-scope="scoped">{{
              `${scoped.row.answerCorrectRate}${
                scoped.row.answerCorrectRate ? "%" : ""
              }`
            }}</template></el-table-column
ce278878   梁保满   2-2 bugfix
63
64
65
66
67
68
69
          >
          <el-table-column
            v-for="(item, index) in optionsList"
            :key="index"
            :label="'Q' + (index + 1)"
            align="center"
            ><template slot-scope="scoped">
22095aba   梁保满   接口联调
70
71
72
73
              <span :class="scoped.row['isRight' + index] ? '' : 'red'">{{
                scoped.row["answer" + index]
              }}</span>
            </template>
d01c5799   梁保满   随堂问 报表开发
74
          </el-table-column>
22095aba   梁保满   接口联调
75
76
        </template>
        <template v-if="types == 2">
ce278878   梁保满   2-2 bugfix
77
78
79
80
81
82
83
84
85
86
87
88
89
90
          <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"
2e5b8dea   梁保满   分数设置修改,
91
92
93
94
95
            ><template slot-scope="scoped">{{
              `${scoped.row.participationRate}${
                scoped.row.participationRate ? "%" : ""
              }`
            }}</template></el-table-column
ce278878   梁保满   2-2 bugfix
96
          >
22095aba   梁保满   接口联调
97
  
ce278878   梁保满   2-2 bugfix
98
99
100
101
102
103
          <el-table-column
            prop="participationRateRank"
            label="总参与度班名"
            align="center"
          ></el-table-column>
          <el-table-column prop="correctRate" label="总正确率" align="center"
2e5b8dea   梁保满   分数设置修改,
104
105
106
            ><template slot-scope="scoped">{{
              `${scoped.row.correctRate}${scoped.row.correctRate ? "%" : ""}`
            }}</template></el-table-column
ce278878   梁保满   2-2 bugfix
107
108
109
110
111
112
113
114
115
116
117
          >
          <el-table-column
            prop="correctRateRank"
            label="总正确率班名"
            sortable
            align="center"
          ></el-table-column>
          <el-table-column
            prop="answerCorrectRate"
            label="已答正确率"
            align="center"
2e5b8dea   梁保满   分数设置修改,
118
119
120
121
122
            ><template slot-scope="scoped">{{
              `${scoped.row.answerCorrectRate}${
                scoped.row.answerCorrectRate ? "%" : ""
              }`
            }}</template></el-table-column
ce278878   梁保满   2-2 bugfix
123
          >
22095aba   梁保满   接口联调
124
125
          <el-table-column label="查看折线图" align="center">
            <template slot-scope="scoped">
ce278878   梁保满   2-2 bugfix
126
127
128
129
130
131
132
133
              <el-button
                @click="openLineChart(scoped.row)"
                type="primary"
                size="mini"
                circle
                icon="el-icon-arrow-right"
              ></el-button
            ></template>
d01c5799   梁保满   随堂问 报表开发
134
          </el-table-column>
22095aba   梁保满   接口联调
135
136
        </template>
        <template v-if="types == 3">
ce278878   梁保满   2-2 bugfix
137
138
139
140
141
142
143
144
145
146
147
          <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"
            >
22095aba   梁保满   接口联调
148
            </el-table-column>
ce278878   梁保满   2-2 bugfix
149
150
151
152
153
            <el-table-column
              align="center"
              :label="index == 0 ? '总出题数' : '出题数'"
              :prop="'questionNum' + item"
            >
22095aba   梁保满   接口联调
154
            </el-table-column>
ce278878   梁保满   2-2 bugfix
155
156
157
158
159
            <el-table-column
              align="center"
              :label="index == 0 ? '总参与度' : '参与度'"
              :prop="'participationRate' + item"
              ><template slot-scope="scoped"
2e5b8dea   梁保满   分数设置修改,
160
161
162
163
164
165
166
167
168
                >{{
                  `${
                    scoped.row["participationRate" + item]
                      ? scoped.row["participationRate" + item] + "%"
                      : ""
                  }
                `
                }}{{
              }}</template>
22095aba   梁保满   接口联调
169
            </el-table-column>
ce278878   梁保满   2-2 bugfix
170
171
172
173
            <el-table-column
              align="center"
              :label="index == 0 ? '总正确率' : '正确率'"
              :prop="'correctRate' + item"
2e5b8dea   梁保满   分数设置修改,
174
175
176
177
178
179
180
              ><template slot-scope="scoped">{{
                `${
                  scoped.row["correctRate" + item]
                    ? scoped.row["correctRate" + item] + "%"
                    : ""
                }`
              }}</template>
22095aba   梁保满   接口联调
181
            </el-table-column>
d01c5799   梁保满   随堂问 报表开发
182
          </el-table-column>
22095aba   梁保满   接口联调
183
184
          <el-table-column label="查看雷达图" align="center">
            <template slot-scope="scoped">
ce278878   梁保满   2-2 bugfix
185
186
187
188
189
190
191
192
              <el-button
                @click="openRandarChart(scoped.row)"
                type="primary"
                size="mini"
                circle
                icon="el-icon-arrow-right"
              ></el-button
            ></template>
d01c5799   梁保满   随堂问 报表开发
193
          </el-table-column>
22095aba   梁保满   接口联调
194
195
        </template>
      </el-table>
ce278878   梁保满   2-2 bugfix
196
197
198
199
200
201
      <el-dialog
        class="chart-dia"
        :visible.sync="chartDia"
        :title="chartTitle"
        width="800"
      >
22095aba   梁保满   接口联调
202
        <div class="chart-box">
ce278878   梁保满   2-2 bugfix
203
204
205
206
207
208
209
          <LineChart
            v-if="types == 2"
            id="askLineChart"
            :params="chartData"
            :xAxis="xAxis"
            :tooltipFormatter="true"
          />
2e5b8dea   梁保满   分数设置修改,
210
211
212
213
214
215
          <RadarChart
            v-if="types == 3"
            id="askRadarChart"
            :params="chartData"
            :tooltipFormatter="true"
          />
22095aba   梁保满   接口联调
216
217
218
        </div>
      </el-dialog>
    </div>
d01c5799   梁保满   随堂问 报表开发
219
220
  </template>
  <script>
ce278878   梁保满   2-2 bugfix
221
222
  import LineChart from "@/components/charts/lineChart";
  import RadarChart from "@/components/charts/radarChart";
d01c5799   梁保满   随堂问 报表开发
223
  export default {
22095aba   梁保满   接口联调
224
225
    components: {
      LineChart,
ce278878   梁保满   2-2 bugfix
226
      RadarChart,
22095aba   梁保满   接口联调
227
    },
d01c5799   梁保满   随堂问 报表开发
228
229
230
    props: {
      tableData: Array,
      types: Number,
22095aba   梁保满   接口联调
231
      subjectNames: Array,
d01c5799   梁保满   随堂问 报表开发
232
233
234
235
236
    },
    data() {
      return {
        optionsList: [],
        phaseOption: [], //问答补充数据
22095aba   梁保满   接口联调
237
238
239
240
241
242
  
        //折线图
        chartDia: false,
        chartTitle: "",
        xAxis: [],
        chartData: [],
d01c5799   梁保满   随堂问 报表开发
243
244
245
246
      };
    },
    computed: {
      resultData: function () {
ce278878   梁保满   2-2 bugfix
247
        let resultData = [];
d01c5799   梁保满   随堂问 报表开发
248
249
250
        if (this.tableData.length) {
          let optionsList = [];
          let subjectName = [];
e88ddd92   梁保满   随堂问多课时学生问答 总参与度以及...
251
          // let rank = {};
d01c5799   梁保满   随堂问 报表开发
252
253
254
255
          resultData = this.tableData.map((item) => {
            let params = {};
  
            if (this.types == 1) {
9865dde4   梁保满   数据同步
256
              const detail = item.detail ? JSON.parse(item.detail) : [];
d01c5799   梁保满   随堂问 报表开发
257
258
259
260
261
262
263
264
265
              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
ce278878   梁保满   2-2 bugfix
266
267
                    ? "✗"
                    : items.answer;
d01c5799   梁保满   随堂问 报表开发
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
              });
            } 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;
              });
            }
e88ddd92   梁保满   随堂问多课时学生问答 总参与度以及...
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
            // 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,
            //   };
            // }
d01c5799   梁保满   随堂问 报表开发
311
312
313
            return {
              ...item,
              ...params,
e88ddd92   梁保满   随堂问多课时学生问答 总参与度以及...
314
              // ...rank,
d01c5799   梁保满   随堂问 报表开发
315
316
317
318
319
            };
          });
          this.phaseOption = [...subjectName];
          this.optionsList = [...optionsList];
        } else {
ce278878   梁保满   2-2 bugfix
320
321
          resultData = [];
          this.optionsList = [];
d01c5799   梁保满   随堂问 报表开发
322
        }
ce278878   梁保满   2-2 bugfix
323
324
        return resultData;
      },
d01c5799   梁保满   随堂问 报表开发
325
    },
ce278878   梁保满   2-2 bugfix
326
    created() {},
d01c5799   梁保满   随堂问 报表开发
327
328
    methods: {
      setDuration(times) {
e17ec739   梁保满   随堂问,即时测导出爆表修改
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
        if (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}秒`;
            }
d01c5799   梁保满   随堂问 报表开发
344
          }
e17ec739   梁保满   随堂问,即时测导出爆表修改
345
          return aTime;
d01c5799   梁保满   随堂问 报表开发
346
        }
d01c5799   梁保满   随堂问 报表开发
347
      },
22095aba   梁保满   接口联调
348
349
      //查看折线图
      openLineChart(obj) {
ce278878   梁保满   2-2 bugfix
350
351
352
353
354
355
356
357
358
359
360
361
        this.chartTitle = `${obj.studentName}-${this.subjectNames[0]}-多课时作答表现图`;
        this.chartDia = true;
        let participationRate = [];
        let correctRate = [];
        let answerCorrectRate = [];
        let dataList = obj.dataList;
        this.xAxis = dataList.map((item) => {
          participationRate.push(item.participationRate);
          correctRate.push(item.correctRate);
          answerCorrectRate.push(item.answerCorrectRate);
          return item.name;
        });
22095aba   梁保满   接口联调
362
363
364
        this.chartData = [
          {
            name: "参与度",
ce278878   梁保满   2-2 bugfix
365
            value: participationRate,
22095aba   梁保满   接口联调
366
367
368
          },
          {
            name: "正确率",
ce278878   梁保满   2-2 bugfix
369
            value: correctRate,
22095aba   梁保满   接口联调
370
371
372
          },
          {
            name: "已答正确率",
ce278878   梁保满   2-2 bugfix
373
            value: answerCorrectRate,
22095aba   梁保满   接口联调
374
          },
ce278878   梁保满   2-2 bugfix
375
        ];
22095aba   梁保满   接口联调
376
377
      },
      openRandarChart(obj) {
5f80d60e   梁保满   备题试卷模版
378
379
380
        this.chartData = {
          indicator: [
            {
ce278878   梁保满   2-2 bugfix
381
382
              name: "",
              max: 100,
5f80d60e   梁保满   备题试卷模版
383
384
385
              axisLabel: {
                show: true,
                showMaxLabel: true,
ce278878   梁保满   2-2 bugfix
386
                formatter: "{value}%",
5f80d60e   梁保满   备题试卷模版
387
388
389
              },
            },
          ],
ce278878   梁保满   2-2 bugfix
390
391
392
393
394
          seriesData: [],
        };
        this.chartTitle = obj.studentName + "-多科-多课时作答表现图";
        let dataList = obj.dataList.slice(1, obj.dataList.length);
        let subjectList = dataList.map((item) => item.subjectName);
22095aba   梁保满   接口联调
395
396
        subjectList.map((item, index) => {
          if (index < 1) {
ce278878   梁保满   2-2 bugfix
397
            this.chartData.indicator[index].name = item;
22095aba   梁保满   接口联调
398
          } else {
ce278878   梁保满   2-2 bugfix
399
            this.chartData.indicator.push({ name: item, max: 100 });
22095aba   梁保满   接口联调
400
          }
ce278878   梁保满   2-2 bugfix
401
        });
22095aba   梁保满   接口联调
402
403
        // 为了美观
        if (this.chartData.indicator.length < 3) {
ce278878   梁保满   2-2 bugfix
404
          let num = this.chartData.indicator.length;
22095aba   梁保满   接口联调
405
406
          for (let i = 0; i < 6; i++) {
            if (i >= num) {
ce278878   梁保满   2-2 bugfix
407
              this.chartData.indicator.push({ name: "", max: 100 });
22095aba   梁保满   接口联调
408
409
410
            }
          }
        }
ce278878   梁保满   2-2 bugfix
411
412
        let participationRate = dataList.map((item) => item.participationRate);
        let correctRate = dataList.map((item) => item.correctRate);
22095aba   梁保满   接口联调
413
414
        this.chartData.seriesData = [
          {
5f80d60e   梁保满   备题试卷模版
415
            value: participationRate,
ce278878   梁保满   2-2 bugfix
416
            name: "参与度",
22095aba   梁保满   接口联调
417
418
          },
          {
5f80d60e   梁保满   备题试卷模版
419
            value: correctRate,
ce278878   梁保满   2-2 bugfix
420
            name: "正确率",
22095aba   梁保满   接口联调
421
          },
ce278878   梁保满   2-2 bugfix
422
423
        ];
        this.chartDia = true;
22095aba   梁保满   接口联调
424
      },
ce278878   梁保满   2-2 bugfix
425
    },
d01c5799   梁保满   随堂问 报表开发
426
427
  };
  </script>
22095aba   梁保满   接口联调
428
  <style lang="scss">
d01c5799   梁保满   随堂问 报表开发
429
430
431
  .red {
    color: #f30;
  }
22095aba   梁保满   接口联调
432
433
434
435
436
437
438
439
440
441
442
  
  .chart-dia {
    .chart-box {
      width: 100%;
      height: 300px;
    }
  
    :deep(.el-dialog__body) {
      padding: 0 0 20px 0;
    }
  }
d01c5799   梁保满   随堂问 报表开发
443
  </style>