|
@@ -241,24 +241,46 @@
|
|
|
},
|
|
|
|
|
|
/* 获取正在进行中的投票活动的投票数据 */
|
|
|
- getVoteRecord(voteItem){
|
|
|
- return new Promise((r,j) => {
|
|
|
- this.$api.learnActivity.FindVoteRecord({
|
|
|
- id: voteItem.id,
|
|
|
- code: voteItem.code,
|
|
|
- }).then(res => {
|
|
|
- if(!res.error){
|
|
|
- r(res)
|
|
|
+ async getVoteRecord(voteItem){
|
|
|
+ return new Promise(async (r,j) => {
|
|
|
+ // 如果是进行中的活动 则从cosmos获取实时作答数据
|
|
|
+ if(voteItem.progress === 'going'){
|
|
|
+ this.$api.learnActivity.FindVoteRecord({
|
|
|
+ id: voteItem.id,
|
|
|
+ code: voteItem.code,
|
|
|
+ }).then(res => {
|
|
|
+ if(!res.error){
|
|
|
+ r(res)
|
|
|
+ }
|
|
|
+ }).catch(err => {
|
|
|
+ j(err)
|
|
|
+ })
|
|
|
+ }else{ // 如果是已结束的活动 则从blob读取作答数据
|
|
|
+ try{
|
|
|
+ let curItemRecord = await this.getBlobJsonFile(voteItem.scope,voteItem.recordUrl)
|
|
|
+ r(curItemRecord)
|
|
|
+ }catch(e){
|
|
|
+ j(e)
|
|
|
}
|
|
|
- }).catch(err => {
|
|
|
- j(err)
|
|
|
- })
|
|
|
+ }
|
|
|
+
|
|
|
})
|
|
|
},
|
|
|
|
|
|
/* 根据已结束的RecordUrl来获取投票结果数据 */
|
|
|
- getRecordUrlData(){
|
|
|
-
|
|
|
+ getBlobJsonFile(scope,url){
|
|
|
+ return new Promise(async (resolve,reject) => {
|
|
|
+ let blobHost = scope === 'private' ? JSON.parse(decodeURIComponent(localStorage.user_profile, "utf-8")).blob_uri : JSON.parse(decodeURIComponent(localStorage.school_profile, "utf-8")).blob_uri
|
|
|
+ // 根据试卷的Blob地址 去读取JSON文件
|
|
|
+ let sasString = scope === 'private' ? await this.$tools.getPrivateSas() : await this.$tools.getSchoolSas()
|
|
|
+ try{
|
|
|
+ let itemJson = JSON.parse(await this.$tools.getFile(blobHost + url + sasString.sas))
|
|
|
+ resolve(itemJson)
|
|
|
+ }catch(e){
|
|
|
+ this.$Message.error('文件获取失败!')
|
|
|
+ reject(e)
|
|
|
+ }
|
|
|
+ })
|
|
|
},
|
|
|
|
|
|
|
|
@@ -325,7 +347,7 @@
|
|
|
this.isLoading = true
|
|
|
let records = await this.getVoteRecord(voteItem)
|
|
|
// 先查找 投票发布对象关联的学生清单 然后再去判断学生的作答情况
|
|
|
- console.log(voteItem)
|
|
|
+ console.log('当前投票的作答数据======',records)
|
|
|
this.$api.schoolSetting.getClassroomStudent({
|
|
|
school_code: this.$store.state.userInfo.schoolCode,
|
|
|
ids: voteItem.classes,
|
|
@@ -339,7 +361,7 @@
|
|
|
id: i.id,
|
|
|
name: i.name,
|
|
|
no: i.no,
|
|
|
- classroomName: i.classId
|
|
|
+ classroomName: i.className
|
|
|
})
|
|
|
})
|
|
|
})
|
|
@@ -363,16 +385,15 @@
|
|
|
console.log(this.studentsTable)
|
|
|
this.tableData = arr
|
|
|
} else {
|
|
|
+ this.studentsTable = []
|
|
|
this.tableData = []
|
|
|
}
|
|
|
- this.isLoading = false
|
|
|
} else {
|
|
|
this.$Message.error(this.$t('vote.getDataFailTip'))
|
|
|
- this.isLoading = false
|
|
|
}
|
|
|
}).catch(err => {
|
|
|
- console.log(err)
|
|
|
this.$Message.error(this.$t('vote.getClassDataFailTip'))
|
|
|
+ }).finally(() => {
|
|
|
this.isLoading = false
|
|
|
})
|
|
|
},
|