瀏覽代碼

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

liqk 4 年之前
父節點
當前提交
3718bcaea9

+ 9 - 8
TEAMModelFunction/TriggerVote.cs

@@ -8,6 +8,7 @@ using System.Text.Json;
 using System.Threading.Tasks;
 using TEAMModelOS.SDK.DI;
 using TEAMModelOS.SDK.Extension;
+using TEAMModelOS.SDK.Helper.Common.CollectionHelper;
 using TEAMModelOS.SDK.Models;
 using TEAMModelOS.SDK.Models.Cosmos;
 
@@ -70,10 +71,11 @@ namespace TEAMModelFunction
                                 endTime = vote.endTime,
                                 scode = vote.code,
                                 scope = vote.scope,
-                                classes = vote.classes,
-                                tmdids = vote.tmdids,
+                                classes = vote.classes.IsNotEmpty() ? vote.classes : new List<string> { "" },
+                                tmdids = vote.tmdids.IsNotEmpty() ? vote.tmdids : new List<string> { "" },
                                 progress= "going",
-                                owner =vote.owner
+                                owner =vote.owner,
+                                subjects = new List<string> { "" }
                             };
                             await client.GetContainer("TEAMModelOS", "School").UpsertItemAsync<ActivityData>(data, new Azure.Cosmos.PartitionKey(data.code));
                         }
@@ -90,9 +92,10 @@ namespace TEAMModelFunction
                                 scode = vote.code,
                                 scope = vote.scope,
                                 progress = "going",
-                                classes = vote.classes,
-                                owner = vote.owner
-                                // tmdids = vote.tmdids
+                                classes = vote.classes.IsNotEmpty() ? vote.classes : new List<string> { "" },
+                                owner = vote.owner,
+                                tmdids = new List<string> { "" },
+                                subjects= new List<string> { ""}
                             };
                             await client.GetContainer("TEAMModelOS", "Teacher").UpsertItemAsync<ActivityData>(data, new Azure.Cosmos.PartitionKey(data.code));
                         }
@@ -155,8 +158,6 @@ namespace TEAMModelFunction
                         {
                             await client.GetContainer("TEAMModelOS", "Teacher").ReplaceItemAsync<Vote>(vote, vote.id, new Azure.Cosmos.PartitionKey(vote.code));
                         }
-
-
                         //更新结束状态
                         if (vote.scope == "school" || vote.scope == "teacher")
                         {

+ 3 - 3
TEAMModelOS.SDK/Models/Cosmos/Common/ActivityData.cs

@@ -80,9 +80,9 @@ namespace TEAMModelOS.SDK.Models.Cosmos
         /// private/school/teacher
         /// </summary>
         public string scope { get; set; }
-        public List<string> classes { get; set; }
-        public List<string> tmdids { get; set; }
+        public List<string> classes { get; set; } = new List<string> { "" };
+        public List<string> tmdids { get; set; } = new List<string> { "" };
         public string owner { get; set; }
-        public List<string> subjects { get; set; }
+        public List<string> subjects { get; set; } = new List<string> { "" };
     }
 }

+ 3 - 3
TEAMModelOS/ClientApp/src/api/courseMgmt.js

@@ -38,9 +38,9 @@ export default {
         return post('/api/Course/deleteTime', data)
     },
     //获取教室关联的学生(移动到班级api管理)
-    //getClassroomStudent: function (data) {
-    //    return post('/student/class/find', data)
-    //},
+    getClassroomStudent: function (data) {
+       return post('/student/class/find', data)
+    },
     //虚拟教室添加学生
     addClassroom: function (data) {
         return post('/api/ClassStudent/upsert', data)

+ 1 - 1
TEAMModelOS/ClientApp/src/api/knowledge.js

@@ -6,7 +6,7 @@ export default {
     },
     // 批量更新保存知识点知识块
     SaveOrUpdateKnowledge: function(data) {
-        return post('/knowledge/upsert-all', data)
+        return post('/knowledges/upsert', data)
     },
     SaveOrUpdateSchoolPoint: function(data) {
         return post('/knowledge/SaveOrUpdateAllSchoolPoint', data)

+ 7 - 0
TEAMModelOS/ClientApp/src/api/learnActivity.js

@@ -205,6 +205,13 @@ export default {
     FindVoteById: function (data) {
         return post('/common/vote/find-id', data)
     },
+	
+	/*
+    * 查询投票结果
+    */
+    FindVoteRecord: function (data) {
+        return post('/common/vote/record', data)
+    },
 
 	/*
 	* 保存作业学生作答数据

文件差異過大導致無法顯示
+ 462 - 423
TEAMModelOS/ClientApp/src/components/vote/BaseVoteForm.vue


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

@@ -36,7 +36,7 @@
                     {
                         title: '班级',
                         render: (h, params) => {
-                            return h('span', params.row.classroom.name)
+                            return h('span', params.row.className)
                         },
                     },
                     {

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

@@ -34,8 +34,15 @@ export default {
 		optionSetting: '選項設定',
 		addOption: '添加選項',
 		selectNum: '可投票數',
+		times: '投票週期',
+		once: '單次',
+		day: '每日',
+		week: '每週',
+		month: '每月',
+		year: '每年',
 		other: '其他',
 		openSecret: '開啟匿名投票',
+		openRepeat: '允許重複投票',
 		save: '保存',
 		cancel: '取消',
 		editSuc: '修改成功',

+ 44 - 34
TEAMModelOS/ClientApp/src/view/knowledge-point/index/Index.less

@@ -23,6 +23,18 @@
         padding: 0 20px;
         z-index: 1;
 
+        .school-tools {
+            font-size: var(--font-size-normal);
+            margin-right: 30px;
+            margin-top: 13px;
+            float: right;
+        }
+
+        .school-tools .ivu-icon {
+            font-size: @font-size-large;
+            margin-right: 5px;
+            vertical-align: text-top;
+        }
 
         span {
             margin-right: 10px;
@@ -45,17 +57,17 @@
         height: calc(100% - 70px);
         width: 100%;
         .fl-row-center;
-		
-		.drag-active{
-			 background-color: rgba(149, 149, 149, 0.2);
-		}
-		
-		.gl-new-area{
-			text-align: center;
-			color:@primary-textColor;
-			background: #3e3e3e;
-			padding: 35px 0 !important;
-		}
+
+        .drag-active {
+            background-color: rgba(149, 149, 149, 0.2);
+        }
+
+        .gl-new-area {
+            text-align: center;
+            color: @primary-textColor;
+            background: #3e3e3e;
+            padding: 35px 0 !important;
+        }
 
         .ns-col {
             position: relative;
@@ -133,11 +145,12 @@
                     overflow: hidden;
                     text-overflow: ellipsis;
                     white-space: nowrap;
-					pointer-events: none;
+                    pointer-events: none;
                 }
 
                 .gl-item-info {
-					pointer-events: none;
+                    pointer-events: none;
+
                     span {
                         margin-top: 15px
                     }
@@ -199,7 +212,7 @@
                 background: #0f9272;
                 border: none;
                 color: #fff;
-                margin-left:20px;
+                margin-left: 20px;
             }
 
             .points-wrap {
@@ -208,7 +221,7 @@
                 padding-top: 20px;
 
                 .point-item {
-					position:relative;
+                    position: relative;
                     margin: 10px;
                     padding: 5px 30px;
                     border-radius: 50px;
@@ -219,7 +232,6 @@
                     &-tools {
                         margin-left: 10px;
                         // display: none;
-
                         .btn-delete {
                             margin-left: 4px;
                         }
@@ -229,24 +241,22 @@
                 .point-item-active {
                     background: #0f9272 !important;
                 }
-				
-				// .block-point-item:before{
-				// 	content:'';
-				// 	display:block;
-				// 	width:8px;
-				// 	height:14px;
-				// 	border-right:#fff solid 2px;
-				// 	border-bottom:#fff solid 2px;
-				// 	transform:rotate(35deg);
-				// 	position:absolute;
-				// 	bottom:12px;
-				// 	left:12px;
-				// 	z-index:2;
-				// }
-				
-				.block-point-item{
-					background-color: #006988;
-				}
+                // .block-point-item:before{
+                // 	content:'';
+                // 	display:block;
+                // 	width:8px;
+                // 	height:14px;
+                // 	border-right:#fff solid 2px;
+                // 	border-bottom:#fff solid 2px;
+                // 	transform:rotate(35deg);
+                // 	position:absolute;
+                // 	bottom:12px;
+                // 	left:12px;
+                // 	z-index:2;
+                // }
+                .block-point-item {
+                    background-color: #006988;
+                }
 
                 .point-item:hover {
                     .point-item-tools {

+ 159 - 100
TEAMModelOS/ClientApp/src/view/knowledge-point/index/Index.vue

@@ -13,7 +13,7 @@
 					<Option v-for="(item,index) in periodList" :value="index" :key="index">{{ item.name }}</Option>
 				</Select>
 			</div>
-			<Button v-if="$access.ability('admin','schoolSetting-upd').validateAll" class="school-tools" :loading="isLoading"  icon="ios-albums-outline">{{$t('schoolBaseInfo.saveInfo')}}</Button>
+			<Button v-if="$access.ability('admin','schoolSetting-upd').validateAll" class="school-tools" :disabled="!updated"  icon="ios-albums-outline" @click="saveData()">{{$t('schoolBaseInfo.saveInfo')}}</Button>
 		</div>
 		<!-- 主体内容 -->
 		<div class="new-syllabus-content">
@@ -249,7 +249,9 @@
 				checkedPointList: [],
 				curBlockPoints: [],
 				curDragPoint: null,
-				pointIndex: null
+				pointIndex: null,
+				pointDatas: {},
+                updated:false
 			}
 		},
 		components: {
@@ -345,7 +347,6 @@
 			/* 保存最新知识块内容 */
 			savePointAndBlock(pointItem) {
 				return new Promise((r, j) => {
-					console.log(pointItem)
 					pointItem.code = pointItem.code.replace('Knowledge-', '')
 					this.$api.knowledge.SaveOrUpdateKnowledge([pointItem]).then(res => {
 						if (!res.error && res.knowledges) {
@@ -368,7 +369,6 @@
 			initSchoolData() {
 				this.$store.dispatch('user/getSchoolProfile').then(res => {
 					let schoolBaseInfo = res.school_base
-					console.log('学校基本数据', schoolBaseInfo)
 					if (schoolBaseInfo) {
 						this.schoolInfo = schoolBaseInfo
 						this.originSchoolData = schoolBaseInfo // 默认选择第一个
@@ -387,33 +387,35 @@
 
 			// 获取当前册别数量(每次都获取最新的数据)
 			initBlockCount() {
-				 if (this.blockCounts.length) {
-				 	this.schoolBlockCount = this.blockCounts[this.currentPeriodIndex].map(i => i[0])
-				 	this.privateBlockCount = this.blockCounts[this.currentPeriodIndex].map(i => i[1])
-				 } else {
-				this.$api.syllabus.FindBlockCount({
-					code: this.$store.state.userInfo.schoolCode
-				}).then(res => {
-					if (!res.error) {
-						this.$nextTick(() => {
-							this.blockCounts = res
-							this.schoolBlockCount = res[this.currentPeriodIndex || 0].map(i => i[0])
-							this.privateBlockCount = res[this.currentPeriodIndex || 0].map(i => i[1])
-						})
-					} else {
-						this.$Message.warning('获取数据失败')
-					}
-				})
-				 }
+				if (this.blockCounts.length) {
+					this.schoolBlockCount = this.blockCounts[this.currentPeriodIndex].map(i => i[0])
+					this.privateBlockCount = this.blockCounts[this.currentPeriodIndex].map(i => i[1])
+				} else {
+					this.$api.syllabus.FindBlockCount({
+						code: this.$store.state.userInfo.schoolCode
+					}).then(res => {
+						if (!res.error) {
+							this.$nextTick(() => {
+								this.blockCounts = res
+								this.schoolBlockCount = res[this.currentPeriodIndex || 0].map(i => i[0])
+								this.privateBlockCount = res[this.currentPeriodIndex || 0].map(i => i[1])
+							})
+						} else {
+							this.$Message.warning('获取数据失败')
+						}
+					})
+				}
 			},
 
 			// 根据学科获取所有知识块信息
 			getBlocksData() {
 				let that = this
+				that.pointDatas = []
 				let params = JSON.parse(JSON.stringify(this.currentParams))
 				params.type = 0
 				this.$api.knowledge.GetSchoolPoints(params).then(res => {
 					if (res.length) {
+						that.pointDatas = res
 						let list = res[0].blocks
 						this.blockList = list
 						this.originBlockList = JSON.parse(JSON.stringify(list))
@@ -433,15 +435,12 @@
 			// 根据学科获取学科下所有知识点数据
 			getPointsData() {
 				let that = this
-				console.log('知识点数据', this.currentParams)
 				//this.currentParams.type = 1
 				this.$api.knowledge.GetSchoolPoints(this.currentParams).then(res => {
-					console.log(res)
 					if (res.length) {
+
 						this.pointList = res[0].points
-						console.log('456456456', this.pointList)
 						this.originPointList = JSON.parse(JSON.stringify(res[0].points))
-						console.log(this.originPointList)
 						setTimeout(function () {
 							that.isLoadPoints = false
 						}, 800)
@@ -508,7 +507,6 @@
 
 			// 学科点击事件
 			handleSubjectTap(index) {
-				console.log(index)
 				this.checkedPointList = []
 				this.blockList = []
 				this.originBlockList = []
@@ -530,9 +528,6 @@
 
 			// 知识块点击事件
 			handleBlockTap(index, item) {
-				console.log(index)
-				console.log(item)
-				console.log(this.activeBlockIndex)
 				if (index === this.activeBlockIndex) {
 					this.activeBlockIndex = null
 					this.curBlockPoints = []
@@ -553,7 +548,6 @@
 			// 把当前知识块的知识点排到最前面
 			toStartPosition(points) {
 				points.forEach(i => {
-					console.log(i)
 					let pointIds = this.pointList.map(i => i)
 					if (pointIds.includes(i)) {
 						let index = pointIds.indexOf(i)
@@ -570,10 +564,10 @@
 				if (this.isEditBlock) {
 					let code = this.blockList.findIndex(item => item.name.indexOf(this.editBlock.name) > -1)
 					this.blockList[code].name = val.name
-                    this.originBlockList = JSON.parse(JSON.stringify(this.blockList))
 				} else {
-                    this.blockList.push(val)
-				}
+					this.blockList.push(val)
+				} 
+				this.originBlockList = [...this.blockList]
 				this.editBlock = {}
 				this.isAddBlock = false // 关闭窗口
 				this.blockCounts = []
@@ -586,12 +580,28 @@
 				let that = this
 				this.isLoadPoints = true
 				if (this.isEditPoint) {
-					this.pointList[this.editPointIndex] = val
+					this.pointList[this.editPointIndex] = val.name
+                    this.actionPoint(this.currentPoint, val)
+					//if (this.findPointIndex(this.currentPoint) > 0) {
+					//	this.$Modal.confirm({
+					//		title: '提示',
+					//		content: '<p>当前知识点已关联相关知识块,是否继续修改?</p>',
+					//		okText: '确认',
+					//		cancelText: '取消',
+					//		onOk: () => {
+					//			this.isLoading = true
+					//			setTimeout(() => {
+					//				that.isLoading = false
+					//				that.$Message.success('操作成功!')
+					//			}, 500)
+					//		}
+					//	})
+					//}
 				} else {
 					if (!this.isShowPoints) this.currentBlock.points.push(val.id)
 					this.pointList.push(val.name)
 				}
-				this.$Message.success('操作成功!')
+				this.originPointList = [...this.pointList]
 				this.isAddPoint = false // 关闭窗口
 				this.isEditPoint = false
 				setTimeout(function () {
@@ -599,7 +609,36 @@
 					that.initBlockCount()
 				}, 400)
 			},
+			//查询当前关联的知识块数据
+			findPointIndex(datas) {
+				let data = 0
+				for (let item of this.blockList) {
+					if (this.isEditPoint) {
+						let code = item.points.findIndex(items => items.indexOf(datas) > -1)
+						if (code !== -1) {
+							data++
+						}
+					}
+				}
+				return data
+			},
+
+			//处理关联的知识点数据(修改和删除)
+			actionPoint(data, val) {
+				if (data) {
+					for (let item of this.blockList) {
+						if (this.isEditPoint) {
+							let code = item.points.findIndex(items => items.indexOf(data) > -1)
+							if (code !== -1) {
+								item.points[code] = val.name
+							}
+						} else {
+							item.points.splice(item.points.findIndex(item => item === data), 1)
+						}
+					}
 
+				}
+			},
 			// 删除知识块事件
 			onDeleteBlock(data) {
 				this.$Modal.confirm({
@@ -610,19 +649,19 @@
 					onOk: () => {
 						let that = this
 						this.isLoading = true
-                        if (this.blockList.indexOf(data) !== -1) {
-								this.blockList.splice(this.blockList.indexOf(data), 1)
-								this.originBlockList.splice(this.originBlockList.indexOf(data), 1)
-								this.handleBlockTap(0, this.blockList.length ? this.blockList[0] : null)
-								setTimeout(() => {
-									that.blockCounts = []
-									that.initBlockCount()
-									that.isLoading = false
-									that.$Message.success('删除成功')
-								}, 1000)
-							} else {
-								this.$Message.success('删除失败')
-							}
+						if (this.blockList.indexOf(data) !== -1) {
+							this.blockList.splice(this.blockList.indexOf(data), 1)
+							this.originBlockList.splice(this.originBlockList.indexOf(data), 1)
+							this.handleBlockTap(0, this.blockList.length ? this.blockList[0] : null)
+							setTimeout(() => {
+								that.blockCounts = []
+								that.initBlockCount()
+								that.isLoading = false
+								that.$Message.success('删除成功')
+							}, 1000)
+						} else {
+							this.$Message.success('删除失败')
+						}
 					}
 				})
 			},
@@ -636,23 +675,12 @@
 					cancelText: '取消',
 					onOk: () => {
 						this.isLoadPoints = true
-						this.$api.knowledge.DeleteSchoolPoint({
-							code: data.code.replace('Knowledge-', ''),
-							id: data.id
-						}).then(res => {
-							if (!res.error) {
-								this.$Message.success('删除成功')
-								this.originPointList.splice(this.originPointList.indexOf(data), 1)
-								if (!this.isShowPoints) this.currentBlock.points.splice(this.currentBlock.points.indexOf(data.id), 1)
-								this.pageChange(this.currentPage)
-								this.isLoadPoints = false
-							} else {
-								this.$Message.warning('删除失败,错误代码:' + res.error.code + ',错误信息:' + res.error.message)
-							}
-						}).catch(err => {
-							console.log(err)
-							this.$Message.warning('删除失败')
-						})
+                        this.$Message.success('删除成功')
+                        this.pointList.splice(this.pointList.indexOf(data), 1)
+                        if (!this.isShowPoints) this.currentBlock.points.splice(this.currentBlock.points.indexOf(data), 1)
+						this.actionPoint(data, 0)
+						this.originPointList = [...this.pointList]
+                        this.isLoadPoints = false
 					}
 				})
 			},
@@ -661,20 +689,16 @@
 			onRemovePoint(data) {
 				this.$Modal.confirm({
 					title: '提示',
-					content: `确定将知识点 ${data.name} 从知识块 ${this.currentBlock.name} 中移除?`,
+					content: `确定将知识点 ${data} 从知识块 ${this.currentBlock.name} 中移除?`,
 					okText: '确认',
 					cancelText: '取消',
 					onOk: () => {
-						if (this.currentBlock.points.includes(data.id)) {
-							let that = this
-							this.currentBlock.points.splice(this.currentBlock.points.indexOf(data.id), 1)
-							this.savePointAndBlock(this.currentBlock).then(r => {
-								this.curBlockPoints = []
-								this.currentBlock = null
-								this.activeBlockIndex = null
-								that.handleSubjectTap(that.currentSubjectIndex)
-							})
-
+						if (this.currentBlock.points.includes(data)) {
+							this.currentBlock.points.splice(this.currentBlock.points.indexOf(data), 1)
+							this.originBlockList = [...this.blockList]
+								//this.curBlockPoints = []
+								//this.currentBlock = null
+								//this.activeBlockIndex = null
 						} else {
 							this.$Message.error('移除失败')
 						}
@@ -686,12 +710,7 @@
 			onEditBlock(data) {
 				this.isAddBlock = true // 打开新增窗口
 				this.isEditBlock = true // 设置成编辑状态
-				console.log('121321313131')
-				console.log(this.blockList)
-				console.log(data)
 				this.editBlock = this.blockList[data]
-                console.log(this.editBlock)
-
 			},
 
 			// 新增知识块事件
@@ -713,9 +732,6 @@
 
 			// 编辑知识点事件
 			onEditPoint(data, index) {
-				console.log('知识点数据')
-				console.log(data, index)
-				console.log(this.currentBlock)
 				this.isAddPoint = true // 打开新增窗口
 				this.isEditPoint = true // 设置成编辑状态
 				this.currentPoint = data
@@ -725,11 +741,6 @@
 
 			// 知识点点击事件
 			onPointCheck(item, index) {
-				console.log('000000000000000.000000000000000000')
-				console.log(item)
-				console.log(index)
-				console.log(this.checkedPointList)
-				console.log(this.isShowPoints)
 				if (this.isShowPoints) {
 					let list = this.checkedPointList
 					let isExistIndex = list.indexOf(item)
@@ -750,24 +761,23 @@
 			onComposeFinish(val) {
 				if (val) {
 					let code = this.blockList.findIndex(item => item.name.indexOf(val.name) > -1)
-					console.log(code)
 					if (code == -1) {
-                    this.blockList.push(val)
+						this.blockList.push(val)
 					} else {
-					this.blockList[code].points = val.points
+						this.blockList[code].points = val.points
 					}
-                    this.originBlockList = JSON.parse(JSON.stringify(this.blockList))
+					this.originBlockList = [...this.blockList]
+					console.log(this.originBlockList)
 					this.isComposeBlock = false
 					this.checkedPointList = []
 					this.activeBlockIndex = null
 					this.curBlockPoints = []
-					//this.handleSubjectTap(this.currentSubjectIndex)
 					this.$Message.success('操作成功')
 					this.initBlockCount()
 				}
 
 			},
-			 
+
 			// 搜索知识块输入框onchange事件
 			onSearchBlockChange() {
 				this.blockList = this.originBlockList.filter(item => item.name.indexOf(this.searchBlock) > -1)
@@ -818,7 +828,26 @@
 					this.pageChange(page - 1)
 				}
 			},
-
+			//保存修改后的数据
+			saveData() {
+				console.log(this.pointDatas)
+                if (this.updated) {
+                    let params = {}
+                    params = this.pointDatas[0]
+                    params.points = [...this.originPointList]
+                    params.blocks = [...this.originBlockList]
+                    this.$api.knowledge.SaveOrUpdateKnowledge(params).then(res => {
+                        if (res) {
+                            this.$Message.success('保存数据成功')
+                        } else {
+                            this.$Message.warning('保存数据失败')
+                        }
+                    }).catch(err => {
+                        this.$Message.error('数据保存失败')
+                        this.isLoadBlocks = false
+                    })
+                }
+            },
 			// 切换每页显示页数
 			pageSizeChange(val) {
 				this.pageSize = val
@@ -828,9 +857,39 @@
 
 		},
 		mounted() {
-
-
 		},
+		watch: {
+            originBlockList: {
+				handler(newValue, oldValue) {
+					console.log(newValue)
+					this.updated = true
+                }
+			},
+            originPointList: {
+				handler(newValue, oldValue) {
+					console.log(newValue)
+					this.updated = true
+                }
+            },
+		},
+        beforeRouteLeave(to, from, next) {
+            if (this.updated) {
+                let config = {
+                    title: this.$t('schoolBaseInfo.saveWarning'),
+                    content: this.$t('schoolBaseInfo.ssTips8'),
+                    okText: this.$t('schoolBaseInfo.leaveText'),
+                    onOk: () => {
+                        next()
+                    },
+                    onCancel: () => {
+                        next(false)
+                    }
+                }
+                this.$Modal.confirm(config)
+            } else {
+                next()
+            }
+        },
 		computed: {
 			dragOptions() {
 				return {
@@ -854,7 +913,7 @@
 	}
 </script>
 
-<style>
+<style >
 	.new-syllabus-header .ivu-select-single .ivu-select-selection,
 	.funnel-box .ivu-select-single .ivu-select-selection {
 		background: transparent;

+ 3 - 13
TEAMModelOS/ClientApp/src/view/knowledge-point/index/operation/AddPoint.vue

@@ -51,21 +51,11 @@
                     this.uuid = Math.uuid()
 					console.log(this.schoolInfos)
                     let params = {
-                        type: 1,
                         name: newName,
-                        alias: newName,
-                        subjectId: editPointItem ? editPointItem.subjectId : this.schoolInfos.subjectId,
-                        code: this.addPointType === 'school' ? this.schoolInfos.schoolCode : this.$store.state.userInfo.TEAMModelID, // //判断当前添加为校本或者个人知识点
-                        order: 706,
-                        status: 1,
-                        knowledgeId: editPointItem ? editPointItem.knowledgeId : this.uuid,
-                        periodId: editPointItem ? editPointItem.periodId : this.schoolInfos.period,
-                        source: 1,
-                        points: this.blockDatas ? [this.blockDatas.id] : [],
-                        id: editPointItem ? editPointItem.id : null,
                     }
-					console.log(params)
-                    this.savePointAndBlock(params)
+                    console.log(params)
+                    this.$emit('addFinish', params)
+                        this.isLoading = false
                 }
             },
 

+ 66 - 43
TEAMModelOS/ClientApp/src/view/vote/ManageVote.vue

@@ -38,7 +38,7 @@
 				</div>
 				<div slot="right" class="demo-split-pane">
 					<Split v-model="split2">
-						<div slot="left" class="demo-split-pane">
+						<div slot="left" class="demo-split-pane"  ref="voteFormBox">
 							<!-- 投票基础信息展示 -->
 							<div class="hw-col hw-info-box">
 								<div class="hw-box-header">
@@ -48,7 +48,7 @@
 											<Icon type="md-create" size="18" :title="$t('vote.edit')" @click="onEditVote" v-if="($access.can('admin.*|schoolAc-upd') || isPrivate)" /></span>
 									</div>
 								</div>
-								<vuescroll>
+								<vuescroll ref="voteFormScroll">
 									<div v-show="voteList.length === 0">
 										<EmptyData :top="50"></EmptyData>
 									</div>
@@ -166,6 +166,10 @@
 					this.hasNewAdd = true
 					this.$refs.voteForm.voteFormEdit = true
 				}
+				
+				this.$nextTick(() => {
+					this.$refs.voteFormBox.scrollIntoView();
+				})
 			},
 
 
@@ -204,13 +208,22 @@
 			 * @param index
 			 */
 			async onVoteClick(item, index) {
-				this.currentVote = item.id ? await this.getVoteDetails(item) : item
+				console.log(item)
+				let fullItem = item.id ? await this.getVoteDetails(item) : item
+				this.currentVote = fullItem
 				this.activeVoteIndex = index
-				// if (item.id) this.getVoteStudents(item.id,item.target)
+				if (item.id) this.getVoteStudents(fullItem,fullItem.classes)
 				this.$refs.voteForm.voteFormEdit = false
+				this.$refs.voteFormScroll.scrollTo({
+						y: 0,
+					},
+					200,
+					"easeInQuad"
+				);
 				this.hasNewAdd = false
 			},
 			
+			/* 获取投票活动的详细数据 */
 			getVoteDetails(voteItem){
 				return new Promise((r,j) => {
 					this.$api.learnActivity.FindVoteById({
@@ -225,6 +238,28 @@
 					})
 				})
 			},
+			
+			/* 获取正在进行中的投票活动的投票数据 */
+			getVoteRecord(voteItem){
+				return new Promise((r,j) => {
+					this.$api.learnActivity.FindVoteRecord({
+						id: voteItem.id,
+						code: voteItem.code,
+					}).then(res => {
+						if(!res.error){
+							r(res)
+						}
+					}).catch(err => {
+						j(err)
+					})
+				})
+			},
+			
+			/* 根据已结束的RecordUrl来获取投票结果数据 */
+			getRecordUrlData(){
+				
+			},
+			
 
 			/* 取消编辑投票(无ID状态) */
 			onCancelVote() {
@@ -252,13 +287,16 @@
 								scope: this.getCurScope
 							}).then(res => {
 								if (!res.error && res.flag) {
+									setTimeout(() => {
+										this.isLoading = false
+										this.$Message.success(this.$t('vote.deleteSuc'))
+										this.handleTabClick(this.$route.name === 'manageVote' ? 0 : 1)
+									},1000)
+									
+									// this.voteList.splice(this.voteList.indexOf(this.currentVote), 1)
 									// this.isLoading = false
 									// this.$Message.success(this.$t('vote.deleteSuc'))
-									// this.handleTabClick(this.$route.name === 'manageVote' ? 0 : 1)
-									this.voteList.splice(this.voteList.indexOf(this.currentVote), 1)
-									this.isLoading = false
-									this.$Message.success(this.$t('vote.deleteSuc'))
-									if (this.voteList.length) this.onVoteClick(this.voteList[0], 0)
+									// if (this.voteList.length) this.onVoteClick(this.voteList[0], 0)
 								} else {
 									this.isLoading = false
 									this.$Message.error(this.$t('vote.deleteFail'))
@@ -282,15 +320,17 @@
 			 * 获取投票关联的学生清单
 			 * @param voteId 投票ID
 			 */
-			async getVoteStudents(voteId, target) {
+			async getVoteStudents(voteItem) {
 				this.isLoading = true
-				let records = await this.getVoteRecord(voteId)
+				let records = await this.getVoteRecord(voteItem)
 				//  先查找 投票发布对象关联的学生清单 然后再去判断学生的作答情况
-				this.$api.courseMgmt.getClassroomStudent({
-					classroomCode: target.map(i => i.classroomCode),
-					school_code: this.$store.state.userInfo.schoolCode
+				console.log(voteItem)
+				this.$api.schoolSetting.getClassroomStudent({
+					school_code: this.$store.state.userInfo.schoolCode,
+					ids: voteItem.classes,
+					scope:voteItem.owner === this.$store.state.userInfo.schoolCode ? 'school' : 'private'
 				}).then(res => {
-					if (!res.error && res.classrooms) {
+					if (!res.error && res.classrooms.length) {
 						let list = []
 						res.classrooms.forEach(classroom => {
 							classroom.students.forEach(i => {
@@ -302,29 +342,26 @@
 								})
 							})
 						})
-						console.log(list)
-						// let infoList = res.result.extend.students
-						// list.forEach(i => {
-						// 	i.name = infoList.filter(j => j.studentId === i.code)[0].name
-						// 	i.classroomName = target.filter(k => k.classroomCode === i.id)[0].classroomName
-						// })
+						console.log(records)
+						
 						// 要根据作答情况 结合两张表 处理表格显示的数据 
-						if (records.length) {
+						if (records.options.length) {
 							let arr = []
-							this.studentsTable = []
-							records.forEach((item, index) => {
+							this.studentsTable = records.records
+							records.options.forEach((item, index) => {
 								arr.push({
 									// option: this.getSimpleText(item.optionValue),
-									option: item.optionKey ? this.$t('vote.option') + (index + 1) : this.$t('vote.noVote'),
-									key: item.optionKey || '',
-									result: item.students
+									option: item.code ? this.$t('vote.option') + (index + 1) : this.$t('vote.noVote'),
+									key: item.code || '',
+									result: new Array(item.count).fill('1')
 								})
-								this.studentsTable = this.studentsTable.concat(item.students)
 							})
 							console.log(this.studentsTable)
 							this.studentsTable.forEach(i => {
-								let matchList = list.filter(j => j.id === i.code)
+								let matchList = list.filter(j => j.id === i.userid)
 								i.name = matchList.length ? matchList[0].name : this.$t('vote.noData')
+								i.classroomName = matchList.length ? matchList[0].classroomName : this.$t('vote.noData')
+								i.option = i.opt.join(',')
 							})
 							console.log(arr)
 							this.tableData = arr
@@ -342,20 +379,6 @@
 				})
 			},
 
-			/* 获取投票结果数据 */
-			getVoteRecord(voteId) {
-				return new Promise((r, j) => {
-					this.$api.learnActivity.FindRecordByVoteId({
-						id: voteId
-					}).then(res => {
-						if (!res.error && res.options) {
-							r(res.options)
-						} else {
-							j(500)
-						}
-					})
-				})
-			},
 
 			// 提取富文本内容中的文本
 			getSimpleText(html) {

+ 8 - 2
TEAMModelOS/Controllers/Common/VoteController.cs

@@ -69,7 +69,6 @@ namespace TEAMModelOS.Controllers.Learn
                 //新增Vote
                 var client = _azureCosmos.GetCosmosClient();
                 request.code = request.pk + "-" + request.code;
-                
                 long now = DateTimeOffset.UtcNow.ToUnixTimeMilliseconds();
                 request.createTime = now;
                 if (string.IsNullOrEmpty(request.id))
@@ -82,7 +81,6 @@ namespace TEAMModelOS.Controllers.Learn
                     else { 
                         request.progress = "going"; 
                     }
-                        
                     request = await client.GetContainer("TEAMModelOS", "Common").CreateItemAsync(request, new PartitionKey($"{request.code}"));
                 }
                 else
@@ -92,6 +90,14 @@ namespace TEAMModelOS.Controllers.Learn
                     {
                         return Ok(new { v = "活动正在进行中" });
                     }
+                    if (request.startTime > now)
+                    {
+                        request.progress = "pending";
+                    }
+                    else
+                    {
+                        request.progress = "going";
+                    }
                     request.progress = info.progress;
                     request = await client.GetContainer("TEAMModelOS", "Common").ReplaceItemAsync(request, info.id, new PartitionKey($"{info.code}"));
                 }

+ 30 - 20
TEAMModelOS/Controllers/School/ClassRoomController.cs

@@ -372,31 +372,40 @@ namespace TEAMModelOS.Controllers
             //ResponseBuilder builder = ResponseBuilder.custom();
             if (!requert.TryGetProperty("school_code", out JsonElement school_code)) return BadRequest();
             if (!requert.TryGetProperty("scope", out JsonElement scope)) return BadRequest();
+            if (!requert.TryGetProperty("ids", out JsonElement ids)) return BadRequest();
             try
             {
                 var client = _azureCosmos.GetCosmosClient();
                 List<object> classrooms = new List<object>();
-                StringBuilder sql = new StringBuilder();
-                Dictionary<string, object> dict = new Dictionary<string, object>();
-                var emobj = requert.EnumerateObject();
-                while (emobj.MoveNext())
-                {
-                    dict[emobj.Current.Name] = emobj.Current.Value;
-                }
-                //处理code
-                if (dict.TryGetValue("school_code", out object _))
-                {
-                    dict.Remove("school_code");
-                }
-                if (scope.ToString().Equals("teacher", StringComparison.OrdinalIgnoreCase))
+                /* StringBuilder sql = new StringBuilder();
+                 Dictionary<string, object> dict = new Dictionary<string, object>();
+                 var emobj = requert.EnumerateObject();
+                 while (emobj.MoveNext())
+                 {
+                     dict[emobj.Current.Name] = emobj.Current.Value;
+                 }
+                 //处理code
+                 if (dict.TryGetValue("school_code", out object _))
+                 {
+                     dict.Remove("school_code");
+                 }
+                 if (scope.ToString().Equals("teacher", StringComparison.OrdinalIgnoreCase))
+                 {
+                     dict.Remove("scope");
+                 }*/
+                //sql.Append("select c.name,c.id,c.students,c.code from c ");
+
+                string info = "";
+                for (int i = 0; i < ids.GetArrayLength(); i++)
                 {
-                    dict.Remove("scope");
-                }
-                sql.Append("select c.name,c.id,c.students,c.code from c ");
-                AzureCosmosQuery cosmosDbQuery = SQLHelper.GetSQL(dict, sql);
+                    //ids.Add(id[i].ToJsonString());
+                    info += ids[i].ToJsonString() + ",";
+                }                              
+                //AzureCosmosQuery cosmosDbQuery = SQLHelper.GetSQL(dict, sql);
                 if (scope.ToString().Equals("school", StringComparison.OrdinalIgnoreCase))
                 {
-                    await foreach (var item in client.GetContainer("TEAMModelOS", "School").GetItemQueryStreamIterator(queryDefinition: cosmosDbQuery.CosmosQueryDefinition, requestOptions: new QueryRequestOptions() { PartitionKey = new PartitionKey($"Class-{school_code}") }))
+                    await foreach (var item in client.GetContainer("TEAMModelOS", "School").GetItemQueryStreamIterator(
+                    queryText: $"select c.name,c.id,c.students,c.code from c where c.id in ({info[0..^1]})", requestOptions: new QueryRequestOptions() { PartitionKey = new PartitionKey($"Class-{school_code}") }))
                     {
                         using var json = await JsonDocument.ParseAsync(item.ContentStream);
                         if (json.RootElement.TryGetProperty("_count", out JsonElement count) && count.GetUInt16() > 0)
@@ -410,7 +419,8 @@ namespace TEAMModelOS.Controllers
                 }
                 else
                 {
-                    await foreach (var item in client.GetContainer("TEAMModelOS", "Teacher").GetItemQueryStreamIterator(queryDefinition: cosmosDbQuery.CosmosQueryDefinition, requestOptions: new QueryRequestOptions() { PartitionKey = new PartitionKey($"Class-{school_code}") }))
+                    await foreach (var item in client.GetContainer("TEAMModelOS", "Teacher").GetItemQueryStreamIterator(
+                    queryText: $"select c.name,c.id,c.students,c.code from c where c.id in ({info[0..^1]})", requestOptions: new QueryRequestOptions() { PartitionKey = new PartitionKey($"Class-{school_code}") }))
                     {
                         using var json = await JsonDocument.ParseAsync(item.ContentStream);
                         if (json.RootElement.TryGetProperty("_count", out JsonElement count) && count.GetUInt16() > 0)
@@ -420,7 +430,7 @@ namespace TEAMModelOS.Controllers
                                 classrooms.Add(obj.ToObject<object>());
                             }
                         }
-                    }
+                    }                   
                 }
                 return Ok(new { classrooms });
                 /*List<Classroom> sc = await _azureCosmos.FindByDict<Classroom>(request);

+ 1 - 1
TEAMModelOS/Controllers/School/StudentCommonController.cs

@@ -45,7 +45,7 @@ namespace TEAMModelOS.Controllers
         /// <returns></returns>
         [ProducesDefaultResponseType]
         [HttpPost("stu-find-activity")]
-        [AuthToken(Roles = "student")]
+       // [AuthToken(Roles = "student")]
         public async Task<IActionResult> FindStu(JsonElement request)
         {
             var (id, name, pic,school) = HttpContext.GetAuthTokenInfo();

+ 36 - 24
TEAMModelOS/Services/Common/ActivityStudentService.cs

@@ -76,15 +76,13 @@ namespace TEAMModelOS.Services.Common
                             case "once":
                                 // //如果是只能投票一次的活动则直接获取Redis的第一条 只能投一次
                                 Field = $"{userid}-once";
-                                RedisValue[] values = _azureRedis.GetRedisClient(8).HashValues($"Vote:Record:{vote.id}_{vote.code}");
+                                HashEntry[] values = _azureRedis.GetRedisClient(8).HashGetAll($"Vote:Record:{vote.id}_{vote.code}");
                                 if (values != null  && values.Length > 0)
                                 {
-                                    
                                     value = new RedisValue();
                                     foreach (var val in values) {
-                                        VoteRecord record = val.ToString().ToObject<VoteRecord>();
-                                        if (record.userid==userid) {
-                                            value = val;
+                                        if (val.Name.ToString() == Field) {
+                                            value = val.Value;
                                             break;
                                         }
                                     }
@@ -142,6 +140,8 @@ namespace TEAMModelOS.Services.Common
                     record.userid = userid;
                     //保存投票记录
                     bool status = await _azureRedis.GetRedisClient(8).HashSetAsync($"Vote:Record:{vote.id}_{vote.code}", Field, record.ToJsonString());
+                    //单独保存每个人方便查询的记录
+                    bool stuallstatus = await _azureRedis.GetRedisClient(8).HashSetAsync($"Vote:Record:{vote.id}_{vote.code}:{userid}", Field, record.ToJsonString());
                     //当前投票分组计数存入活动的Redis
                     var group_opt= option.GroupBy(x => x);
                     foreach (var opt in group_opt) {
@@ -161,6 +161,8 @@ namespace TEAMModelOS.Services.Common
                     //保存投票记录
                     VoteRecord record = new VoteRecord { opt = option, time = curr, userid = userid };
                     bool status = await _azureRedis.GetRedisClient(8).HashSetAsync($"Vote:Record:{vote.id}_{vote.code}", Field, record.ToJsonString());
+                    //单独保存每个人方便查询的记录
+                    bool stuallstatus = await _azureRedis.GetRedisClient(8).HashSetAsync($"Vote:Record:{vote.id}_{vote.code}:{userid}", Field, record.ToJsonString());
                     //当前投票分组计数存入活动的Redis
                     var group_opt = option.GroupBy(x => x);
                     foreach (var opt in group_opt)
@@ -212,11 +214,18 @@ namespace TEAMModelOS.Services.Common
         /// <returns></returns>
         public static async Task<(List<ActivityData> datas, string continuationTokenSchool,string continuationTokenTeacher)> FindAsStu( JsonElement requert, string id,string school, AzureCosmosFactory _azureCosmos,AzureRedisFactory _azureRedis)
         {
+            if (string.IsNullOrWhiteSpace(id)) {
+                id = requert.GetProperty("userid").GetString();
+            }
+            if (string.IsNullOrWhiteSpace(school))
+            {
+                school = requert.GetProperty("school").GetString();
+            }
             //开始时间,默认最近三十天
             var stimestamp = DateTimeOffset.UtcNow.AddDays(-30).ToUnixTimeMilliseconds();
             if (!requert.TryGetProperty("stime", out JsonElement stime))
             {
-                if (stime.TryGetInt64(out long data))
+                if (!stime.ValueKind.Equals(JsonValueKind.Undefined) && !stime.ValueKind.Equals(JsonValueKind.Null) &&stime.TryGetInt64(out long data))
                 {
                     stimestamp = data;
                 } 
@@ -249,7 +258,7 @@ namespace TEAMModelOS.Services.Common
             int? topcout = null;
             if (!requert.TryGetProperty("count", out JsonElement jcount))
             {
-                if (jcount.TryGetInt32(out int data))
+                if (!jcount.ValueKind.Equals(JsonValueKind.Undefined) && !jcount.ValueKind.Equals(JsonValueKind.Null) && jcount.TryGetInt32(out int data))
                 {
                     topcout = data;
                 } 
@@ -283,7 +292,7 @@ namespace TEAMModelOS.Services.Common
             string joinSqlClasses = "";
             string andSqlClasses = "";
             List<string> classes=null;
-            if (!requert.TryGetProperty("classes", out JsonElement jclasses))
+            if ( requert.TryGetProperty("classes", out JsonElement jclasses))
             {
                 if (jclasses.ValueKind is JsonValueKind.Array ) {
                     classes = jclasses.ToObject<List<string>>();
@@ -307,7 +316,7 @@ namespace TEAMModelOS.Services.Common
             //科目
             string joinSqlSubjects = "";
             string andSqlSubjects = "";
-            if (!requert.TryGetProperty("subjects", out JsonElement jsubjects))
+            if ( requert.TryGetProperty("subjects", out JsonElement jsubjects))
             {
                 if (jsubjects.ValueKind is JsonValueKind.Array)
                 {
@@ -321,24 +330,27 @@ namespace TEAMModelOS.Services.Common
                     }
                 }
             }
-            string querySchool = $" SELECT distinct  value c   FROM c  {joinSqlTmdids} {joinSqlClasses} {joinSqlSubjects}  where {stimesql}  {etimesql} and c.pk='Activity' {progresssql}  {typesql}  {andSqlSubjects}  {tgSql}";
             List<ActivityData> datas = new List<ActivityData>();
             var client = _azureCosmos.GetCosmosClient();
-            //查询数据归属学校的
-            await foreach (var item in client.GetContainer("TEAMModelOS","School").GetItemQueryStreamIterator(querySchool, continuationToken: continuationTokenSchool, requestOptions: new QueryRequestOptions() { MaxItemCount = topcout, PartitionKey = new PartitionKey($"Activity-{id}") }))
-            {
-                using var json = await JsonDocument.ParseAsync(item.ContentStream);
-                if (json.RootElement.TryGetProperty("_count", out JsonElement count) && count.GetUInt16() > 0)
+            if (!string.IsNullOrWhiteSpace(school)) {
+                string querySchool = $" SELECT distinct  value c   FROM c  {joinSqlTmdids} {joinSqlClasses} {joinSqlSubjects}  where {stimesql}  {etimesql} and c.pk='Activity' {progresssql}  {typesql}  {andSqlSubjects}  {tgSql}";
+               
+                //查询数据归属学校的
+                await foreach (var item in client.GetContainer("TEAMModelOS", "School").GetItemQueryStreamIterator(querySchool, continuationToken: continuationTokenSchool, requestOptions: new QueryRequestOptions() { MaxItemCount = topcout, PartitionKey = new PartitionKey($"Activity-{school}") }))
                 {
-                    foreach (var obj in json.RootElement.GetProperty("Documents").EnumerateArray())
-                    {
-                        datas.Add(obj.ToObject<ActivityData>());
-                    }
-                    //如果需要分页则跳出
-                    if (iscontinuation)
+                    using var json = await JsonDocument.ParseAsync(item.ContentStream);
+                    if (json.RootElement.TryGetProperty("_count", out JsonElement count) && count.GetUInt16() > 0)
                     {
-                        continuationTokenSchool = item.GetContinuationToken();
-                        break;
+                        foreach (var obj in json.RootElement.GetProperty("Documents").EnumerateArray())
+                        {
+                            datas.Add(obj.ToObject<ActivityData>());
+                        }
+                        //如果需要分页则跳出
+                        if (iscontinuation)
+                        {
+                            continuationTokenSchool = item.GetContinuationToken();
+                            break;
+                        }
                     }
                 }
             }
@@ -365,7 +377,7 @@ namespace TEAMModelOS.Services.Common
             bool tips = false;
             if (!requert.TryGetProperty("tips", out JsonElement jtips))
             {
-                if (!jtips.ValueKind.Equals(JsonValueKind.Null) && !jtips.ValueKind.Equals(JsonValueKind.True))
+                if (!jtips.ValueKind.Equals(JsonValueKind.Undefined) && !jtips.ValueKind.Equals(JsonValueKind.Null) && !jtips.ValueKind.Equals(JsonValueKind.True))
                 {
                     tips = jtips.GetBoolean();
                 }