Browse Source

调整异常卷和仲裁卷任务

zhouj1203@hotmail.com 3 years ago
parent
commit
00faeac8fa
1 changed files with 120 additions and 34 deletions
  1. 120 34
      TEAMModelFunction/TriggerCorrect.cs

+ 120 - 34
TEAMModelFunction/TriggerCorrect.cs

@@ -32,14 +32,17 @@ namespace TEAMModelFunction
                 adcode = $"Activity-{tdata.school}";
                 adcode = $"Activity-{tdata.school}";
                 blobcntr = tdata.school;
                 blobcntr = tdata.school;
             }
             }
-            else {
+            else
+            {
                 return;
                 return;
             }
             }
             await _dingDing.SendBotMsg($"{Environment.GetEnvironmentVariable("Option:Location")}阅卷配置【{tdata.name}-{tdata.id}-ttl={tdata.ttl}】正在执行", GroupNames.成都开发測試群組);
             await _dingDing.SendBotMsg($"{Environment.GetEnvironmentVariable("Option:Location")}阅卷配置【{tdata.name}-{tdata.id}-ttl={tdata.ttl}】正在执行", GroupNames.成都开发測試群組);
             Correct correct = await client.GetContainer("TEAMModelOS", "Common").ReadItemAsync<Correct>(input.Id, new Azure.Cosmos.PartitionKey($"{tdata.code}"));
             Correct correct = await client.GetContainer("TEAMModelOS", "Common").ReadItemAsync<Correct>(input.Id, new Azure.Cosmos.PartitionKey($"{tdata.code}"));
             List<ChangeRecord> correctRecords = await _azureStorage.FindListByDict<ChangeRecord>(new Dictionary<string, object>() { { "RowKey", input.Id }, { "PartitionKey", correct.progress } });
             List<ChangeRecord> correctRecords = await _azureStorage.FindListByDict<ChangeRecord>(new Dictionary<string, object>() { { "RowKey", input.Id }, { "PartitionKey", correct.progress } });
-            if (correct != null) {
-                switch (correct.progress) {
+            if (correct != null)
+            {
+                switch (correct.progress)
+                {
                     case "pending":
                     case "pending":
                         var messageCorrect = new ServiceBusMessage(new { id = input.Id, progress = "going", code = tdata.code }.ToJsonString());
                         var messageCorrect = new ServiceBusMessage(new { id = input.Id, progress = "going", code = tdata.code }.ToJsonString());
                         messageCorrect.ApplicationProperties.Add("name", "Correct");
                         messageCorrect.ApplicationProperties.Add("name", "Correct");
@@ -64,35 +67,39 @@ namespace TEAMModelFunction
                         }
                         }
                         break;
                         break;
                     case "going":
                     case "going":
-                        if (correct.subs.IsNotEmpty()) {
-                            
-                            foreach (var sub in correct.subs) {
+                        if (correct.subs.IsNotEmpty())
+                        {
+
+                            foreach (var sub in correct.subs)
+                            {
                                 ///生成阅卷教师的阅卷任务列表
                                 ///生成阅卷教师的阅卷任务列表
-                                if (sub.markers.IsNotEmpty()) {
-                                    foreach (var marker in sub.markers) {
+                                if (sub.markers.IsNotEmpty())
+                                {
+                                    foreach (var marker in sub.markers)
+                                    {
                                         CorrectTask task = new CorrectTask
                                         CorrectTask task = new CorrectTask
                                         {
                                         {
                                             ttl = -1,
                                             ttl = -1,
-                                            pk= "CorrectTask",
+                                            pk = "CorrectTask",
                                             code = "CorrectTask-" + marker.id,
                                             code = "CorrectTask-" + marker.id,
                                             //评测id 或者阅卷配置id
                                             //评测id 或者阅卷配置id
                                             id = correct.id,
                                             id = correct.id,
                                             //科目
                                             //科目
-                                            subject=sub.id,
+                                            subject = sub.id,
                                             //科目名称
                                             //科目名称
-                                            subjectName=sub.name,
+                                            subjectName = sub.name,
                                             //评测code
                                             //评测code
-                                            ecode=correct.scode,
+                                            ecode = correct.scode,
                                             //阅卷配置code
                                             //阅卷配置code
-                                            scode=correct.code,
+                                            scode = correct.code,
                                             //任务名称
                                             //任务名称
-                                            name=correct.name,
+                                            name = correct.name,
                                             //开始时间
                                             //开始时间
-                                            startTime=correct.startTime,
+                                            startTime = correct.startTime,
                                             //结束时间
                                             //结束时间
-                                            endTime=correct.endTime,
+                                            endTime = correct.endTime,
                                             //批改数量
                                             //批改数量
-                                            count=marker.count,
+                                            count = marker.count,
                                             //按题阅卷时,题号
                                             //按题阅卷时,题号
                                             qu = marker.qu,
                                             qu = marker.qu,
                                             //模块术
                                             //模块术
@@ -107,14 +114,89 @@ namespace TEAMModelFunction
                                         {
                                         {
                                             task.type = 2;
                                             task.type = 2;
                                         }
                                         }
-                                        else {
+                                        else
+                                        {
                                             task.type = 1;
                                             task.type = 1;
                                         }
                                         }
-                                       await  client.GetContainer("TEAMModelOS", "Teacher").UpsertItemAsync<CorrectTask>(task,new Azure.Cosmos.PartitionKey(task.code));
+                                        await client.GetContainer("TEAMModelOS", "Teacher").UpsertItemAsync<CorrectTask>(task, new Azure.Cosmos.PartitionKey(task.code));
                                     }
                                     }
                                 }
                                 }
+
+
                                 //生成异常卷处理人员
                                 //生成异常卷处理人员
+                                if (sub.err.IsNotEmpty())
+                                {
+
+                                    foreach (var tId in sub.arb)
+                                    {
+                                        CorrectTask task = new CorrectTask
+                                        {
+                                            ttl = -1,
+                                            pk = "CorrectTask",
+                                            code = "CorrectTask-" + tId,
+                                            //评测id 或者阅卷配置id
+                                            id = correct.id,
+                                            //科目
+                                            subject = sub.id,
+                                            //科目名称
+                                            subjectName = sub.name,
+                                            //评测code
+                                            ecode = correct.scode,
+                                            //阅卷配置code
+                                            scode = correct.code,
+                                            //任务名称
+                                            name = correct.name,
+                                            //开始时间
+                                            startTime = correct.startTime,
+                                            //结束时间
+                                            endTime = correct.endTime,
+                                            //模块术
+                                            model = sub.model,
+                                            type = 2
+                                        };
+                                        await client.GetContainer("TEAMModelOS", "Teacher").UpsertItemAsync<CorrectTask>(task, new Azure.Cosmos.PartitionKey(task.code));
+                                    }
+
+
+                                }
+
                                 //生成仲裁人员
                                 //生成仲裁人员
+
+                                if (sub.arb.IsNotEmpty())
+                                {
+
+                                    foreach (var tId in sub.arb)
+                                    {
+                                        CorrectTask task = new CorrectTask
+                                        {
+                                            ttl = -1,
+                                            pk = "CorrectTask",
+                                            code = "CorrectTask-" + tId,
+                                            //评测id 或者阅卷配置id
+                                            id = correct.id,
+                                            //科目
+                                            subject = sub.id,
+                                            //科目名称
+                                            subjectName = sub.name,
+                                            //评测code
+                                            ecode = correct.scode,
+                                            //阅卷配置code
+                                            scode = correct.code,
+                                            //任务名称
+                                            name = correct.name,
+                                            //开始时间
+                                            startTime = correct.startTime,
+                                            //结束时间
+                                            endTime = correct.endTime,
+                                            //模块术
+                                            model = sub.model,
+                                            type = 3
+                                        };
+                                        await client.GetContainer("TEAMModelOS", "Teacher").UpsertItemAsync<CorrectTask>(task, new Azure.Cosmos.PartitionKey(task.code));
+                                    }
+
+
+                                }
                                 //调用本次考试所涉及的所有已经作答的数据 并生成阅卷池,存入redis
                                 //调用本次考试所涉及的所有已经作答的数据 并生成阅卷池,存入redis
                                 //评测id
                                 //评测id
                                 string eid = correct.id;
                                 string eid = correct.id;
@@ -128,12 +210,14 @@ namespace TEAMModelFunction
                                 List<ExamClassResult> classResults = new List<ExamClassResult>();
                                 List<ExamClassResult> classResults = new List<ExamClassResult>();
                                 //获取原题配分
                                 //获取原题配分
                                 int paperIndex = 0;
                                 int paperIndex = 0;
-                                foreach (ExamSubject subject in info.subjects) {
+                                foreach (ExamSubject subject in info.subjects)
+                                {
                                     if (subject.id.Equals(subjectId))
                                     if (subject.id.Equals(subjectId))
                                     {
                                     {
                                         break;
                                         break;
                                     }
                                     }
-                                    else {
+                                    else
+                                    {
                                         paperIndex++;
                                         paperIndex++;
                                     }
                                     }
                                 }
                                 }
@@ -162,7 +246,8 @@ namespace TEAMModelFunction
                                 //初始化老师阅卷记录
                                 //初始化老师阅卷记录
                                 //List<string> tmds = new List<string>();
                                 //List<string> tmds = new List<string>();
                                 List<string> marks = new List<string>();
                                 List<string> marks = new List<string>();
-                                for (int i = 0; i < correct.num; i++) {
+                                for (int i = 0; i < correct.num; i++)
+                                {
                                     marks.Add("");
                                     marks.Add("");
                                 }
                                 }
                                 //初始化阅卷试题部分数据
                                 //初始化阅卷试题部分数据
@@ -180,22 +265,23 @@ namespace TEAMModelFunction
                                     foreach (string stuId in examClass.studentIds)
                                     foreach (string stuId in examClass.studentIds)
                                     {
                                     {
                                         int index = examClass.studentIds.IndexOf(stuId);
                                         int index = examClass.studentIds.IndexOf(stuId);
-                                        if (index > -1) {
+                                        if (index > -1)
+                                        {
                                             List<double> scc = examClass.studentScores[index];
                                             List<double> scc = examClass.studentScores[index];
                                             List<Item> items = new List<Item>();
                                             List<Item> items = new List<Item>();
                                             int itemIndex = 0;
                                             int itemIndex = 0;
                                             foreach (double psc in scc)
                                             foreach (double psc in scc)
                                             {
                                             {
                                                 List<Info> infos = new List<Info>();
                                                 List<Info> infos = new List<Info>();
-/*                                                for (int i = 0; i < correct.num; i++)
-                                                {
-                                                    Info fo = new Info
-                                                    {
-                                                        sc = psc,
-                                                        index = itemIndex
-                                                    };
-                                                    infos.Add(fo);
-                                                }*/
+                                                /*                                                for (int i = 0; i < correct.num; i++)
+                                                                                                {
+                                                                                                    Info fo = new Info
+                                                                                                    {
+                                                                                                        sc = psc,
+                                                                                                        index = itemIndex
+                                                                                                    };
+                                                                                                    infos.Add(fo);
+                                                                                                }*/
                                                 Item item = new Item
                                                 Item item = new Item
                                                 {
                                                 {
                                                     ssc = paperPoint[itemIndex],
                                                     ssc = paperPoint[itemIndex],
@@ -209,7 +295,7 @@ namespace TEAMModelFunction
                                                 id = Guid.NewGuid().ToString(),
                                                 id = Guid.NewGuid().ToString(),
                                                 code = "Scoring-" + info.school,
                                                 code = "Scoring-" + info.school,
                                                 blob = examClass.studentAnswers[index].Count > 0 ? examClass.studentAnswers[index][0] : "",
                                                 blob = examClass.studentAnswers[index].Count > 0 ? examClass.studentAnswers[index][0] : "",
-                                                stuId =stuId,
+                                                stuId = stuId,
                                                 examId = eid,
                                                 examId = eid,
                                                 subjectId = subjectId,
                                                 subjectId = subjectId,
                                                 scores = examClass.studentScores[index],
                                                 scores = examClass.studentScores[index],
@@ -220,7 +306,7 @@ namespace TEAMModelFunction
 
 
                                             };
                                             };
                                             tasks.Add(client.GetContainer("TEAMModelOS", "Teacher").CreateItemAsync<Scoring>(sc, new Azure.Cosmos.PartitionKey(sc.code)));
                                             tasks.Add(client.GetContainer("TEAMModelOS", "Teacher").CreateItemAsync<Scoring>(sc, new Azure.Cosmos.PartitionKey(sc.code)));
-                                        }                                        
+                                        }
                                         //tasks.Add(redisClient.HashSetAsync($"Exam:Scoring:{eid}-{subjectId}", stuId, new { tmdId = tmds, ans = examClass.studentAnswers[index].Count > 0 ? examClass.studentAnswers[index][0] : "", score = examClass.studentScores[index] }.ToJsonString()));
                                         //tasks.Add(redisClient.HashSetAsync($"Exam:Scoring:{eid}-{subjectId}", stuId, new { tmdId = tmds, ans = examClass.studentAnswers[index].Count > 0 ? examClass.studentAnswers[index][0] : "", score = examClass.studentScores[index] }.ToJsonString()));
                                     }
                                     }