Browse Source

处理平均分返回值

zhouj1203@hotmail.com 3 years ago
parent
commit
bc749e073f
1 changed files with 4 additions and 2 deletions
  1. 4 2
      TEAMModelOS/Controllers/Common/ExamController.cs

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

@@ -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 c.id,c.name,c.schoolId 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)
@@ -1306,6 +1306,7 @@ namespace TEAMModelOS.Controllers
                                 {
                                     id = account.GetProperty("id").GetString(),
                                     name = account.GetProperty("name").GetString(),
+                                    schoolId = account.GetProperty("schoolId").GetString(),
                                     type = 2
                                 };
                                 students.Add(fo);
@@ -1531,7 +1532,7 @@ namespace TEAMModelOS.Controllers
                         }
                     }
                 }
-                var queryAnswers = $"select c.id,c.code,c.studentIds,c.subjectId,c.studentAnswers,c.studentScores,c.sum,c.mark,c.krate,c.frate from c where c.examId ='{id}' and array_contains(c.studentIds,'{studentId}') and c.pk = 'ExamClassResult' ";
+                var queryAnswers = $"select c.id,c.code,c.studentIds,c.subjectId,c.studentAnswers,c.studentScores,c.average,c.sum,c.mark,c.krate,c.frate from c where c.examId ='{id}' and array_contains(c.studentIds,'{studentId}') and c.pk = 'ExamClassResult' ";
                 List<ExamClassResult> answers = new List<ExamClassResult>();
                 await foreach (var item in client.GetContainer(Constant.TEAMModelOS, "Common").GetItemQueryStreamIterator(queryText: queryAnswers,
                     requestOptions: new QueryRequestOptions() { PartitionKey = new PartitionKey($"ExamClassResult-{school}") }))
@@ -3206,5 +3207,6 @@ namespace TEAMModelOS.Controllers
         public string id { get; set; }
         public string name { get; set; }
         public int type { get; set; }
+        public string schoolId { get; set; }
     }
 }