Browse Source

调整名单变化

zhouj1203@hotmail.com 3 năm trước cách đây
mục cha
commit
7a78bcd7ee

+ 5 - 3
TEAMModelOS.FunctionV4/CosmosDB/TriggerExam.cs

@@ -305,8 +305,9 @@ namespace TEAMModelOS.FunctionV4
                                         {
                                             newStatus = 1;
                                         }
+                                        long nowTime = DateTimeOffset.UtcNow.ToUnixTimeMilliseconds();
                                         //判断评分状态是否发生变化,便于实时的更新评测基本信息
-                                        if (info.sStatus != newStatus)
+                                        if (info.sStatus != newStatus || info.updateTime != nowTime)
                                         {
                                             info.sStatus = newStatus;
                                             await client.GetContainer(Constant.TEAMModelOS, "Common").ReplaceItemAsync<ExamInfo>(info, info.id, new PartitionKey(info.code));
@@ -466,7 +467,7 @@ namespace TEAMModelOS.FunctionV4
                                 }
                                 info.standard = Math.Round(examResults[0].studentIds.Count > 0 ? Math.Pow(powSum / examResults[0].studentIds.Count, 0.5) : 0, 2);
                                 double NewsRate = allScore > 0 ? Math.Round(NewsRateScore / allScore * 100, 2) : 0;
-                                info.lostStu = losStu;
+                                //info.lostStu = losStu;
                                 /*//补充历史数据的容器名称
                                 if (string.IsNullOrEmpty(info.cn)) {
                                     if (info.scope.Equals("school"))
@@ -478,11 +479,12 @@ namespace TEAMModelOS.FunctionV4
                                     }
                                 }*/
                                 //判断均分是否发生变化,便于实时的更新评测基本信息
-                                if (info.sRate != NewsRate || info.average != NewsRateScore || info.sStatus != newStatus)
+                                if (info.sRate != NewsRate || info.average != NewsRateScore || info.sStatus != newStatus || info.lostStu.Count != losStu.Count)
                                 {
                                     info.sRate = NewsRate;
                                     info.average = NewsRateScore;
                                     info.sStatus = newStatus;
+                                    info.lostStu = losStu;
                                     await client.GetContainer(Constant.TEAMModelOS, "Common").ReplaceItemAsync<ExamInfo>(info, info.id, new Azure.Cosmos.PartitionKey(info.code));
                                 }
                             }

+ 24 - 6
TEAMModelOS.SDK/Models/Service/ActivityService.cs

@@ -100,7 +100,7 @@ namespace TEAMModelOS.SDK
                     //stujoin新加入名单的
                     foreach (Member member in groupChange.stujoin)
                     {
-                        await updateClassResulte(client, classResults, standerAnswers, member.id, groupChange.listid);
+                        await updateClassResulte(client, classResults, standerAnswers, member.id, groupChange,activity.id);
                         var stucourse = new StuActivity
                         {
                             id = activity.id,
@@ -127,7 +127,7 @@ namespace TEAMModelOS.SDK
                     //tmdjoin新加入的
                     foreach (Member member in groupChange.tmdjoin)
                     {
-                        await updateClassResulte(client, classResults, standerAnswers, member.id,groupChange.listid);
+                        await updateClassResulte(client, classResults, standerAnswers, member.id,groupChange, activity.id);
                         var stucourse = new StuActivity
                         {
                             id = activity.id,
@@ -180,7 +180,7 @@ namespace TEAMModelOS.SDK
                     {
                         try
                         {
-                            await updateClassResulte(client, classResults, standerAnswers, member.id, groupChange.listid);
+                            await updateClassResulte(client, classResults, standerAnswers, member.id, groupChange, activity.id);
                             await client.GetContainer(Constant.TEAMModelOS, "Student").DeleteItemAsync<StuActivity>(activity.id, new PartitionKey($"Activity-{member.code.Replace("Base-", "")}-{member.id}"));
                         }
                         catch (CosmosException)
@@ -193,7 +193,7 @@ namespace TEAMModelOS.SDK
                     {
                         try
                         {
-                            await updateClassResulte(client, classResults, standerAnswers, member.id, groupChange.listid);
+                            await updateClassResulte(client, classResults, standerAnswers, member.id, groupChange, activity.id);
                             await client.GetContainer(Constant.TEAMModelOS, "Student").DeleteItemAsync<StuActivity>(activity.id, new PartitionKey($"Activity-{member.id}"));
                         }
                         catch (CosmosException)
@@ -407,13 +407,13 @@ namespace TEAMModelOS.SDK
                 await Task.WhenAll(tasks);
             }
         }
-        public static async Task updateClassResulte(CosmosClient client,List<ExamClassResult> classResults, List<PaperSimple> standerAnswers, string id,string stuListId)
+        public static async Task updateClassResulte(CosmosClient client,List<ExamClassResult> classResults, List<PaperSimple> standerAnswers, string id,GroupChange change,string acId)
         {
             if (classResults.Count > 0)
             {
                 foreach (var item in classResults)
                 {
-                    if (item.info.id.Equals(stuListId)) {
+                    if (item.info.id.Equals(change.listid)) {
                         int index = item.studentIds.IndexOf(id);
                         if (index == -1)
                         {
@@ -455,6 +455,24 @@ namespace TEAMModelOS.SDK
                     }                                       
                     await client.GetContainer(Constant.TEAMModelOS, "Common").ReplaceItemAsync(item, item.id, new PartitionKey($"{item.code}"));
                 }
+                /*if (change.scope.Equals("school"))
+                {
+                    try {
+                        ExamInfo exam = await client.GetContainer(Constant.TEAMModelOS, "Common").ReadItemAsync<ExamInfo>(acId, new PartitionKey($"Exam-{change.school}"));
+                        exam.updateTime = DateTimeOffset.UtcNow.ToUnixTimeMilliseconds();
+                        await client.GetContainer(Constant.TEAMModelOS, "Common").ReplaceItemAsync(exam, id.ToString(), new PartitionKey($"Exam-{change.school}"));
+                    } catch (Exception e) {
+                        ExamInfo exam = await client.GetContainer(Constant.TEAMModelOS, "Common").ReadItemAsync<ExamInfo>(acId, new PartitionKey($"Exam-{change.creatorId}"));
+                        exam.updateTime = DateTimeOffset.UtcNow.ToUnixTimeMilliseconds();
+                        await client.GetContainer(Constant.TEAMModelOS, "Common").ReplaceItemAsync(exam, id.ToString(), new PartitionKey($"Exam-{change.creatorId}"));
+                    }               
+                }
+                else {
+                    ExamInfo exam = await client.GetContainer(Constant.TEAMModelOS, "Common").ReadItemAsync<ExamInfo>(acId, new PartitionKey($"Exam-{change.creatorId}"));
+                    exam.updateTime = DateTimeOffset.UtcNow.ToUnixTimeMilliseconds();
+                    await client.GetContainer(Constant.TEAMModelOS, "Common").ReplaceItemAsync(exam, id.ToString(), new PartitionKey($"Exam-{change.creatorId}"));
+                }*/
+               
             }
         }
         public static async Task DeleteActivity(CoreAPIHttpService _coreAPIHttpService, CosmosClient client, DingDing _dingDing, ActivityList activityList) {