소스 검색

完成阅卷后结算

zhouj1203@hotmail.com 3 년 전
부모
커밋
154dbaf7a4
1개의 변경된 파일56개의 추가작업 그리고 25개의 파일을 삭제
  1. 56 25
      TEAMModelOS/Controllers/Common/ExamController.cs

+ 56 - 25
TEAMModelOS/Controllers/Common/ExamController.cs

@@ -1565,11 +1565,11 @@ namespace TEAMModelOS.Controllers
                         indexScore++;
                         indexScore++;
                         //sc.Add(item.scores.Where(x => x.tmdId.Equals(tId.GetString())).Select(c => c.sc).FirstOrDefault());
                         //sc.Add(item.scores.Where(x => x.tmdId.Equals(tId.GetString())).Select(c => c.sc).FirstOrDefault());
                         //item.scores = item.scores.Where(x => x.tmdId.Equals(tId.GetString())).ToList();
                         //item.scores = item.scores.Where(x => x.tmdId.Equals(tId.GetString())).ToList();
-                    }                    
-                    var obj = new { ss.id,ss.stuId, ss.examId, ss.subjectId, item = sc,ss.qs, ss.blob, ss.tIds, ss.scores, ss.model, ss.mode };
+                    }
+                    var obj = new { ss.id, ss.stuId, ss.examId, ss.subjectId, item = sc, ss.qs, ss.blob, ss.tIds, ss.scores, ss.model, ss.mode };
                     objs.Add(obj);
                     objs.Add(obj);
                 }
                 }
-                return Ok(new {objs, paper = info.papers[index].blob });
+                return Ok(new { objs, paper = info.papers[index].blob });
             }
             }
             catch (Exception ex)
             catch (Exception ex)
             {
             {
@@ -1624,7 +1624,7 @@ namespace TEAMModelOS.Controllers
                     {
                     {
                         ss.qs = qs;
                         ss.qs = qs;
                         errs.Add(ss);
                         errs.Add(ss);
-                    }                                     
+                    }
                 }
                 }
                 return Ok(new { errs, paper = info.papers[index].blob });
                 return Ok(new { errs, paper = info.papers[index].blob });
             }
             }
@@ -1651,7 +1651,8 @@ namespace TEAMModelOS.Controllers
                 //if (!requert.TryGetProperty("tmdId", out JsonElement tId)) return BadRequest();
                 //if (!requert.TryGetProperty("tmdId", out JsonElement tId)) return BadRequest();
                 var client = _azureCosmos.GetCosmosClient();
                 var client = _azureCosmos.GetCosmosClient();
                 long time = DateTimeOffset.UtcNow.ToUnixTimeMilliseconds();
                 long time = DateTimeOffset.UtcNow.ToUnixTimeMilliseconds();
-                if (et.GetInt64() > time) {
+                if (et.GetInt64() > time)
+                {
                     return Ok(new { msg = "还在进行中", code = 202 });
                     return Ok(new { msg = "还在进行中", code = 202 });
                 }
                 }
                 ExamInfo info = await client.GetContainer("TEAMModelOS", "Common").ReadItemAsync<ExamInfo>(id.ToString(), new PartitionKey($"Exam-{code}"));
                 ExamInfo info = await client.GetContainer("TEAMModelOS", "Common").ReadItemAsync<ExamInfo>(id.ToString(), new PartitionKey($"Exam-{code}"));
@@ -1688,9 +1689,9 @@ namespace TEAMModelOS.Controllers
                     {
                     {
                         ss.items = arb;
                         ss.items = arb;
                         arbs.Add(ss);
                         arbs.Add(ss);
-                    }                   
+                    }
                 }
                 }
-                return Ok(new {objs, paper = info.papers[index].blob });
+                return Ok(new { objs, paper = info.papers[index].blob });
             }
             }
             catch (Exception ex)
             catch (Exception ex)
             {
             {
@@ -1819,14 +1820,14 @@ namespace TEAMModelOS.Controllers
                         {
                         {
                             List<double> scc = item.scores.Where(x => x.tmdId.Equals(tId.GetString())).Select(c => c.sc).ToList();
                             List<double> scc = item.scores.Where(x => x.tmdId.Equals(tId.GetString())).Select(c => c.sc).ToList();
                             //item.scores.Where(x => x.tmdId.Equals(tId.GetString())).SelectMany(p => p.sc, (p, d) => new { });
                             //item.scores.Where(x => x.tmdId.Equals(tId.GetString())).SelectMany(p => p.sc, (p, d) => new { });
-                            
+
                             if (scc.Count > 0)
                             if (scc.Count > 0)
                             {
                             {
-                                sc.Add(new { sc = scc.FirstOrDefault(),item.ssc});
+                                sc.Add(new { sc = scc.FirstOrDefault(), item.ssc });
                             }
                             }
                             else
                             else
                             {
                             {
-                                sc.Add(new { sc = ss.scores[indexScore], item.ssc});
+                                sc.Add(new { sc = ss.scores[indexScore], item.ssc });
                             }
                             }
                             indexScore++;
                             indexScore++;
                             //sc.Add(item.scores.Where(x => x.tmdId.Equals(tId.GetString())).Select(c => c.sc).FirstOrDefault());
                             //sc.Add(item.scores.Where(x => x.tmdId.Equals(tId.GetString())).Select(c => c.sc).FirstOrDefault());
@@ -1911,7 +1912,7 @@ namespace TEAMModelOS.Controllers
                             indexScore++;
                             indexScore++;
                             //sc.Add(item.scores.Where(x => x.tmdId.Equals(tId.GetString())).Select(c => c.sc).FirstOrDefault());
                             //sc.Add(item.scores.Where(x => x.tmdId.Equals(tId.GetString())).Select(c => c.sc).FirstOrDefault());
                             //item.scores = item.scores.Where(x => x.tmdId.Equals(tId.GetString())).ToList();
                             //item.scores = item.scores.Where(x => x.tmdId.Equals(tId.GetString())).ToList();
-                        }                       
+                        }
                         var obj = new { item.id, item.stuId, item.examId, item.subjectId, item = sc, item.qs, item.blob, item.tIds, item.scores, item.model, item.mode };
                         var obj = new { item.id, item.stuId, item.examId, item.subjectId, item = sc, item.qs, item.blob, item.tIds, item.scores, item.model, item.mode };
                         return Ok(obj);
                         return Ok(obj);
                     }
                     }
@@ -2162,7 +2163,35 @@ namespace TEAMModelOS.Controllers
                             if (index != -1)
                             if (index != -1)
                             {
                             {
                                 exam.studentScores[index] = scoring.scores;
                                 exam.studentScores[index] = scoring.scores;
-                                //exam.mark[index] = scoring.marks;
+                                int itemIndex = 0;
+                                foreach (Item item in scoring.items)
+                                {
+                                    string tmdId = item.scores[itemIndex].tmdId;
+                                    //判定是否已经存在对应的批注信息
+                                    bool flag = exam.mark[index][itemIndex].Exists(x => x.tmdId.Equals(tmdId));
+                                    if (flag)
+                                    {
+                                        //重复打分更新部分值
+                                        exam.mark[index][itemIndex].Where(x => x.tmdId.Equals(tmdId)).ToList().ForEach(score =>
+                                        {
+                                            score.sc = item.scores[itemIndex].sc;
+                                            score.mark = item.scores[itemIndex].mark;
+                                        });
+                                    }
+                                    else
+                                    {
+                                        Details dt = new()
+                                        {
+                                            index = item.scores[itemIndex].index,
+                                            sc = item.scores[itemIndex].sc,
+                                            tmdId = item.scores[itemIndex].tmdId,
+                                            mark = item.scores[itemIndex].mark,
+                                            identity = item.scores[itemIndex].identity
+                                        };
+                                        exam.mark[index][itemIndex].Add(dt);
+                                    }
+                                    itemIndex++;
+                                }
                             }
                             }
 
 
                         }
                         }
@@ -2225,18 +2254,20 @@ namespace TEAMModelOS.Controllers
                     scoring.qs[index.GetInt32()].tId = tId.GetString();
                     scoring.qs[index.GetInt32()].tId = tId.GetString();
                     scoring.qs[index.GetInt32()].index = index.GetInt32();
                     scoring.qs[index.GetInt32()].index = index.GetInt32();
                 }
                 }
-                else {
+                else
+                {
                     return Ok(new { msg = "改题已经被申报", code = 404 });
                     return Ok(new { msg = "改题已经被申报", code = 404 });
                 }
                 }
-               
-               /* scoring.type = 2;
-                scoring.err = err.GetString();*/
+
+                /* scoring.type = 2;
+                 scoring.err = err.GetString();*/
             }
             }
-            else {
+            else
+            {
                 return Ok(new { code = 404 });
                 return Ok(new { code = 404 });
             }
             }
             var sc = await client.GetContainer("TEAMModelOS", "Teacher").ReplaceItemAsync(scoring, scoring.id, new PartitionKey($"{scoring.code}"));
             var sc = await client.GetContainer("TEAMModelOS", "Teacher").ReplaceItemAsync(scoring, scoring.id, new PartitionKey($"{scoring.code}"));
-            return Ok( new { sc });
+            return Ok(new { sc });
         }
         }
 
 
         //处理异常卷内容
         //处理异常卷内容
@@ -2262,7 +2293,7 @@ namespace TEAMModelOS.Controllers
                 }
                 }
                 else
                 else
                 {
                 {
-                    return Ok(new { msg = "改题已经被处理",code = 404 });
+                    return Ok(new { msg = "改题已经被处理", code = 404 });
                 }
                 }
 
 
                 /* scoring.type = 2;
                 /* scoring.type = 2;
@@ -2300,12 +2331,12 @@ namespace TEAMModelOS.Controllers
                 }
                 }
                 foreach (ExamClassResult exam in classResults)
                 foreach (ExamClassResult exam in classResults)
                 {
                 {
-                        int index = exam.studentIds.IndexOf(scoring.stuId);                        
-                        if (index != -1)
-                        {
-                            exam.studentScores[index] = scoring.scores;
-                            //exam.mark[index] = scoring.marks;
-                        }
+                    int index = exam.studentIds.IndexOf(scoring.stuId);
+                    if (index != -1)
+                    {
+                        exam.studentScores[index] = scoring.scores;
+                        //exam.mark[index] = scoring.marks;
+                    }
 
 
                     await client.GetContainer("TEAMModelOS", "Common").ReplaceItemAsync(exam, exam.id, new PartitionKey($"{exam.code}"));
                     await client.GetContainer("TEAMModelOS", "Common").ReplaceItemAsync(exam, exam.id, new PartitionKey($"{exam.code}"));
                 }
                 }