소스 검색

1、新增直播完课答题记录

yys 3 일 전
부모
커밋
370713ccb0
2개의 변경된 파일307개의 추가작업 그리고 0개의 파일을 삭제
  1. 27 0
      src/api/live/liveCompletionAnswerRecord.js
  2. 280 0
      src/views/live/liveCompletionAnswerRecord/index.vue

+ 27 - 0
src/api/live/liveCompletionAnswerRecord.js

@@ -0,0 +1,27 @@
+import request from '@/utils/request'
+
+// 查询直播完课答题记录列表
+export function listLiveCompletionAnswerRecord(query) {
+  return request({
+    url: '/live/liveCompletionAnswerRecord/list',
+    method: 'get',
+    params: query
+  })
+}
+
+// 查询直播完课答题记录详细
+export function getLiveCompletionAnswerRecord(id) {
+  return request({
+    url: '/live/liveCompletionAnswerRecord/' + id,
+    method: 'get'
+  })
+}
+
+// 导出直播完课答题记录
+export function exportLiveCompletionAnswerRecord(query) {
+  return request({
+    url: '/live/liveCompletionAnswerRecord/export',
+    method: 'get',
+    params: query
+  })
+}

+ 280 - 0
src/views/live/liveCompletionAnswerRecord/index.vue

@@ -0,0 +1,280 @@
+<template>
+  <div class="app-container">
+    <el-form :model="queryParams" ref="queryForm" :inline="true" v-show="showSearch" label-width="100px">
+      <el-form-item label="直播间ID" prop="liveId">
+        <el-input
+          v-model="queryParams.liveId"
+          placeholder="请输入直播间ID"
+          clearable
+          size="small"
+          @keyup.enter.native="handleQuery"
+        />
+      </el-form-item>
+      <el-form-item label="用户ID" prop="userId">
+        <el-input
+          v-model="queryParams.userId"
+          placeholder="请输入用户ID"
+          clearable
+          size="small"
+          @keyup.enter.native="handleQuery"
+        />
+      </el-form-item>
+      <el-form-item label="用户名称" prop="userName">
+        <el-input
+          v-model="queryParams.userName"
+          placeholder="请输入用户名称"
+          clearable
+          size="small"
+          @keyup.enter.native="handleQuery"
+        />
+      </el-form-item>
+      <el-form-item label="是否全部正确" prop="isRight">
+        <el-select v-model="queryParams.isRight" placeholder="请选择" clearable size="small">
+          <el-option label="是" :value="1" />
+          <el-option label="否" :value="0" />
+        </el-select>
+      </el-form-item>
+      <el-form-item label="答题时间">
+        <el-date-picker
+          v-model="createTimeRange"
+          size="small"
+          style="width: 340px"
+          value-format="yyyy-MM-dd HH:mm:ss"
+          type="datetimerange"
+          range-separator="-"
+          start-placeholder="开始时间"
+          end-placeholder="结束时间"
+          @change="handleTimeChange"
+        />
+      </el-form-item>
+      <el-form-item>
+        <el-button type="primary" icon="el-icon-search" size="mini" @click="handleQuery">搜索</el-button>
+        <el-button icon="el-icon-refresh" size="mini" @click="resetQuery">重置</el-button>
+      </el-form-item>
+    </el-form>
+
+    <el-row :gutter="10" class="mb8">
+      <el-col :span="1.5">
+        <el-button
+          type="warning"
+          plain
+          icon="el-icon-download"
+          size="mini"
+          :loading="exportLoading"
+          @click="handleExport"
+          v-hasPermi="['live:liveCompletionAnswerRecord:export']"
+        >导出</el-button>
+      </el-col>
+      <right-toolbar :showSearch.sync="showSearch" @queryTable="getList"></right-toolbar>
+    </el-row>
+
+    <el-table border v-loading="loading" :data="recordList">
+      <el-table-column label="序号" align="center" type="index" width="60" />
+      <el-table-column label="记录ID" align="center" prop="id" width="90" />
+      <el-table-column label="直播ID" align="center" prop="liveId" width="120" />
+      <el-table-column label="直播名称" align="center" prop="liveName" min-width="160" show-overflow-tooltip />
+      <el-table-column label="用户ID" align="center" prop="userId" width="120" />
+      <el-table-column label="用户名称" align="center" prop="userName" width="150" show-overflow-tooltip />
+      <el-table-column label="是否全部正确" align="center" prop="isRight" width="120">
+        <template slot-scope="scope">
+          <el-tag :type="scope.row.isRight === 1 ? 'success' : 'danger'">
+            {{ scope.row.isRight === 1 ? '是' : '否' }}
+          </el-tag>
+        </template>
+      </el-table-column>
+      <el-table-column label="答题时间" align="center" prop="createTime" width="180">
+        <template slot-scope="scope">
+          <span>{{ parseTime(scope.row.createTime, '{y}-{m}-{d} {h}:{i}:{s}') }}</span>
+        </template>
+      </el-table-column>
+      <el-table-column label="操作" align="center" width="100" fixed="right">
+        <template slot-scope="scope">
+          <el-button
+            size="mini"
+            type="text"
+            icon="el-icon-view"
+            @click="handleView(scope.row)"
+            v-hasPermi="['live:liveCompletionAnswerRecord:query']"
+          >详情</el-button>
+        </template>
+      </el-table-column>
+    </el-table>
+
+    <pagination
+      v-show="total > 0"
+      :total="total"
+      :page.sync="queryParams.pageNum"
+      :limit.sync="queryParams.pageSize"
+      @pagination="getList"
+    />
+
+    <el-dialog title="答题详情" :visible.sync="detailOpen" width="860px" append-to-body>
+      <el-descriptions :column="2" border size="small">
+        <el-descriptions-item label="记录ID">{{ detail.id }}</el-descriptions-item>
+        <el-descriptions-item label="直播ID">{{ detail.liveId }}</el-descriptions-item>
+        <el-descriptions-item label="直播名称">{{ detail.liveName }}</el-descriptions-item>
+        <el-descriptions-item label="用户ID">{{ detail.userId }}</el-descriptions-item>
+        <el-descriptions-item label="用户名称">{{ detail.userName }}</el-descriptions-item>
+        <el-descriptions-item label="是否全部正确">
+          <el-tag :type="detail.isRight === 1 ? 'success' : 'danger'">
+            {{ detail.isRight === 1 ? '是' : '否' }}
+          </el-tag>
+        </el-descriptions-item>
+        <el-descriptions-item label="答题时间" :span="2">
+          {{ parseTime(detail.createTime, '{y}-{m}-{d} {h}:{i}:{s}') }}
+        </el-descriptions-item>
+      </el-descriptions>
+
+      <div class="answer-json-title">答题明细</div>
+      <el-table v-if="questionDetailList.length" :data="questionDetailList" border size="small">
+        <el-table-column label="题干" prop="title" min-width="200" show-overflow-tooltip />
+        <el-table-column label="题型" width="80" align="center">
+          <template slot-scope="scope">{{ scope.row.type === 2 ? '多选' : '单选' }}</template>
+        </el-table-column>
+        <el-table-column label="用户答案" prop="userAnswer" min-width="120" show-overflow-tooltip />
+        <el-table-column label="正确答案" prop="correctAnswer" min-width="120" show-overflow-tooltip />
+        <el-table-column label="结果" width="80" align="center">
+          <template slot-scope="scope">
+            <el-tag :type="scope.row.isRight === 1 ? 'success' : 'danger'" size="mini">
+              {{ scope.row.isRight === 1 ? '正确' : '错误' }}
+            </el-tag>
+          </template>
+        </el-table-column>
+      </el-table>
+      <pre v-else class="answer-json">{{ formatAnswerJson(detail.answerJson) }}</pre>
+    </el-dialog>
+  </div>
+</template>
+
+<script>
+import {
+  listLiveCompletionAnswerRecord,
+  getLiveCompletionAnswerRecord,
+  exportLiveCompletionAnswerRecord
+} from '@/api/live/liveCompletionAnswerRecord'
+
+export default {
+  name: 'LiveCompletionAnswerRecord',
+  data() {
+    return {
+      loading: true,
+      exportLoading: false,
+      showSearch: true,
+      total: 0,
+      recordList: [],
+      createTimeRange: [],
+      detailOpen: false,
+      detail: {},
+      questionDetailList: [],
+      queryParams: {
+        pageNum: 1,
+        pageSize: 10,
+        liveId: null,
+        userId: null,
+        userName: null,
+        isRight: null,
+        beginTime: null,
+        endTime: null
+      }
+    }
+  },
+  created() {
+    this.getList()
+  },
+  methods: {
+    getList() {
+      this.loading = true
+      listLiveCompletionAnswerRecord(this.queryParams).then(response => {
+        this.recordList = response.rows
+        this.total = response.total
+        this.loading = false
+      }).catch(() => {
+        this.loading = false
+      })
+    },
+    handleQuery() {
+      this.queryParams.pageNum = 1
+      this.getList()
+    },
+    resetQuery() {
+      this.createTimeRange = []
+      this.queryParams.beginTime = null
+      this.queryParams.endTime = null
+      this.resetForm('queryForm')
+      this.handleQuery()
+    },
+    handleTimeChange(value) {
+      if (value && value.length === 2) {
+        this.queryParams.beginTime = value[0]
+        this.queryParams.endTime = value[1]
+      } else {
+        this.queryParams.beginTime = null
+        this.queryParams.endTime = null
+      }
+    },
+    handleView(row) {
+      getLiveCompletionAnswerRecord(row.id).then(response => {
+        this.detail = response.data || {}
+        this.questionDetailList = this.parseQuestionDetailList(this.detail.questionJson)
+        this.detailOpen = true
+      })
+    },
+    parseQuestionDetailList(questionJson) {
+      if (!questionJson) {
+        return []
+      }
+      try {
+        const list = JSON.parse(questionJson)
+        return Array.isArray(list) ? list : []
+      } catch (e) {
+        return []
+      }
+    },
+    formatAnswerJson(answerJson) {
+      if (!answerJson) {
+        return '-'
+      }
+      try {
+        return JSON.stringify(JSON.parse(answerJson), null, 2)
+      } catch (e) {
+        return answerJson
+      }
+    },
+    handleExport() {
+      this.$confirm('是否确认导出完课答题记录?', '警告', {
+        confirmButtonText: '确定',
+        cancelButtonText: '取消',
+        type: 'warning'
+      }).then(() => {
+        this.exportLoading = true
+        return exportLiveCompletionAnswerRecord(this.queryParams)
+      }).then(response => {
+        this.download(response.msg)
+        this.exportLoading = false
+      }).catch(() => {
+        this.exportLoading = false
+      })
+    }
+  }
+}
+</script>
+
+<style scoped>
+.answer-json-title {
+  margin: 16px 0 8px;
+  font-weight: 600;
+  color: #303133;
+}
+
+.answer-json {
+  max-height: 320px;
+  overflow: auto;
+  padding: 12px;
+  background: #f5f7fa;
+  border-radius: 4px;
+  white-space: pre-wrap;
+  word-break: break-all;
+  font-size: 12px;
+  line-height: 1.6;
+}
+</style>