浏览代码

处理名单联动问题

zhouj1203@hotmail.com 3 年之前
父节点
当前提交
82f6a8cab8

+ 127 - 105
TEAMModelOS.FunctionV4/CosmosDB/TriggerExam.cs

@@ -314,11 +314,15 @@ namespace TEAMModelOS.FunctionV4
                                         {
                                             newStatus = 1;
                                         }
+                                        Settlement settlement = await getMore(client, info, examClassResults);
                                         long nowTime = DateTimeOffset.UtcNow.ToUnixTimeMilliseconds();
                                         //判断评分状态是否发生变化,便于实时的更新评测基本信息
-                                        if (info.sStatus != newStatus || info.updateTime != nowTime)
+                                        if ((info.updateTime != nowTime && info.average != settlement.score) || info.sStatus != newStatus)
                                         {
+                                            info.sRate = settlement.rate;
                                             info.sStatus = newStatus;
+                                            info.updateTime = nowTime;
+                                            info.average = settlement.score;
                                             await client.GetContainer(Constant.TEAMModelOS, "Common").ReplaceItemAsync<ExamInfo>(info, info.id, new PartitionKey(info.code));
                                         }
                                     }
@@ -385,99 +389,7 @@ namespace TEAMModelOS.FunctionV4
                                     fno++;
                                 }
 
-                                //计算单次考试简易统计信息
-                                List<ExamResult> examResults = new List<ExamResult>();
-                                await foreach (var item in client.GetContainer(Constant.TEAMModelOS, "Common").GetItemQueryIterator<ExamResult>(
-                                                   queryText: $"select value(c) from c where c.examId  = '{info.id}'", requestOptions: new QueryRequestOptions() { PartitionKey = new Azure.Cosmos.PartitionKey($"ExamResult-{info.id}") }))
-                                {
-                                    examResults.Add(item);
-                                }
-                                
-                                List<Task<ItemResponse<ExamClassResult>>> tasks = new List<Task<ItemResponse<ExamClassResult>>>();
-                                //结算单科单班的标准差和平均分
-                                foreach (ExamClassResult classResult in examClassResults)
-                                {
-                                    //标记单科单班总得分
-                                    double subScore = 0;
-                                    //标准差
-                                    double sPowSum = 0;
-                                    List<double> newSumScore = new List<double>();
-                                    var scount = classResult.studentIds.Count;
-                                    foreach (List<double> sc in classResult.studentScores)
-                                    {
-                                        List<double> newSc = new List<double>();
-                                        foreach (double ssc in sc)
-                                        {
-                                            if (ssc == -1)
-                                            {
-                                                newSc.Add(0);
-                                            }
-                                            else
-                                            {
-                                                newSc.Add(ssc);
-                                            }
-                                        }
-                                        double nc = newSc.Sum();
-                                        newSumScore.Add(nc);
-                                        subScore += nc;
-                                    }
-                                    double rateScore = scount > 0 ? Math.Round(subScore * 1.0 / scount, 2) : 0;
-                                    foreach (double scs in newSumScore)
-                                    {
-                                        sPowSum += Math.Pow(scs - rateScore, 2);
-
-                                    }
-                                    classResult.standard = Math.Round(scount > 0 ? Math.Pow(sPowSum / scount, 0.5) : 0, 2);
-                                    classResult.average = scount > 0 ? Math.Round(subScore / scount, 2) : 0;
-                                    classResult.progress = true;
-                                    tasks.Add(client.GetContainer(Constant.TEAMModelOS, "Common").ReplaceItemAsync(classResult, classResult.id, new Azure.Cosmos.PartitionKey($"{classResult.code}")));
-                                }
-                                await Task.WhenAll(tasks);
-                                //记录某次考试所有学生得分总分
-                                double score = 0;
-                                double allScore = 0;
-                                int stuCount = 0;
-                                //标准差
-                                double powSum = 0;
-                                List<string> losStu = new List<string>();
-                                //当前完成考试得人数
-                                int total = examResults[0].studentIds.Count;
-                                //先与第一个值取并集
-                                if (examResults.Count > 0)
-                                {
-                                    losStu = losStu.Union(examResults[0].lostStus).ToList();
-                                    foreach (ExamResult examResult in examResults)
-                                    {
-                                        if (info.id == examResult.examId)
-                                        {
-                                            foreach (List<double> sc in examResult.studentScores)
-                                            {
-                                                score += sc.Sum();
-                                            }
-                                            stuCount = examResult.studentIds.Count;
-                                        }
-                                        //powSum += Math.Pow(score - examResult.studentIds.Count > 0 ? Math.Round(score * 1.0 / examResult.studentIds.Count, 2) : 0, 2);
-                                        //取交集
-                                        losStu = losStu.Intersect(examResult.lostStus).ToList();
-                                    }
-                                }
-                                double NewsRateScore = stuCount > 0 ? Math.Round(score * 1.0 / stuCount, 2) : 0;
-                                foreach (PaperSimple simple in info.papers)
-                                {
-                                    allScore += simple.point.Sum();
-                                }
-                                //计算全科标准差
-                                foreach (string id in examResults[0].studentIds)
-                                {
-                                    double sc = 0;
-                                    foreach (ExamResult result in examResults)
-                                    {
-                                        sc += result.studentScores[result.studentIds.IndexOf(id)].Sum();
-                                    }
-                                    powSum += Math.Pow(sc - NewsRateScore, 2);
-                                }
-                                info.standard = Math.Round(total > 0 ? Math.Pow(powSum / total, 0.5) : 0, 2);
-                                double NewsRate = allScore > 0 ? Math.Round(NewsRateScore / allScore * 100, 2) : 0;
+                                Settlement settlement = await getMore(client, info, examClassResults);
                                 //info.lostStu = losStu;
                                 /*//补充历史数据的容器名称
                                 if (string.IsNullOrEmpty(info.cn)) {
@@ -490,13 +402,13 @@ namespace TEAMModelOS.FunctionV4
                                     }
                                 }*/
                                 //判断均分是否发生变化,便于实时的更新评测基本信息
-                                if (info.sRate != NewsRate || info.average != NewsRateScore || info.sStatus != newStatus)
+                                if (info.sRate != settlement.rate || info.average != settlement.score || info.sStatus != newStatus)
                                 {
-                                    info.sRate = NewsRate;
-                                    info.average = NewsRateScore;
+                                    info.sRate = settlement.rate;
+                                    info.average = settlement.score;
                                     info.sStatus = newStatus;
-                                    info.lostStu = losStu;
-                                    info.stuCount = total;
+                                    info.lostStu = settlement.stus;
+                                    info.stuCount = settlement.total;
                                     await client.GetContainer(Constant.TEAMModelOS, "Common").ReplaceItemAsync<ExamInfo>(info, info.id, new Azure.Cosmos.PartitionKey(info.code));
                                 }
                             }
@@ -517,6 +429,109 @@ namespace TEAMModelOS.FunctionV4
             }
 
         }
+
+        public static async Task<Settlement> getMore(CosmosClient client,ExamInfo info,List<ExamClassResult> examClassResults) {
+            //计算单次考试简易统计信息
+            Settlement settlement = new Settlement();
+            List<ExamResult> examResults = new List<ExamResult>();
+            await foreach (var item in client.GetContainer(Constant.TEAMModelOS, "Common").GetItemQueryIterator<ExamResult>(
+                               queryText: $"select value(c) from c where c.examId  = '{info.id}'", requestOptions: new QueryRequestOptions() { PartitionKey = new Azure.Cosmos.PartitionKey($"ExamResult-{info.id}") }))
+            {
+                examResults.Add(item);
+            }
+
+            List<Task<ItemResponse<ExamClassResult>>> tasks = new List<Task<ItemResponse<ExamClassResult>>>();
+            //结算单科单班的标准差和平均分
+            foreach (ExamClassResult classResult in examClassResults)
+            {
+                //标记单科单班总得分
+                double subScore = 0;
+                //标准差
+                double sPowSum = 0;
+                List<double> newSumScore = new List<double>();
+                var scount = classResult.studentIds.Count;
+                foreach (List<double> sc in classResult.studentScores)
+                {
+                    List<double> newSc = new List<double>();
+                    foreach (double ssc in sc)
+                    {
+                        if (ssc == -1)
+                        {
+                            newSc.Add(0);
+                        }
+                        else
+                        {
+                            newSc.Add(ssc);
+                        }
+                    }
+                    double nc = newSc.Sum();
+                    newSumScore.Add(nc);
+                    subScore += nc;
+                }
+                double rateScore = scount > 0 ? Math.Round(subScore * 1.0 / scount, 2) : 0;
+                foreach (double scs in newSumScore)
+                {
+                    sPowSum += Math.Pow(scs - rateScore, 2);
+
+                }
+                classResult.standard = Math.Round(scount > 0 ? Math.Pow(sPowSum / scount, 0.5) : 0, 2);
+                classResult.average = scount > 0 ? Math.Round(subScore / scount, 2) : 0;
+                classResult.progress = true;
+                tasks.Add(client.GetContainer(Constant.TEAMModelOS, "Common").ReplaceItemAsync(classResult, classResult.id, new Azure.Cosmos.PartitionKey($"{classResult.code}")));
+            }
+            await Task.WhenAll(tasks);
+            //记录某次考试所有学生得分总分
+            double score = 0;
+            double allScore = 0;
+            int stuCount = 0;
+            //标准差
+            double powSum = 0;
+            List<string> losStu = new List<string>();
+            //当前完成考试得人数
+            int total = examResults[0].studentIds.Count;
+            //先与第一个值取并集
+            if (examResults.Count > 0)
+            {
+                losStu = losStu.Union(examResults[0].lostStus).ToList();
+                foreach (ExamResult examResult in examResults)
+                {
+                    if (info.id == examResult.examId)
+                    {
+                        foreach (List<double> sc in examResult.studentScores)
+                        {
+                            score += sc.Sum();
+                        }
+                        stuCount = examResult.studentIds.Count;
+                    }
+                    //powSum += Math.Pow(score - examResult.studentIds.Count > 0 ? Math.Round(score * 1.0 / examResult.studentIds.Count, 2) : 0, 2);
+                    //取交集
+                    losStu = losStu.Intersect(examResult.lostStus).ToList();
+                }
+            }
+            double NewsRateScore = stuCount > 0 ? Math.Round(score * 1.0 / stuCount, 2) : 0;
+            foreach (PaperSimple simple in info.papers)
+            {
+                allScore += simple.point.Sum();
+            }
+            //计算全科标准差
+            foreach (string id in examResults[0].studentIds)
+            {
+                double sc = 0;
+                foreach (ExamResult result in examResults)
+                {
+                    sc += result.studentScores[result.studentIds.IndexOf(id)].Sum();
+                }
+                powSum += Math.Pow(sc - NewsRateScore, 2);
+            }
+            info.standard = Math.Round(total > 0 ? Math.Pow(powSum / total, 0.5) : 0, 2);
+            double NewsRate = allScore > 0 ? Math.Round(NewsRateScore / allScore * 100, 2) : 0;
+            settlement.rate = NewsRate;
+            settlement.score = NewsRateScore;
+            settlement.stus = losStu;
+            settlement.total = total;
+            return settlement;
+        }
+
         //处理全部学生选题计数
         public static async Task examRecordCount(ExamInfo info, ExamSubject subject, DingDing _dingDing, int no, ExamResult result, List<ExamClassResult> classResults, AzureCosmosFactory _azureCosmos)
         {
@@ -626,7 +641,7 @@ namespace TEAMModelOS.FunctionV4
                             if (index != -1)
                             {
                                 flag = exam.studentScores[index].Exists(x => x == -1);
-                                if (flag) {
+                                if (!flag) {
                                     break;
                                 }
                             }
@@ -650,9 +665,9 @@ namespace TEAMModelOS.FunctionV4
                         blob = null,
                         owner = info.owner,
                         createTime = DateTimeOffset.UtcNow.ToUnixTimeMilliseconds(),
-                        taskStatus = flag ? 0:-1,
+                        taskStatus = -1,
                         ext = new Dictionary<string, JsonElement>() { { "type",info.type.ToJsonString().ToObject<JsonElement>() },{ "subjects", info.subjects.ToJsonString().ToObject<JsonElement>() }},
-                        //sStatus = info.sStatus,
+                        sStatus = flag ? 0 : 1,
                         classIds = classIds.ToList()
 
                     }); ;
@@ -679,7 +694,7 @@ namespace TEAMModelOS.FunctionV4
                             if (index != -1)
                             {
                                 flag = exam.studentScores[index].Exists(x => x == -1);
-                                if (flag)
+                                if (!flag)
                                 {
                                     break;
                                 }
@@ -708,8 +723,8 @@ namespace TEAMModelOS.FunctionV4
                         createTime = DateTimeOffset.UtcNow.ToUnixTimeMilliseconds(),
                         ext = new Dictionary<string, JsonElement>() { { "type", info.type.ToJsonString().ToObject<JsonElement>() }, 
                             { "subjects", info.subjects.ToJsonString().ToObject<JsonElement>() } },
-                        taskStatus = flag ? 0 : -1
-                        //sStatus = info.sStatus,
+                        taskStatus = -1,
+                        sStatus = flag ? 0 : 1,
                     });
                 });
             }
@@ -1100,5 +1115,12 @@ namespace TEAMModelOS.FunctionV4
 
         }
        
+        public class Settlement
+        {
+            public double rate { get; set; }
+            public double score { get; set; }
+            public List<string> stus { get; set; } = new List<string>();
+             public int total { get; set; }
+        }
     }
 }

+ 76 - 25
TEAMModelOS.SDK/Models/Service/ActivityService.cs

@@ -74,7 +74,8 @@ namespace TEAMModelOS.SDK
                     List<string> classes = ExamService.getClasses(activity.classes, activity.stuLists);
                     List<ExamClassResult> classResults = new List<ExamClassResult>();
                     List<PaperSimple> standerAnswers = new List<PaperSimple>();
-                    if (type.Equals("Exam")) {
+                    if (type.Equals("Exam"))
+                    {
                         if (groupChange.scope.Equals("school"))
                         {
                             await foreach (var item in client.GetContainer(Constant.TEAMModelOS, "Common").GetItemQueryIterator<ExamClassResult>(queryText: $"select value(c) from c where c.examId = '{activity.id}'",
@@ -83,14 +84,15 @@ namespace TEAMModelOS.SDK
                                 classResults.Add(item);
                             }
                         }
-                        else {
+                        else
+                        {
                             await foreach (var item in client.GetContainer(Constant.TEAMModelOS, "Common").GetItemQueryIterator<ExamClassResult>(queryText: $"select value(c) from c where c.examId = '{activity.id}'",
                                requestOptions: new QueryRequestOptions() { PartitionKey = new Azure.Cosmos.PartitionKey($"ExamClassResult-{groupChange.creatorId}") }))
                             {
                                 classResults.Add(item);
                             }
                         }
-                        
+
                         await foreach (var item in client.GetContainer(Constant.TEAMModelOS, "Common").GetItemQueryIterator<PaperSimple>(
                             queryText: $"select A0.answers from c join A0 in c.papers where c.id = '{activity.id}'",
                             requestOptions: new QueryRequestOptions() { PartitionKey = new PartitionKey($"{activity.code}") }))
@@ -101,7 +103,7 @@ namespace TEAMModelOS.SDK
                     //stujoin新加入名单的
                     foreach (Member member in groupChange.stujoin)
                     {
-                        await updateClassResulte(client, classResults, standerAnswers, member.id, groupChange,activity.id);
+                        await updateClassResulte(client, classResults, standerAnswers, member.id, groupChange, activity.id);
                         var stucourse = new StuActivity
                         {
                             id = activity.id,
@@ -128,7 +130,7 @@ namespace TEAMModelOS.SDK
                     //tmdjoin新加入的
                     foreach (Member member in groupChange.tmdjoin)
                     {
-                        await updateClassResulte(client, classResults, standerAnswers, member.id,groupChange, activity.id);
+                        await updateClassResulte(client, classResults, standerAnswers, member.id, groupChange, activity.id);
                         var stucourse = new StuActivity
                         {
                             id = activity.id,
@@ -182,16 +184,17 @@ namespace TEAMModelOS.SDK
                         try
                         {
                             await updateClassResulte(client, classResults, standerAnswers, member.id, groupChange, activity.id);
-                            StuActivity stuActivity= await client.GetContainer(Constant.TEAMModelOS, "Student").ReadItemAsync<StuActivity>(activity.id, new PartitionKey($"Activity-{member.code.Replace("Base-", "")}-{member.id}"));
+                            StuActivity stuActivity = await client.GetContainer(Constant.TEAMModelOS, "Student").ReadItemAsync<StuActivity>(activity.id, new PartitionKey($"Activity-{member.code.Replace("Base-", "")}-{member.id}"));
                             stuActivity.classIds.Remove(groupChange.listid);
                             if (stuActivity.classIds.IsNotEmpty())
                             {
-                                await client.GetContainer(Constant.TEAMModelOS, "Student").ReplaceItemAsync<StuActivity>(stuActivity,activity.id, new PartitionKey(stuActivity.code));
+                                await client.GetContainer(Constant.TEAMModelOS, "Student").ReplaceItemAsync<StuActivity>(stuActivity, activity.id, new PartitionKey(stuActivity.code));
                             }
-                            else {
+                            else
+                            {
                                 await client.GetContainer(Constant.TEAMModelOS, "Student").DeleteItemAsync<StuActivity>(activity.id, new PartitionKey($"Activity-{member.code.Replace("Base-", "")}-{member.id}"));
                             }
-                           
+
                         }
                         catch (CosmosException)
                         {
@@ -203,8 +206,8 @@ namespace TEAMModelOS.SDK
                     {
                         try
                         {
-                            await updateClassResulte(client, classResults, standerAnswers, member.id, groupChange,activity.id);
-                            StuActivity stuActivity= await client.GetContainer(Constant.TEAMModelOS, "Student").ReadItemAsync<StuActivity>(activity.id, new PartitionKey($"Activity-{member.id}"));
+                            await updateClassResulte(client, classResults, standerAnswers, member.id, groupChange, activity.id);
+                            StuActivity stuActivity = await client.GetContainer(Constant.TEAMModelOS, "Student").ReadItemAsync<StuActivity>(activity.id, new PartitionKey($"Activity-{member.id}"));
                             stuActivity.classIds.Remove(groupChange.listid);
                             if (stuActivity.classIds.IsNotEmpty())
                             {
@@ -225,7 +228,7 @@ namespace TEAMModelOS.SDK
                     {
                         try
                         {
-                            StuActivity stuActivity= await client.GetContainer(Constant.TEAMModelOS, "Teacher").ReadItemAsync<StuActivity>(activity.id, new PartitionKey($"Activity-{member.id}"));
+                            StuActivity stuActivity = await client.GetContainer(Constant.TEAMModelOS, "Teacher").ReadItemAsync<StuActivity>(activity.id, new PartitionKey($"Activity-{member.id}"));
                             stuActivity.classIds.Remove(groupChange.listid);
                             if (stuActivity.classIds.IsNotEmpty())
                             {
@@ -233,7 +236,7 @@ namespace TEAMModelOS.SDK
                             }
                             else
                             {
-                                await client.GetContainer(Constant.TEAMModelOS, "Teacher").DeleteItemAsync<StuActivity> (activity.id, new PartitionKey($"Activity-{member.id}"));
+                                await client.GetContainer(Constant.TEAMModelOS, "Teacher").DeleteItemAsync<StuActivity>(activity.id, new PartitionKey($"Activity-{member.id}"));
                             }
                         }
                         catch (CosmosException)
@@ -243,7 +246,9 @@ namespace TEAMModelOS.SDK
                         }
                     }
                 }
-            } catch (CosmosException e) {
+            }
+            catch (CosmosException e)
+            {
                 await _dingDing.SendBotMsg($"{Environment.GetEnvironmentVariable("Option:Location")}-GroupListService-FixActivity\n{e.Message}\n{e.StackTrace}CosmosException{e.Status}", GroupNames.成都开发測試群組);
             }
             catch (Exception ex)
@@ -358,7 +363,7 @@ namespace TEAMModelOS.SDK
             }
             return "";
         }
-        public static async Task RefreshStuActivity(CoreAPIHttpService _coreAPIHttpService ,CosmosClient client, DingDing _dingDing, string id, string code)
+        public static async Task RefreshStuActivity(CoreAPIHttpService _coreAPIHttpService, CosmosClient client, DingDing _dingDing, string id, string code)
         {
             MQActivity activity = null;
             try
@@ -383,7 +388,8 @@ namespace TEAMModelOS.SDK
                     foreach (RMember tmdid in tmdids)
                     {
                         var response = await client.GetContainer(Constant.TEAMModelOS, "Student").ReadItemStreamAsync(activity.id, new PartitionKey($"Activity-{tmdid.id}"));
-                        if (response.Status == 200) {
+                        if (response.Status == 200)
+                        {
                             using var json = await JsonDocument.ParseAsync(response.ContentStream);
                             StuActivity stu = json.ToObject<StuActivity>();
                             stu.id = activity.id;
@@ -400,8 +406,8 @@ namespace TEAMModelOS.SDK
                             stu.blob = activity.blob;
                             stu.owner = activity.owner;
                             stu.createTime = DateTimeOffset.UtcNow.ToUnixTimeMilliseconds();
-                            tasks.Add(client.GetContainer(Constant.TEAMModelOS, "Student").ReplaceItemAsync(stu,stu.id, new PartitionKey(stu.code)));
-                        }                                              
+                            tasks.Add(client.GetContainer(Constant.TEAMModelOS, "Student").ReplaceItemAsync(stu, stu.id, new PartitionKey(stu.code)));
+                        }
                     }
                 }
                 if (students.IsNotEmpty())
@@ -435,13 +441,24 @@ namespace TEAMModelOS.SDK
                 await Task.WhenAll(tasks);
             }
         }
-        public static async Task updateClassResulte(CosmosClient client,List<ExamClassResult> classResults, List<PaperSimple> standerAnswers, string id,GroupChange change,string acId)
+        public static async Task updateClassResulte(CosmosClient client, List<ExamClassResult> classResults, List<PaperSimple> standerAnswers, string id, GroupChange change, string acId)
         {
+            ExamInfo info = new ExamInfo();
             if (classResults.Count > 0)
             {
+                if (classResults[0].scope.Equals("school"))
+                {
+                    info = await client.GetContainer(Constant.TEAMModelOS, "Common").ReadItemAsync<ExamInfo>(classResults[0].examId, new PartitionKey($"{classResults[0].school}"));
+                }
+                else
+                {
+                    string code = classResults[0].code.Replace("ExamClassResult-", "");
+                    info = await client.GetContainer(Constant.TEAMModelOS, "Common").ReadItemAsync<ExamInfo>(classResults[0].examId, new PartitionKey($"{code}"));
+                }
                 foreach (var item in classResults)
                 {
-                    if (item.info.id.Equals(change.listid)) {
+                    if (item.info.id.Equals(change.listid))
+                    {
                         int index = item.studentIds.IndexOf(id);
                         if (index == -1)
                         {
@@ -480,9 +497,42 @@ namespace TEAMModelOS.SDK
                             item.studentAnswers.RemoveAt(index);
                             item.sum.RemoveAt(index);
                         }
-                    }                                       
-                    await client.GetContainer(Constant.TEAMModelOS, "Common").ReplaceItemAsync(item, item.id, new PartitionKey($"{item.code}"));
+
+                        bool isAns = item.studentScores.Exists(s => s.Contains(-1));
+                        if (isAns)
+                        {
+                            //整合名单
+                            List<string> classes = ExamService.getClasses(info.classes, info.stuLists);
+                            item.progress = true;
+                            info.subjects.ForEach(s =>
+                            {
+                                if (s.classCount != classes.Count)
+                                {
+                                    if (s.id.Equals(item.subjectId))
+                                    {
+                                        s.classCount += 1;
+                                    }
+
+                                }
+
+                            });
+                            long nowTime = DateTimeOffset.UtcNow.ToUnixTimeMilliseconds();
+                            info.updateTime = nowTime;
+                            await client.GetContainer(Constant.TEAMModelOS, "Common").ReplaceItemAsync(info, id.ToString(), new PartitionKey($"{info.code}"));
+
+
+                        }
+                        await client.GetContainer(Constant.TEAMModelOS, "Common").ReplaceItemAsync(item, item.id, new PartitionKey($"{item.code}"));
+                    }
+
+
+                }
+                var isScore = classResults.SelectMany(e => e.studentScores).ToList().Exists(c => c.Contains(-1));
+                if (!isScore)
+                {
+
                 }
+
                 /*if (change.scope.Equals("school"))
                 {
                     try {
@@ -500,10 +550,11 @@ namespace TEAMModelOS.SDK
                     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) {
+        public static async Task DeleteActivity(CoreAPIHttpService _coreAPIHttpService, CosmosClient client, DingDing _dingDing, ActivityList activityList)
+        {
             List<(string pId, List<string> gid)> ps = new List<(string pId, List<string> gid)>();
             if (activityList.groupLists.Count > 0)
             {
@@ -606,7 +657,7 @@ namespace TEAMModelOS.SDK
             }
             return "";
         }
-    }    
+    }
 
     public class ActivityList
     {

+ 2 - 2
TEAMModelOS/Controllers/Common/ExamController.cs

@@ -1152,7 +1152,7 @@ namespace TEAMModelOS.Controllers
                                     }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'"))
+                                        await foreach (var item in client.GetContainer(Constant.TEAMModelOS, "Student").GetItemQueryStreamIterator(queryText: $"select distinct c.id,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)
@@ -1293,7 +1293,7 @@ namespace TEAMModelOS.Controllers
                     List<string> sIds = new();
                     List<string> tIds = new();
                     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}'"))}) and c.pk = 'Base'"))
+                    await foreach (var item in client.GetContainer(Constant.TEAMModelOS, "Student").GetItemQueryStreamIterator(queryText: $"select distinct 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);
                         if (stuJson.RootElement.TryGetProperty("_count", out JsonElement count) && count.GetUInt16() > 0)