Explorar el Código

问卷和投票的作答数据接口对接

OnePsycho hace 3 años
padre
commit
af789f4db7

+ 26 - 43
TEAMModelOS/ClientApp/src/components/questionnaire/BaseQuestionnaire.vue

@@ -35,7 +35,7 @@
 							<transition name="indexFade">
 							      <div>
 									  <!-- <BaseQnBar :barId="'bar' + index" :barData="item.result || []" v-if="curIndexList.includes(index) && item.type !== 'subjective'"></BaseQnBar> -->
-									  <BaseAnsList v-if="curIndexList.includes(index) && item.type === 'subjective'" :ansList="item.result.details"></BaseAnsList>
+									  <BaseAnsList v-if="curIndexList.includes(index) && currentQn.progress !== 'pending' && item.type === 'subjective'" :ansList="item.result.details"></BaseAnsList>
 								  </div>
 							</transition>
 							<!-- 工具栏 -->
@@ -49,13 +49,13 @@
 									<span>{{ $t('survey.questionaire.remove') }}</span>
 								</div>
 								<!-- <div class="qn-tools-item" @click="onItemAnalysis(index)"> -->
-								<div class="qn-tools-item" @click="onItemAnalysis(index,item)" v-if="currentQn.progress === 'finish' && item.type === 'subjective'">
+								<div class="qn-tools-item" @click="onItemAnalysis(index,item)" v-if="currentQn.progress !== 'pending' && item.type === 'subjective'">
 									<Icon type="md-podium" />
 									<span>{{ $t('survey.questionaire.analysisData') }}</span>
 								</div>
 							</div>
 						</div>
-						<div class="qn-item-charts" v-if="currentQn.progress === 'finish' && item.type !== 'subjective'">
+						<div class="qn-item-charts" v-if="item.type !== 'subjective'">
 							<BaseMiniBar :barId="'minibar' + index" :barData="item.result || []"></BaseMiniBar>
 						</div>
 					</div>
@@ -323,25 +323,25 @@
 						obj = {};
 					});
 					item.result.count = resultArr;
-					// let curItemRecord = result.question[index]
-					// if(item.type === 'subjective'){
-					// 	let result = []
-					// 	for(let key in curItemRecord.other){
-					// 		result.push({
-					// 			id:key,
-					// 			name:this.students.filter(i => i.id === key)[0].name,
-					// 			value:curItemRecord.other[key]
+					let curItemRecord = result.question[index]
+					if(item.type === 'subjective'){
+						let result = []
+						for(let key in curItemRecord.other){
+							result.push({
+								id:key,
+								name:this.students.filter(i => i.id === key)[0].name,
+								value:curItemRecord.other[key]
 								
-					// 		})
-					// 	}
-					// 	item.result.details = result
-					// }else{
-					// 	console.log(this.students)
-					// 	for(let key in curItemRecord.opt){
-					// 		curItemRecord.opt[key] = curItemRecord.opt[key].map(id => this.students.filter(i => i.id === id)[0].name) 
-					// 	}
-					// 	item.result.details = curItemRecord.opt
-					// }
+							})
+						}
+						item.result.details = result
+					}else{
+						console.log(this.students)
+						for(let key in curItemRecord.opt){
+							curItemRecord.opt[key] = curItemRecord.opt[key].map(id => this.students.filter(i => i.id === id)[0].name) 
+						}
+						item.result.details = curItemRecord.opt
+					}
 				});
 				console.log(items)
 				this.items = items
@@ -363,29 +363,12 @@
 			
 			async getQnRecord(item) {
 				return new Promise(async (r, j) => {
-					console.log(item)
-					if(item.progress === 'finish' && item.recordUrl){
-						try{
-							let finishRecord = await this.getBlobJsonFile(item.scope,item.recordUrl)
-							r(finishRecord)
-						}catch(e){
-							j(e)
-						}
-					}else{
-						this.$api.questionnaire
-							.FindRecordSurvey({
-								id: item.id,
-								code: item.code
-							})
-							.then((res) => {
-								if (!res.error) {
-									r(res);
-								} else {
-									j(500);
-								}
-						});
+					try{
+						let finishRecord = await this.getBlobJsonFile(item.scope,item.recordUrl)
+						r(finishRecord)
+					}catch(e){
+						j(e)
 					}
-					
 				});
 			},
 		},

+ 1 - 1
TEAMModelOS/ClientApp/src/components/vote/BaseVoteBar.vue

@@ -77,7 +77,7 @@
                     series: [{
                         type: 'bar',
                         data: data.map(item => item.value),
-                        barMaxWidth: 50, //柱子宽度
+                        barMaxWidth: 40, //柱子宽度
                         itemStyle: {
                             normal: {
                                 color: new that.$echarts.graphic.LinearGradient(0, 0, 0, 1, [{

+ 1 - 1
TEAMModelOS/ClientApp/src/components/vote/BaseVoteTable.vue

@@ -1,6 +1,6 @@
 <template>
     <div class="component-vote-table">
-        <Table border size='small' ref="selection" :columns="columns" :data="tableData" stripe></Table>
+        <Table border size='small' ref="selection" :no-data-text="$t('vote.noVoteData')" :columns="columns" :data="tableData" stripe></Table>
     </div>
 </template>
 <script>

+ 1 - 0
TEAMModelOS/ClientApp/src/locale/lang/zh-CN/vote.js

@@ -1,4 +1,5 @@
 export default {
+	noVoteData:'暂无投票数据',
     list:'投票活动列表',
 	pending:'待发布',
 	going:'进行中',

+ 1 - 0
TEAMModelOS/ClientApp/src/locale/lang/zh-TW/vote.js

@@ -1,4 +1,5 @@
 export default {
+	noVoteData:'暫無投票數據',
 	list: '投票活動清單',
 	pending: '待發佈',
 	going: '進行中',

+ 0 - 22
TEAMModelOS/ClientApp/src/view/evaluation/components/BaseExerciseList.vue

@@ -564,32 +564,10 @@
 							exercise.score = averageArr[exerciseIndex]
 							let listItem = this.exerciseList.filter(item => item.id === exercise.id)[0]
 							listItem.score = exercise.score
-							// 先找到原始列表里面的当前题目
-							// // 先判断是否总分除以题目数量能否除尽
-							// let remainder = item.score % item.list.length
-							// // 如果可以整除 则直接计算
-							// if (remainder === 0) {
-							// 	exercise.score = item.score / 
-							// } else {
-							// 	// 如果不能整除 则前面所有取整 最后一题加上余数 即可完成配分
-							// 	let integerScore = parseInt(item.score / item.list.length)
-							// 	// let lastItem = exerciseIndex === item.list.length - 1
-							// 	// exercise.score = lastItem ? integerScore + remainder : integerScore
-							// 	exercise.score = exerciseIndex + 1 > remainder ? integerScore :
-							// 		integerScore + 1
-							// }
-
 							if (exercise.type === 'compose' && exercise.children && exercise.children.length) {
 								let childrenScoreArr = this.$tools.doAverage(exercise.score,exercise.children.length,step)
 								exercise.children.forEach((child, childIndex) => {
 									child.score =childrenScoreArr[childIndex]
-									// let remainder = exercise.score % exercise.children.length
-									// let integerScore = parseInt(exercise.score / exercise.children
-									// 	.length)
-									// // let lastItem = childIndex === exercise.children.length - 1
-									// // child.score = lastItem ? integerScore + remainder : integerScore
-									// child.score = childIndex + 1 > remainder ? integerScore :
-									// 	integerScore + 1
 								})
 							}
 

+ 0 - 9
TEAMModelOS/ClientApp/src/view/evaluation/index/CreatePaper.vue

@@ -595,11 +595,6 @@
 					}
 					Promise.all(promiseArr).then(result => {
 						console.log(result)
-						// 子题保存之后 统一更新blobSize
-						// blobTool.updateSize([{
-						// 	url: 'item',
-						// 	size: updateSize
-						// }], containerName).then(res => {
 							let slides = []
 							// 主观题的answer为空数组
 							let nullType = ['complete', 'subjective', 'compose', 'correct',
@@ -625,10 +620,6 @@
 								slides: slides,
 								files: itemJsonFiles
 							})
-						// }).catch(err => {
-						// 	this.$Message.error(this.$t(
-						// 		'evaluation.newExercise.uploadErrorTip'));
-						// })
 					}).catch(err => {
 						console.log(err)
 						this.$Message.error(this.$t('evaluation.paperList.saveItemsFailTip'))

+ 20 - 18
TEAMModelOS/ClientApp/src/view/questionnaire/ManageQuestionnaire.vue

@@ -452,6 +452,7 @@
 				this.isLoading = true
 				try{
 					let answerdList = await this.getAnswerdRecord(surveyItem)
+					console.log('作答记录',answerdList)
 					//  先查找 投票发布对象关联的学生清单 然后再去判断学生的作答情况
 					this.$api.schoolSetting.getClassroomStudent({
 						school_code: this.$store.state.userInfo.schoolCode,
@@ -569,25 +570,26 @@
 			/* 获取正在进行中的投票活动的投票数据 */
 			getAnswerdRecord(surveyItem){
 				return new Promise(async (r,j) => {
-					if(surveyItem.progress !== 'finish'){
-						this.$api.questionnaire.GetAnswerdRecord({
-							id: surveyItem.id,
-							code: surveyItem.code,
-						}).then(res => {
-							if(!res.error){
-								r(res.userids)
-							}
-						}).catch(err => {
-							j(err)
-						})
-					}else{ // 如果是已结束的活动 则从blob读取作答数据 
-						try{
-							let curItemRecord = await this.getBlobJsonFile(surveyItem.scope,surveyItem.recordUrl)
-							r(curItemRecord.userids)
-						}catch(e){
-							j(e)
-						}
+					try{
+						let curItemRecord = await this.getBlobJsonFile(surveyItem.scope,surveyItem.recordUrl)
+						r(curItemRecord.userids)
+					}catch(e){
+						j(e)
 					}
+					// if(surveyItem.progress !== 'finish'){
+					// 	this.$api.questionnaire.GetAnswerdRecord({
+					// 		id: surveyItem.id,
+					// 		code: surveyItem.code,
+					// 	}).then(res => {
+					// 		if(!res.error){
+					// 			r(res.userids)
+					// 		}
+					// 	}).catch(err => {
+					// 		j(err)
+					// 	})
+					// }else{ // 如果是已结束的活动 则从blob读取作答数据 
+						
+					// }
 					
 				})
 			},

+ 50 - 36
TEAMModelOS/ClientApp/src/view/vote/ManageVote.vue

@@ -77,8 +77,7 @@
 									<span>{{ $t('vote.voteResult') }}</span>
 									<div class="hw-box-header-tools">
 										<div>
-											<span class="hw-box-header-tools-tool" @click="changeTableView"
-												v-show="tableData.length">
+											<span class="hw-box-header-tools-tool" @click="changeTableView">
 												<Icon type="md-podium" />
 												{{ isOptionView ? $t('vote.stuListView') : $t('vote.optionView') }}
 											</span>
@@ -100,7 +99,7 @@
 										</BaseVoteSsTable>
 										<div style="display:flex">
 											<BaseVotePie pieId="votePie" :pieData="studentsTable"
-												v-show="studentsTable.length"></BaseVotePie>
+												v-show="tableData.length"></BaseVotePie>
 											<BaseVoteBar pieId="votePie2" v-if="tableData.length" :pieData="tableData">
 											</BaseVoteBar>
 										</div>
@@ -297,27 +296,28 @@
 			/* 获取正在进行中的投票活动的投票数据 */
 			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)
-						}
+					try {
+						let curItemRecord = await this.getBlobJsonFile(voteItem.scope, voteItem
+							.recordUrl)
+						r(curItemRecord)
+					} catch (e) {
+						j(e)
 					}
+					// 如果是进行中的活动 则从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读取作答数据 
+						
+					// }
 
 				})
 			},
@@ -409,29 +409,35 @@
 					let records = await this.getVoteRecord(voteItem)
 					//  先查找 投票发布对象关联的学生清单 然后再去判断学生的作答情况
 					console.log('当前投票的作答数据======', records)
-					this.$api.schoolSetting.getClassroomStudent({
+					this.$api.schoolSetting.getStusByClassId({
 						school_code: this.$store.state.userInfo.schoolCode,
 						ids: voteItem.classes.length ? voteItem.classes : voteItem.stuLists,
-						scope: voteItem.scope
 					}).then(res => {
-						if (!res.error && res.stus.length) {
-							let list = []
-							res.stus.forEach(classStus => {
-								classStus.forEach(i => {
+						if (!res.error) {
+							let list = [] //学生清单 
+							let arr = [] //选项清单
+							res.list.forEach(classStus => {
+								classStus.class.stuInfos.forEach(i => {
 									list.push({
 										id: i.id,
 										name: i.name,
-										no: i.no,
-										classroomName: i.className
+										no: i.no || 0,
+										classroomName: classStus.class.name
+									})
+								})
+								classStus.class.tmdInfos.forEach(i => {
+									list.push({
+										id: i.id,
+										name: i.name,
+										no: i.no || 0,
+										classroomName: classStus.class.name
 									})
 								})
 							})
-							console.log(list)
 							this.studentsTable = list
+							
 							// 要根据作答情况 结合两张表 处理表格显示的数据 
 							if (records.options.length) {
-								let arr = []
-								this.studentsTable = list
 								records.options.forEach((item, index) => {
 									arr.push({
 										option: item.code ? this.$t('vote.option') + (index +
@@ -445,11 +451,19 @@
 									i.option = matchList.length ? Object.keys(matchList[0].opt).join(
 										',') : null
 								})
+								this.tableData = arr
 								console.log(arr)
 								console.log(this.studentsTable)
-								this.tableData = arr
 							} else {
-								this.studentsTable = []
+								// 如果是还没有投票作答数据 则默认显示0
+								// this.currentVote.forEach((item, index) => {
+								// 	arr.push({
+								// 		option: item.code ? this.$t('vote.option') + (index +
+								// 			1) : this.$t('vote.noVote'),
+								// 		key: item.code || '',
+								// 		result: 0
+								// 	})
+								// })
 								this.tableData = []
 							}
 						} else {