Просмотр исходного кода

当前名单无学生只有tmdId

zhouj1203@hotmail.com 3 лет назад
Родитель
Сommit
1c448c4827

+ 3 - 3
TEAMModelFunction/TriggerCorrect.cs

@@ -105,7 +105,7 @@ namespace TEAMModelFunction
                                             count = marker.count,
                                             //按题阅卷时,题号
                                             qu = marker.qu,
-                                            //模块
+                                            //模块
                                             model = sub.model,
                                             type = 1,
                                             createTime = DateTimeOffset.UtcNow.ToUnixTimeMilliseconds()
@@ -144,7 +144,7 @@ namespace TEAMModelFunction
                                             startTime = correct.startTime,
                                             //结束时间
                                             endTime = correct.endTime,
-                                            //模块
+                                            //模块
                                             model = sub.model,
                                             type = 2,
                                             createTime = DateTimeOffset.UtcNow.ToUnixTimeMilliseconds()
@@ -185,7 +185,7 @@ namespace TEAMModelFunction
                                             startTime = correct.startTime,
                                             //结束时间
                                             endTime = correct.endTime,
-                                            //模块
+                                            //模块
                                             model = sub.model,
                                             type = 3,
                                             createTime = DateTimeOffset.UtcNow.ToUnixTimeMilliseconds()

+ 9 - 0
TEAMModelOS.SDK/Models/Cosmos/Common/Scoring.cs

@@ -71,6 +71,15 @@ namespace TEAMModelOS.SDK.Models.Cosmos.Common
 
             }
         }
+        public int isArb { get {
+                if (flag)
+                {
+                    return 0;
+                }
+                else {
+                    return 1;
+                }
+            } }
 
     }
     public class Info { 

+ 92 - 10
TEAMModelOS/Controllers/Common/ExamController.cs

@@ -655,7 +655,23 @@ namespace TEAMModelOS.Controllers
                     if (info.scope.Equals("private"))
                     {
                         await foreach (var item in client.GetContainer(Constant.TEAMModelOS, "Teacher").GetItemQueryStreamIterator(
-                        queryText: $"select c.id from c join A0 in c.students where c.id = '{cId}' and (A0.id = '{userId}' or array_contains(c.tmids,'{userId}')) and A0.schoolId = '{info.school}'",
+                        queryText: $"select c.id from c join A0 in c.students where c.id = '{cId}' and A0.id = '{userId}'and A0.schoolId = '{info.school}'",
+                        requestOptions: new QueryRequestOptions() { PartitionKey = new PartitionKey($"StuList") }))
+                        {
+                            using var json = await JsonDocument.ParseAsync(item.ContentStream);
+                            if (json.RootElement.TryGetProperty("_count", out JsonElement count) && count.GetUInt16() > 0)
+                            {
+                                var accounts = json.RootElement.GetProperty("Documents").EnumerateArray();
+                                while (accounts.MoveNext())
+                                {
+                                    JsonElement account = accounts.Current;
+                                    cIds.Add(account.GetProperty("id").GetString());
+                                }
+                                break;
+                            }
+                        }
+                        await foreach (var item in client.GetContainer(Constant.TEAMModelOS, "Teacher").GetItemQueryStreamIterator(
+                        queryText: $"select c.id from c where c.id = '{cId}' and array_contains(c.tmids,'{userId}') ",
                         requestOptions: new QueryRequestOptions() { PartitionKey = new PartitionKey($"StuList") }))
                         {
                             using var json = await JsonDocument.ParseAsync(item.ContentStream);
@@ -758,7 +774,8 @@ namespace TEAMModelOS.Controllers
                         foreach (List<string> num in standard)
                         {
                             List<string> newAns = new List<string>();
-                            foreach (string san in num) {
+                            foreach (string san in num)
+                            {
                                 newAns.Add(san);
                             }
                             anc.Add(newAns);
@@ -959,7 +976,8 @@ namespace TEAMModelOS.Controllers
                             }
                         });
                         await client.GetContainer(Constant.TEAMModelOS, "Common").ReplaceItemAsync(info, id.ToString(), new PartitionKey($"{scode}"));
-                        try {
+                        try
+                        {
                             if (string.IsNullOrEmpty(school))
                             {
                                 StuActivity activity = await client.GetContainer(Constant.TEAMModelOS, "Student").ReadItemAsync<StuActivity>(id.ToString(), new PartitionKey($"Activity-{userId}"));
@@ -972,13 +990,16 @@ namespace TEAMModelOS.Controllers
                                 activity.taskStatus = 1;
                                 await client.GetContainer(Constant.TEAMModelOS, "Student").ReplaceItemAsync(activity, activity.id, new PartitionKey($"{activity.code}"));
                             }
-                        } catch (CosmosException e) {
-                            if (e.Status == 404) {
+                        }
+                        catch (CosmosException e)
+                        {
+                            if (e.Status == 404)
+                            {
                                 StuActivity activity = await client.GetContainer(Constant.TEAMModelOS, "Student").ReadItemAsync<StuActivity>(id.ToString(), new PartitionKey($"Activity-{userId}"));
                                 activity.taskStatus = 1;
                                 await client.GetContainer(Constant.TEAMModelOS, "Student").ReplaceItemAsync(activity, activity.id, new PartitionKey($"{activity.code}"));
                             }
-                        }                        
+                        }
                     }
                     else
                     {
@@ -1817,7 +1838,7 @@ namespace TEAMModelOS.Controllers
             }
             catch (Exception ex)
             {
-                await _dingDing.SendBotMsg($"OS,{_option.Location},exam/scoring\n{ex.Message}", GroupNames.醍摩豆服務運維群組);
+                await _dingDing.SendBotMsg($"OS,{_option.Location},exam/find-err\n{ex.Message}", GroupNames.醍摩豆服務運維群組);
                 return BadRequest();
             }
 
@@ -1878,11 +1899,11 @@ namespace TEAMModelOS.Controllers
                         arbs.Add(ss);
                     }
                 }
-                return Ok(new { objs, paper = info.papers[index].blob });
+                return Ok(new { arbs, paper = info.papers[index].blob });
             }
             catch (Exception ex)
             {
-                await _dingDing.SendBotMsg($"OS,{_option.Location},exam/scoring\n{ex.Message}", GroupNames.醍摩豆服務運維群組);
+                await _dingDing.SendBotMsg($"OS,{_option.Location},exam/find-arb\n{ex.Message}", GroupNames.醍摩豆服務運維群組);
                 return BadRequest();
             }
 
@@ -2551,7 +2572,68 @@ namespace TEAMModelOS.Controllers
         [HttpPost("analysis-scoring")]
         public async Task<IActionResult> Analysis(JsonElement requert)
         {
-            return null;
+            try
+            {
+                if (!requert.TryGetProperty("id", out JsonElement id)) return BadRequest();
+                if (!requert.TryGetProperty("code", out JsonElement code)) return BadRequest();
+                //if (!requert.TryGetProperty("subjectId", out JsonElement subjectId)) return BadRequest();
+                //if (!requert.TryGetProperty("tmdId", out JsonElement tId)) return BadRequest();
+                var client = _azureCosmos.GetCosmosClient();
+                var response = await client.GetContainer(Constant.TEAMModelOS, "Common").ReadItemStreamAsync(id.ToString(), new PartitionKey($"Exam-{code}"));
+                if (response.Status == 200)
+                {
+                    using var json = await JsonDocument.ParseAsync(response.ContentStream);
+                    ExamInfo info = json.ToObject<ExamInfo>();
+                    List<ExamClassResult> classResults = new();
+                    List<SDK.Models.Cosmos.Common.Scoring> attr = new List<SDK.Models.Cosmos.Common.Scoring>();
+                    await foreach (var item in client.GetContainer(Constant.TEAMModelOS, "Teacher").GetItemQueryIterator<SDK.Models.Cosmos.Common.Scoring>(
+                                        queryText: $"select value(c) from c where c.examId = '{id}' ",
+                                        requestOptions: new QueryRequestOptions() { PartitionKey = new PartitionKey($"Scoring-{code}") }))
+                    {
+                        attr.Add(item);
+                    }
+                    List<SDK.Models.Cosmos.Common.Scoring> errs = new();
+                    List<(string subjectId, int count)> ps = new List<(string subjectId, int count)>();
+                    List<(string subjectId, int count)> tps = new List<(string subjectId, int count)>();
+                    List<(string subjectId, int count)> arbs = new List<(string subjectId, int count)>();
+                    List<(string subjectId, int count)> tarbs = new List<(string subjectId, int count)>();
+                    List<(string subjectId, int count)> cs = new List<(string subjectId, int count)>();
+                    foreach (SDK.Models.Cosmos.Common.Scoring ss in attr)
+                    {
+                        List<Qs> qs = ss.qs.Where(s => !string.IsNullOrEmpty(s.err)).ToList();
+                        List<Qs> tqs = ss.qs.Where(s => !string.IsNullOrEmpty(s.improve)).ToList();
+                        List<Item> arb = ss.items.Where(s => s.isArb == 1).ToList();
+                        List<Item> tarb = ss.items.Where(s => s.isArb == 1 && s.flag == true).ToList();
+                        bool flag = ss.scores.Exists(s => s == -1);
+                        if (!flag) cs.Add((ss.subjectId, 1));
+                        ps.Add((ss.subjectId, qs.Count));
+                        tps.Add((ss.subjectId, tqs.Count));
+                        arbs.Add((ss.subjectId, arb.Count));
+                        tarbs.Add((ss.subjectId, tarb.Count));
+                    }
+                    var sc = info.subjects.Select(s => new
+                    {
+                        s.name,
+                        count = info.stuCount,
+                        tqs = tps.Where(p => p.subjectId.Equals(s.id)).Select(c => c.count).Sum(),
+                        qs = ps.Where(p => p.subjectId.Equals(s.id)).Select(c => c.count).Sum(),
+                        tarbs = tarbs.Where(p => p.subjectId.Equals(s.id)).Select(c => c.count).Sum(),
+                        arbs = arbs.Where(p => p.subjectId.Equals(s.id)).Select(c => c.count).Sum(),
+                        cs = cs.Where(p => p.subjectId.Equals(s.id)).Select(c => c.count).Sum()
+                    }); 
+                    return Ok(new { sc });
+                }
+                else
+                {
+                    return BadRequest();
+                }
+
+            }
+            catch (Exception ex)
+            {
+                await _dingDing.SendBotMsg($"OS,{_option.Location},exam/analysis-scoring\n{ex.Message}", GroupNames.醍摩豆服務運維群組);
+                return BadRequest();
+            }
         }
 
         private async Task deleteAsync(CosmosClient client, string id, string tId)

+ 1 - 0
TEAMModelOS/Controllers/School/CourseController.cs

@@ -929,6 +929,7 @@ namespace TEAMModelOS.Controllers
                 //List<int> stuCount = new List<int>();
                 List<string> ids = new();
                 ids = classId.ToObject<List<string>>();
+                if (!(ids.Count > 0)) return BadRequest();
                 //List<Students> stu = new();
                 var query = $"select c.id,c.name,c.students,c.tmids,c.no,c.code,c.scope,c.school,c.creatorId from c where c.id in ({string.Join(",", ids.Select(o => $"'{o}'"))})";
                 if (scope.ToString().Equals("school", StringComparison.OrdinalIgnoreCase))