Bladeren bron

targetClassIds调整为classes

zhouj1203@hotmail.com 4 jaren geleden
bovenliggende
commit
f21713caec

+ 2 - 2
TEAMModelFunction/ActivityHttpTrigger.cs

@@ -77,7 +77,7 @@ namespace TEAMModelFunction
                             endTime = info.endTime,
                             scode = info.code,
                             scope = info.scope,
-                            classes = info.targetClassIds.IsNotEmpty() ? info.targetClassIds : new List<string> { "" },
+                            classes = info.classes.IsNotEmpty() ? info.classes : new List<string> { "" },
                             tmdids = new List<string> { "" },
                             progress = "going",
                             owner = info.school,
@@ -98,7 +98,7 @@ namespace TEAMModelFunction
                             scode = info.code,
                             scope = info.scope,
                             progress = "going",
-                            classes = info.targetClassIds.IsNotEmpty() ? info.targetClassIds : new List<string> { "" },
+                            classes = info.classes.IsNotEmpty() ? info.classes : new List<string> { "" },
                             tmdids = new List<string> { "" },
                             owner = info.creatorId,
                             subjects = sub

+ 6 - 6
TEAMModelFunction/TriggerExam.cs

@@ -101,7 +101,7 @@ namespace TEAMModelFunction
                             endTime = info.endTime,
                             scode = info.code,
                             scope = info.scope,
-                            classes = info.targetClassIds.IsNotEmpty() ? info.targetClassIds : new List<string> { "" },
+                            classes = info.classes.IsNotEmpty() ? info.classes : new List<string> { "" },
                             tmdids =  new List<string> { "" },
                             progress = "going",
                             owner = info.school,
@@ -122,7 +122,7 @@ namespace TEAMModelFunction
                             scode = info.code,
                             scope = info.scope,
                             progress = "going",
-                            classes = info.targetClassIds.IsNotEmpty() ? info.targetClassIds : new List<string> { "" },
+                            classes = info.classes.IsNotEmpty() ? info.classes : new List<string> { "" },
                             tmdids = new List<string> { "" },
                             owner = info.creatorId,
                             subjects = sub
@@ -131,7 +131,7 @@ namespace TEAMModelFunction
                     }
                     if (examClassResults.Count == 0)
                     {
-                        foreach (string cla in info.targetClassIds)
+                        foreach (string cla in info.classes)
                         {
                             int m = 0;
                             foreach (ExamSubject subject in info.subjects)
@@ -269,7 +269,7 @@ namespace TEAMModelFunction
                         int gno = 0;
                         foreach (ExamSubject subject in info.subjects)
                         {
-                            if (subject.classCount == info.targetClassIds.Count)
+                            if (subject.classCount == info.classes.Count)
                             {
                                 await createClassResultAsync(info, examClassResults, subject, gno,_azureCosmos);
                             }
@@ -298,7 +298,7 @@ namespace TEAMModelFunction
                             scode = info.code,
                             scope = info.scope,
                             progress = "finish",
-                            classes = info.targetClassIds.IsNotEmpty() ? info.targetClassIds : new List<string> { "" },
+                            classes = info.classes.IsNotEmpty() ? info.classes : new List<string> { "" },
                             tmdids = new List<string> { "" },
                             owner = info.school,
                             subjects = sub
@@ -318,7 +318,7 @@ namespace TEAMModelFunction
                             scode = info.code,
                             scope = info.scope,
                             progress = "finish",
-                            classes = info.targetClassIds.IsNotEmpty() ? info.targetClassIds : new List<string> { "" },
+                            classes = info.classes.IsNotEmpty() ? info.classes : new List<string> { "" },
                             tmdids = new List<string> { "" },
                             owner = info.creatorId,
                             subjects = sub

+ 2 - 2
TEAMModelOS.SDK/Models/Cosmos/School/ExamInfo.cs

@@ -20,7 +20,7 @@ namespace TEAMModelOS.SDK.Models
             grades = new List<Grade>();
             subjects = new List<ExamSubject>();
             papers = new List<PaperSimple>();
-            targetClassIds = new List<string>();
+            classes = new List<string>();
         }
         /// <summary>
         /// 学校编码或教室tmdid
@@ -61,7 +61,7 @@ namespace TEAMModelOS.SDK.Models
         public int year { get; set; }
         public string range { get; set; }
         public string source { get; set; }
-        public List<string> targetClassIds { get; set; }
+        public List<string> classes { get; set; }
         public List<PaperSimple> papers { get; set; }
         ///考试类型 段考 stage  联考 union 平常考 normal 其他 other
         /// </summary>

+ 3 - 3
TEAMModelOS/Controllers/Analysis/AchievementController.cs

@@ -1873,7 +1873,7 @@ namespace TEAMModelOS.Controllers.Analysis
                         idName.Add(ids);
                     }
                 }
-                foreach (string s in info.targetClassIds)
+                foreach (string s in info.classes)
                 {
 
                     //存放每个班级学生总分
@@ -2309,7 +2309,7 @@ namespace TEAMModelOS.Controllers.Analysis
             List<string> classList = new List<string>();
             List<Dictionary<string, object>> exerciseScatter = new List<Dictionary<string, object>>();
             //Dictionary<string, object> scatterAnalysis = new Dictionary<string, object>();
-            classList = exam.targetClassIds;
+            classList = exam.classes;
             List<string> key = new List<string>
             {
                 "id",
@@ -2761,7 +2761,7 @@ namespace TEAMModelOS.Controllers.Analysis
                 info.subjects = examDtos.subjects;
                 info.period = examDtos.period;
                 examDtos.targetClasses.ForEach(e => {
-                    info.targetClassIds.Add(e.id);
+                    info.classes.Add(e.id);
                 });
                 examDtos.papers.ForEach(p => {
                     PaperSimple simple = new PaperSimple();

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

@@ -289,7 +289,7 @@ namespace TEAMModelOS.Controllers.Analysis
                 gradeTotal.Sort((s1, s2) => { return s2.CompareTo(s1); });
                 ipoint = gradeTotal[personCount];
                 //以班级为单位
-                foreach (string classId in info.targetClassIds)
+                foreach (string classId in info.classes)
                 {
                     Class classroom = null;
                     var sresponse = await client.GetContainer("TEAMModelOS", "School").ReadItemStreamAsync(classId, new PartitionKey($"Class-{code}"));

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

@@ -68,12 +68,12 @@ namespace TEAMModelOS.Controllers
                 request.code = "Exam-" + request.code;
                 request.createTime = DateTimeOffset.UtcNow.ToUnixTimeMilliseconds();
                 int stuCount = 0;
-                for (int i = 0; i < request.targetClassIds.Count; i++)
+                for (int i = 0; i < request.classes.Count; i++)
                 {
                     List<string> ids = new List<string>();
                     //处理班级人数(公共部分的校本名单)
                     //List<Student> students = new List<Student>();
-                    await foreach (var item in client.GetContainer("TEAMModelOS", "Student").GetItemQueryStreamIterator(queryText: $"select c.id from c where c.classId = '{request.targetClassIds[i]}'", requestOptions: new QueryRequestOptions() { PartitionKey = new PartitionKey($"Base-{request.school}") }))
+                    await foreach (var item in client.GetContainer("TEAMModelOS", "Student").GetItemQueryStreamIterator(queryText: $"select c.id from c where c.classId = '{request.classes[i]}'", requestOptions: new QueryRequestOptions() { PartitionKey = new PartitionKey($"Base-{request.school}") }))
                     {
                         using var json = await JsonDocument.ParseAsync(item.ContentStream);
                         if (json.RootElement.TryGetProperty("_count", out JsonElement count) && count.GetUInt16() > 0)
@@ -90,7 +90,7 @@ namespace TEAMModelOS.Controllers
                     {                        
                         //处理发布对象为自选名单(个人)
                         List<StuList> stuLists = new List<StuList>();
-                        await foreach (var item in client.GetContainer("TEAMModelOS", "Teacher").GetItemQueryIterator<StuList>(queryText: $"select value(c) from c where c.id = '{request.targetClassIds[i]}'", requestOptions: new QueryRequestOptions() { PartitionKey = new PartitionKey($"StuList") }))
+                        await foreach (var item in client.GetContainer("TEAMModelOS", "Teacher").GetItemQueryIterator<StuList>(queryText: $"select value(c) from c where c.id = '{request.classes[i]}'", requestOptions: new QueryRequestOptions() { PartitionKey = new PartitionKey($"StuList") }))
                         {
                             stuLists.Add(item);
                         }
@@ -121,7 +121,7 @@ namespace TEAMModelOS.Controllers
                     {
                         //发布对象为自选名单(校本)
                         List<StuList> stuLists = new List<StuList>();
-                        await foreach (var item in client.GetContainer("TEAMModelOS", "School").GetItemQueryIterator<StuList>(queryText: $"select value(c) from c where c.id = '{request.targetClassIds[i]}'", requestOptions: new QueryRequestOptions() { PartitionKey = new PartitionKey($"StuList-{code}") }))
+                        await foreach (var item in client.GetContainer("TEAMModelOS", "School").GetItemQueryIterator<StuList>(queryText: $"select value(c) from c where c.id = '{request.classes[i]}'", requestOptions: new QueryRequestOptions() { PartitionKey = new PartitionKey($"StuList-{code}") }))
                         {
                             stuLists.Add(item);
                         }
@@ -276,23 +276,23 @@ namespace TEAMModelOS.Controllers
             try
             {
                 if (!requert.TryGetProperty("code", out JsonElement code)) return BadRequest();
-                var query = $"select c.id,c.name,c.code,c.period,c.startTime,c.endTime,c.stuCount,c.type,c.progress,c.examType,c.createTime, c.subjects, c.grades, c.scope,c.targetClassIds from c ";
+                var query = $"select c.id,c.name,c.code,c.period,c.startTime,c.endTime,c.stuCount,c.type,c.progress,c.examType,c.createTime, c.subjects, c.grades, c.scope,c.classes from c ";
                 if (requert.TryGetProperty("classIds", out JsonElement classIds)) {
                     List<string> ids = classIds.ToObject<List<string>>();
                     HashSet<string> strs = new HashSet<string>();
                     if (ids.Count > 1)
                     {
                         foreach (string id in ids) {
-                            strs.Add($"array_contains(c.targetClassIds,'{id}')");
+                            strs.Add($"array_contains(c.classes,'{id}')");
                         }                           
                     }
                     else
                     {
                         string ssr = ids.Count > 0 ? ids[0] : "";
-                        strs.Add($"array_contains(c.targetClassIds,'{ssr}')");
+                        strs.Add($"array_contains(c.classes,'{ssr}')");
                     }
                     string ss = string.Join(" or ", strs);
-                    query = $"select c.id,c.name,c.code,c.period,c.startTime,c.endTime,c.stuCount,c.type,c.progress,c.examType,c.createTime, c.subjects, c.grades, c.scope,c.targetClassIds from c where ({ss})";
+                    query = $"select c.id,c.name,c.code,c.period,c.startTime,c.endTime,c.stuCount,c.type,c.progress,c.examType,c.createTime, c.subjects, c.grades, c.scope,c.classes from c where ({ss})";
                 };
                 var client = _azureCosmos.GetCosmosClient();
                 List<ExamInfo> examInfo = new List<ExamInfo>();                
@@ -880,7 +880,7 @@ namespace TEAMModelOS.Controllers
                     }
 
                 }
-                var queryClassId = $"select c.targetClassIds id from c where c.id ='{id}'";
+                var queryClassId = $"select c.classes id from c where c.id ='{id}'";
                 await foreach (var item in client.GetContainer("TEAMModelOS", "Common").GetItemQueryStreamIterator(queryText: queryClassId, requestOptions: new QueryRequestOptions() { PartitionKey = new PartitionKey($"{scode}") }))
                 {
                     using var json = await JsonDocument.ParseAsync(item.ContentStream);
@@ -1023,7 +1023,7 @@ namespace TEAMModelOS.Controllers
                 {
                     foreach (string str in resultIds)
                     {
-                        strs.Add($"array_contains(c.targetClassIds,'{str}')");
+                        strs.Add($"array_contains(c.classes,'{str}')");
                         //builder.Append($"array_contains(c.targetClassIds,'{str}')").Append("or");
                     }
                     
@@ -1031,7 +1031,7 @@ namespace TEAMModelOS.Controllers
                 }
                 else {
                     string ssr = resultIds.Count > 0 ? resultIds[0] : "";
-                    strs.Add($"array_contains(c.targetClassIds,'{ssr}')");
+                    strs.Add($"array_contains(c.classes,'{ssr}')");
                     //builder.Append($" array_contains(c.targetClassIds,'{ssr}')");
                 }
                 string ss = string.Join(" or ", strs);