Prechádzať zdrojové kódy

Merge branch 'develop3.0' of http://106.12.23.251:10080/TEAMMODEL/TEAMModelOS into develop3.0

liqk 4 rokov pred
rodič
commit
20372fa929

+ 4 - 0
TEAMModelOS/ClientApp/src/api/questionnaire.js

@@ -24,4 +24,8 @@ export default {
 	FindRecordSurvey: function(data) {
 	FindRecordSurvey: function(data) {
 	    return post('/api/Survey/findRecord', data)
 	    return post('/api/Survey/findRecord', data)
 	},
 	},
+	// 查询问卷作答记录
+	UpsertRecord: function(data) {
+	    return post('/api/Survey/upsertRecord', data)
+	},
 }
 }

+ 80 - 3
TEAMModelOS/ClientApp/src/common/BaseMock.vue

@@ -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() {}
 	};
 	};

+ 1 - 1
TEAMModelOS/ClientApp/src/components/learnactivity/BaseHwTable.vue

@@ -262,7 +262,7 @@
                                         that.setScoreModal = true
                                         that.setScoreModal = true
                                     }
                                     }
                                 },
                                 },
-                            }, params.row.teacherComments.comment)
+                            }, params.row.teacherComments ? params.row.teacherComments.comment : '')
                         }
                         }
                     },
                     },
                     {
                     {

+ 24 - 0
TEAMModelOS/ClientApp/src/view/questionnaire/ManageQuestionnaire.vue

@@ -123,6 +123,7 @@
 				currentQn: {
 				currentQn: {
 					status: 100
 					status: 100
 				},
 				},
+				currentRecord:null,
 				editItem: {},
 				editItem: {},
 				activeQnIndex: null,
 				activeQnIndex: null,
 				addQnModal: false,
 				addQnModal: false,
@@ -245,6 +246,9 @@
 						this.qnList.splice(this.qnList.indexOf(item), 1)
 						this.qnList.splice(this.qnList.indexOf(item), 1)
 					})
 					})
 				}
 				}
+				// 如果当前点击活动是已结束 则获取问卷的作答数据
+				this.currentRecord = item.status === 300 && item.id ? await this.getQnRecord(item.id) : null
+				this.currentRecord && this.makeItemResult(this.currentRecord)
 				this.currentQn = item.id ? await this.getQnDetails(item.id) : this.currentQn
 				this.currentQn = item.id ? await this.getQnDetails(item.id) : this.currentQn
 				this.activeQnIndex = hasNewQn ? this.qnList.indexOf(item) : index
 				this.activeQnIndex = hasNewQn ? this.qnList.indexOf(item) : index
 				this.$refs.qnForm.qnFormEdit = false
 				this.$refs.qnForm.qnFormEdit = false
@@ -280,6 +284,26 @@
 			onAddItem(name) {
 			onAddItem(name) {
 				this.$refs.qnPaper.onMenuClick(name)
 				this.$refs.qnPaper.onMenuClick(name)
 			},
 			},
+			
+			async getQnRecord(id){
+				return new Promise((r, j) => {
+					this.$api.questionnaire.FindRecordSurvey({
+						id: id
+					}).then(res => {
+						if (!res.error && res.result.data) {
+							r(res.result.data)
+						} else {
+							j(500)
+						}
+					})
+				})
+			},
+			
+			/* 根据学生的作答记录 处理成 图表需要的记录 */
+			makeItemResult(result){
+				console.log(result)
+				console.log(this.currentQn.items)
+			},
 
 
 			/**
 			/**
 			 * 新增问卷或者编辑问卷
 			 * 新增问卷或者编辑问卷

+ 1 - 1
TEAMModelOS/ClientApp/src/view/selflearning/ManageHomeWork.vue

@@ -250,7 +250,7 @@
 									} else {
 									} else {
 										i.submissionBool = false
 										i.submissionBool = false
 										i.submissionTime = null
 										i.submissionTime = null
-										i.teacherComments = []
+										i.teacherComments = null
 										i.studentComments = []
 										i.studentComments = []
 										i.score = 0
 										i.score = 0
 										i.content = []
 										i.content = []