|
@@ -27,7 +27,7 @@
|
|
return {
|
|
return {
|
|
isLoading: false,
|
|
isLoading: false,
|
|
acType: 0,
|
|
acType: 0,
|
|
- acId: '8942f69a-6f11-4fd4-936a-70d932e24f81'
|
|
|
|
|
|
+ acId: '5ed79799-4e2d-471e-a484-deedb81a8ad7'
|
|
};
|
|
};
|
|
},
|
|
},
|
|
created() {},
|
|
created() {},
|
|
@@ -43,7 +43,7 @@
|
|
this.doMockVote(this.acId)
|
|
this.doMockVote(this.acId)
|
|
break
|
|
break
|
|
case 2:
|
|
case 2:
|
|
- console.log(this.acType)
|
|
|
|
|
|
+ this.doMockQuestionnaire(this.acId)
|
|
break
|
|
break
|
|
case 3:
|
|
case 3:
|
|
this.doMockEvaluation(this.acId)
|
|
this.doMockEvaluation(this.acId)
|
|
@@ -125,7 +125,7 @@
|
|
result.push({
|
|
result.push({
|
|
id: acId,
|
|
id: acId,
|
|
code: i.code,
|
|
code: i.code,
|
|
- score: 88,
|
|
|
|
|
|
+ score: Mock.mock({"number|1-100": 100}).number,
|
|
content: [{
|
|
content: [{
|
|
answers: Mock.mock('@cparagraph(2)'),
|
|
answers: Mock.mock('@cparagraph(2)'),
|
|
resource: []
|
|
resource: []
|
|
@@ -179,6 +179,50 @@
|
|
this.isLoading = false
|
|
this.isLoading = false
|
|
})
|
|
})
|
|
},
|
|
},
|
|
|
|
+
|
|
|
|
+ /* 生成问卷活动学生作答数据 */
|
|
|
|
+ async doMockQuestionnaire(acId) {
|
|
|
|
+ let result = []
|
|
|
|
+ // 拿到班级Code去换取学生名单
|
|
|
|
+ let qnItem = await this.getQuestionnaireInfo(acId)
|
|
|
|
+ let classCodeArr = qnItem.target.map(i => i.classroomCode)
|
|
|
|
+ let arr = await this.getStudentList(classCodeArr)
|
|
|
|
+ console.log(arr)
|
|
|
|
+ // 遍历随机赋值作答数据
|
|
|
|
+ arr.forEach(i => {
|
|
|
|
+ result.push({
|
|
|
|
+ id: acId,
|
|
|
|
+ code: i.code,
|
|
|
|
+ classroom:{
|
|
|
|
+ name:qnItem.target.filter(j => j.classroomCode === i.id)[0].classroomName ,
|
|
|
|
+ code:i.id
|
|
|
|
+ },
|
|
|
|
+ submit: true,
|
|
|
|
+ submitTime: new Date(Mock.mock('@datetime')).getTime(),
|
|
|
|
+ answers:[]
|
|
|
|
+ })
|
|
|
|
+ })
|
|
|
|
+
|
|
|
|
+ qnItem.items.forEach((item,index) => {
|
|
|
|
+ result.forEach((i) => {
|
|
|
|
+ i.answers.push({
|
|
|
|
+ order:i.answers.length,
|
|
|
|
+ answer:this.randomQnAnswer(item)
|
|
|
|
+ })
|
|
|
|
+ })
|
|
|
|
+ })
|
|
|
|
+
|
|
|
|
+ // 保存模拟数据
|
|
|
|
+ this.$api.questionnaire.UpsertRecord(result).then(res => {
|
|
|
|
+ if (!res.error && res.result.data) {
|
|
|
|
+ this.$Message.success('保存成功!')
|
|
|
|
+ this.$emit('onSuccess')
|
|
|
|
+ } else {
|
|
|
|
+ this.$Message.error('保存失败!')
|
|
|
|
+ }
|
|
|
|
+ this.isLoading = false
|
|
|
|
+ })
|
|
|
|
+ },
|
|
|
|
|
|
/* 获取当前活动下的发布对象CODE */
|
|
/* 获取当前活动下的发布对象CODE */
|
|
async getHomeWorkClass(id) {
|
|
async getHomeWorkClass(id) {
|
|
@@ -209,6 +253,21 @@
|
|
})
|
|
})
|
|
})
|
|
})
|
|
},
|
|
},
|
|
|
|
+
|
|
|
|
+ /* 获取当前活动下的发布对象CODE */
|
|
|
|
+ async getQuestionnaireInfo(id) {
|
|
|
|
+ return new Promise((r, j) => {
|
|
|
|
+ this.$api.questionnaire.FindSurveys({
|
|
|
|
+ id: id
|
|
|
|
+ }).then(res => {
|
|
|
|
+ if (!res.error && res.result.data) {
|
|
|
|
+ r(res.result.data[0])
|
|
|
|
+ } else {
|
|
|
|
+ j(500)
|
|
|
|
+ }
|
|
|
|
+ })
|
|
|
|
+ })
|
|
|
|
+ },
|
|
|
|
|
|
/* 获取班级下面所有的学生清单 */
|
|
/* 获取班级下面所有的学生清单 */
|
|
async getStudentList(classCodeList) {
|
|
async getStudentList(classCodeList) {
|
|
@@ -291,6 +350,24 @@
|
|
break;
|
|
break;
|
|
}
|
|
}
|
|
},
|
|
},
|
|
|
|
+ /* 根据题型生成随机答案 */
|
|
|
|
+ randomQnAnswer(item) {
|
|
|
|
+ switch (item.type) {
|
|
|
|
+ case 'Single':
|
|
|
|
+ return [item.options[Math.floor(Math.random() * item.options.length)].code]
|
|
|
|
+ break;
|
|
|
|
+ case 'Multiple':
|
|
|
|
+ return [item.options[Math.floor(Math.random() * item.options.length)].code]
|
|
|
|
+ break;
|
|
|
|
+ case 'Judge':
|
|
|
|
+ let arr = ['A','B']
|
|
|
|
+ return [arr[Math.floor(Math.random() * 2)]]
|
|
|
|
+ break;
|
|
|
|
+ default:
|
|
|
|
+ return Mock.mock('@cparagraph(2)')
|
|
|
|
+ break;
|
|
|
|
+ }
|
|
|
|
+ },
|
|
},
|
|
},
|
|
mounted() {}
|
|
mounted() {}
|
|
};
|
|
};
|