瀏覽代碼

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

XW 3 年之前
父節點
當前提交
680ba09985

+ 1 - 1
TEAMModelOS/ClientApp/src/common/BaseLayout.vue

@@ -885,7 +885,7 @@ export default {
 <style lang="less">
 // html,
 // body {
-// 	font-family:'DFPKing';
+// 	font-family:'微軟正黑體','Microsoft JhengHei UI','Microsoft JhengHei';
 // }
 
 .biz-menu .ivu-menu-vertical .ivu-menu-item-group-title {

+ 1 - 2
TEAMModelOS/ClientApp/src/components/evaluation/ExerciseList.less

@@ -41,10 +41,9 @@
     flex-direction: row;
     justify-content: center;
     margin: 20px 0;
-    color: #fff;
     position: fixed;
     bottom: 5px;
-    background: #c7c7c7;
+    background: #fff;
     width: 100%;
     padding: 10px;
   }

+ 2 - 2
TEAMModelOS/ClientApp/src/locale/lang/zh-TW/jyzx.js

@@ -211,7 +211,7 @@ export default{
         totalTime: '總學時',
         online: "線上研修",
         offline: "線下研修",
-        application: "應用考核",
+        application: "認證材料",
         classRecord: "課堂實錄",
         studyPoint: "已學能力點",
         okPoint: "檢測合格能力點",
@@ -224,7 +224,7 @@ export default{
         schoolVote: "校本投票",
         time: "學時",
         minute: "分鐘",
-        remarks1: "總學時:線上研修 + 校本研修 + 應用考核 + 課堂實錄",
+        remarks1: "總學時:線上研修 + 校本研修 + 認證材料 + 課堂實錄",
         remarks2: "注:各指標達到要求後,多餘學時不再計入總學時",
         remarks3: "注:45分鐘 = 1學時",
     }

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

@@ -62,7 +62,7 @@ export default {
         resourceCenter:'資源中心',
         trainCount:'研修統計',
         onlineTrain:'線上研修',
-        appAssassment:'應用考核',
+        appAssassment:'認證材料',
         discuss:'討論中心',
         policy:'政策文件'
     },

+ 2 - 2
TEAMModelOS/ClientApp/src/utils/directive.js

@@ -12,7 +12,7 @@ const specialChar = {
     bind: function (el, binding, vnode) {
         // 正则规则可根据需求自定义
         // var regRule = /[`~!@#$%^&*()\-+=<>?:"{}|,.\/;'\\[\]·~!@#¥%……&*()——\-+={}|《》?:“”【】、;‘’,。、]/g
-        var regRule = /[`~!@#$^&*\-+=<>?:"{}|,;'\\[\]·~!@#&*——\-+={}|]/g
+        var regRule = /[`~!@#$^&*\-+=<>?"{}|,;'\\[\]·~!@#&*——\-+={}|]/g
         let $inp = findEle(el, 'input')
         el.$inp = $inp
         $inp.handle = function () {
@@ -24,7 +24,7 @@ const specialChar = {
         $inp.addEventListener('keyup', $inp.handle)
     },
     unbind: function (el) {
-        el.$inp.removeEventListener('keyup', el.$inp.handle)
+        el.$inp && el.$inp.removeEventListener('keyup', el.$inp.handle)
     },
 }
 

+ 2 - 8
TEAMModelOS/ClientApp/src/view/evaluation/bank/ExerciseList.vue

@@ -300,7 +300,7 @@
 			/** 执行筛选条件获取数据 */
 			doFilter(filterKey) {
 				this.dataLoading = true;
-				this.$refs.childRef && (this.$refs.childRef[0].collapseList = [])
+				this.$refs.childRef && this.$refs.childRef[0] && (this.$refs.childRef[0].collapseList = [])
 				this.collapseList = []; // 所有详情都收起来
 				/** 定义查询接口的参数规格 */
 				this.filterParams = {
@@ -340,7 +340,6 @@
 				this.$api.newEvaluation.FindExerciseList(data).then(async (res) => {
 					if(res.items.length){
 						let list = res.items;
-						console.log(list)
 						if((!this.flag && this.isShowSchoolBank) || (!this.flag && !this.isShowSchoolBank && this.filterOrigin === this.schoolCode)){
 							this.periodCountArr = this.getPeriodCount(res.items)
 							list = res.items.filter(i => i.periodId === this.periodList[this.filterPeriod].id)
@@ -351,7 +350,6 @@
 						/* 获取试题总数 */
 						this.totalNum = list.length;
 						this.originData = list;
-						console.log(list)
 						this.pageChange(1);
 					}else{
 						this.originData = []
@@ -404,9 +402,6 @@
 				this.fieldCountArr = fieldList.map(i => {
 					return curPeriodCond.subjects.reduce((a,b) => a + this._.sum(this.findKey(b,'field').map(j => j[+i+1+''])),0)
 				})
-				console.log(curPeriodCond)
-				console.log(this.subjectList)
-				console.log(this.subjectCountArr)
 			},
 			
 			findKey(data, field) {
@@ -625,7 +620,6 @@
 			 * @param page
 			 */
 			async pageChange(page) {
-				console.log(this.originData)
 				this.pageNum = page;
 				let start = this.pageSize * (page - 1);
 				let end = this.pageSize * page;
@@ -638,7 +632,7 @@
 					// this.totalNum = this.exerciseList.length
 					this.pageScrollTo(0);
 					this.onHandleToggle(true)
-					this.$refs.childRef && (this.$refs.childRef[0].collapseList = [])
+					this.$refs.childRef && this.$refs.childRef[0] && (this.$refs.childRef[0].collapseList = [])
 				} catch (e) {
 					this.$Message.error('Blob Error : ' + e)
 				}

+ 101 - 260
TEAMModelOS/Controllers/Common/ExamController.cs

@@ -320,7 +320,7 @@ namespace TEAMModelOS.Controllers
                 var cresponse = await client.GetContainer(Constant.TEAMModelOS, "Common").ReadItemStreamAsync(id.ToString(), new PartitionKey($"Correct-{code}"));
                 if (cresponse.Status == 200)
                 {
-                    using var json = await JsonDocument.ParseAsync(response.ContentStream);
+                    using var json = await JsonDocument.ParseAsync(cresponse.ContentStream);
                     Correct correct = json.ToObject<Correct>();
                     if (correct.subs.IsNotEmpty())
                     {
@@ -389,7 +389,7 @@ namespace TEAMModelOS.Controllers
             }
             catch (Exception e)
             {
-                await _dingDing.SendBotMsg($"OS,{_option.Location},exam/delete()\n{e.Message}", GroupNames.醍摩豆服務運維群組);
+                await _dingDing.SendBotMsg($"OS,{_option.Location},exam/delete()\n{e.Message}\n{e.StackTrace}", GroupNames.醍摩豆服務運維群組);
                 return BadRequest();
             }
         }
@@ -1907,31 +1907,7 @@ namespace TEAMModelOS.Controllers
                     List<dynamic> allSc = new List<dynamic>();
                     ss.qs = ss.qs.Where(s => !string.IsNullOrEmpty(s.tId)).ToList();
                     int indexScore = 0;
-
-                    var queryClass = $"select c.studentAnswers,c.studentIds from c where array_contains(c.studentIds,'{ss.stuId}') and c.examId = '{ss.examId}' and c.subjectId = '{ss.subjectId}'";
-                    List<List<string>> ans = new List<List<string>>();
-                    List<string> ids = new List<string>();
-                    await foreach (var item in client.GetContainer(Constant.TEAMModelOS, "Common").GetItemQueryStreamIterator(queryText: queryClass, requestOptions: new QueryRequestOptions() { PartitionKey = new PartitionKey($"ExamClassResult-{code}") }))
-                    {
-                        using var json = await JsonDocument.ParseAsync(item.ContentStream);
-                        if (json.RootElement.TryGetProperty("_count", out JsonElement count) && count.GetUInt16() > 0)
-                        {
-                            var accounts = json.RootElement.GetProperty("Documents").EnumerateArray();
-                            while (accounts.MoveNext())
-                            {
-                                JsonElement account = accounts.Current;
-                                ans = account.GetProperty("studentAnswers").ToObject<List<List<string>>>();
-                                ids = account.GetProperty("studentIds").ToObject<List<string>>();
-                            }
-                        }
-                    }
-                    int num = ids.IndexOf(ss.stuId);
-                    string ansBlob = "";
-                    if (num > 0) {
-                        if (ans[num].Count > 0) {
-                            ansBlob = ans[num].First();
-                        }                       
-                    }
+                    (string ansBlob, List<double> scores) = await getMoreStuInfo(client, ss.stuId, ss.examId, ss.subjectId, code.GetString());
                     foreach (Item item in ss.items)
                     {
                         var count = item.scores.GroupBy(i => new { i.tmdId, i.sc }).Select(c => c.Key.sc).ToList();
@@ -1946,13 +1922,12 @@ namespace TEAMModelOS.Controllers
                         }
                         else
                         {
+                            ss.scores = scores;
                             sc.Add(new { sc = ss.scores[indexScore], blob = "", item.ssc });
                         }
                         indexScore++;
-                        //sc.Add(item.scores.Where(x => x.tmdId.Equals(tId.GetString())).Select(c => c.sc).FirstOrDefault());
-                        //item.scores = item.scores.Where(x => x.tmdId.Equals(tId.GetString())).ToList();
                     }
-                    var obj = new { ss.id, ss.stuId, ss.examId, ss.subjectId, item = sc, ss.qs, blob = ansBlob, ss.tIds, ss.scores, ss.model, ss.mode };
+                    var obj = new { ss.id, ss.stuId, ss.examId, ss.subjectId, item = sc, ss.qs, blob = ansBlob, ss.tIds, scores = scores, ss.model, ss.mode };
                     objs.Add(obj);
                 }
                 var fp = attr.Count > 0 ? Math.Round(finishCount * 1.0 / (attrSc.Count * correct.num), 2) : 0;
@@ -2062,6 +2037,7 @@ namespace TEAMModelOS.Controllers
                 {
                     attr.Add(item);
                 }
+                
                 int index = 0;
                 foreach (ExamSubject subject in info.subjects)
                 {
@@ -2085,11 +2061,15 @@ namespace TEAMModelOS.Controllers
                 {
                     //List<double> original = new List<double>();
                     List<Item> arb = ss.items.Where(s => s.flag == false).ToList();
+                    (string ansBlob, List<double> scores) = await getMoreStuInfo(client, ss.stuId, ss.examId, ss.subjectId, code.GetString());
+                    ss.blob = ansBlob;
+                    ss.scores = scores;
                     if (arb.Count > 0)
                     {
                         ss.items = arb;
                         arbs.Add(ss);
                     }
+
                 }
                 return Ok(new { arbs = arbs.Select(a => new { a.items, a.blob, a.stuId, a.subjectId, a.id, a.scores }), paper = info.papers[index].blob });
             }
@@ -2139,34 +2119,6 @@ namespace TEAMModelOS.Controllers
                         all.Add(scoring);
                     }
                 }
-                /*var record = await redisClient.HashGetAllAsync($"Exam:Scoring:{id}-{subjectId}");
-                foreach (var rcd in record)
-                {
-                    var value = JsonDocument.Parse(rcd.Value.ToString());
-                    value.RootElement.TryGetProperty("info", out JsonElement json);
-                    List<tmdInfo> tmds = json.ToObject<List<tmdInfo>>();
-                    foreach (tmdInfo tmd in tmds)
-                    {
-                        if (!string.IsNullOrEmpty(tmd.tmdId) && tmd.tmdId.Equals(tId.ToString()))
-                        {
-                            recs.Add(new { stuId = rcd.Name.ToString(), info = value });
-                            break;
-                        }
-                        if (string.IsNullOrEmpty(tmd.tmdId))
-                        {
-                            all.Add(new { stuId = rcd.Name.ToString(), ans = value });
-                            break;
-                        }
-                    }
-                    *//*if (tId.ToString().Equals(tmdId.ToString()))
-                    {
-                        recs.Add(new { stuId = rcd.Name.ToString(), ans = value });
-                    }
-                    if (string.IsNullOrEmpty(tmdId.ToString()))
-                    {
-                        all.Add(new { stuId = rcd.Name.ToString(), ans = value });
-                    }*//*
-                }*/
                 if (requert.TryGetProperty("stuId", out JsonElement stuId))
                 {
 
@@ -2192,23 +2144,6 @@ namespace TEAMModelOS.Controllers
                             }
                         }
                     }
-                    /*var stuAns = await redisClient.HashGetAsync($"Exam:Scoring:{id}-{subjectId}", stuId.ToString());
-                    var value = JsonDocument.Parse(stuAns.ToString());
-                    //保证此学生与该老师绑定
-                    value.RootElement.TryGetProperty("ans", out JsonElement blob);
-                    value.RootElement.TryGetProperty("score", out JsonElement sc);
-                    value.RootElement.TryGetProperty("info", out JsonElement json);
-                    List<tmdInfo> tmds = json.ToObject<List<tmdInfo>>();
-                    foreach (tmdInfo tmd in tmds)
-                    {
-                        if (string.IsNullOrEmpty(tmd.tmdId))
-                        {
-                            tmd.tmdId = tId.ToString();
-                            break;
-                        }
-                    }
-                    await redisClient.HashSetAsync($"Exam:Scoring:{id}-{subjectId}", stuId.ToString(), new { info = tmds, ans = blob, score = sc }.ToJsonString());*/
-                    //var its = value.Where(x => x.items.s)
                     List<dynamic> objs = new List<dynamic>();
                     List<SDK.Models.Cosmos.Common.Scoring> val = new List<SDK.Models.Cosmos.Common.Scoring>();
                     foreach (SDK.Models.Cosmos.Common.Scoring ss in value)
@@ -2216,24 +2151,24 @@ namespace TEAMModelOS.Controllers
                         //var scc = ss.items.SelectMany(p => p.scores, (p, d) => new { p.ssc, d.sc, d.tmdId }).Where(x => x.tmdId.Equals(tId.GetString())).Select(m => new { m.sc, m.ssc });
                         List<dynamic> sc = new List<dynamic>();
                         int indexScore = 0;
+                        (string ansBlob, List<double> scores) = await getMoreStuInfo(client, ss.stuId, ss.examId, ss.subjectId, code.GetString());
                         foreach (Item item in ss.items)
                         {
                             List<double> scc = item.scores.Where(x => x.tmdId.Equals(tId.GetString())).Select(c => c.sc).ToList();
                             //item.scores.Where(x => x.tmdId.Equals(tId.GetString())).SelectMany(p => p.sc, (p, d) => new { });
-
+                            
                             if (scc.Count > 0)
                             {
                                 sc.Add(new { sc = scc.FirstOrDefault(), item.ssc });
                             }
                             else
                             {
+                                ss.scores = scores;
                                 sc.Add(new { sc = ss.scores[indexScore], item.ssc });
                             }
                             indexScore++;
-                            //sc.Add(item.scores.Where(x => x.tmdId.Equals(tId.GetString())).Select(c => c.sc).FirstOrDefault());
-                            //item.scores = item.scores.Where(x => x.tmdId.Equals(tId.GetString())).ToList();
                         }
-                        var obj = new { ss.id, ss.stuId, ss.examId, ss.subjectId, item = sc, ss.qs, ss.blob, ss.tIds, ss.scores, ss.model, ss.mode };
+                        var obj = new { ss.id, ss.stuId, ss.examId, ss.subjectId, item = sc, ss.qs, blob = ansBlob, ss.tIds, scores = scores, ss.model, ss.mode };
                         objs.Add(obj);
                     }
                     return Ok(objs);
@@ -2269,90 +2204,28 @@ namespace TEAMModelOS.Controllers
                             item.tIds.Add(tId.ToString());
                         }
                         await client.GetContainer(Constant.TEAMModelOS, "Teacher").ReplaceItemAsync(item, item.id, new PartitionKey(item.code));
-                        //序列化单个学生作答记录、得分情况、批注情况
-                        /*var cs = JsonSerializer.Serialize(item);
-                        var json = JsonDocument.Parse(cs);
-                        json.RootElement.TryGetProperty("stuId", out JsonElement sId);
-                        json.RootElement.TryGetProperty("ans", out JsonElement ans);
-                        ans.TryGetProperty("score", out JsonElement sc);
-                        ans.TryGetProperty("ans", out JsonElement blob);
-                        ans.TryGetProperty("info", out JsonElement element);
-                        List<tmdInfo> tmds = element.ToObject<List<tmdInfo>>();
-                        foreach (tmdInfo tmd in tmds)
-                        {
-                            if (string.IsNullOrEmpty(tmd.tmdId))
-                            {
-                                tmd.tmdId = tId.ToString();
-                                break;
-                            }
-                        }*/
-                        //选取后,缓存池相应的减少,以便于分配给其他的老师
-                        //await redisClient.HashSetAsync($"Exam:Scoring:{id}-{subjectId}", sId.ToString(), new { info = tmds, ans = blob, score = sc }.ToJsonString());
-                        //ss.items.Add(ss.items.Where(x => x.scores.))
-                        /*foreach (Item its in item.items)
-                        {
-                            its.scores = its.scores.Where(x => x.tmdId.Equals(tId.GetString())).ToList();
-                        }*/
-                        //List<double> sc = new List<double>();
-                        // var scc = item.items.SelectMany(p => p.scores, (p, d) => new { p.ssc, d.sc, d.tmdId }).Where(x => x.tmdId.Equals(tId.GetString())).Select(m => new { m.sc, m.ssc });
                         List<dynamic> sc = new List<dynamic>();
+                        (string ansBlob, List<double> scores) = await getMoreStuInfo(client, item.stuId, item.examId, item.subjectId, code.GetString());
                         int indexScore = 0;
                         foreach (Item its in item.items)
                         {
                             List<double> ssc = its.scores.Where(x => x.tmdId.Equals(tId.GetString())).Select(c => c.sc).ToList();
-                            //item.scores.Where(x => x.tmdId.Equals(tId.GetString())).SelectMany(p => p.sc, (p, d) => new { });
                             if (ssc.Count > 0)
                             {
                                 sc.Add(new { sc = ssc.FirstOrDefault(), its.ssc });
                             }
                             else
                             {
+                                item.scores = scores;
                                 sc.Add(new { sc = item.scores[indexScore], its.ssc });
                             }
                             indexScore++;
-                            //sc.Add(item.scores.Where(x => x.tmdId.Equals(tId.GetString())).Select(c => c.sc).FirstOrDefault());
-                            //item.scores = item.scores.Where(x => x.tmdId.Equals(tId.GetString())).ToList();
                         }
-                        var obj = new { item.id, item.stuId, item.examId, item.subjectId, item = sc, item.qs, item.blob, item.tIds, item.scores, item.model, item.mode };
+                        var obj = new { item.id, item.stuId, item.examId, item.subjectId, item = sc, item.qs, blob = ansBlob, item.tIds, scores = scores, item.model, item.mode };
                         return Ok(obj);
                     }
 
-                }
-
-                //var json = JsonDocument.Parse(record);
-                /*ExamInfo info = await client.GetContainer(Constant.TEAMModelOS, "Common").ReadItemAsync<ExamInfo>(id.ToString(), new Azure.Cosmos.PartitionKey($"Exam-hbcn"));
-                if (info.scope.Equals("school"))
-                {
-
-                    await foreach (var item in client.GetContainer(Constant.TEAMModelOS, "Common").GetItemQueryIterator<ExamClassResult>(
-                    queryText: $"select value(c) from c where c.examId = '{id}' and c.subjectId = '{subjectId}'",
-                    requestOptions: new QueryRequestOptions() { PartitionKey = new PartitionKey($"ExamClassResult-{info.school}") }))
-                    {
-                        classResults.Add(item);
-                    }
-                }
-                else
-                {
-                    await foreach (var item in client.GetContainer(Constant.TEAMModelOS, "Common").GetItemQueryIterator<ExamClassResult>(
-                        queryText: $"select value(c) from c where c.examId = '{id}' and c.subjectId = '{subjectId}'",
-                        requestOptions: new QueryRequestOptions() { PartitionKey = new PartitionKey($"ExamClassResult-{info.creatorId}") }))
-                    {
-                        classResults.Add(item);
-                    }
-                }
-                List<Task<bool>> tasks = new List<Task<bool>>();
-                foreach (ExamClassResult examClass in classResults)
-                {
-                    foreach (string stuId in examClass.studentIds)
-                    {
-                        int index = examClass.studentIds.IndexOf(stuId);
-                        tasks.Add(redisClient.HashSetAsync($"Exam:Scoring:{id}-{subjectId}", stuId, new { ans = examClass.studentAnswers[index].Count > 0 ? examClass.studentAnswers[index][0] : "", score = examClass.studentScores[index] }.ToJsonString()));
-                    }
-
-                }
-                await Task.WhenAll(tasks);
-                return Ok();*/
-                //info = await client.GetContainer(Constant.TEAMModelOS, "Common").ReplaceItemAsync(info, info.id, new PartitionKey($"Exam-{code}"));                
+                }                
             }
             catch (Exception ex)
             {
@@ -2380,10 +2253,8 @@ namespace TEAMModelOS.Controllers
                 if (!requert.TryGetProperty("score", out JsonElement score)) return BadRequest();
                 if (!requert.TryGetProperty("count", out JsonElement count)) return BadRequest();
                 if (!requert.TryGetProperty("code", out JsonElement code)) return BadRequest();
-                //if (!requert.TryGetProperty("mark", out JsonElement mark)) return BadRequest();
                 requert.TryGetProperty("mark", out JsonElement mark);
                 var client = _azureCosmos.GetCosmosClient();
-                //var redisClient = _azureRedis.GetRedisClient(8);
                 List<ExamClassResult> classResults = new();
                 List<SDK.Models.Cosmos.Common.Scoring> attr = new();
                 await foreach (var item in client.GetContainer(Constant.TEAMModelOS, "Teacher").GetItemQueryIterator<SDK.Models.Cosmos.Common.Scoring>(
@@ -2392,82 +2263,10 @@ namespace TEAMModelOS.Controllers
                 {
                     attr.Add(item);
                 }
-                /*List<dynamic> recs = new List<dynamic>();
-                var record = await redisClient.HashGetAllAsync($"Exam:Scoring:{id}-{subjectId}");
-                foreach (var rcd in record)
-                {
-                    var values = JsonDocument.Parse(rcd.Value.ToString());
-                    values.RootElement.TryGetProperty("info", out JsonElement json);
-                    List<tmdInfo> tmdInfos = json.ToObject<List<tmdInfo>>();
-                    foreach (tmdInfo tmd in tmdInfos)
-                    {
-                        if (!string.IsNullOrEmpty(tmd.tmdId) && tmd.tmdId.Equals(tId.ToString()))
-                        {
-                            recs.Add(new { stuId = rcd.Name.ToString(), info = values });
-                            break;
-                        }
-                    }
-                    *//*if (tId.ToString().Equals(tmdId.ToString()))
-                    {
-                        recs.Add(new { stuId = rcd.Name.ToString(), ans = values });
-                    }*//*
-                }*/
-                /*var stuAns = await redisClient.HashGetAsync($"Exam:Scoring:{id}-{subjectId}", sId.ToString());
-                var value = JsonDocument.Parse(stuAns.ToString());
-                value.RootElement.TryGetProperty("ans", out JsonElement blob);
-                value.RootElement.TryGetProperty("info", out JsonElement element);
-                List<tmdInfo> tmds = element.ToObject<List<tmdInfo>>();*/
                 List<double> ssc = score.ToObject<List<double>>();
                 List<string> marks = mark.ToObject<List<string>>();
                 StringBuilder builder = new();
-                /*if (requert.TryGetProperty("mark", out JsonElement mark))
-                {
-                    //存放老师批注信息到blob                   
-                    builder.Append(id).Append('/');
-                    builder.Append(subjectId).Append('/');
-                    builder.Append(sId).Append("mark").Append('/');
-                    //builder.Append(tId).Append('/');
-                    builder.Append("ans.json");
-                    await _azureStorage.UploadFileByContainer(code.ToString(), mark.ToJsonString(), "exam", builder.ToString(), false);
-                    if (attr.Count > 0)
-                    {
-                        foreach (SDK.Models.Cosmos.Common.Scoring scoring in attr)
-                        {
-                            foreach (Item item in scoring.items)
-                            {
-                                bool flag = false;
-                                int index = 0;
-                                if (item.scores.Count > 0)
-                                {
-                                    foreach (Info info in item.scores)
-                                    {
-                                        if (!info.tmdId.Equals(tId.GetString()))
-                                        {
-                                            index++;
-                                        }
-                                        else
-                                        {
-                                            scoring.marks[index] = builder.ToString();
-                                            flag = true;
-                                            break;
-                                        }
-                                    }
-                                }
-                                if (flag)
-                                {
-                                    break;
-                                }
-                                //List<Info> info = item.scores.Where(x => x.tmdId.Equals(tId.GetString())).ToList();
-                            }
-                            int index = scoring.tIds.IndexOf(tId.GetString());
-                            if (index != -1)
-                            {
-                                scoring.marks[index] = builder.ToString();
-                            }
 
-                        }
-                    }
-                }*/
                 if (attr.Count > 0)
                 {
                     foreach (SDK.Models.Cosmos.Common.Scoring scoring in attr)
@@ -2534,48 +2333,58 @@ namespace TEAMModelOS.Controllers
                 {
                     return BadRequest();
                 }
-                //判定阅卷结算的条件
-                if (attr.Count == count.GetInt32())
+                Correct correct = null;
+                var cResponse = await client.GetContainer(Constant.TEAMModelOS, "Common").ReadItemStreamAsync(id.ToString(), new PartitionKey($"Correct-{code}"));
+                if (cResponse.Status == 200)
                 {
+                    using var cJson = await JsonDocument.ParseAsync(cResponse.ContentStream);
+                    correct = cJson.ToObject<Correct>();
+                }
 
-                    await foreach (var item in client.GetContainer(Constant.TEAMModelOS, "Common").GetItemQueryIterator<ExamClassResult>(
-                    queryText: $"select value(c) from c where c.examId = '{id}' and c.subjectId = '{subjectId}'",
-                    requestOptions: new QueryRequestOptions() { PartitionKey = new PartitionKey($"ExamClassResult-{code}") }))
-                    {
-                        classResults.Add(item);
-                    }
+                await foreach (var item in client.GetContainer(Constant.TEAMModelOS, "Common").GetItemQueryIterator<ExamClassResult>(
+                queryText: $"select value(c) from c where c.examId = '{id}' and c.subjectId = '{subjectId}'",
+                requestOptions: new QueryRequestOptions() { PartitionKey = new PartitionKey($"ExamClassResult-{code}") }))
+                {
+                    classResults.Add(item);
+                }
+                int scount = attr.Select(a => a.items[0].scores).ToList().Count;
+                if (correct.num == scount) {
                     foreach (ExamClassResult exam in classResults)
                     {
                         foreach (SDK.Models.Cosmos.Common.Scoring scoring in attr)
                         {
                             int index = exam.studentIds.IndexOf(scoring.stuId);
-                            //均分
-                            int n = 0;
-                            foreach (Item item in scoring.items)
-                            {
-                                var ace = item.scores.Where(x => string.IsNullOrEmpty(x.tmdId)).ToList();
-                                if (ace.Count > 0)
-                                {
-                                    return Ok(new { code = 404 });
-                                }
-                                //判定是否仲裁卷
-                                if (!item.flag)
-                                {
-                                    //scoring.type = 3;
-                                    await client.GetContainer(Constant.TEAMModelOS, "Teacher").ReplaceItemAsync(scoring, scoring.id, new PartitionKey(scoring.code));
-                                    return Ok(new { msg = "试题分数差异过大" });
-                                }
-                                double sc = item.scores.Select(x => x.sc).ToList().Aggregate((i, j) => (i + j) / item.scores.Count);
-                                scoring.scores[n] = sc;
-                                n++;
-                            }
                             if (index != -1)
                             {
-                                exam.studentScores[index] = scoring.scores;
                                 int itemIndex = 0;
                                 foreach (Item item in scoring.items)
                                 {
-                                    string tmdId = item.scores[itemIndex].tmdId;
+                                    var ace = item.scores.Where(x => string.IsNullOrEmpty(x.tmdId)).ToList();
+                                    if (ace.Count > 0)
+                                    {
+                                        return Ok(new { code = 404 });
+                                    }
+                                    //判定是否仲裁卷
+                                    if (!item.flag)
+                                    {
+                                        return Ok(new { msg = "试题分数差异过大" });
+                                    }
+                                    double sc = item.scores.Select(x => x.sc).ToList().Aggregate((i, j) => (i + j) / item.scores.Count);
+                                    scoring.scores[itemIndex] = sc;
+                                    string tmdId = tId.GetString();
+                                    //定位老师是几阅
+                                    int indexOfSc = 0;
+                                    foreach (Info info in item.scores)
+                                    {
+                                        if (info.tmdId.Equals(tmdId))
+                                        {
+                                            break;
+                                        }
+                                        else
+                                        {
+                                            indexOfSc++;
+                                        }
+                                    }
                                     //判定是否已经存在对应的批注信息
                                     bool flag = exam.mark[index][itemIndex].Exists(x => x.tmdId.Equals(tmdId));
                                     if (flag)
@@ -2583,32 +2392,31 @@ namespace TEAMModelOS.Controllers
                                         //重复打分更新部分值
                                         exam.mark[index][itemIndex].Where(x => x.tmdId.Equals(tmdId)).ToList().ForEach(score =>
                                         {
-                                            score.sc = item.scores[itemIndex].sc;
-                                            score.mark = item.scores[itemIndex].mark;
+                                            score.sc = item.scores[indexOfSc].sc;
+                                            score.mark = item.scores[indexOfSc].mark;
                                         });
                                     }
                                     else
                                     {
                                         Details dt = new()
                                         {
-                                            index = item.scores[itemIndex].index,
-                                            sc = item.scores[itemIndex].sc,
-                                            tmdId = item.scores[itemIndex].tmdId,
-                                            mark = item.scores[itemIndex].mark,
-                                            identity = item.scores[itemIndex].identity
+                                            index = item.scores[indexOfSc].index,
+                                            sc = item.scores[indexOfSc].sc,
+                                            tmdId = item.scores[indexOfSc].tmdId,
+                                            mark = item.scores[indexOfSc].mark,
+                                            identity = item.scores[indexOfSc].identity
                                         };
-                                        exam.mark[index][itemIndex].Add(dt);
+                                        exam.mark[index][indexOfSc].Add(dt);
                                     }
                                     itemIndex++;
                                 }
+                                exam.studentScores[index] = scoring.scores;
                             }
 
                         }
                         await client.GetContainer(Constant.TEAMModelOS, "Common").ReplaceItemAsync(exam, exam.id, new PartitionKey($"{exam.code}"));
                     }
-
-                }
-
+                }               
                 return Ok(new { code = 200 });
             }
             catch (Exception ex)
@@ -2989,5 +2797,38 @@ namespace TEAMModelOS.Controllers
                 await client.GetContainer(Constant.TEAMModelOS, "Teacher").DeleteItemsStreamAsync(correctIds, $"CorrectTask-{tId}");
             }
         }
+        private async Task<(string blob,List<double>)> getMoreStuInfo(CosmosClient client, string stuId, string examId,string subjectId,string code) {
+            var queryClass = $"select c.studentAnswers,c.studentIds,c.studentScores from c where array_contains(c.studentIds,'{stuId}') and c.examId = '{examId}' and c.subjectId = '{subjectId}'";
+            List<List<string>> ans = new List<List<string>>();
+            List<string> ids = new List<string>();
+            List<List<double>> scs = new List<List<double>>();
+            await foreach (var item in client.GetContainer(Constant.TEAMModelOS, "Common").GetItemQueryStreamIterator(queryText: queryClass, requestOptions: new QueryRequestOptions() { PartitionKey = new PartitionKey($"ExamClassResult-{code}") }))
+            {
+                using var json = await JsonDocument.ParseAsync(item.ContentStream);
+                if (json.RootElement.TryGetProperty("_count", out JsonElement count) && count.GetUInt16() > 0)
+                {
+                    var accounts = json.RootElement.GetProperty("Documents").EnumerateArray();
+                    while (accounts.MoveNext())
+                    {
+                        JsonElement account = accounts.Current;
+                        ans = account.GetProperty("studentAnswers").ToObject<List<List<string>>>();
+                        ids = account.GetProperty("studentIds").ToObject<List<string>>();
+                        scs = account.GetProperty("studentScores").ToObject<List<List<double>>>();
+                    }
+                }
+            }
+            int num = ids.IndexOf(stuId);
+            string ansBlob = "";
+            List<double> scores = new List<double>();
+            if (num >= 0)
+            {
+                if (ans[num].Count > 0)
+                {
+                    ansBlob = ans[num].First();
+                }
+                scores = scs[num];
+            }
+            return (ansBlob, scores);
+        }
     }
 }

+ 4 - 1
TEAMModelOS/Controllers/School/NoticeController.cs

@@ -66,7 +66,10 @@ namespace TEAMModelOS.Controllers
                 request.ttl = -1;
                 long now = DateTimeOffset.UtcNow.ToUnixTimeMilliseconds();
                 if (request.autoDelete) {
-                    request.ttl=(int?)(request.endTime - now);
+                    int time = (int)(request.endTime - now) / 1000;
+                    if (time > 0) {
+                        request.ttl = time;
+                    }
                 }
                 request.createTime = now;
                 request.creatorId = userid;