Browse Source

接口调整,以及批注blob地址调整

zhouj1203@hotmail.com 3 years ago
parent
commit
ab4adc3313

+ 1 - 1
TEAMModelFunction/TriggerCorrect.cs

@@ -275,7 +275,7 @@ namespace TEAMModelFunction
                                                 marks = marks,
                                                 marks = marks,
                                                 items = items,
                                                 items = items,
                                                 qs = qss,
                                                 qs = qss,
-                                                endTime = correct.endTime,
+                                                //endTime = correct.endTime,
                                                 model = sub.model
                                                 model = sub.model
 
 
                                             };
                                             };

+ 99 - 1
TEAMModelOS/Controllers/Analysis/AchievementController.cs

@@ -3870,7 +3870,7 @@ namespace TEAMModelOS.Controllers.Analysis
                                             {
                                             {
                                                 sc.ForEach(s =>
                                                 sc.ForEach(s =>
                                                 {
                                                 {
-                                                    scores.Add(double.Parse(s));
+                                                    scores.Add(s);
                                                 });
                                                 });
                                             }
                                             }
                                             newScores.Add(scores);
                                             newScores.Add(scores);
@@ -4181,6 +4181,104 @@ namespace TEAMModelOS.Controllers.Analysis
                 return BadRequest();
                 return BadRequest();
             }
             }
         }
         }
+
+
+        [HttpPost("import-exam")]
+        public async Task<IActionResult> importExam(JsonElement request)
+        {
+            //获取评测的ID
+            if (!request.TryGetProperty("exam", out JsonElement exam)) return BadRequest();
+            if (!request.TryGetProperty("code", out JsonElement code)) return BadRequest();
+            try
+            {
+                var client = _azureCosmos.GetCosmosClient();
+                ExamInfo info = exam.ToObject<ExamInfo>();
+                info.progress = "going";
+                await client.GetContainer("TEAMModelOS", "Common").UpsertItemAsync(info, new PartitionKey($"Exam-{code}"));
+                return Ok(new { info });
+            }
+            catch (Exception e)
+            {
+                await _dingDing.SendBotMsg($"OS,{_option.Location},analysis/import-exam()\n{e.Message}", GroupNames.醍摩豆服務運維群組);
+                return BadRequest();
+            }
+        }
+
+
+        [HttpPost("import-result")]
+        public async Task<IActionResult> importResult(JsonElement request)
+        {
+            //获取评测的ID
+            if (!request.TryGetProperty("classResult", out JsonElement classResult)) return BadRequest();
+            if (!request.TryGetProperty("id", out JsonElement id)) return BadRequest();
+            if (!request.TryGetProperty("code", out JsonElement code)) return BadRequest();
+            try
+            {
+                var client = _azureCosmos.GetCosmosClient();
+                List<ExamClassResultDto> examClassResultDto = new();
+                examClassResultDto = classResult.ToObject<List<ExamClassResultDto>>();
+                //获取本次评测所有班级作答结果
+                List<ExamClassResult> examClassResults = new();
+                var queryClass = $"select value(c) from c where c.examId =  '{id}'";
+                await foreach (var item in client.GetContainer("TEAMModelOS", "Common").GetItemQueryIterator<ExamClassResult>(queryText: queryClass, requestOptions: new QueryRequestOptions() { PartitionKey = new PartitionKey($"ExamClassResult-{code}") }))
+                {
+                    examClassResults.Add(item);
+
+                }
+                ExamInfo info = await client.GetContainer("TEAMModelOS", "Common").ReadItemAsync<ExamInfo>(id.ToString(), new PartitionKey($"Exam-{code}"));
+                List<Task<ItemResponse<ExamClassResult>>> tasks = new();
+                if (info == null)
+                {
+                    return Ok(new { code = 404, msg = "请先录入评测数据" });
+                }
+                else
+                {
+                    foreach (ExamClassResultDto e in examClassResultDto)
+                    {
+                        int no = 0;
+                        foreach (ExamSubject sub in info.subjects)
+                        {
+                            if (!sub.id.Equals(e.subject))
+                            {
+                                no++;
+                            }
+                        }
+                        //获取标准答案
+                        List<List<string>> standard = new();
+                        standard = info.papers[no].answers;
+
+                        foreach (ExamClassResult ex in examClassResults)
+                        {
+                            if (e.subject.Equals(ex.subjectId))
+                            {
+                                foreach (ClassResults examClass in e.examClassResult)
+                                {
+                                    if (examClass.classInfo.id.Equals(ex.info.id))
+                                    {
+                                        ex.studentIds = examClass.studentIds;
+                                        ex.studentScores = examClass.studentScores;
+                                        //ex.studentAnswers = examClass.studentAnswers;
+                                        ex.ans = examClass.ans;
+                                    }
+                                }
+                            }
+                        }
+                    }
+                }
+                foreach (ExamClassResult result in examClassResults)
+                {
+                    result.progress = true;
+                    tasks.Add(client.GetContainer("TEAMModelOS", "Common").ReplaceItemAsync(result, result.id, new PartitionKey($"{result.code}")));
+                }
+                await Task.WhenAll(tasks);
+                return Ok(new { examClassResults });
+            }
+            catch (Exception e)
+            {
+                await _dingDing.SendBotMsg($"OS,{_option.Location},analysis/import-result()\n{e.StackTrace}", GroupNames.醍摩豆服務運維群組);
+                return BadRequest();
+            }
+        }
     }
     }
 }
 }
 //private List<Dictionary<string, dynamic>> getKnowledgePoint(List<ExamResult> examResults, ExamInfo info)
 //private List<Dictionary<string, dynamic>> getKnowledgePoint(List<ExamResult> examResults, ExamInfo info)

+ 1 - 0
TEAMModelOS/Controllers/Common/ExamController.cs

@@ -2023,6 +2023,7 @@ namespace TEAMModelOS.Controllers
                     builder.Append(id).Append('/');
                     builder.Append(id).Append('/');
                     builder.Append(subjectId).Append('/');
                     builder.Append(subjectId).Append('/');
                     builder.Append(sId).Append("mark").Append('/');
                     builder.Append(sId).Append("mark").Append('/');
+                    builder.Append(tId).Append('/');
                     builder.Append("ans.json");
                     builder.Append("ans.json");
                     await _azureStorage.UploadFileByContainer(code.ToString(), mark.ToJsonString(), "exam", builder.ToString(), false);
                     await _azureStorage.UploadFileByContainer(code.ToString(), mark.ToJsonString(), "exam", builder.ToString(), false);
                     if (attr.Count > 0)
                     if (attr.Count > 0)

+ 2 - 0
TEAMModelOS/Controllers/Teacher/CommentController.cs

@@ -148,6 +148,7 @@ namespace TEAMModelOS.Controllers
             if (!request.TryGetProperty("id", out JsonElement id)) return BadRequest();
             if (!request.TryGetProperty("id", out JsonElement id)) return BadRequest();
             if (!request.TryGetProperty("answer", out JsonElement answer)) return BadRequest();
             if (!request.TryGetProperty("answer", out JsonElement answer)) return BadRequest();
             if (!request.TryGetProperty("studentId", out JsonElement studentId)) return BadRequest();
             if (!request.TryGetProperty("studentId", out JsonElement studentId)) return BadRequest();
+            if (!request.TryGetProperty("tmdId", out JsonElement tId)) return BadRequest();
             if (!request.TryGetProperty("subjectId", out JsonElement subjectId)) return BadRequest();
             if (!request.TryGetProperty("subjectId", out JsonElement subjectId)) return BadRequest();
             if (!request.TryGetProperty("classId", out JsonElement classId)) return BadRequest();
             if (!request.TryGetProperty("classId", out JsonElement classId)) return BadRequest();
             //根据不同评测的类型返回对应的编码
             //根据不同评测的类型返回对应的编码
@@ -181,6 +182,7 @@ namespace TEAMModelOS.Controllers
                     builder.Append(result.examId).Append("/");
                     builder.Append(result.examId).Append("/");
                     builder.Append(result.subjectId).Append("/");
                     builder.Append(result.subjectId).Append("/");
                     builder.Append(studentId).Append("mark").Append("/");
                     builder.Append(studentId).Append("mark").Append("/");
+                    builder.Append(tId).Append('/');
                     builder.Append("ans.json");
                     builder.Append("ans.json");
                     /*string FileName = result.examId + "/" + result.subjectId + "/" + studentId;
                     /*string FileName = result.examId + "/" + result.subjectId + "/" + studentId;
                     string blob = FileName + "/" + "ans.json";*/
                     string blob = FileName + "/" + "ans.json";*/

+ 2 - 1
TEAMModelOS/Models/Dto/ExamClassResultDto.cs

@@ -15,7 +15,8 @@ namespace TEAMModelOS.Models.Dto
         public ClassInfo classInfo { get; set; } = new ClassInfo();
         public ClassInfo classInfo { get; set; } = new ClassInfo();
         public List<string> studentIds { get; set; } = new List<string>();
         public List<string> studentIds { get; set; } = new List<string>();
         public List<List<string>> studentAnswers { get; set; } = new List<List<string>>();
         public List<List<string>> studentAnswers { get; set; } = new List<List<string>>();
-        public List<List<string>> studentScores { get; set; } = new List<List<string>>();
+        public List<List<double>> studentScores { get; set; } = new List<List<double>>();
+        public List<List<List<string>>> ans { get; set; } = new List<List<List<string>>>();
     }
     }
     public class ClassInfo { 
     public class ClassInfo { 
         public string id { get; set; }
         public string id { get; set; }