소스 검색

优化调整

liqk 3 년 전
부모
커밋
81cb6f68bd
2개의 변경된 파일46개의 추가작업 그리고 6개의 파일을 삭제
  1. 1 1
      TEAMModelOS.SDK/Models/Cosmos/Common/Scoring.cs
  2. 45 5
      TEAMModelOS/Controllers/Common/ExamController.cs

+ 1 - 1
TEAMModelOS.SDK/Models/Cosmos/Common/Scoring.cs

@@ -21,7 +21,7 @@ namespace TEAMModelOS.SDK.Models.Cosmos.Common
         public List<double> scores { get; set; } = new List<double>();
         public int model { get; set; }
         public string mode { get; set; }
-        public long endTime { get; set; }
+        //public long endTime { get; set; }
         //阅卷类型1 正常卷 2 异常卷 3 仲裁卷
         /*public int type { get; set; } = 1;
         public string err { get; set; }*/

+ 45 - 5
TEAMModelOS/Controllers/Common/ExamController.cs

@@ -1653,15 +1653,18 @@ namespace TEAMModelOS.Controllers
                 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("type", out JsonElement type)) return BadRequest();
+                if (!requert.TryGetProperty("et", out JsonElement et)) return BadRequest();
                 //if (!requert.TryGetProperty("tmdId", out JsonElement tId)) return BadRequest();
                 var client = _azureCosmos.GetCosmosClient();
                 long time = DateTimeOffset.UtcNow.ToUnixTimeMilliseconds();
+                if (et.GetInt64() > time) {
+                    return Ok(new { msg = "还在进行中", code = 202 });
+                }
                 ExamInfo info = await client.GetContainer("TEAMModelOS", "Common").ReadItemAsync<ExamInfo>(id.ToString(), new PartitionKey($"Exam-{code}"));
                 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("TEAMModelOS", "Teacher").GetItemQueryIterator<SDK.Models.Cosmos.Common.Scoring>(
-                                    queryText: $"select value(c) from c where c.examId = '{id}' and c.subjectId = '{subjectId}' and c.endTime < {time}",
+                                    queryText: $"select value(c) from c where c.examId = '{id}' and c.subjectId = '{subjectId}'",
                                     requestOptions: new QueryRequestOptions() { PartitionKey = new PartitionKey($"Scoring-{code}") }))
                 {
                     attr.Add(item);
@@ -2206,7 +2209,7 @@ namespace TEAMModelOS.Controllers
             return Ok(attr);
         }
 
-        //处理异常卷内容
+        //申报异常卷内容
         [ProducesDefaultResponseType]
         //[AuthToken(Roles = "Student")]
         [HttpPost("save-err")]
@@ -2228,7 +2231,7 @@ namespace TEAMModelOS.Controllers
                     scoring.qs[index.GetInt32()].index = index.GetInt32();
                 }
                 else {
-                    return Ok(new { msg = "改题已经被申报" });
+                    return Ok(new { msg = "改题已经被申报", code = 404 });
                 }
                
                /* scoring.type = 2;
@@ -2241,6 +2244,43 @@ namespace TEAMModelOS.Controllers
             return Ok( new { sc });
         }
 
+        //处理异常卷内容
+        [ProducesDefaultResponseType]
+        //[AuthToken(Roles = "Student")]
+        [HttpPost("fd-err")]
+        public async Task<IActionResult> fdErr(JsonElement requert)
+        {
+            if (!requert.TryGetProperty("id", out JsonElement id)) return BadRequest();
+            if (!requert.TryGetProperty("improve", out JsonElement improve)) return BadRequest();
+            if (!requert.TryGetProperty("code", out JsonElement code)) return BadRequest();
+            if (!requert.TryGetProperty("index", out JsonElement index)) return BadRequest();
+            //if (!requert.TryGetProperty("tId", out JsonElement tId)) return BadRequest();
+            var client = _azureCosmos.GetCosmosClient();
+            SDK.Models.Cosmos.Common.Scoring scoring = await client.GetContainer("TEAMModelOS", "Teacher").ReadItemAsync<SDK.Models.Cosmos.Common.Scoring>(id.GetString(), new PartitionKey($"Scoring-{code}"));
+            if (null != scoring)
+            {
+                if (string.IsNullOrEmpty(scoring.qs[index.GetInt32()].improve))
+                {
+                    scoring.qs[index.GetInt32()].improve = improve.GetString();
+                    //scoring.qs[index.GetInt32()].tId = tId.GetString();
+                    //scoring.qs[index.GetInt32()].index = index.GetInt32();
+                }
+                else
+                {
+                    return Ok(new { msg = "改题已经被处理",code = 404 });
+                }
+
+                /* scoring.type = 2;
+                 scoring.err = err.GetString();*/
+            }
+            else
+            {
+                return Ok(new { code = 404 });
+            }
+            var sc = await client.GetContainer("TEAMModelOS", "Teacher").ReplaceItemAsync(scoring, scoring.id, new PartitionKey($"{scoring.code}"));
+            return Ok(new { sc });
+        }
+
         //处理仲裁卷内容
         [ProducesDefaultResponseType]
         //[AuthToken(Roles = "Student")]
@@ -2248,7 +2288,7 @@ namespace TEAMModelOS.Controllers
         public async Task<IActionResult> saveArb(JsonElement requert)
         {
             if (!requert.TryGetProperty("id", out JsonElement id)) return BadRequest();
-            if (!requert.TryGetProperty("score", out JsonElement score)) return BadRequest();
+            if (!requert.TryGetProperty("score", out JsonElement score)) return BadRequest();//就是一维数组
             if (!requert.TryGetProperty("code", out JsonElement code)) return BadRequest();
             var client = _azureCosmos.GetCosmosClient();
             List<double> scs = score.ToObject<List<double>>();