|
@@ -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 });
|
|
|
}
|