Просмотр исходного кода

Merge branch 'develop5.0-tmd' of http://106.12.23.251:10000/TEAMMODEL/TEAMModelOS into develop5.0-tmd

liqk 4 лет назад
Родитель
Сommit
8533628541

+ 3 - 1
TEAMModelOS.SDK/Models/Cosmos/Common/Snode.cs

@@ -2,6 +2,7 @@ using System;
 using System.Collections.Generic;
 using System.Collections.Generic;
 using System.ComponentModel.DataAnnotations;
 using System.ComponentModel.DataAnnotations;
 using System.Text;
 using System.Text;
+using System.Text.Json;
 
 
 namespace TEAMModelOS.SDK.Models.Cosmos.Common
 namespace TEAMModelOS.SDK.Models.Cosmos.Common
 {
 {
@@ -63,6 +64,7 @@ namespace TEAMModelOS.SDK.Models.Cosmos.Common
         /// <summary>
         /// <summary>
         /// 存放地址 外部链接是绝对地址有http   blob是相对地址
         /// 存放地址 外部链接是绝对地址有http   blob是相对地址
         /// </summary>
         /// </summary>
-        public List<string> link { get; set; }
+        public string link { get; set; }
+       
     }
     }
 }
 }

+ 5 - 6
TEAMModelOS.SDK/Models/Cosmos/Common/Syllabus.cs

@@ -32,15 +32,14 @@ namespace TEAMModelOS.SDK.Models
     {
     {
         public string tmdid { get; set; }
         public string tmdid { get; set; }
         public string tmdname { get; set; }
         public string tmdname { get; set; }
-        public bool coedit { get; set; }
-        public bool share { get; set; }
         /// <summary>
         /// <summary>
-        /// 共编-是否同意
+        /// 分享  type=coedit共编,share分享
         /// </summary>
         /// </summary>
-        public int cagree { get; set; } = 0;
+        public string type { get; set; }
         /// <summary>
         /// <summary>
-        /// 分享-是否同意
+        /// 是否同意
         /// </summary>
         /// </summary>
-        public int sagree { get; set; } = 0;
+        public int agree { get; set; } = 0;
     }
     }
+     
 }
 }

+ 1 - 0
TEAMModelOS.SDK/Models/Cosmos/School/Paper.cs

@@ -62,6 +62,7 @@ namespace TEAMModelOS.SDK.Models
         public int multipleRule { get; set; }
         public int multipleRule { get; set; }
         //记录试卷大小
         //记录试卷大小
         public long? size { get; set; } = 0;
         public long? size { get; set; } = 0;
+        
         /// <summary>
         /// <summary>
         /// type:{
         /// type:{
         ///     pointkey:[num1,num2....]
         ///     pointkey:[num1,num2....]

+ 15 - 23
TEAMModelOS.SDK/Models/Cosmos/Teacher/Share.cs

@@ -45,14 +45,6 @@ namespace TEAMModelOS.SDK.Models
         [Required(ErrorMessage = "scope 必须设置")]
         [Required(ErrorMessage = "scope 必须设置")]
         public string scope { get; set; }
         public string scope { get; set; }
         /// <summary>
         /// <summary>
-        /// 共编
-        /// </summary>
-        public bool coedit { get; set; }
-        /// <summary>
-        /// 分享
-        /// </summary>
-        public bool share { get; set; }
-        /// <summary>
         /// 册别id
         /// 册别id
         /// </summary>
         /// </summary>
         public string volumeId { get; set; }
         public string volumeId { get; set; }
@@ -65,14 +57,15 @@ namespace TEAMModelOS.SDK.Models
         /// 册别名称
         /// 册别名称
         /// </summary>
         /// </summary>
         public string volumeName { get; set; }
         public string volumeName { get; set; }
+       
         /// <summary>
         /// <summary>
-        /// 共编-是否同意
+        /// 分享  type=coedit共编,share分享
         /// </summary>
         /// </summary>
-        public int cagree { get; set; } = 0;
+        public string type { get; set; }
         /// <summary>
         /// <summary>
-        /// 分享-是否同意
+        /// 是否同意
         /// </summary>
         /// </summary>
-        public int sagree { get; set; } =0;
+        public int agree { get; set; } = 0;
     }
     }
     /// <summary>
     /// <summary>
     /// 主动分享给谁,当接收者接收并完成相关资源复制后则删除本条数据。
     /// 主动分享给谁,当接收者接收并完成相关资源复制后则删除本条数据。
@@ -97,15 +90,7 @@ namespace TEAMModelOS.SDK.Models
 
 
         [Required(ErrorMessage = "tmdid 必须设置")]
         [Required(ErrorMessage = "tmdid 必须设置")]
         public List<TmdInfo> tmdInfo { get; set; } = new List<TmdInfo>();
         public List<TmdInfo> tmdInfo { get; set; } = new List<TmdInfo>();
-        
-        /// <summary>
-        /// 共编权限
-        /// </summary>
-        public bool coedit { get; set; } = false;
-        /// <summary>
-        /// 分享权限
-        /// </summary>
-        public bool share { get; set; } = false;
+      
         /// <summary>
         /// <summary>
         /// 课纲章节的id
         /// 课纲章节的id
         /// </summary>
         /// </summary>
@@ -129,7 +114,14 @@ namespace TEAMModelOS.SDK.Models
         /// </summary>
         /// </summary>
         [Required(ErrorMessage = "issuer 必须设置")]
         [Required(ErrorMessage = "issuer 必须设置")]
         public string issuer { get; set; }
         public string issuer { get; set; }
-    }
-
 
 
+        /// <summary>
+        /// 分享  type=coedit共编,share分享
+        /// </summary>
+        public string type { get; set; }
+        /// <summary>
+        /// 是否同意
+        /// </summary>
+        public int agree { get; set; } = 0;
+    }
 }
 }

+ 3 - 0
TEAMModelOS/ClientApp/src/api/syllabus.js

@@ -28,6 +28,9 @@ export default {
 	ViewShare:function(data) {
 	ViewShare:function(data) {
 	    return post('/teacher/share/view-share', data)
 	    return post('/teacher/share/view-share', data)
 	},
 	},
+	ShareAgree:function(data) {
+	    return post('/teacher/share/agree', data)
+	},
 	// 查找知识块数量
 	// 查找知识块数量
 	FindBlockCount: function (data) {
 	FindBlockCount: function (data) {
 		return post('/knowledges/find-count', data)
 		return post('/knowledges/find-count', data)

+ 8 - 1
TEAMModelOS/ClientApp/src/components/syllabus/DragTree.vue

@@ -11,7 +11,11 @@
 						<Icon type="md-cube" color="#00c38d" :title="$t('syllabus.tree.hasResource')" v-if="data.rnodes && data.rnodes.length" />
 						<Icon type="md-cube" color="#00c38d" :title="$t('syllabus.tree.hasResource')" v-if="data.rnodes && data.rnodes.length" />
 						<Icon type="md-git-compare" color="#00c38d" :title="$t('syllabus.tree.hasCoEdit')" v-if="hasEditAuth(data) && isSchool" />
 						<Icon type="md-git-compare" color="#00c38d" :title="$t('syllabus.tree.hasCoEdit')" v-if="hasEditAuth(data) && isSchool" />
 					</span>
 					</span>
-					<span class="custom-tree-tools" v-if="(hasEditAuth(data) || $access.can('admin.*|Syllabus_Edit'))">
+					<span class="custom-tree-tools" v-if="inShareView && isFirstLevel(data)">
+						<Icon type="ios-remove-circle-outline" style="margin-right: 5px;" size="16" />
+						<span style="color: #9f9f9f;font-size: 12px;margin-right: 20px;">忽略该章节</span>
+					</span>
+					<span class="custom-tree-tools" v-if="((hasEditAuth(data) || $access.can('admin.*|Syllabus_Edit')) && !inShareView)">
 						<Icon type="md-create" size="16" :title="$t('syllabus.tree.edit')" @click="onEditItem(node,data,$event)" />
 						<Icon type="md-create" size="16" :title="$t('syllabus.tree.edit')" @click="onEditItem(node,data,$event)" />
 						<Icon type="md-add" size="16" :title="$t('syllabus.tree.add')" @click="onAddNode(node,data,$event)" />
 						<Icon type="md-add" size="16" :title="$t('syllabus.tree.add')" @click="onAddNode(node,data,$event)" />
 						<Icon type="md-remove" size="16" :title="$t('syllabus.tree.remove')" @click="remove(node,data)" v-if="!isFirstLevel(data) ||  (canDeleteChapter(data) && isFirstLevel(data))"/>
 						<Icon type="md-remove" size="16" :title="$t('syllabus.tree.remove')" @click="remove(node,data)" v-if="!isFirstLevel(data) ||  (canDeleteChapter(data) && isFirstLevel(data))"/>
@@ -310,6 +314,9 @@
 				return nodeData => {
 				return nodeData => {
 					return nodeData.creatorId === this.$store.state.userInfo.TEAMModelId
 					return nodeData.creatorId === this.$store.state.userInfo.TEAMModelId
 				}
 				}
+			},
+			inShareView(){
+				return !this.isSchool && this.$parent.activeTab === 'fromShare'
 			}
 			}
 		},
 		},
 		watch: {
 		watch: {

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

@@ -720,6 +720,7 @@
 						this.pageScrollTo(0)
 						this.pageScrollTo(0)
 						this.$nextTick(() => {
 						this.$nextTick(() => {
 							// this.$MathJax.MathQueue(this.$refs.mathJaxContainer);
 							// this.$MathJax.MathQueue(this.$refs.mathJaxContainer);
+							// this.onConfirmTypeScore()
 						})
 						})
 					}
 					}
 				},
 				},

+ 20 - 3
TEAMModelOS/ClientApp/src/view/evaluation/index/CreatePaper.vue

@@ -320,6 +320,17 @@
 			 */
 			 */
 			async getAutoQuestions(questions) {
 			async getAutoQuestions(questions) {
 				let autoQuestions = await this.$evTools.getFullItem(questions)
 				let autoQuestions = await this.$evTools.getFullItem(questions)
+				let arr = autoQuestions
+				let scoreArr = this.averageTotalScore(this.evaluationInfo.score, arr.length)
+				arr.forEach((i, index) => {
+					i.score = scoreArr[index] || 0
+					if(i.type === 'compose' && i.children.length){
+						let childrenScoreArr = this.averageTotalScore(i.score, i.children.length)
+						i.children.forEach((child,childIndex) => {
+							child.score = childrenScoreArr[childIndex]
+						})
+					}
+				})
 				this.evaluationInfo.item = []
 				this.evaluationInfo.item = []
 				this.evaluationInfo.item = this.evaluationInfo.item.concat([...autoQuestions])
 				this.evaluationInfo.item = this.evaluationInfo.item.concat([...autoQuestions])
 				this.activeTab = 'preview'
 				this.activeTab = 'preview'
@@ -335,8 +346,13 @@
 				let scoreArr = this.averageTotalScore(this.evaluationInfo.score, arr.length)
 				let scoreArr = this.averageTotalScore(this.evaluationInfo.score, arr.length)
 				arr.forEach((i, index) => {
 				arr.forEach((i, index) => {
 					i.score = scoreArr[index] || 0
 					i.score = scoreArr[index] || 0
+					if(i.type === 'compose' && i.children.length){
+						let childrenScoreArr = this.averageTotalScore(i.score, i.children.length)
+						i.children.forEach((child,childIndex) => {
+							child.score = childrenScoreArr[childIndex]
+						})
+					}
 				})
 				})
-				console.log()
 				// 如果是编辑试卷 则往原试卷添加不包含的新题目进入
 				// 如果是编辑试卷 则往原试卷添加不包含的新题目进入
 				if (this.isEditPaper) {
 				if (this.isEditPaper) {
 					let list = this.evaluationInfo.item
 					let list = this.evaluationInfo.item
@@ -351,14 +367,15 @@
 				console.log('手动挑题返回')
 				console.log('手动挑题返回')
 				console.log(arr)
 				console.log(arr)
 			},
 			},
-
+			
+			/* 根据总分给出固定长度的平均分配数组 */
 			averageTotalScore(total, length) {
 			averageTotalScore(total, length) {
 				let result = new Array(length).fill(0)
 				let result = new Array(length).fill(0)
 				// 先判断是否总分除以题目数量能否除尽
 				// 先判断是否总分除以题目数量能否除尽
 				let remainder = total % length
 				let remainder = total % length
 				// 如果可以整除 则直接计算
 				// 如果可以整除 则直接计算
 				if (remainder === 0) {
 				if (remainder === 0) {
-					result = result.map(i => total % length)
+					result = result.map(i => total / length)
 				} else {
 				} else {
 					// 如果不能整除 则前面所有取整 最后一题加上余数 即可完成配分
 					// 如果不能整除 则前面所有取整 最后一题加上余数 即可完成配分
 					let integerScore = parseInt(total / length)
 					let integerScore = parseInt(total / length)

+ 27 - 0
TEAMModelOS/ClientApp/src/view/syllabus/Syllabus.less

@@ -131,6 +131,33 @@
 								margin: 0 8px;
 								margin: 0 8px;
 							}
 							}
 						}
 						}
+						
+						.volume-btn-agree{
+							display: inline-flex;
+							justify-content: center;
+							align-items: center;
+							padding: 3px 8px;
+							color: #fff;
+							border-radius: 4px;
+							vertical-align: middle;
+							span{
+								display: inline-block;
+								margin: 2px 5px 0 5px;
+							}
+						}
+						
+						.volume-btn-refuse{
+							display: inline-flex;
+							justify-content: center;
+							align-items: center;
+							padding: 3px 8px;
+							vertical-align: middle;
+							color: #fff;
+							span{
+								display: inline-block;
+								margin: 2px 5px 0 5px;
+							}
+						}
 					}
 					}
 					&:hover{
 					&:hover{
 						.volume-active;
 						.volume-active;

+ 39 - 5
TEAMModelOS/ClientApp/src/view/syllabus/Syllabus.vue

@@ -28,10 +28,11 @@
 					<div v-if="!isSearchVolume">
 					<div v-if="!isSearchVolume">
 						<span>册别清单</span>
 						<span>册别清单</span>
 						<span class="syllabus-content-header-tools">
 						<span class="syllabus-content-header-tools">
-							<Icon type="md-search" @click="doSearchVolume" />
-							<Icon type="md-create" @click="doEditVolume" v-if="hasSyllabusAuth" />
-							<Icon type="md-trash" @click="doDeleteVolume" v-if="hasSyllabusAuth" />
-							<Icon type="md-add" @click="doAddVolume" v-if="hasSyllabusAuth" />
+							<Icon type="md-search" title="搜索" @click="doSearchVolume" />
+							<Icon type="md-copy" title="复制副本" @click="doCopyVolume" v-if="hasSyllabusAuth && inShareView" />
+							<Icon type="md-create" title="编辑" @click="doEditVolume" v-if="hasSyllabusAuth" />
+							<Icon type="md-trash" title="删除" @click="doDeleteVolume" v-if="hasSyllabusAuth && !inShareView" />
+							<Icon type="md-add" title="新建册别" @click="doAddVolume" v-if="hasSyllabusAuth" />
 						</span>
 						</span>
 					</div>
 					</div>
 					<div style="width: 90%;" v-else>
 					<div style="width: 90%;" v-else>
@@ -51,6 +52,21 @@
 								<span>|</span>
 								<span>|</span>
 								<span>{{ getSemesterName(volume.semesterId) }}</span>
 								<span>{{ getSemesterName(volume.semesterId) }}</span>
 							</p>
 							</p>
+							<p class="volume-item-info" v-if="inShareView">
+								<span  style="display: flex;align-items: center;">
+									<Icon type="ios-remove-circle-outline" style="font-weight: bold;margin-right: 5px;"/>
+									忽略该分享
+								</span>
+								<!-- <span class="volume-btn-agree" @click="onAgreeShare(volume,'agree')">
+									<Icon type="md-checkmark-circle-outline" size="20" color="#27c684" />
+									<span>接受</span>
+								</span>
+								<span class="volume-btn-refuse" @click="onAgreeShare(volume,'refuse')">
+									<Icon type="ios-close-circle-outline" size="20" color="#d02a4e"
+										style="font-weight: bold;" />
+										<span>拒绝</span>
+									</span> -->
+							</p>
 						</div>
 						</div>
 					</div>
 					</div>
 				</vuescroll>
 				</vuescroll>
@@ -448,8 +464,19 @@
 					this.$Message.error(err);
 					this.$Message.error(err);
 				})
 				})
 			},
 			},
+			/* 是否接受分享的课纲 */
+			onAgreeShare(volume,type){
+				// this.$api.syllabus.ShareAgree({
+				// 	code:volume.code,
+				// 	id:volume.id,
+				// 	agree:type === 'agree' ? 3 : 4
+				// }).then(res => {
+					
+				// })
+			},
 			/* 点击某个册别 */
 			/* 点击某个册别 */
 			onVolumeClick(volume, volumeIndex) {
 			onVolumeClick(volume, volumeIndex) {
+				console.log(volume)
 				if (!volume || (volume.id === this.curVolume.id && !this.isEditVolume)) return
 				if (!volume || (volume.id === this.curVolume.id && !this.isEditVolume)) return
 				this.isLoading = true
 				this.isLoading = true
 				this.curVolume = volume
 				this.curVolume = volume
@@ -467,6 +494,10 @@
 				}
 				}
 				this.isEditVolume = false
 				this.isEditVolume = false
 				this.isAddVolumeModal = true
 				this.isAddVolumeModal = true
+			},
+			/* 复制副本 */
+			doCopyVolume(){
+				
 			},
 			},
 			/* 搜索册别 */
 			/* 搜索册别 */
 			doSearchVolume() {
 			doSearchVolume() {
@@ -499,7 +530,7 @@
 				let curVolume = this.curVolume
 				let curVolume = this.curVolume
 				this.$Modal.confirm({
 				this.$Modal.confirm({
 					title: "删除册别",
 					title: "删除册别",
-					content: "<p>确认除该册别?</p>",
+					content: "<p>确认除该册别?</p>",
 					onOk: () => {
 					onOk: () => {
 						this.isLoading = true;
 						this.isLoading = true;
 						this.$api.syllabus.DeleteVolume({
 						this.$api.syllabus.DeleteVolume({
@@ -1290,6 +1321,9 @@
 			// 是否可以操作课纲模块(个人课纲或者管理员或者有课纲权限)
 			// 是否可以操作课纲模块(个人课纲或者管理员或者有课纲权限)
 			hasSyllabusAuth() {
 			hasSyllabusAuth() {
 				return !this.isSchool || this.$access.can('admin.*|Syllabus_Edit')
 				return !this.isSchool || this.$access.can('admin.*|Syllabus_Edit')
+			},
+			inShareView(){
+				return !this.isSchool && this.activeTab === 'fromShare'
 			}
 			}
 		},
 		},
 	}
 	}

+ 11 - 3
TEAMModelOS/Controllers/Common/ExamController.cs

@@ -24,6 +24,7 @@ using TEAMModelOS.SDK.Models.Cosmos.Common;
 using TEAMModelOS.SDK.Models.Table;
 using TEAMModelOS.SDK.Models.Table;
 using Azure.Messaging.ServiceBus;
 using Azure.Messaging.ServiceBus;
 using Microsoft.Extensions.Configuration;
 using Microsoft.Extensions.Configuration;
+using TEAMModelOS.Filter;
 
 
 namespace TEAMModelOS.Controllers
 namespace TEAMModelOS.Controllers
 {
 {
@@ -62,7 +63,7 @@ namespace TEAMModelOS.Controllers
         /// <param name="request"></param>
         /// <param name="request"></param>
         /// <returns></returns>
         /// <returns></returns>
         [ProducesDefaultResponseType]
         [ProducesDefaultResponseType]
-        //[AuthToken(Roles = "Teacher")]
+        [AuthToken(Roles = "Teacher")]
         [HttpPost("save")]
         [HttpPost("save")]
         public async Task<IActionResult> Save(ExamInfo request)
         public async Task<IActionResult> Save(ExamInfo request)
         {
         {
@@ -1192,12 +1193,19 @@ namespace TEAMModelOS.Controllers
                         total.Add(result.sum.Where(s => s > 90 && s <= 100).Count());
                         total.Add(result.sum.Where(s => s > 90 && s <= 100).Count());
                     }
                     }
                 }
                 }
-                return Ok(new { papers, subjects, stuScore, stuAns, mark, total, claId = infoIds });
+                if (papers.IsNotEmpty())
+                {
+                    return Ok(new { papers, subjects, stuScore, stuAns, mark, total, claId = infoIds, status = 200 });
+                }
+                else {
+                    return Ok(new { papers, subjects, stuScore, stuAns, mark, total, claId = infoIds,status=404 });
+                }
+               
             }
             }
             catch (Exception ex)
             catch (Exception ex)
             {
             {
                 await _dingDing.SendBotMsg($"OS,{_option.Location},exam/find-summary-by-student()\n{ex.Message}", GroupNames.醍摩豆服務運維群組);
                 await _dingDing.SendBotMsg($"OS,{_option.Location},exam/find-summary-by-student()\n{ex.Message}", GroupNames.醍摩豆服務運維群組);
-                return BadRequest();
+                return Ok(new {  status = 400 });
             }
             }
 
 
         }
         }

+ 3 - 3
TEAMModelOS/Controllers/Pager/PaperController.cs

@@ -93,7 +93,7 @@ namespace TEAMModelOS.Controllers
             var id = jwt.Payload.Sub;
             var id = jwt.Payload.Sub;
             var client = _azureCosmos.GetCosmosClient();
             var client = _azureCosmos.GetCosmosClient();
             List<object> papers = new List<object>();
             List<object> papers = new List<object>();
-            var query = $"select c.id,c.subjectCode,c.code,c.periodCode,c.name,c.itemCount,c.level,c.pointItem,c.pointScore,c.score,c.gradeCode from c where c.id = {id}";
+            var query = $"select c.id,c.subjectCode,c.code,c.periodCode,c.name,c.itemCount,c.level,c.pointItem,c.pointScore,c.score,c.gradeCode,c.createTime from c where c.id = {id}";
             await foreach (var item in client.GetContainer("TEAMModelOS", "School").GetItemQueryStreamIterator(queryText: query, requestOptions: new QueryRequestOptions() { PartitionKey = new PartitionKey($"Paper-{school_code}") }))
             await foreach (var item in client.GetContainer("TEAMModelOS", "School").GetItemQueryStreamIterator(queryText: query, requestOptions: new QueryRequestOptions() { PartitionKey = new PartitionKey($"Paper-{school_code}") }))
             {
             {
                 using var json = await JsonDocument.ParseAsync(item.ContentStream);
                 using var json = await JsonDocument.ParseAsync(item.ContentStream);
@@ -154,7 +154,7 @@ namespace TEAMModelOS.Controllers
             
             
             if (scope.ToString().Equals("school"))
             if (scope.ToString().Equals("school"))
             {
             {
-                sql.Append("select c.id,c.code,c.name,c.blob,c.periodId,c.gradeIds,c.subjectId,c.subjectName,c.score,c.useCount,c.scope,c.scoring from c");
+                sql.Append("select c.id,c.code,c.name,c.blob,c.periodId,c.gradeIds,c.subjectId,c.subjectName,c.score,c.useCount,c.scope,c.scoring,c.createTime from c");
                 AzureCosmosQuery cosmosDbQuery = SQLHelper.GetSQL(dict, sql);
                 AzureCosmosQuery cosmosDbQuery = SQLHelper.GetSQL(dict, sql);
                 await foreach (var item in client.GetContainer("TEAMModelOS", "School").GetItemQueryStreamIterator(queryDefinition: cosmosDbQuery.CosmosQueryDefinition, requestOptions: new QueryRequestOptions() { PartitionKey = new PartitionKey($"Paper-{code}") }))
                 await foreach (var item in client.GetContainer("TEAMModelOS", "School").GetItemQueryStreamIterator(queryDefinition: cosmosDbQuery.CosmosQueryDefinition, requestOptions: new QueryRequestOptions() { PartitionKey = new PartitionKey($"Paper-{code}") }))
                 {
                 {
@@ -171,7 +171,7 @@ namespace TEAMModelOS.Controllers
             }
             }
             if (scope.ToString().Equals("private"))
             if (scope.ToString().Equals("private"))
             {
             {
-                sql.Append("select c.id,c.code,c.name,c.blob,c.subjectName,c.score,c.useCount,c.scope,c.scoring from c");
+                sql.Append("select c.id,c.code,c.name,c.blob,c.subjectName,c.score,c.useCount,c.scope,c.scoring ,c.createTime from c");
                 AzureCosmosQuery cosmosDbQuery = SQLHelper.GetSQL(dict, sql);
                 AzureCosmosQuery cosmosDbQuery = SQLHelper.GetSQL(dict, sql);
                 await foreach (var item in client.GetContainer("TEAMModelOS", "Teacher").GetItemQueryStreamIterator(queryDefinition: cosmosDbQuery.CosmosQueryDefinition, requestOptions: new QueryRequestOptions() { PartitionKey = new PartitionKey($"Paper-{code}") }))
                 await foreach (var item in client.GetContainer("TEAMModelOS", "Teacher").GetItemQueryStreamIterator(queryDefinition: cosmosDbQuery.CosmosQueryDefinition, requestOptions: new QueryRequestOptions() { PartitionKey = new PartitionKey($"Paper-{code}") }))
                 {
                 {

+ 79 - 143
TEAMModelOS/Controllers/Syllabus/ShareController.cs

@@ -49,8 +49,8 @@ namespace TEAMModelOS.Controllers
             "school": "学校编码",
             "school": "学校编码",
             "scope":"school|private",
             "scope":"school|private",
             "tmdInfo":["tmdid":"id1","tmdname":"name1"],
             "tmdInfo":["tmdid":"id1","tmdname":"name1"],
-            "coedit":true,
-            "share":true,
+            "type":"coedit共编,share分享",
+            "agree":0,1,
             "issuer":"权限颁发者tmdid",
             "issuer":"权限颁发者tmdid",
             "opt":"add/del/edit"
             "opt":"add/del/edit"
             "syllabusId":"分享的课纲章节id",
             "syllabusId":"分享的课纲章节id",
@@ -103,42 +103,21 @@ namespace TEAMModelOS.Controllers
                         shares.ForEach(async x=> {
                         shares.ForEach(async x=> {
                             await client.GetContainer("TEAMModelOS", "Teacher").UpsertItemAsync<Share>(x, new PartitionKey($"{x.code}"));
                             await client.GetContainer("TEAMModelOS", "Teacher").UpsertItemAsync<Share>(x, new PartitionKey($"{x.code}"));
                             //发送共编或分享通知
                             //发送共编或分享通知
-                            if (x.coedit == true) {
-                                Notification notification = new Notification
-                                {
-                                    hubName = "hita",
-                                    type = "msg",
-                                    from = $"ies5:{request.school}",
-                                    to = new List<string>() { x.code.Replace("Share-","") },
-                                    label = $"coedit_syllabus",
-                                    body = new { biz = "coedit", tmdid = x.issuer,  schoolcode = $"{request.school}",  status = 1, time = DateTimeOffset.UtcNow.ToUnixTimeMilliseconds() }.ToJsonString(),
-                                    expires = DateTimeOffset.UtcNow.AddDays(7).ToUnixTimeSeconds()
-                                };
-                                var url = _configuration.GetValue<string>("HaBookAuth:CoreService:sendnotification");
-                                var clientID = _configuration.GetValue<string>("HaBookAuth:CoreService:clientID");
-                                var clientSecret = _configuration.GetValue<string>("HaBookAuth:CoreService:clientSecret");
-                                var location = _option.Location;
-                                var code = await _notificationService.SendNotification(clientID, clientSecret, location, url, notification);
-                            }
-                            if (x.share == true)
+                            Notification notification = new Notification
                             {
                             {
-                                Notification notification = new Notification
-                                {
-                                    hubName = "hita",
-                                    type = "msg",
-                                    from = $"ies5:{request.school}",
-                                    to = new List<string>() { x.code.Replace("Share-", "") },
-                                    label = $"share_syllabus",
-                                    body = new { biz = "share", tmdid = x.issuer, schoolcode = $"{request.school}", status = 1, time = DateTimeOffset.UtcNow.ToUnixTimeMilliseconds() }.ToJsonString(),
-                                    expires = DateTimeOffset.UtcNow.AddDays(7).ToUnixTimeSeconds()
-                                }; 
-                                var url = _configuration.GetValue<string>("HaBookAuth:CoreService:sendnotification");
-                                var clientID = _configuration.GetValue<string>("HaBookAuth:CoreService:clientID");
-                                var clientSecret = _configuration.GetValue<string>("HaBookAuth:CoreService:clientSecret");
-                                var location = _option.Location;
-                                var code = await _notificationService.SendNotification(clientID, clientSecret, location, url, notification);
-                            }
-                           
+                                hubName = "hita",
+                                type = "msg",
+                                from = $"ies5:{request.school}",
+                                to = new List<string>() { x.code.Replace("Share-","") },
+                                label = $"{x.type}_syllabus",
+                                body = new { biz = x.type, tmdid = x.issuer,  schoolcode = $"{request.school}",  status = 1, time = DateTimeOffset.UtcNow.ToUnixTimeMilliseconds() }.ToJsonString(),
+                                expires = DateTimeOffset.UtcNow.AddDays(7).ToUnixTimeSeconds()
+                            };
+                            var url = _configuration.GetValue<string>("HaBookAuth:CoreService:sendnotification");
+                            var clientID = _configuration.GetValue<string>("HaBookAuth:CoreService:clientID");
+                            var clientSecret = _configuration.GetValue<string>("HaBookAuth:CoreService:clientSecret");
+                            var location = _option.Location;
+                            var code = await _notificationService.SendNotification(clientID, clientSecret, location, url, notification);
                         });
                         });
                         await client.GetContainer("TEAMModelOS", "School").UpsertItemAsync<Syllabus>(syllabus, new PartitionKey($"Syllabus-{request.volumeId}"));
                         await client.GetContainer("TEAMModelOS", "School").UpsertItemAsync<Syllabus>(syllabus, new PartitionKey($"Syllabus-{request.volumeId}"));
 
 
@@ -196,17 +175,15 @@ namespace TEAMModelOS.Controllers
                     volumeId = request.volumeId,
                     volumeId = request.volumeId,
                     volumeName = request.volumeName,
                     volumeName = request.volumeName,
                     syllabusName = request.syllabusName,
                     syllabusName = request.syllabusName,
-                    code = $"Share-{xmd.tmdid}",
+                    code = $"Share-{request.type}-{xmd.tmdid}",
                     pk = "Share",
                     pk = "Share",
                     ttl = -1,
                     ttl = -1,
                     issuer = request.issuer,
                     issuer = request.issuer,
                     createTime = now,
                     createTime = now,
                     school = request.school,
                     school = request.school,
                     scope = request.scope,
                     scope = request.scope,
-                    coedit = request.coedit,
-                    share = request.share,
-                    cagree = 0,
-                    sagree = 0
+                    type =request.type,
+                    agree = request.agree
                 };
                 };
                 shares.Add(share);
                 shares.Add(share);
             });
             });
@@ -219,7 +196,7 @@ namespace TEAMModelOS.Controllers
                     int indx = 0;
                     int indx = 0;
                     for (int index = 0; index < syllabus.auth.Count; index++)
                     for (int index = 0; index < syllabus.auth.Count; index++)
                     {
                     {
-                        if (syllabus.auth[index].tmdid == xmd.tmdid)
+                        if (syllabus.auth[index].tmdid == xmd.tmdid && request.type== syllabus.auth[index].type)
                         {
                         {
                             flag = true;
                             flag = true;
                             indx = index;
                             indx = index;
@@ -233,8 +210,8 @@ namespace TEAMModelOS.Controllers
                         {
                         {
                             tmdid = xmd.tmdid,
                             tmdid = xmd.tmdid,
                             tmdname = xmd.tmdname,
                             tmdname = xmd.tmdname,
-                            coedit = request.coedit,
-                            share = request.share,
+                            type = request.type,
+                            agree = request.agree,
                         };
                         };
                     }
                     }
                     //新增
                     //新增
@@ -244,8 +221,8 @@ namespace TEAMModelOS.Controllers
                         {
                         {
                             tmdid = xmd.tmdid,
                             tmdid = xmd.tmdid,
                             tmdname = xmd.tmdname,
                             tmdname = xmd.tmdname,
-                            coedit = request.coedit,
-                            share = request.share,
+                            type = request.type,
+                            agree = request.agree,
                         });
                         });
                     }
                     }
                 });
                 });
@@ -257,114 +234,84 @@ namespace TEAMModelOS.Controllers
                         new SyllabusAuth {
                         new SyllabusAuth {
                             tmdid = xmd.tmdid,
                             tmdid = xmd.tmdid,
                             tmdname = xmd.tmdname,
                             tmdname = xmd.tmdname,
-                            coedit=request.coedit,
-                            share=request.share,
+                            type = request.type,
+                            agree = request.agree,
                         }
                         }
                     };
                     };
                 });
                 });
             }
             }
             return (syllabus, shares);
             return (syllabus, shares);
         }
         }
-
         /// <summary>
         /// <summary>
-        /// {"code":"教师编码","id":"章节id","agree":1共编同意,2共编拒绝,3分享同意,4分享拒绝} 
-        /// 教师拉取自己收到的分享及共编
+        /// {"code":"教师编码","id":"章节id","type":"coedit/share","opt":"ignore/agree"} 
+        /// 
+        /// 教师操作收到的分享及课纲共编, ignore 忽略,需要删除Share 数据 并更新syllabus.auth
         /// </summary>
         /// </summary>
         /// <param name="request"></param>
         /// <param name="request"></param>
         /// <returns></returns>
         /// <returns></returns>
         [ProducesDefaultResponseType]
         [ProducesDefaultResponseType]
-        [HttpPost("agree")]
+        [HttpPost("agree-share")]
         // [AuthToken(Roles = "Teacher")]
         // [AuthToken(Roles = "Teacher")]
-        public async Task<IActionResult> Agree(JsonElement request) {
-            try { 
-            if (!request.TryGetProperty("agree", out JsonElement agree)) { return BadRequest(); }
-            if (!request.TryGetProperty("code", out JsonElement code)) { return BadRequest(); }
-            if (!request.TryGetProperty("id", out JsonElement id)) { return BadRequest(); }
-            var client = _azureCosmos.GetCosmosClient();
-            Share share= await client.GetContainer("TEAMModelOS", "Teacher").ReadItemAsync<Share>($"{id}", new PartitionKey($"Share-{code}"));
-                if (agree.ValueKind.Equals(JsonValueKind.Number))
+        public async Task<IActionResult> AgreeShare(JsonElement request) {
+            try {
+                if (!request.TryGetProperty("type", out JsonElement type)) { return BadRequest(); }
+                if (!request.TryGetProperty("code", out JsonElement code)) { return BadRequest(); }
+                if (!request.TryGetProperty("id", out JsonElement id)) { return BadRequest(); }
+                if (!request.TryGetProperty("opt", out JsonElement opt)) { return BadRequest(); }
+                var client = _azureCosmos.GetCosmosClient();
+                Share share = await client.GetContainer("TEAMModelOS", "Teacher").ReadItemAsync<Share>($"{id}", new PartitionKey($"Share-{type}-{code}"));
+                Syllabus syllabus = null;
+                if (share.scope == "school")
                 {
                 {
-                    int agreeNum = agree.GetInt32();
-                    if (agreeNum == 1)
-                    {
-                        share.cagree = 1;
-                    }
-                    else if (agreeNum == 2)
-                    {
-                        share.cagree = 2;
-                    }
-                    else if (agreeNum == 3)
-                    {
-                        share.sagree = 1;
-                    }
-                    else if (agreeNum == 4)
-                    {
-                        share.sagree = 2;
-                    }
-                    else
-                    {
-                        return Ok(new { status = 500 });
-                    }
-                    await client.GetContainer("TEAMModelOS", "Teacher").ReplaceItemAsync<Share>(share, $"{id}", new PartitionKey($"Share-{code}"));
-                    Syllabus syllabus = null;
-                    if (share.scope == "school")
-                    {
-                        syllabus = await client.GetContainer("TEAMModelOS", "School").ReadItemAsync<Syllabus>($"{id}", new PartitionKey($"Syllabus-{share.volumeId}"));
-                    }
-                    else if (share.scope == "private")
-                    {
-                        syllabus = await client.GetContainer("TEAMModelOS", "Teacher").ReadItemAsync<Syllabus>($"{id}", new PartitionKey($"Syllabus-{share.volumeId}"));
-                    }
-                    if (syllabus.auth.IsNotEmpty())
+                    syllabus = await client.GetContainer("TEAMModelOS", "School").ReadItemAsync<Syllabus>($"{id}", new PartitionKey($"Syllabus-{share.volumeId}"));
+                }
+                else if (share.scope == "private")
+                {
+                    syllabus = await client.GetContainer("TEAMModelOS", "Teacher").ReadItemAsync<Syllabus>($"{id}", new PartitionKey($"Syllabus-{share.volumeId}"));
+                }
+                if (syllabus.auth.IsNotEmpty())
+                {
+                    syllabus.auth.ForEach(x =>
                     {
                     {
-                        syllabus.auth.ForEach(x =>
+                        if (x.tmdid == $"{code}" && x.type==$"{type}")
                         {
                         {
-                            if (x.tmdid == $"{code}")
+                            if ($"{opt}".Equals("ignore"))
                             {
                             {
-                                if (agreeNum == 1)
-                                {
-                                    x.cagree = 1;
-                                }
-                                else if (agreeNum == 2)
-                                {
-                                    x.cagree = 2;
-                                }
-                                else if (agreeNum == 3)
-                                {
-                                    x.sagree = 1;
-                                }
-                                else if (agreeNum == 4)
-                                {
-                                    x.sagree = 2;
-                                }
+                                x.agree = 0;
                             }
                             }
-                        });
-                    }
-                    if (share.scope == "school")
-                    {
-                        syllabus = await client.GetContainer("TEAMModelOS", "School").ReplaceItemAsync<Syllabus>(syllabus, $"{id}", new PartitionKey($"Syllabus-{share.volumeId}"));
-                    }
-                    else if (share.scope == "private")
-                    {
-                        syllabus = await client.GetContainer("TEAMModelOS", "Teacher").ReplaceItemAsync<Syllabus>(syllabus, $"{id}", new PartitionKey($"Syllabus-{share.volumeId}"));
-                    }
-                    return Ok(new { status = 200 });
+                            else if ($"{opt}".Equals("ignore")) {
+                                x.agree = 1;
+                            }
+                          
+                        }
+                    });
                 }
                 }
-                else
+                if (share.scope == "school")
                 {
                 {
-                    return Ok(new { status = 500 });
+                    syllabus = await client.GetContainer("TEAMModelOS", "School").ReplaceItemAsync<Syllabus>(syllabus, $"{id}", new PartitionKey($"Syllabus-{share.volumeId}"));
                 }
                 }
-            }  catch (Exception ex)
-            {
-                await _dingDing.SendBotMsg($"OS,{_option.Location},teacher/share/agree()\n{ex.Message}{ex.StackTrace}", GroupNames.醍摩豆服務運維群組);
+                else if (share.scope == "private")
+                {
+                    syllabus = await client.GetContainer("TEAMModelOS", "Teacher").ReplaceItemAsync<Syllabus>(syllabus, $"{id}", new PartitionKey($"Syllabus-{share.volumeId}"));
+                }
+                if ($"{opt}".Equals("ignore"))
+                {
+                    share.agree = 1;
+                    await client.GetContainer("TEAMModelOS", "Teacher").ReplaceItemAsync<Share>(share,$"{id}", new PartitionKey($"Share-{type}-{code}"));
+                }
+                else if ($"{opt}".Equals("ignore"))
+                {
+                    await client.GetContainer("TEAMModelOS", "Teacher").DeleteItemAsync<Share>($"{id}", new PartitionKey($"Share-{type}-{code}"));
+                }
+                return Ok(new { status = 200 });
+            } catch (Exception ex) {
+                await _dingDing.SendBotMsg($"OS,{_option.Location},teacher/share/agree-share()\n{ex.Message}{ex.StackTrace}", GroupNames.醍摩豆服務運維群組);
                 return Ok(new { status = 500 });
                 return Ok(new { status = 500 });
             }
             }
-
         }
         }
 
 
-
         /// <summary>
         /// <summary>
-        /// {"code":"教师编码","type":"coedit/share"} 
+        /// {"code":"教师编码","type":"coedit/share","id":"册别id"} 
         /// 教师拉取自己收到的分享及共编
         /// 教师拉取自己收到的分享及共编
         /// </summary>
         /// </summary>
         /// <param name="request"></param>
         /// <param name="request"></param>
@@ -382,23 +329,12 @@ namespace TEAMModelOS.Controllers
                 request.TryGetProperty("id", out JsonElement id);
                 request.TryGetProperty("id", out JsonElement id);
                 var client = _azureCosmos.GetCosmosClient();
                 var client = _azureCosmos.GetCosmosClient();
                 StringBuilder queryText = new StringBuilder("select value(c) from c");
                 StringBuilder queryText = new StringBuilder("select value(c) from c");
-                if (type.ValueKind.Equals(JsonValueKind.String) && type.GetString() == "coedit")
-                {
-                    queryText.Append(" where c.coedit=true");
-                }
-                else if (type.ValueKind.Equals(JsonValueKind.String) && type.GetString() == "share")
-                {
-                    queryText.Append(" where c.share=true");
-                }
-                else {
-                    await _dingDing.SendBotMsg($"OS,{_option.Location},teacher/share/find()\n type== coedit|share 参数必选一个", GroupNames.醍摩豆服務運維群組);
-                    return BadRequest();
-                }
+                queryText.Append($" where c.type='{type}' ");
                 if (id.ValueKind.Equals(JsonValueKind.String) && !string.IsNullOrEmpty(id.GetString())) {
                 if (id.ValueKind.Equals(JsonValueKind.String) && !string.IsNullOrEmpty(id.GetString())) {
                     queryText.Append($" and c.id='{id}'");
                     queryText.Append($" and c.id='{id}'");
                 }
                 }
                 await foreach (var item in client.GetContainer("TEAMModelOS", "Teacher").GetItemQueryIterator<Share>(queryText: queryText.ToString(),
                 await foreach (var item in client.GetContainer("TEAMModelOS", "Teacher").GetItemQueryIterator<Share>(queryText: queryText.ToString(),
-                requestOptions: new QueryRequestOptions() { PartitionKey = new Azure.Cosmos.PartitionKey($"Share-{code}") }))
+                requestOptions: new QueryRequestOptions() { PartitionKey = new Azure.Cosmos.PartitionKey($"Share-{type}-{code}") }))
                 {
                 {
                     shares.Add(item);
                     shares.Add(item);
                 }
                 }

+ 1 - 1
TEAMModelOS/Controllers/Teacher/InitController.cs

@@ -183,7 +183,7 @@ namespace TEAMModelOS.Controllers
                 await container.CreateIfNotExistsAsync(PublicAccessType.None); //嘗試創建Teacher私有容器,如存在則不做任何事,保障容器一定存在
                 await container.CreateIfNotExistsAsync(PublicAccessType.None); //嘗試創建Teacher私有容器,如存在則不做任何事,保障容器一定存在
                 var (blob_uri, blob_sas) = _azureStorage.GetBlobContainerSAS(id, BlobContainerSasPermissions.Write | BlobContainerSasPermissions.Read | BlobContainerSasPermissions.List | BlobContainerSasPermissions.Delete);
                 var (blob_uri, blob_sas) = _azureStorage.GetBlobContainerSAS(id, BlobContainerSasPermissions.Write | BlobContainerSasPermissions.Read | BlobContainerSasPermissions.List | BlobContainerSasPermissions.Delete);
 
 
-                return Ok(new { auth_token, blob_uri, blob_sas, schools, defaultschool, courses });
+                return Ok(new { auth_token, blob_uri, blob_sas, schools, defaultschool, courses ,size});
 
 
             }
             }
             catch (Exception ex)
             catch (Exception ex)