zhouj1203@hotmail.com 2 年之前
父节点
当前提交
b5116b8ea8

+ 1 - 2
TEAMModelOS.FunctionV4/CosmosDB/TriggerExam.cs

@@ -1387,7 +1387,7 @@ namespace TEAMModelOS.FunctionV4
                     }
                 }
             }
-
+            result.lostStus = lostStu;
             result.record = getMore(info, no, opt);
             result.average = result.studentIds.Count - result.lostStus.Count > 0 ? Math.Round(score * 1.0 / (result.studentIds.Count - result.lostStus.Count), 2) : 0;
             double stand = 0;
@@ -1407,7 +1407,6 @@ namespace TEAMModelOS.FunctionV4
             await tasks.TaskPage(10);
             result.standard = sco > 0 ? Math.Round(stand / sco, 2) : 0;
             result.csRate = csRate;
-            result.lostStus = lostStu;
 
             result.sRate = allScore > 0 ? Math.Round(result.average / allScore * 100, 2) : 0;
             result.classes = classRanges;

+ 44 - 22
TEAMModelOS.FunctionV4/CosmosDB/TriggerStudy.cs

@@ -1,6 +1,9 @@
 using Azure.Cosmos;
 using Azure.Messaging.ServiceBus;
+using DocumentFormat.OpenXml.Bibliography;
 using DocumentFormat.OpenXml.Office2013.Excel;
+using DocumentFormat.OpenXml.Spreadsheet;
+using DocumentFormat.OpenXml.VariantTypes;
 using DocumentFormat.OpenXml.Vml;
 using HTEXLib.COMM.Helpers;
 using Microsoft.Azure.Documents;
@@ -130,32 +133,51 @@ namespace TEAMModelOS.FunctionV4
                                         list.school = school.id;
                                         list.standard = school.standard;
                                     }
-                                    tchList.ForEach(x =>
+                                    string queryScore = $" select c.id from c where c.id ='{study.id}' and c.pk = 'Activity' ";
+                                    List<string> ids = new();
+                                    await foreach (var item in client.GetContainer(Constant.TEAMModelOS, Constant.Teacher).GetItemQueryStreamIterator
+                                        (queryText: queryScore))
                                     {
-                                        tchActivities.Add(new StuActivity
+                                        using var json = await JsonDocument.ParseAsync(item.ContentStream);
+                                        if (json.RootElement.TryGetProperty("_count", out JsonElement count) && count.GetUInt16() > 0)
                                         {
-                                            pk = "Activity",
-                                            id = study.id,
-                                            code = $"Activity-{x.id}",
-                                            type = "Study",
-                                            name = study.name,
-                                            startTime = study.startTime,
-                                            endTime = study.endTime,
-                                            scode = study.code,
-                                            scope = study.scope,
-                                            school = study.school,
-                                            creatorId = study.creatorId,
-                                            subjects = new List<string> { "" },
-                                            blob = null,
-                                            owner = study.owner,
-                                            createTime = DateTimeOffset.UtcNow.ToUnixTimeMilliseconds(),
-                                            taskStatus = -1,
-                                            classIds = study.tchLists
+                                            foreach (var obj in json.RootElement.GetProperty("Documents").EnumerateArray())
+                                            {
+                                                if (obj.TryGetProperty("id", out JsonElement acId))
+                                                {
+                                                    ids.Add(acId.GetString());
+                                                }
+                                            }
+                                        }
+                                    }
+                                   /* var groupNames =  study.groupLists.FirstOrDefault().Select(x => x.Value).FirstOrDefault();
+                                    var gname = tchList.FirstOrDefault().groupName;*/
+                                    if (ids.Count == 0) {
+                                        tchList.ForEach(x =>
+                                        {
+                                            tchActivities.Add(new StuActivity
+                                            {
+                                                pk = "Activity",
+                                                id = study.id,
+                                                code = $"Activity-{x.id}",
+                                                type = "Study",
+                                                name = study.name,
+                                                startTime = study.startTime,
+                                                endTime = study.endTime,
+                                                scode = study.code,
+                                                scope = study.scope,
+                                                school = study.school,
+                                                creatorId = study.creatorId,
+                                                subjects = new List<string> { "" },
+                                                blob = null,
+                                                owner = study.owner,
+                                                createTime = DateTimeOffset.UtcNow.ToUnixTimeMilliseconds(),
+                                                taskStatus = -1,
+                                                classIds = study.tchLists
+                                            });
                                         });
-                                    });
-
+                                    }                         
                                 }
-
                                 await ActivityService.SaveStuActivity(client, _dingDing, null, null, tchActivities);
                                 await StatisticsService.SendServiceBus(list, _configuration, _serviceBus,client);
                                 var messageWorkEnd = new ServiceBusMessage(new { id = tdata.id, progress = "finish", code = tdata.code }.ToJsonString());

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

@@ -27,6 +27,7 @@ namespace TEAMModelOS.SDK.Models
         public long endTime { get; set; }
         public string source { get; set; }
         public List<JsonElement> targets { get; set; } = new List<JsonElement>();
+        public List<Dictionary<string, List<string>>> groupLists { get; set; } = new List<Dictionary<string, List<string>>>();
 
     }
     public class Sub { 

+ 54 - 22
TEAMModelOS.SDK/Models/Service/ActivityService.cs

@@ -23,7 +23,7 @@ namespace TEAMModelOS.SDK
         {
             try
             {
-                var query = $"SELECT distinct c.owner, c.id,c.code, c.classes,c.stuLists,c.subjects,c.progress,c.scope,c.startTime,c.school,c.creatorId,c.name,c.pk ,c.endTime,c.targets   FROM c  " +
+                var query = $"SELECT distinct c.owner, c.id,c.code, c.classes,c.stuLists,c.subjects,c.progress,c.scope,c.groupLists,c.startTime,c.school,c.creatorId,c.name,c.pk ,c.endTime,c.targets   FROM c  " +
                     $"where (c.status<>404 or IS_DEFINED(c.status) = false ) and  c.pk='{type}' " +
                     $" and (( array_contains(c.classes,'{groupChange.listid}')) or ( array_contains(c.stuLists,'{groupChange.listid}'))or ( array_contains(c.tchLists,'{groupChange.listid}')))";
                 //$"and A1 in('{groupChange.listid}') ";
@@ -46,7 +46,7 @@ namespace TEAMModelOS.SDK
                     }
                     foreach (var techer in teachers)
                     {
-                        var queryTech = $"SELECT distinct c.owner, c.id,c.code, c.classes,c.stuLists,c.subjects,c.progress,c.scope,c.startTime,c.school,c.creatorId,c.name,c.pk ,c.endTime,c.targets   FROM c " +
+                        var queryTech = $"SELECT distinct c.owner, c.id,c.code, c.classes,c.stuLists,c.subjects,c.progress,c.groupLists,c.scope,c.startTime,c.school,c.creatorId,c.name,c.pk ,c.endTime,c.targets   FROM c " +
                             $" where (c.status<>404 or IS_DEFINED(c.status) = false ) and  c.school='{groupChange.school}'   and   c.pk='{type}'" +
                             $" and (( array_contains(c.classes,'{groupChange.listid}')) or ( array_contains(c.stuLists,'{groupChange.listid}')))";
                         //  $" and A1 in('{groupChange.listid}') ";
@@ -185,27 +185,59 @@ namespace TEAMModelOS.SDK
                     foreach (Member member in groupChange.tchjoin)
                     {
                         //await updateClassResulte(client, classResults, standerAnswers, member.id);
-                        var stucourse = new StuActivity
+
+                        var groupNames =  activity.groupLists.FirstOrDefault().Select(x => x.Value).FirstOrDefault();
+                        if (groupNames.Count > 0)
                         {
-                            id = activity.id,
-                            scode = activity.code,
-                            name = activity.name,
-                            code = $"Activity-{member.id}",
-                            scope = activity.scope,
-                            school = activity.school,
-                            creatorId = activity.creatorId,
-                            pk = "Activity",
-                            type = type,
-                            subjects = activity.pk.ToLower().Equals("exam") && activity.subjects.IsNotEmpty() ? new List<string>() { activity.subjects[0].id } : new List<string>() { "" },
-                            startTime = activity.startTime,
-                            endTime = activity.endTime,
-                            blob = activity.blob,
-                            owner = activity.owner,
-                            createTime = nowtime,
-                            taskStatus = -1,
-                            classIds = classId
-                        };
-                        await client.GetContainer(Constant.TEAMModelOS, "Teacher").UpsertItemAsync(stucourse, new PartitionKey(stucourse.code));
+                            if (groupNames.Contains(member.groupName))
+                            {
+                                var stucourse = new StuActivity
+                                {
+                                    id = activity.id,
+                                    scode = activity.code,
+                                    name = activity.name,
+                                    code = $"Activity-{member.id}",
+                                    scope = activity.scope,
+                                    school = activity.school,
+                                    creatorId = activity.creatorId,
+                                    pk = "Activity",
+                                    type = type,
+                                    subjects = activity.pk.ToLower().Equals("exam") && activity.subjects.IsNotEmpty() ? new List<string>() { activity.subjects[0].id } : new List<string>() { "" },
+                                    startTime = activity.startTime,
+                                    endTime = activity.endTime,
+                                    blob = activity.blob,
+                                    owner = activity.owner,
+                                    createTime = nowtime,
+                                    taskStatus = -1,
+                                    classIds = classId
+                                };
+                                await client.GetContainer(Constant.TEAMModelOS, "Teacher").UpsertItemAsync(stucourse, new PartitionKey(stucourse.code));
+                            }
+                        }
+                        else {
+                            var stucourse = new StuActivity
+                            {
+                                id = activity.id,
+                                scode = activity.code,
+                                name = activity.name,
+                                code = $"Activity-{member.id}",
+                                scope = activity.scope,
+                                school = activity.school,
+                                creatorId = activity.creatorId,
+                                pk = "Activity",
+                                type = type,
+                                subjects = activity.pk.ToLower().Equals("exam") && activity.subjects.IsNotEmpty() ? new List<string>() { activity.subjects[0].id } : new List<string>() { "" },
+                                startTime = activity.startTime,
+                                endTime = activity.endTime,
+                                blob = activity.blob,
+                                owner = activity.owner,
+                                createTime = nowtime,
+                                taskStatus = -1,
+                                classIds = classId
+                            };
+                            await client.GetContainer(Constant.TEAMModelOS, "Teacher").UpsertItemAsync(stucourse, new PartitionKey(stucourse.code));
+                        }
+                                        
                     }
                     foreach (Member member in groupChange.stuleave)
                     {

+ 14 - 14
TEAMModelOS/Controllers/Analysis/AnalysisController.cs

@@ -387,7 +387,7 @@ namespace TEAMModelOS.Controllers.Analysis
                     //计算标准差
                     //总平均分
                     double totalAverage = 0;
-                    totalAverage = stuCount > 0 ? classTotal * 1.0 / stuCount : 0;
+                    totalAverage = stuCount > 0 ? classTotal * 1.0 / (stuCount -  info.lostStu.Count): 0;
                     //totalAverage = classTotal / stuCount;
                     //获取整个班级 科目的分数情况
                     List<KeyValuePair<string, double>> keyValues = new List<KeyValuePair<string, double>>();
@@ -439,7 +439,7 @@ namespace TEAMModelOS.Controllers.Analysis
                         }
                         //班级全科的pr
                         int index = stuTotals.IndexOf(x.total);
-                        double CPR = stuCount > 0 ? Math.Floor(100 - (100 * (index + 1) - 50) * 1.0 / stuCount) : 0;
+                        double CPR = stuCount > 0 ? Math.Floor(100 - (100 * (index + 1) - 50) * 1.0 / (stuCount - info.lostStu.Count)) : 0;
                         //double CPR = 100 - (100 * (index + 1) - 50) / stuCount;
                         x.cpr = CPR;
                         x.csort = index + 1;
@@ -451,7 +451,7 @@ namespace TEAMModelOS.Controllers.Analysis
                             var subjectT = classStudents.SelectMany(s => s.subjects).Where(sub => sub.id == y.id).Select(scr => scr.score).ToList();
                             subjectT.Sort((s1, s2) => { return s2.CompareTo(s1); });
                             int index = subjectT.IndexOf(y.score);
-                            double CPR = stuCount > 0 ? Math.Floor(100 - (100 * (index + 1) - 50) * 1.0 / stuCount) : 0;
+                            double CPR = stuCount > 0 ? Math.Floor(100 - (100 * (index + 1) - 50) * 1.0 / (stuCount - info.lostStu.Count)) : 0;
                             //double CPR = 100 - (100 * (index + 1) - 50) / stuCount;
                             y.cpr = CPR;
                             y.csort = index + 1;
@@ -470,7 +470,7 @@ namespace TEAMModelOS.Controllers.Analysis
 
                         });
                     });
-                    var pow = stuCount > 0 ? Math.Pow(powSum / stuCount, 0.5) : 0;
+                    var pow = stuCount > 0 ? Math.Pow(powSum / (stuCount - info.lostStu.Count), 0.5) : 0;
                     //var pow = Math.Pow(powSum / stuCount, 0.5);
                     ClassAys classAys = new ClassAys
                     {
@@ -498,9 +498,9 @@ namespace TEAMModelOS.Controllers.Analysis
                                 passCount += 1;
                             }
                         });
-                        double passPercent = stuCount > 0 ? Math.Round(passCount * 1.0 / stuCount, 2) : 0;
+                        double passPercent = stuCount > 0 ? Math.Round(passCount * 1.0 / (stuCount - info.lostStu.Count), 2) : 0;
                         //double passPercent = Math.Round(passCount * 1.0 / stuCount,2) ;
-                        double average = stuCount > 0 ? Math.Round(subScore.Sum() * 1.0 / stuCount, 2) : 0;
+                        double average = stuCount > 0 ? Math.Round(subScore.Sum() * 1.0 / (stuCount - info.lostStu.Count), 2) : 0;
                         //double average = Math.Round(subScore.Sum() * 1.0 / stuCount,2) ;
                         List<double> tt = new List<double>();
                         List<double> fieldPoints = new List<double>();
@@ -508,12 +508,12 @@ namespace TEAMModelOS.Controllers.Analysis
                         pp.ForEach(s =>
                         {
 
-                            tt.Add(stuCount > 0 ? Math.Round(s * 1.0 / stuCount, 2) : 0);
+                            tt.Add(stuCount > 0 ? Math.Round(s * 1.0 / (stuCount - info.lostStu.Count), 2) : 0);
                         });
                         var ff = fieldClassTotal.Where(su => su.Key == key).Select(pint => pint.Value).First();
                         ff.ForEach(s =>
                         {
-                            fieldPoints.Add(stuCount > 0 ? Math.Round(s * 1.0 / stuCount, 2) : 0);
+                            fieldPoints.Add(stuCount > 0 ? Math.Round(s * 1.0 / (stuCount - info.lostStu.Count), 2) : 0);
                         });
                         double val = examClassResults.FirstOrDefault(c => c.subjectId == key && c.info.id == rGroup.id).standard;
                         List<double> krate = examClassResults.FirstOrDefault(c => c.subjectId == key && c.info.id == rGroup.id).krate;
@@ -602,7 +602,7 @@ namespace TEAMModelOS.Controllers.Analysis
                             {
                                 //年级全科的pr
                                 int index = stuGradeTotal.IndexOf(x.total);
-                                double GPR = stuCount > 0 ? Math.Floor(100 - (100 * (index + 1) - 50) * 1.0 / stuCount) : 0;
+                                double GPR = stuCount > 0 ? Math.Floor(100 - (100 * (index + 1) - 50) * 1.0 / (stuCount - info.lostStu.Count)) : 0;
                                 //double GPR = 100 - (100 * (index + 1) - 50) / stuCount;
                                 x.gpr = GPR;
                                 x.gsort = index + 1;
@@ -612,7 +612,7 @@ namespace TEAMModelOS.Controllers.Analysis
                                     var subjectT = studentAys.SelectMany(s => s.subjects).Where(sub => sub.id == y.id).Select(scr => scr.score).ToList();
                                     subjectT.Sort((s1, s2) => { return s2.CompareTo(s1); });
                                     int index = subjectT.IndexOf(y.score);
-                                    double GPR = stuCount > 0 ? Math.Floor(100 - (100 * (index + 1) - 50) * 1.0 / stuCount) : 0;
+                                    double GPR = stuCount > 0 ? Math.Floor(100 - (100 * (index + 1) - 50) * 1.0 / (stuCount - info.lostStu.Count)) : 0;
                                     //double GPR = 100 - (100 * (index + 1) - 50) / stuCount;
                                     y.gpr = GPR;
                                     y.gsort = index + 1;
@@ -670,7 +670,7 @@ namespace TEAMModelOS.Controllers.Analysis
                 average = examResults.FirstOrDefault(c => c.id == x.id).average,
                 standard = examResults.FirstOrDefault(c => c.id == x.id).standard
             });*/
-            var subAll = new { sRate = info.sRate, average = info.average, standard = info.standard, total = info.stuCount };
+            var subAll = new { info.sRate, info.average, info.standard, total = info.stuCount,lost = info.lostStu.Count };
             return Ok(new
             {
                 students,
@@ -678,10 +678,10 @@ namespace TEAMModelOS.Controllers.Analysis
                 grades,
                 paper = subjectPaperDatas,
                 subjects = sub,
-                scatterKey = scatterKey,
-                paperKey = paperKey,
+                scatterKey,
+                paperKey,
                 pointLevelKey = valuePairs,
-                ipoint = ipoint,
+                ipoint,
                 touchScore = touch,
                 knowKey = knowkey,
                 wrongKey = keynowWrong,

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

@@ -343,8 +343,8 @@ namespace TEAMModelOS.Controllers.Common
                     {
                         if (obj.TryGetProperty("id", out JsonElement subScore))
                         {
-                            string sId = obj.GetProperty("id").GetString();
-                            ids.Add(sId);
+                            //string sId = obj.GetProperty("id").GetString();
+                            ids.Add(subScore.GetString());
                         }
                     }
                 }

+ 21 - 3
TEAMModelOS/Controllers/OpenApi/OpenApiService.cs

@@ -47,6 +47,7 @@ using Microsoft.Extensions.Hosting;
 using Microsoft.AspNetCore.Hosting;
 using TEAMModelOS.Models.ShanDa;
 using System.Runtime.ConstrainedExecution;
+using DocumentFormat.OpenXml.Wordprocessing;
 
 namespace TEAMModelOS.Controllers
 {
@@ -772,7 +773,9 @@ namespace TEAMModelOS.Controllers
                 string input = stringBuilder.ToString();
                 Field fields = input.ToObject<Field>();
                 List<CourseBase> courses = new();
-                List<(string name, double T, double P, int attendCount,int mCount,int groups,long time, List<(string name, int count)> counts, List<(string name, double score)> ps, List<(string name, long time)> appTimes)> scores = new();
+                List<(string name, double T, double P, int attendCount,int mCount,int groups,long time, 
+                    List<(string name, int count)> counts, List<(string name, double score)> ps,
+                    List<(string name, long time)> appTimes, List<(string name, string url, int duration, long time)> vd)> scores = new();
                 //List<(string name, List<(string name, int count)> counts)> eveCounts = new();
                 if (response.IsSuccessStatusCode)
                 {
@@ -788,6 +791,7 @@ namespace TEAMModelOS.Controllers
                         var mCount = ne["mCount"].Value<int>();
                         var time = ne["time"].Value<long>();
                         var obj = ne["events"].ToObject<List<Events>>();
+                        var video = ne["videos"].ToObject<List<Videos>>();
                         @base.tmdname = tname;
                         @base.courseName = cname;
                         @base.attendCount = attendCount;
@@ -795,6 +799,7 @@ namespace TEAMModelOS.Controllers
                         @base.groups = new List<string>();
                         @base.time = time;
                         @base.eves = obj;
+                        @base.videos = video;
                         //events.Add(obj);
                         courses.Add(@base);
                     }
@@ -813,6 +818,10 @@ namespace TEAMModelOS.Controllers
                         int P4Count = 0;
                         int P5Count = 0;
                         List<(string name, long time)> eveTimes = new();
+                        List<(string name, string url,int duration, long time)> videos = new();
+                        foreach (var v in eve.videos) {
+                            videos.Add((v.videoName,v.video,v.duration, v.startTime));
+                        }
                         foreach (var apps in eve.eves) {
                             var name = fields.fields.Where(x => x.field.Equals(apps.@event)).FirstOrDefault()?.desc;
                             eveTimes.Add((name, apps.createTime));
@@ -943,7 +952,7 @@ namespace TEAMModelOS.Controllers
                         double scoreT = scoreA + scoreB + scoreC;
                         scoreT = scoreT > 0 ? Math.Round(scoreT, 2) : 0;
                         P = P > 0 ? Math.Round(P, 2) : 0;
-                        scores.Add((eve.courseName, scoreT, P,eve.attendCount,eve.mCount,eve.groups.Count,eve.time,eves, PScore, eveTimes));
+                        scores.Add((eve.courseName, scoreT, P,eve.attendCount,eve.mCount,eve.groups.Count,eve.time,eves, PScore, eveTimes, videos));
                         //eveCounts.Add((eve.courseName, eves));
                     }
                     //var eve = courses.Select(c => c.eves).ToList();
@@ -964,7 +973,8 @@ namespace TEAMModelOS.Controllers
                     c.time,
                     count = c.counts.Select(x => new { x.name, x.count }),
                     pScore = c.ps.Select(x => new {x.name,x.score }),
-                    appTime = c.appTimes.Select(x => new {x.name,x.time })
+                    appTime = c.appTimes.Select(x => new {x.name,x.time }),
+                    videos = c.vd.Select(x =>new { x.name,x.url,x.duration,x.time})
                 });
                 /*var courseCount = eveCounts.Select(c => new
                 {
@@ -2186,6 +2196,7 @@ namespace TEAMModelOS.Controllers
         public List<string> groups { get; set; }
         public long time { get; set; }
         public List<Events> eves { get; set; }
+        public List<Videos> videos { get; set; }
     }
     public class Events
     {
@@ -2193,4 +2204,11 @@ namespace TEAMModelOS.Controllers
         public int freq { get; set; }
         public long createTime { get; set; }
     }
+    public class Videos
+    {
+        public string videoName { get; set; }
+        public string video { get; set; }
+        public int duration { get; set; }
+        public long startTime { get; set; }
+    }
 }