zhouj1203@hotmail.com 1 year ago
parent
commit
cee65ea078

+ 15 - 10
TEAMModelOS.FunctionV4/CosmosDB/TriggerExam.cs

@@ -106,7 +106,11 @@ namespace TEAMModelOS.FunctionV4
                     List<ChangeRecord> records = await table.FindListByDict<ChangeRecord>(new Dictionary<string, object>() { { "RowKey", data.id }, { "PartitionKey", PartitionKey } });
                     //处理科目信息
                     List<string> sub = new List<string>();
-                    School sc = await client.GetContainer(Constant.TEAMModelOS, "School").ReadItemAsync<School>(info.school, new Azure.Cosmos.PartitionKey("Base"));
+                    School sc = new();
+                    if (!string.IsNullOrEmpty(info.school)) {
+                        sc = await client.GetContainer(Constant.TEAMModelOS, "School").ReadItemAsync<School>(info.school, new Azure.Cosmos.PartitionKey("Base"));
+                    }
+                    
                     foreach (ExamSubject subject in info.subjects)
                     {
                         sub.Add(subject.id);
@@ -358,7 +362,7 @@ namespace TEAMModelOS.FunctionV4
                                     {
                                         newStatus = 1;
                                     }
-                                    Settlement settlement = await getMore(client, info, examClassResults);
+                                    Settlement settlement = await getMore(client, info);
                                     long nowTime = DateTimeOffset.UtcNow.ToUnixTimeMilliseconds();
                                     //判断评分状态是否发生变化,便于实时的更新评测基本信息
                                     if (info.average != settlement.score || info.sStatus != newStatus)
@@ -417,19 +421,20 @@ namespace TEAMModelOS.FunctionV4
                                 //用来判定是否完成评分
                                 //bool isScore = true;
                                 await resultStatus(client, examClassResults);
-                                Settlement settlement = await getMore(client, info, examClassResults);
-                                var isScore = examClassResults.SelectMany(e => e.studentScores).ToList().Exists(c => c.Contains(-1));
-                                int newStatus = 0;
-                                if (!isScore)
-                                {
-                                    newStatus = 1;
-                                }
+                                
                                 await Activity(_coreAPIHttpService, info, classes, client, _dingDing, sub, examClassResults);
                                 foreach (ExamSubject subject in info.subjects)
                                 {
                                     await createClassResultAsync(info, examClassResults, subject, fno, _azureCosmos, _dingDing, _azureStorage, _httpClient, _configuration);
                                     fno++;
                                 }
+                                Settlement settlement = await getMore(client, info);
+                                var isScore = examClassResults.SelectMany(e => e.studentScores).ToList().Exists(c => c.Contains(-1));
+                                int newStatus = 0;
+                                if (!isScore)
+                                {
+                                    newStatus = 1;
+                                }
                                 //判断均分是否发生变化,便于实时的更新评测基本信息
                                 if (info.sRate != settlement.rate || info.average != settlement.score || info.sStatus != newStatus || info.qRate != settlement.qrate)
                                 {
@@ -637,7 +642,7 @@ namespace TEAMModelOS.FunctionV4
             }
             await Task.WhenAll(tasks);
         }
-        public static async Task<Settlement> getMore(CosmosClient client, ExamInfo info, List<ExamClassResult> examClassResults)
+        public static async Task<Settlement> getMore(CosmosClient client, ExamInfo info)
         {
             //计算单次考试简易统计信息
             Settlement settlement = new();

+ 2 - 0
TEAMModelOS.SDK/Models/Cosmos/School/ExamInfo.cs

@@ -143,6 +143,8 @@ namespace TEAMModelOS.SDK.Models
     public class PaperSimple { 
         public string id { get; set; }
         public string code { get; set; }
+        //标记试卷来源学段
+        public string periodId { get; set; }
         public string name { get; set; }
         public string blob { get; set; }
         public string scope { get; set; }

+ 14 - 4
TEAMModelOS/Controllers/Analysis/ArtAnalysisController.cs

@@ -154,14 +154,24 @@ namespace TEAMModelOS.Controllers.Analysis
                 //var examId = arts[0].settings.SelectMany(s => s.task).Where(a => a.type == 1 && a.subject.Equals(subjectId.GetString())).FirstOrDefault().acId;
                 //根据科目标识获取科目ID以及知识块和知识点关系TODO 引用不同试卷时 获取知识点得差异
                 int index = 0;
-                foreach (var pr in info.subjects) {
+                foreach (var pr in info.subjects)
+                {
                     if (pr.id.Equals(subjectId.GetString()))
                     {
                         break;
                     }
                     index++;
                 }
-                (string subId, List<(string name, List<string> kno)> values) = await getKnowledge(info.papers[index].code, client, subjectId.GetString(), info.period.id);
+                List<(string name, List<string> kno)> knos = new();
+                if (string.IsNullOrEmpty(info.papers[index].periodId))
+                {
+                    (string subId, List<(string name, List<string> kno)> values) = await getKnowledge("hbcn", client, subjectId.GetString(), "be32942d-97a9-52ba-45d6-2e5b722583f5");
+                    knos = values;
+                }
+                else {
+                    (string subId, List<(string name, List<string> kno)> values) = await getKnowledge(info.papers[index].code, client, subjectId.GetString(), info.papers[index].periodId);
+                    knos = values;
+                }                             
                 var query = $"select c.id,c.name,c.subjectId,c.studentScores,c.studentIds,c.paper,c.classes,c.sRate,c.average,c.standard,c.lostStus,c.record,c.phc,c.plc from c where c.examId = '{examId}' and c.subjectId = '{subjectId}' ";
                 await foreach (var item in client.GetContainer(Constant.TEAMModelOS, "Common").GetItemQueryIterator<ExamResult>(queryText: query, requestOptions: new QueryRequestOptions() { PartitionKey = new PartitionKey($"ExamResult-{examId}") }))
                 {
@@ -172,7 +182,7 @@ namespace TEAMModelOS.Controllers.Analysis
                 KeyValuePair<string, List<(string id, double sta, double pass, string stu)>> key = DoSubjectScatter(examResults[0]);
                 pointPersent.Add(key3);
                 List<(string name, double score)> blockScore = new();
-                foreach (var block in values)
+                foreach (var block in knos)
                 {
                     double sc = 0;
                     foreach (var no in pointPersent)
@@ -198,7 +208,7 @@ namespace TEAMModelOS.Controllers.Analysis
                 {
                     x.name,
                     x.score,
-                    block = values.Where(v => null != v.kno && v.kno.Contains(x.name)).Select(x => x.name)
+                    block = knos.Where(v => null != v.kno && v.kno.Contains(x.name)).Select(x => x.name)
                 });
                 //学生信息
                 var students = stus.Select(s => new