zhouj1203@hotmail.com 1 år sedan
förälder
incheckning
331c022320
1 ändrade filer med 99 tillägg och 2 borttagningar
  1. 99 2
      TEAMModelOS.SDK/Models/Service/StudentService.cs

+ 99 - 2
TEAMModelOS.SDK/Models/Service/StudentService.cs

@@ -57,11 +57,12 @@ namespace TEAMModelOS.SDK
             public Custom examType { get; set; } = new Custom();
 
             public List<ExamSubject> subjects { get; set; } = new List<ExamSubject>();
-
+            public List<string> subs { get; set; } = new List<string>();
             public List<string> classIds { get; set; } = new List<string>();
             public List<string> classes { get; set; } = new List<string>();
             public List<string> stuLists { get; set; } = new List<string>();
             public List<string> tchLists { get; set; } = new List<string>();
+            public List<JsonElement> targets { get; set; } = new List<JsonElement>();
             public long createTime { get; set; } = DateTimeOffset.UtcNow.ToUnixTimeMilliseconds();
             public Dictionary<string, JsonElement> ext { get; set; } = new Dictionary<string, JsonElement>();
             /// 评分状态,0,未评分, 1已评分
@@ -92,7 +93,7 @@ namespace TEAMModelOS.SDK
         /// <param name="azureRedis"></param>
         public static async Task<List<StudentActivity>> FindActivity(JsonElement request, string userId, string userScope, List<string> groupListIds, List<string> subjects, string school, List<string> types, AzureCosmosFactory _azureCosmos)
         {
-            string filed = "c.id ,c.code,c.owner,c.pk as type,c.examType,c.qamode,c.name,c.school,c.startTime,c.endTime,c.classes,c.stuLists,c.tchLists,c.createTime,c.creatorId,c.isSub,c.mustSubmit,c.sStatus,c.scope,c.source,c.subjects";
+            string filed = "c.id ,c.code,c.owner,c.pk as type,c.examType,c.targets,c.qamode,c.name,c.school,c.startTime,c.endTime,c.classes,c.stuLists,c.tchLists,c.createTime,c.creatorId,c.isSub,c.mustSubmit,c.sStatus,c.scope,c.source,c.subjects";
             if (string.IsNullOrWhiteSpace(school))
             {
                 if (request.TryGetProperty("school", out JsonElement schooljson))
@@ -177,11 +178,60 @@ namespace TEAMModelOS.SDK
                 if (userScope.Equals(Constant.ScopeStudent) && !string.IsNullOrWhiteSpace(school))
                 {
                     var resultSchool = await _azureCosmos.GetCosmosClient().GetContainer(Constant.TEAMModelOS, Constant.Common).GetList<StudentActivity>($"{SQL.ToString()}  and c.owner='school' ", $"Vote-{school}");
+                    if (resultSchool.list.Count > 0)
+                    {
+                        foreach (var vote in resultSchool.list)
+                        {
+                            vote.scode = vote.code;
+                            List<string> sub = new();
+                            if (vote.tchLists.Count == 0)
+                            {
+                                if (vote.targets.Count > 0)
+                                {
+                                    foreach (var course in vote.targets)
+                                    {
+                                        var info = course.ToObject<List<string>>();
+                                        if (info.Count > 1)
+                                        {
+                                            sub.Add(info[0]);
+                                        }
+                                    }
+                                }
+                            }
+                            vote.subs = sub;
+
+                        }
+                    }
                     datas.AddRange(resultSchool.list);
                 }
                 //获取教师发布的活动(个人名单,学校名单)
                 {
                     var resultTeacher = await _azureCosmos.GetCosmosClient().GetContainer(Constant.TEAMModelOS, Constant.Common).GetList<StudentActivity>($"{SQL.ToString()}  and c.owner='teacher' ");
+                    if (resultTeacher.list.Count > 0)
+                    {
+                        foreach (var vote in resultTeacher.list)
+                        {
+                            vote.scode = vote.code;
+
+                                List<string> sub = new();
+                                if (vote.tchLists.Count == 0)
+                                {
+                                    if (vote.targets.Count > 0)
+                                    {
+                                        foreach (var course in vote.targets)
+                                        {
+                                            var info = course.ToObject<List<string>>();
+                                            if (info.Count > 1)
+                                            {
+                                                sub.Add(info[0]);
+                                            }
+                                        }
+                                    }
+                                }
+                                vote.subs = sub;
+                            
+                        }
+                    }
                     datas.AddRange(resultTeacher.list);
                 }
             }
@@ -193,11 +243,58 @@ namespace TEAMModelOS.SDK
                 if (userScope.Equals(Constant.ScopeStudent) && !string.IsNullOrWhiteSpace(school))
                 {
                     var resultSchool = await _azureCosmos.GetCosmosClient().GetContainer(Constant.TEAMModelOS, Constant.Common).GetList<StudentActivity>($"{SQL.ToString()}  and c.owner='school' ", $"Survey-{school}");
+                    if (resultSchool.list.Count > 0)
+                    {
+                        foreach (var survey in resultSchool.list)
+                        {
+                            survey.scode = survey.code;
+                            List<string> sub = new();
+                            if (survey.tchLists.Count == 0)
+                            {
+                                if (survey.targets.Count > 0)
+                                {
+                                    foreach (var course in survey.targets)
+                                    {
+                                        var info = course.ToObject<List<string>>();
+                                        if (info.Count > 1)
+                                        {
+                                            sub.Add(info[0]);
+                                        }
+                                    }
+                                }
+                            }
+                            survey.subs = sub;
+
+                        }
+                    }
                     datas.AddRange(resultSchool.list);
                 }
                 //获取教师发布的活动(个人名单,学校名单)
                 {
                     var resultTeacher = await _azureCosmos.GetCosmosClient().GetContainer(Constant.TEAMModelOS, Constant.Common).GetList<StudentActivity>($"{SQL.ToString()}  and c.owner='teacher' ");
+                    if (resultTeacher.list.Count > 0) {
+                        foreach (var survey in resultTeacher.list) {
+                            survey.scode = survey.code;
+
+                                List<string> sub = new();
+                                if (survey.tchLists.Count == 0)
+                                {
+                                    if (survey.targets.Count > 0)
+                                    {
+                                        foreach (var course in survey.targets)
+                                        {
+                                            var info = course.ToObject<List<string>>();
+                                            if (info.Count > 1)
+                                            {
+                                                sub.Add(info[0]);
+                                            }
+                                        }
+                                    }
+                                }
+                                survey.subs = sub;
+                            
+                        }
+                    }
                     datas.AddRange(resultTeacher.list);
                 }
             }