Browse Source

评测状态调整以及BUG修复

zhouj1203@hotmail.com 3 years ago
parent
commit
afead85ff9

+ 53 - 16
TEAMModelOS.FunctionV4/CosmosDB/TriggerExam.cs

@@ -133,10 +133,10 @@ namespace TEAMModelOS.FunctionV4
                                 //await _serviceBus.GetServiceBusClient().SendMessageAsync(Environment.GetEnvironmentVariable("Azure:ServiceBus:ActiveTask"), messageBlob);
                                 #endregion
                                 //List<string> classes = new List<string>();
+                                //处理活动中间件
+                                List<RGroupList> members = await Activity(_coreAPIHttpService, info, classes, client, _dingDing, sub, examClassResults);
                                 if (examClassResults.Count == 0)
                                 {
-                                    //处理活动中间件
-                                    List<RGroupList> members = await Activity(_coreAPIHttpService, info, classes, client, _dingDing, sub, examClassResults);
                                     foreach (string cla in classes)
                                     {
                                         int m = 0;
@@ -642,7 +642,9 @@ namespace TEAMModelOS.FunctionV4
                             }
                         });
                     });
-                    bool flag = false;
+                    bool iss = false;
+                    //标记学生作答状态
+                    int ts = 0;
                     if (results.Count > 0)
                     {
                         foreach (ExamClassResult exam in results)
@@ -650,14 +652,30 @@ namespace TEAMModelOS.FunctionV4
                             int index = exam.studentIds.IndexOf(x.id);
                             if (index != -1)
                             {
-                                flag = exam.studentScores[index].Exists(x => x == -1);
-                                if (!flag)
+                                if (exam.studentAnswers[index].Count > 0)
                                 {
-                                    break;
+                                    bool flag = exam.studentScores[index].Exists(x => x == -1);
+                                    if (!flag)
+                                    {
+                                        ts = 1;
+                                        iss = true;
+                                        break;
+                                    }
+                                    else
+                                    {
+                                        ts = 0;
+                                    }
                                 }
+                                else {
+                                    ts = -1;
+                                }                                                                
                             }
                         }
                     }
+                    else
+                    {
+                        ts = -1;
+                    }
                     tmdActivities.Add(new StuActivity
                     {
                         pk = "Activity",
@@ -675,10 +693,10 @@ namespace TEAMModelOS.FunctionV4
                         subjects = sub,
                         blob = null,
                         owner = info.owner,
-                        createTime = DateTimeOffset.UtcNow.ToUnixTimeMilliseconds(),
-                        taskStatus = -1,
+                        createTime = info.createTime,
+                        taskStatus = ts,
                         ext = new Dictionary<string, JsonElement>() { { "type", info.type.ToJsonString().ToObject<JsonElement>() }, { "subjects", info.subjects.ToJsonString().ToObject<JsonElement>() } },
-                        sStatus = flag ? 0 : 1,
+                        sStatus = iss ? 1 : 0,
                         classIds = classIds.ToList()
 
                     }); ;
@@ -699,7 +717,9 @@ namespace TEAMModelOS.FunctionV4
                             }
                         });
                     });
-                    bool flag = false;
+                    bool iss = false;
+                    //标记学生作答状态
+                    int ts = 0;
                     if (results.Count > 0)
                     {
                         foreach (ExamClassResult exam in results)
@@ -707,14 +727,31 @@ namespace TEAMModelOS.FunctionV4
                             int index = exam.studentIds.IndexOf(x.id);
                             if (index != -1)
                             {
-                                flag = exam.studentScores[index].Exists(x => x == -1);
-                                if (!flag)
+                                if (exam.studentAnswers[index].Count > 0)
+                                {
+                                     bool flag = exam.studentScores[index].Exists(x => x == -1);
+                                    if (!flag)
+                                    {
+                                        ts = 1;
+                                        iss = true;
+                                        break;
+                                    }
+                                    else
+                                    {
+                                        ts = 0;
+                                    }
+                                }
+                                else
                                 {
-                                    break;
+                                    ts = -1;
                                 }
                             }
                         }
                     }
+                    else
+                    {
+                        ts = -1;
+                    }
 
                     stuActivities.Add(new StuActivity
                     {
@@ -734,11 +771,11 @@ namespace TEAMModelOS.FunctionV4
                         blob = null,
                         owner = info.owner,
                         classIds = classIds.ToList(),
-                        createTime = DateTimeOffset.UtcNow.ToUnixTimeMilliseconds(),
+                        createTime = info.createTime,
                         ext = new Dictionary<string, JsonElement>() { { "type", info.type.ToJsonString().ToObject<JsonElement>() },
                             { "subjects", info.subjects.ToJsonString().ToObject<JsonElement>() } },
-                        taskStatus = -1,
-                        sStatus = flag ? 0 : 1,
+                        taskStatus = ts,
+                        sStatus = iss ? 1 : 0,
                     });
                 });
             }

+ 1 - 1
TEAMModelOS.SDK/Models/Service/ActivityService.cs

@@ -495,7 +495,7 @@ namespace TEAMModelOS.SDK
                                 item.studentScores.Add(ansPoint);
                                 item.studentAnswers.Add(new List<string>());
                                 item.sum.Add(0);
-                                item.scIds.Add(member.code);
+                                item.scIds.Add(member.code??"");
                                 item.status.Add(0);
                             }
                             else

+ 1 - 1
TEAMModelOS.SDK/Models/Service/FixDataService.cs

@@ -516,7 +516,7 @@ namespace TEAMModelOS.SDK.Models.Service
             List<Task<ItemResponse<ExamClassResult>>> tasks = new List<Task<ItemResponse<ExamClassResult>>>();
             try
             {
-                await foreach (var item in client.GetContainer(Constant.TEAMModelOS, "Common").GetItemQueryIterator<ExamClassResult>(queryText: $"SELECT value(c) FROM c where c.pk = 'ExamClassResult' and c.year = 2022"))
+                await foreach (var item in client.GetContainer(Constant.TEAMModelOS, "Common").GetItemQueryIterator<ExamClassResult>(queryText: $"SELECT value(c) FROM c where c.pk = 'ExamClassResult' and c._ts > 1640966400"))
                 {
                     results.Add(item);
                     //await Task.WhenAll(tasks);