zhouj1203@hotmail.com 1 vuosi sitten
vanhempi
commit
3d7da382a9

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

@@ -1550,13 +1550,14 @@ namespace TEAMModelOS.Controllers
             if (!request.TryGetProperty("subjectId", out JsonElement subjectId)) return BadRequest();
             if (!request.TryGetProperty("code", out JsonElement school_code)) return BadRequest();
             if (!request.TryGetProperty("classId", out JsonElement classId)) return BadRequest();
+            if (!request.TryGetProperty("startTime", out JsonElement startTime)) return BadRequest();
             try
             {
                 // 如果只有学生id则返回学生参加过的考试 只返回相关摘要信息
                 var client = _azureCosmos.GetCosmosClient();
                 var (_, _, _, school) = HttpContext.GetAuthTokenInfo();
                 //string code = school_code.ToString().Substring(5);
-                ExamInfo info = await client.GetContainer(Constant.TEAMModelOS, "Common").ReadItemAsync<ExamInfo>(id.ToString(), new PartitionKey($"Exam-{school_code}"));
+                //ExamInfo info = await client.GetContainer(Constant.TEAMModelOS, "Common").ReadItemAsync<ExamInfo>(id.ToString(), new PartitionKey($"Exam-{school_code}"));
                 List<ExamClassResult> examClassResults = new List<ExamClassResult>();
                 await foreach (var item in client.GetContainer(Constant.TEAMModelOS, "Common").GetItemQueryIterator<ExamClassResult>(queryText: $"select c.id,c.subjectId,c.code,c.scIds,c.info,c.studentIds,c.studentAnswers,c.studentScores,c.mark,c.status from c where c.examId = '{id}' and c.subjectId = '{subjectId}' and c.info.id = '{classId}'",
                     requestOptions: new QueryRequestOptions() { PartitionKey = new PartitionKey($"ExamClassResult-{school_code}") }))
@@ -1574,7 +1575,7 @@ namespace TEAMModelOS.Controllers
                 {
                     classId.GetString()
                 };
-                (List<RMember> members, List<RGroupList> groups) = await GroupListService.GetMemberByListids(_coreAPIHttpService, client, _dingDing, cid, $"{school}", null, -1, info.startTime);
+                (List<RMember> members, List<RGroupList> groups) = await GroupListService.GetMemberByListids(_coreAPIHttpService, client, _dingDing, cid, $"{school}", null, -1, startTime.GetInt64());
                 //await client.GetContainer(Constant.TEAMModelOS, "Common").ReadItemAsync<GroupList>(classId.GetString, new PartitionKey($"Exam-{code}"));
                 ///获取真实的名称 
                 List<ufo> ufos = new();

+ 34 - 15
TEAMModelOS/Controllers/XTest/FixDataController.cs

@@ -312,40 +312,59 @@ namespace TEAMModelOS.Controllers
                     }
                 }
             }
-            
+
 
             //Dictionary<string, int> optCount = new Dictionary<string, int>();
             //Dictionary<string, int> ansCount = new Dictionary<string, int>();
-           /* List<(string stuId, List<(string type, double score)> stuType)> stus = new();
-            foreach (StudentArtResult result in artResults)
+            /* List<(string stuId, List<(string type, double score)> stuType)> stus = new();
+             foreach (StudentArtResult result in artResults)
+             {
+                 List<(string type, double score)> stuTtpe = new();
+                 foreach (ArtQuotaResult artQuotas in result.results)
+                 {
+                     if (artQuotas.quotaId.Equals("quota_21")) {
+                         stuTtpe.Add((artQuotas.subjectId, artQuotas.score > 0 ? 1 : 0));
+                     }
+                     if (artQuotas.quotaId.Equals("quota_22") && artQuotas.subjectId.Equals("subject_music")) {
+                         stuTtpe.Add(("zy", artQuotas.score > 0 ? 1 : 0));
+                     }
+
+                 }
+                 stus.Add((result.studentId, stuTtpe));
+             }*/
+            var classList = artResults.SelectMany(c => c.classIds).ToList().Distinct();
+
+            string classSql = $"select c.id, c.name from c where c.pk = 'Class' and c.id in ({string.Join(",", classList.Select(o => $"'{o}'"))})";
+            List<(string id, string name)> classInfos = new();
+            await foreach (var item in _azureCosmos.GetCosmosClient().GetContainer(Constant.TEAMModelOS, Constant.School)
+                .GetItemQueryStreamIterator(queryText: classSql))
             {
-                List<(string type, double score)> stuTtpe = new();
-                foreach (ArtQuotaResult artQuotas in result.results)
+                using var sc_json = await JsonDocument.ParseAsync(item.ContentStream);
+                if (sc_json.RootElement.TryGetProperty("_count", out JsonElement count) && count.GetUInt16() > 0)
                 {
-                    if (artQuotas.quotaId.Equals("quota_21")) {
-                        stuTtpe.Add((artQuotas.subjectId, artQuotas.score > 0 ? 1 : 0));
-                    }
-                    if (artQuotas.quotaId.Equals("quota_22") && artQuotas.subjectId.Equals("subject_music")) {
-                        stuTtpe.Add(("zy", artQuotas.score > 0 ? 1 : 0));
+                    var accounts = sc_json.RootElement.GetProperty("Documents").EnumerateArray();
+                    while (accounts.MoveNext())
+                    {
+                        JsonElement account = accounts.Current;
+                        classInfos.Add((account.GetProperty("id").GetString(), account.GetProperty("name").GetString()));
                     }
-                    
                 }
-                stus.Add((result.studentId, stuTtpe));
-            }*/
+            }
             var stuList = artResults.Select(p => new {
 
                 id = p.studentId,
                 name = p.studentName,
                 school = sc.Where(x => x.id.Equals(p.school)).FirstOrDefault().name,
                 code = p.school,
-                info = p.results.Select(c => new
+                classId = classInfos.Where(x => x.id.Equals(p.classIds[0])).FirstOrDefault().name
+                /*info = p.results.Select(c => new
                 {
                     c.score,
                     c.quotaId,
                     c.quotaName,
                     c.subjectId
 
-                })
+                })*/
             });            
             return Ok(new { stuList });
         }