Blame view

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