فهرست منبع

Merge branch 'develop6.0-tmd' of http://52.130.252.100:10000/TEAMMODEL/TEAMModelOS into develop6.0-tmd

CrazyIter_Bin 3 سال پیش
والد
کامیت
c6f1314477

+ 1 - 0
TEAMModelOS.SDK/Models/Cosmos/Common/Study.cs

@@ -35,6 +35,7 @@ namespace TEAMModelOS.SDK.Models
         /// 教研组名单
         /// 教研组名单
         /// </summary>
         /// </summary>
         public List<string> tchLists { get; set; } = new List<string>();
         public List<string> tchLists { get; set; } = new List<string>();
+        public List<string> teacIds { get; set; } = new List<string>();
         public List<Dictionary<string, List<string>>> groupLists { get; set; } = new List<Dictionary<string, List<string>>>();
         public List<Dictionary<string, List<string>>> groupLists { get; set; } = new List<Dictionary<string, List<string>>>();
         /// <summary>
         /// <summary>
         /// student 学生名单类型    research 教研组名单
         /// student 学生名单类型    research 教研组名单

+ 33 - 4
TEAMModelOS/ClientApp/src/utils/public.js

@@ -897,6 +897,10 @@ export default {
 	},
 	},
 	/* 上传视频到BLob */
 	/* 上传视频到BLob */
 	async doUploadVideo(vm, file, editor) {
 	async doUploadVideo(vm, file, editor) {
+		// 判断试卷编辑试题环境下 则直接取scope
+		let editorEnv = sessionStorage.getItem('editorEnv')
+		let inPaperEnv = editorEnv && editorEnv !== 'normal'
+		let paperName = inPaperEnv ? sessionStorage.getItem('paper_name') : null
 		vm.$Spin.show({
 		vm.$Spin.show({
 			render: (h) => {
 			render: (h) => {
 				return h('div', {
 				return h('div', {
@@ -921,9 +925,8 @@ export default {
 		});
 		});
 		const blobTool = require('./blobTool.js')
 		const blobTool = require('./blobTool.js')
 		const isSchool = vm.$parent.exerciseScope ? vm.$parent.exerciseScope === 1 : vm.exerciseScope === 1
 		const isSchool = vm.$parent.exerciseScope ? vm.$parent.exerciseScope === 1 : vm.exerciseScope === 1
-		const sasData = isSchool ? await this.getSchoolSas() : await this.getPrivateSas()
-
-		const scope = isSchool ? 'school' : 'private'
+		const scope = inPaperEnv ? editorEnv : (isSchool ? 'school' : 'private')
+		const sasData = scope === 'school' ? await this.getSchoolSas() : await this.getPrivateSas()
 		const blobToolClass = blobTool.default
 		const blobToolClass = blobTool.default
 		//初始化Blob
 		//初始化Blob
 		let containerClient = new blobToolClass(sasData.url, sasData.name, sasData.sas, scope)
 		let containerClient = new blobToolClass(sasData.url, sasData.name, sasData.sas, scope)
@@ -931,7 +934,7 @@ export default {
 			let id = vm.curId || vm.$parent.curId
 			let id = vm.curId || vm.$parent.curId
 			// 上传文件
 			// 上传文件
 			let blobFile = await containerClient.upload(file, {
 			let blobFile = await containerClient.upload(file, {
-				path: 'item/' + id
+				path: inPaperEnv && paperName ? ('paper/' + paperName)  : ('item/' + id)
 			})
 			})
 			// 获取blob链接以及视频封面截图
 			// 获取blob链接以及视频封面截图
 			const fileSas = await this.getFileSas(blobFile.url)
 			const fileSas = await this.getFileSas(blobFile.url)
@@ -942,6 +945,19 @@ export default {
 				fileBlobUrl +
 				fileBlobUrl +
 				' class="richText-video" width="300" preload controls="controls"></video><span>&nbsp;</span></span>'
 				' class="richText-video" width="300" preload controls="controls"></video><span>&nbsp;</span></span>'
 			editor.change.emit()
 			editor.change.emit()
+			
+			// 如果是在试卷环境下上传多媒体 则需要先保留以下 试题的数据 如果同步到题库 再进行上传
+			if(inPaperEnv && paperName){
+				let needSaveToItem = sessionStorage.getItem('syncItemBlob') ? JSON.parse(sessionStorage.getItem('syncItemBlob')) : []
+				needSaveToItem.push({
+					paperName:paperName,
+					target:'item/' + id + '/' + file.name,
+					path:blobFile.blob,
+					scope: scope
+				})
+				sessionStorage.setItem('syncItemBlob',JSON.stringify(needSaveToItem))
+			}
+			
 			vm.$EventBus.$emit('noSave', {
 			vm.$EventBus.$emit('noSave', {
 				path: blobFile.blob,
 				path: blobFile.blob,
 				size: blobFile.size,
 				size: blobFile.size,
@@ -1007,6 +1023,19 @@ export default {
 					<audio src="${fileBlobUrl}"  id="audio" controls="controls" controlsList="nodownload"></audio>
 					<audio src="${fileBlobUrl}"  id="audio" controls="controls" controlsList="nodownload"></audio>
 				</span><span>&nbsp;</span></span>`
 				</span><span>&nbsp;</span></span>`
 			editor.change.emit()
 			editor.change.emit()
+			
+			// 如果是在试卷环境下上传多媒体 则需要先保留以下 试题的数据 如果同步到题库 再进行上传
+			if(inPaperEnv && paperName){
+				let needSaveToItem = sessionStorage.getItem('syncItemBlob') ? JSON.parse(sessionStorage.getItem('syncItemBlob')) : []
+				needSaveToItem.push({
+					paperName:paperName,
+					target:'item/' + id + '/' + file.name,
+					path:blobFile.blob,
+					scope: scope
+				})
+				sessionStorage.setItem('syncItemBlob',JSON.stringify(needSaveToItem))
+			}
+			
 			vm.$EventBus.$emit('noSave', {
 			vm.$EventBus.$emit('noSave', {
 				path: blobFile.blob,
 				path: blobFile.blob,
 				size: blobFile.size,
 				size: blobFile.size,

+ 43 - 10
TEAMModelOS/ClientApp/src/view/evaluation/index/CreatePaper.vue

@@ -1217,7 +1217,7 @@
 								this.isLoading = false
 								this.isLoading = false
 							}
 							}
 						}))
 						}))
-						// 上传未保存的多媒体文件
+						// 任务: 上传未保存的多媒体文件
 						let noSaveArr = JSON.parse(localStorage.getItem('noSave'))
 						let noSaveArr = JSON.parse(localStorage.getItem('noSave'))
 						if (noSaveArr && noSaveArr.length) {
 						if (noSaveArr && noSaveArr.length) {
 							noSaveArr.forEach(i => {
 							noSaveArr.forEach(i => {
@@ -1248,17 +1248,37 @@
 								}))
 								}))
 							})
 							})
 						}
 						}
-						// 校本组卷情况下 同步知识点数据
-						if (this.isSchool && this.isSavePoints && this.evaluationInfo.createType ===
-							'import') {
-							if (this.importKnowledges.length) {
-								this.importKnowledges.push(...refreshList.map(i => i.knowledge).flat(1))
-								promiseArr.push(this.saveImportPoints([...new Set(this.importKnowledges)],
-									paperItem))
-							}
+						// 任务:如果要同步试题到试题库 则需要检查是否有多媒体文件 需要上传到对应试题目录下
+						let needSaveToItem = sessionStorage.getItem('syncItemBlob') ? JSON.parse(
+							sessionStorage.getItem('syncItemBlob')) : []
+						if (isToItemBank && needSaveToItem.length) {
+							needSaveToItem.forEach(i => {
+								promiseArr.push(new Promise(async (r, j) => {
+									let containerName = i.scope === 'private' ?
+										this.$store.state.userInfo.TEAMModelId :
+										this.$store.state.userInfo.schoolCode
+									let client = i.scope === 'private' ?
+										privateBlob : schoolBlob
+									let sas = i.scope === 'private' ? privateSas :
+										schoolSas
+									let mediaFullPath = this.$evTools
+										.getBlobHost() + '/' + containerName + i
+										.path
+									let fileName = i.path.split('/')[i.path.split(
+										'/').length - 1]
+									client.copyBlob(i.target, mediaFullPath, sas
+											.sas)
+										.then(res => {
+											r(200)
+										}).catch(e => {
+											console.log(e);
+											j(e)
+										})
+								}))
+							})
 						}
 						}
 
 
-						// 如果编辑试卷的时候修改了试卷名称 则需要把原试卷目录下的文件进行清空
+						// 任务:如果编辑试卷的时候修改了试卷名称 则需要把原试卷目录下的文件进行清空
 						if (this.isEditPaper && (this.oldPaper.name !== paperItem.name)) {
 						if (this.isEditPaper && (this.oldPaper.name !== paperItem.name)) {
 							promiseArr.push(new Promise(async (r, j) => {
 							promiseArr.push(new Promise(async (r, j) => {
 								let blobList = await this.getPaperFiles('paper/' + this
 								let blobList = await this.getPaperFiles('paper/' + this
@@ -1271,6 +1291,17 @@
 								})
 								})
 							}))
 							}))
 						}
 						}
+						
+						// 任务:校本组卷情况下 同步知识点数据
+						if (this.isSchool && this.isSavePoints && this.evaluationInfo.createType ===
+							'import') {
+							if (this.importKnowledges.length) {
+								this.importKnowledges.push(...refreshList.map(i => i.knowledge).flat(1))
+								promiseArr.push(this.saveImportPoints([...new Set(this.importKnowledges)],
+									paperItem))
+							}
+						}
+						
 						// 进行试卷文件上传Blob 先上传所有题目 再上传index.json文件
 						// 进行试卷文件上传Blob 先上传所有题目 再上传index.json文件
 						Promise.all(promiseArr).then(async result => {
 						Promise.all(promiseArr).then(async result => {
 							try {
 							try {
@@ -1322,6 +1353,8 @@
 													}
 													}
 												})
 												})
 												sessionStorage.setItem('isSave', 0)
 												sessionStorage.setItem('isSave', 0)
+												sessionStorage.setItem('syncItemBlob',
+													'[]')
 												localStorage.setItem('noSave', '[]')
 												localStorage.setItem('noSave', '[]')
 											} else {
 											} else {
 												this.$Message.error(this.$t(
 												this.$Message.error(this.$t(

+ 63 - 22
TEAMModelOS/Controllers/Common/ExamController.cs

@@ -59,7 +59,7 @@ namespace TEAMModelOS.Controllers
             _azureStorage = azureStorage;
             _azureStorage = azureStorage;
             _azureRedis = azureRedis;
             _azureRedis = azureRedis;
             _configuration = configuration;
             _configuration = configuration;
-            _notificationService = notificationService; 
+            _notificationService = notificationService;
             _coreAPIHttpService = coreAPIHttpService;
             _coreAPIHttpService = coreAPIHttpService;
         }
         }
 
 
@@ -266,7 +266,8 @@ namespace TEAMModelOS.Controllers
                 {
                 {
                     using var json = await JsonDocument.ParseAsync(response.ContentStream);
                     using var json = await JsonDocument.ParseAsync(response.ContentStream);
                     ExamInfo exam = json.ToObject<ExamInfo>();
                     ExamInfo exam = json.ToObject<ExamInfo>();
-                    if (request.TryGetProperty("time", out JsonElement time)) {
+                    if (request.TryGetProperty("time", out JsonElement time))
+                    {
                         exam.endTime = time.GetInt64();
                         exam.endTime = time.GetInt64();
                     }
                     }
                     if (request.TryGetProperty("name", out JsonElement name))
                     if (request.TryGetProperty("name", out JsonElement name))
@@ -321,7 +322,8 @@ namespace TEAMModelOS.Controllers
                         flag = true;
                         flag = true;
                     }
                     }
                 }
                 }
-                if (flag) {
+                if (flag)
+                {
                     exam.ttl = 1;
                     exam.ttl = 1;
                     exam.status = 404;
                     exam.status = 404;
                     exam = await client.GetContainer(Constant.TEAMModelOS, "Common").ReplaceItemAsync(exam, exam.id, new PartitionKey($"{exam.code}"));
                     exam = await client.GetContainer(Constant.TEAMModelOS, "Common").ReplaceItemAsync(exam, exam.id, new PartitionKey($"{exam.code}"));
@@ -1121,31 +1123,66 @@ namespace TEAMModelOS.Controllers
                         }
                         }
                         result.sum[index] = result.studentScores[index].Sum();
                         result.sum[index] = result.studentScores[index].Sum();
                         bool flag = result.studentScores[index].Exists(r => r == -1);
                         bool flag = result.studentScores[index].Exists(r => r == -1);
-                        if (!flag) {
+                        if (!flag)
+                        {
                             if (s.type == 1)
                             if (s.type == 1)
                             {
                             {
-                                try {
+                                try
+                                {
                                     StuActivity activity = await client.GetContainer(Constant.TEAMModelOS, "Student").ReadItemAsync<StuActivity>(id.ToString(), new PartitionKey($"Activity-{s.id}"));
                                     StuActivity activity = await client.GetContainer(Constant.TEAMModelOS, "Student").ReadItemAsync<StuActivity>(id.ToString(), new PartitionKey($"Activity-{s.id}"));
                                     activity.sStatus = 1;
                                     activity.sStatus = 1;
                                     tasks.Add(client.GetContainer(Constant.TEAMModelOS, "Student").ReplaceItemAsync(activity, activity.id, new PartitionKey($"{activity.code}")));
                                     tasks.Add(client.GetContainer(Constant.TEAMModelOS, "Student").ReplaceItemAsync(activity, activity.id, new PartitionKey($"{activity.code}")));
-                                } catch (Exception ex) {
-                                  await  _dingDing.SendBotMsg($"{_option.Location}\n{ex.Message}\n{ex.StackTrace}\n,id:{id},code:{s.id},school:{result?.school}", GroupNames.成都开发測試群組);
+                                }
+                                catch (Exception ex)
+                                {
+                                    await _dingDing.SendBotMsg($"{_option.Location}\n{ex.Message}\n{ex.StackTrace}\n,id:{id},code:{s.id},school:{result?.school}", GroupNames.成都开发測試群組);
                                 }
                                 }
                             }
                             }
                             else
                             else
                             {
                             {
-                                try { 
-                                    StuActivity activity = await client.GetContainer(Constant.TEAMModelOS, "Student").ReadItemAsync<StuActivity>(id.ToString(), new PartitionKey($"Activity-{result.school}-{s.id}"));
-                                    activity.sStatus = 1;
-                                    tasks.Add(client.GetContainer(Constant.TEAMModelOS, "Student").ReplaceItemAsync(activity, activity.id, new PartitionKey($"{activity.code}")));
+                                try
+                                {
+                                    var response = await client.GetContainer(Constant.TEAMModelOS, "Student").ReadItemStreamAsync(id.ToString(), new PartitionKey($"Activity-{result.school}-{s.id}"));
+                                    if (response.Status == 200)
+                                    {
+                                        using var json = await JsonDocument.ParseAsync(response.ContentStream);
+                                        StuActivity activity = json.ToObject<StuActivity>();
+                                        activity.sStatus = 1;
+                                        tasks.Add(client.GetContainer(Constant.TEAMModelOS, "Student").ReplaceItemAsync(activity, activity.id, new PartitionKey($"{activity.code}")));
+
+                                    }else
+                                    {
+                                        List<string> scode = new();
+                                        await foreach (var item in client.GetContainer(Constant.TEAMModelOS, "Student").GetItemQueryStreamIterator(queryText: $"select c.shoolId from c where c.id = '{s.id}' and c.pk = 'Base'"))
+                                        {
+                                            using var stuJson = await JsonDocument.ParseAsync(item.ContentStream);
+                                            if (stuJson.RootElement.TryGetProperty("_count", out JsonElement count) && count.GetUInt16() > 0)
+                                            {
+                                                var accounts = stuJson.RootElement.GetProperty("Documents").EnumerateArray();
+                                                while (accounts.MoveNext())
+                                                {
+                                                    JsonElement account = accounts.Current;
+                                                    scode.Add(account.GetProperty("shoolId").GetString());
+                                                }
+                                            }
+                                        }
+                                        foreach (var sid in scode)
+                                        {
+                                            StuActivity activity = await client.GetContainer(Constant.TEAMModelOS, "Student").ReadItemAsync<StuActivity>(id.ToString(), new PartitionKey($"Activity-{sid}-{s.id}"));
+                                            activity.sStatus = 1;
+                                            tasks.Add(client.GetContainer(Constant.TEAMModelOS, "Student").ReplaceItemAsync(activity, activity.id, new PartitionKey($"{activity.code}")));
+                                        }
+                                    }
+                                    //StuActivity activity = await client.GetContainer(Constant.TEAMModelOS, "Student").ReadItemAsync<StuActivity>(id.ToString(), new PartitionKey($"Activity-{result.school}-{s.id}"));
+                                   
                                 }
                                 }
                                 catch (Exception ex)
                                 catch (Exception ex)
-                                {
+                                {                                  
                                     await _dingDing.SendBotMsg($"{_option.Location}\n{ex.Message}\n{ex.StackTrace}\n,id:{id},code:{s.id},school:{result?.school}", GroupNames.成都开发測試群組);
                                     await _dingDing.SendBotMsg($"{_option.Location}\n{ex.Message}\n{ex.StackTrace}\n,id:{id},code:{s.id},school:{result?.school}", GroupNames.成都开发測試群組);
                                 }
                                 }
                             }
                             }
                         }
                         }
-                        
+
                         index_sc++;
                         index_sc++;
                     }
                     }
                     if (!result.progress)
                     if (!result.progress)
@@ -1173,7 +1210,7 @@ namespace TEAMModelOS.Controllers
                                     s.classCount += 1;
                                     s.classCount += 1;
                                 }
                                 }
                             });
                             });
-                            await client.GetContainer(Constant.TEAMModelOS, "Common").ReplaceItemAsync(exam, id.ToString(), new PartitionKey($"Exam-{code}"));                            
+                            await client.GetContainer(Constant.TEAMModelOS, "Common").ReplaceItemAsync(exam, id.ToString(), new PartitionKey($"Exam-{code}"));
                         }
                         }
                     }
                     }
                     else
                     else
@@ -1245,18 +1282,19 @@ namespace TEAMModelOS.Controllers
                     examClassResults.Add(item);
                     examClassResults.Add(item);
                 }
                 }
                 List<string> ids = new();
                 List<string> ids = new();
-                foreach (ExamClassResult result in examClassResults) {
+                foreach (ExamClassResult result in examClassResults)
+                {
                     ids.AddRange(result.studentIds);
                     ids.AddRange(result.studentIds);
                 }
                 }
                 ///获取真实的名称 
                 ///获取真实的名称 
                 List<ufo> ufos = new();
                 List<ufo> ufos = new();
                 List<string> delIds = new();
                 List<string> delIds = new();
-                if (ids.Count > 0) {
+                if (ids.Count > 0)
+                {
                     List<string> sIds = new();
                     List<string> sIds = new();
                     List<string> tIds = new();
                     List<string> tIds = new();
                     List<ufo> students = new List<ufo>();
                     List<ufo> students = new List<ufo>();
-                    await foreach (var item in client.GetContainer(Constant.TEAMModelOS, "Student").GetItemQueryStreamIterator(queryText: $"select c.id,c.name from c where c.id in ({string.Join(",", ids.Select(o => $"'{o}'"))})",
-                        requestOptions: new QueryRequestOptions() { PartitionKey = new PartitionKey($"Base-{school}") }))
+                    await foreach (var item in client.GetContainer(Constant.TEAMModelOS, "Student").GetItemQueryStreamIterator(queryText: $"select c.id,c.name from c where c.id in ({string.Join(",", ids.Select(o => $"'{o}'"))}) and c.pk = 'Base'"))
                     {
                     {
                         using var stuJson = await JsonDocument.ParseAsync(item.ContentStream);
                         using var stuJson = await JsonDocument.ParseAsync(item.ContentStream);
                         if (stuJson.RootElement.TryGetProperty("_count", out JsonElement count) && count.GetUInt16() > 0)
                         if (stuJson.RootElement.TryGetProperty("_count", out JsonElement count) && count.GetUInt16() > 0)
@@ -1282,7 +1320,8 @@ namespace TEAMModelOS.Controllers
                         {
                         {
                             sIds.Add(f.id);
                             sIds.Add(f.id);
                         }
                         }
-                        if (ids.Count > sIds.Count) { 
+                        if (ids.Count > sIds.Count)
+                        {
                             tIds = ids.Except(sIds).ToList();
                             tIds = ids.Except(sIds).ToList();
                             var content = new StringContent(tIds.ToJsonString(), Encoding.UTF8, "application/json");
                             var content = new StringContent(tIds.ToJsonString(), Encoding.UTF8, "application/json");
                             string json = await _coreAPIHttpService.GetUserInfos(content);
                             string json = await _coreAPIHttpService.GetUserInfos(content);
@@ -1310,7 +1349,8 @@ namespace TEAMModelOS.Controllers
                         }
                         }
                         delIds = ids.Except(sIds.Union(tIds)).ToList();
                         delIds = ids.Except(sIds.Union(tIds)).ToList();
                     }
                     }
-                    else {
+                    else
+                    {
                         var content = new StringContent(ids.ToJsonString(), Encoding.UTF8, "application/json");
                         var content = new StringContent(ids.ToJsonString(), Encoding.UTF8, "application/json");
                         string json = await _coreAPIHttpService.GetUserInfos(content);
                         string json = await _coreAPIHttpService.GetUserInfos(content);
 
 
@@ -1337,7 +1377,7 @@ namespace TEAMModelOS.Controllers
                         }
                         }
                     }
                     }
                 }
                 }
-                
+
                 /*if (StringHelper.getKeyCount(requert) == 1 && requert.TryGetProperty("code", out JsonElement code))
                 /*if (StringHelper.getKeyCount(requert) == 1 && requert.TryGetProperty("code", out JsonElement code))
                 {
                 {
                     List<object> props = new List<object>();
                     List<object> props = new List<object>();
@@ -3162,7 +3202,8 @@ namespace TEAMModelOS.Controllers
         public string id { get; set; }
         public string id { get; set; }
         public int type { get; set; }
         public int type { get; set; }
     }
     }
-    public class ufo { 
+    public class ufo
+    {
         public string id { get; set; }
         public string id { get; set; }
         public string name { get; set; }
         public string name { get; set; }
         public int type { get; set; }
         public int type { get; set; }