杨磊
12 分钟以前 32702d7bf48ed961e8f89f487fb5de264b7649cc
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
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
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
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
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
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
<template>
  <div class="classManagePage-box">
    <div class="classManagePage-nav">
      <el-breadcrumb :separator-icon="ArrowRight">
        <el-breadcrumb-item>我的班级</el-breadcrumb-item>
        <el-breadcrumb-item>{{ classInfo?.name }}</el-breadcrumb-item>
        <el-breadcrumb-item>互动学生列表</el-breadcrumb-item>
      </el-breadcrumb>
    </div>
    <div class="classManagePage-content">
      <div class="backBtn">
        <el-button @click="goBack()" type="primary" link>
          <el-icon style="margin-right: 5px"><ArrowLeftBold /></el-icon> 返回
        </el-button>
      </div>
      <div class="contentBox">
        <div class="titleOptions">
          <span>互动学生列表</span>
        </div>
        <div class="content-tab-box">
          <div class="content-list-box">
            <el-table
              :header-cell-style="{ background: '#eee' }"
              :data="dataList"
              max-height="600px"
              style="width: 100%"
              v-loading="pages.loading"
            >
              <el-table-column prop="index" label="序号" width="70" />
              <el-table-column prop="userName" label="姓名" width="500" />
              <el-table-column label="状态">
                <el-button link type="success">已完成</el-button>
              </el-table-column>
              <el-table-column prop="questionTime" label="答题时间" />
              <el-table-column label="操作" #default="scoped">
                <el-button link type="primary" @click="getQuestions(scoped.row)">
                  答题详情
                </el-button>
              </el-table-column>
            </el-table>
            <div class="pageBox">
              <el-pagination
                style="float: right"
                v-model:current-page="pages.currentPage"
                :page-size="pages.pageSize"
                :size="'small'"
                :disabled="pages.count <= 1"
                layout="total, prev, pager, next"
                :total="pages.count"
                @size-change="handleSizeChange"
                @current-change="handleCurrentChange"
              />
            </div>
          </div>
        </div>
      </div>
      <!-- 浏览答题 -->
      <el-dialog
        class="customDialog"
        title="浏览答题"
        v-model="visible"
        destroy-on-close
        width="1000"
        align-center
      >
        <div class="pubContent" v-if="dialogList.length > 0 && !dialogLLoading">
          <div v-for="(item, index) in dialogList" :key="index">
            <span class="userName">答题人:{{ item.userName ?? '-' }}</span>
            <question-dom
              v-if="item.questionTypeList.length > 0"
              :questionList="item.questionTypeList"
              :noCheckbox="false"
              :is-preview="true"
              :is-interaction="true"
            />
          </div>
        </div>
        <div class="pubContent" v-if="dialogLLoading" v-loading="dialogLLoading"></div>
        <div class="pubContent noData" v-if="dialogList.length == 0 && !dialogLLoading">
          <el-empty></el-empty>
        </div>
        <template #footer>
          <div class="selectedFooter" style="padding: 0">
            <el-button type="primary" @click="visible = false"> 关闭 </el-button>
          </div>
        </template>
      </el-dialog>
    </div>
  </div>
</template>
<script setup lang="ts">
import { useRoute, useRouter } from 'vue-router'
import { inject, onMounted, reactive, ref } from 'vue'
import { Search, UserFilled, ArrowRight } from '@element-plus/icons-vue'
import { ElMessage } from 'element-plus'
import moment from 'moment'
import questionDom from './components/questionDom.vue'
 
const route: any = useRoute()
const router = useRouter()
const classInfo = JSON.parse(route.query.classInfo)
const MG: any = inject('MG')
const config: any = inject('config')
const tool: any = inject('toolClass')
 
const dataList = ref([])
let pages = reactive({
  currentPage: 1,
  page: 1,
  pageSize: 15,
  count: 0,
  loading: false
})
 
const visible = ref(false)
const dialogList: any = ref([])
const dialogLLoading = ref(false)
const defaultCmsPath = ref('')
 
const handleDelete = (item: any) => {
  const data = {
    messageIds: [item.id]
  }
  MG.ugc.delTopicMessage(data).then((res: any) => {
    ElMessage.success('删除成功')
    getMessage()
  })
}
 
// 获取当前话题
const getMessage = () => {
  pages.loading = true
  const data = {
    start: (pages.page - 1) * pages.pageSize,
    size: pages.pageSize,
    appRefCode: config.appRefCode,
    topicIdOrRefCode: String(classInfo.teachInteractionId),
    sort: {
      type: 'Desc',
      field: 'CreateDate'
    },
    searchList: [
      {
        keywords: classInfo.questionName,
        field: 'Name',
        compareType: 'Contains'
      }
    ]
  }
  MG.ugc.getTopicMessageList(data).then((res: any) => {
    pages.loading = false
    pages.count = res.totalSize
    dataList.value = res.datas.map((item: any, i: number) => {
      item.question = []
      item.bookId = null
      item.path = ''
      item.index = i + 1
      try {
        const obj = JSON.parse(item.content)
        if (obj.bookId) {
          item.question = obj.content
          item.bookId = obj.bookId
          item.path = obj.path
          item.userName = obj.userName ?? '-'
        }
      } catch (error) {
        console.log(item)
      }
      return {
        ...item,
        questionTime: moment(item.updateDate).format('YYYY-MM-DD HH:mm:ss')
      }
    })
  })
}
 
//  分页
const handleSizeChange = (val: number) => {
  pages.pageSize = val
  getMessage()
}
 
const handleCurrentChange = (val: number) => {
  pages.page = val
  pages.currentPage = val
  getMessage()
}
 
onMounted(() => {
  defaultCmsPath.value = classInfo.bookRefCode ? '*' : 'defaultGoodsStore3'
  getMessage()
})
 
// 获取题目列表
const getQuestions = (item: any) => {
  visible.value = true
  dialogLLoading.value = true
  MG.store
    .getProductDetail({
      path: defaultCmsPath.value,
      queryType: '*',
      productId: classInfo.bookId,
      cmsPath: item.path,
      itemFields: {
        Embedded_QuestionBank_AnalysisCon: [],
        Embedded_QuestionBank_Answer: [],
        Embedded_QuestionBank_Difficulty: [],
        Embedded_QuestionBank_KnowledgePoint: [],
        Embedded_QuestionBank_Option: [],
        Embedded_QuestionBank_OptionStyle: [],
        Embedded_QuestionBank_QuestionType: [],
        Embedded_QuestionBank_Score: [],
        Embedded_QuestionBank_Stem: [],
        Embedded_QuestionBank_StemStyle: []
      }
    })
    .then((res: any) => {
      try {
        let list = []
        list = res.datas.cmsDatas[0]?.datas.map((item: any) => {
          try {
            if (item.Embedded_QuestionBank_Stem) {
              item.questionStem = JSON.parse(item.Embedded_QuestionBank_Stem)
            }
            if (
              item.Embedded_QuestionBank_Option &&
              item.Embedded_QuestionBank_Option.indexOf('[') > -1
            ) {
              item.questionOption = JSON.parse(item.Embedded_QuestionBank_Option)
            }
            if (
              item.Embedded_QuestionBank_Answer &&
              item.Embedded_QuestionBank_Answer.indexOf('[') > -1
            ) {
              item.Embedded_QuestionBank_Answer = JSON.parse(item.Embedded_QuestionBank_Answer)
            }
            return {
              ...item,
              questionType: item.Embedded_QuestionBank_QuestionType,
              questionAnalysisCon: item.Embedded_QuestionBank_AnalysisCon,
              questionAnswer: item.Embedded_QuestionBank_Answer,
              customAnswer: null
            }
          } catch (error) {
            console.log(item)
          }
        })
        dialogList.value = chageData([item], list)
        dialogLLoading.value = false
      } catch (error) {
        dialogList.value = []
        dialogLLoading.value = false
      }
    })
}
 
// 处理数据结构
const chageData = (arr: any, zrr: any) => {
  let newData = []
  // 题库题目类型
  const questionTypeList = [
    { name: '单选题', value: 'singleChoice', data: [] },
    { name: '多选题', value: 'multipleChoice', data: [] },
    { name: '判断题', value: 'judge', data: [] },
    { name: '简答题', value: 'shortAnswer', data: [] },
    { name: '论述题', value: 'discuss', data: [] },
    { name: '填空题', value: 'completion', data: [] },
    { name: '连线题', value: 'matching', data: [] },
    { name: '分类题', value: 'classification', data: [] }
  ]
  for (let i = 0; i < arr.length; i++) {
    const item = arr[i]
    item.questionTypeList = JSON.parse(JSON.stringify(questionTypeList))
    for (let j = 0; j < zrr.length; j++) {
      const ele = zrr[j]
      const qusObj = item.question.find((citem: any) => citem.cmsItemId == ele.id)
      if (qusObj?.cmsItemId) {
        ele.userAnswer = qusObj.answer
        const index = findIndexByValue(questionTypeList, ele.questionType)
        if (index > -1) {
          item.questionTypeList[index].data.push(ele)
        }
      }
    }
    item.questionTypeList = item.questionTypeList.filter((item: any) => item.data.length > 0)
    newData.push(item)
  }
  return newData.filter((item) => item.questionTypeList.length > 0)
}
 
const findIndexByValue = (res: any, type: string) => {
  for (let i = 0; i < res.length; i++) {
    if (res[i].value == type) {
      return i
    }
  }
  return -1 // 如果未找到,则返回 -1
}
 
// 作业搜索
const searchData = () => {}
 
const goBack = () => {
  router.go(-1)
}
</script>
<style lang="less" scoped>
.classManagePage-box {
  background: #fff;
 
  .classManagePage-nav {
    width: 100%;
    padding: 0 20px;
    height: 40px;
    border-bottom: 1px solid #e6e8ed;
    position: sticky;
    top: 0;
    z-index: 999;
    display: flex;
    align-items: center;
    background: #fff;
  }
  .classManagePage-content {
    width: 100%;
    position: relative;
    .backBtn {
      width: 100%;
      height: 45px;
      margin-bottom: 10px;
      padding: 0 20px;
      display: flex;
      align-items: center;
      position: sticky;
      top: 40px;
      z-index: 99;
      background: #fff;
      box-shadow: 0px 0px 20px 1px #eeeeee83;
      box-sizing: border-box;
    }
    .contentBox {
      width: 100%;
      padding: 0 20px;
      box-sizing: border-box;
      .titleOptions {
        width: 160px;
        display: flex;
        justify-content: space-between;
        align-items: center;
        margin-bottom: 20px;
        span {
          height: 30px;
          font-family: PingFang SC;
          font-weight: bold;
          font-size: 16px;
          color: #333;
          line-height: 30px;
          text-align: left;
          border-left: 6px solid #019e58;
          padding-left: 10px;
        }
      }
    }
    .pubContent {
      padding: 10px;
      box-sizing: border-box;
      min-height: 750px;
      .userName {
        color: #019e58;
      }
    }
  }
}
</style>