Forráskód Böngészése

学生作答数据推送调整

zj 2 éve
szülő
commit
fdb2aa2bcc
1 módosított fájl, 10 hozzáadás és 5 törlés
  1. 10 5
      TEAMModelOS/Controllers/Common/ExamController.cs

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

@@ -30,6 +30,7 @@ using Azure.Core;
 using DocumentFormat.OpenXml.Spreadsheet;
 using DocumentFormat.OpenXml.Wordprocessing;
 using Item = TEAMModelOS.SDK.Models.Cosmos.Common.Item;
+using DocumentFormat.OpenXml.Office2016.Excel;
 
 namespace TEAMModelOS.Controllers
 {
@@ -803,7 +804,7 @@ namespace TEAMModelOS.Controllers
             //根据不同评测的类型返回对应的编码
             if (!request.TryGetProperty("code", out JsonElement code)) return BadRequest();
             if (!request.TryGetProperty("scode", out JsonElement scode)) return BadRequest();
-            var (userId, _, _, school) = HttpContext.GetAuthTokenInfo();
+            var (userId, name, picture, school) = HttpContext.GetAuthTokenInfo();
             try
             {
                 List<string> ids = new List<string>();
@@ -1113,6 +1114,7 @@ namespace TEAMModelOS.Controllers
                         await client.GetContainer(Constant.TEAMModelOS, "Common").ReplaceItemAsync(info, id.ToString(), new PartitionKey($"{scode}"));
 
                     }
+                    result.sum[newIndex] = result.studentScores[newIndex].Sum();
                     if (isAns)
                     {
                         if ($"{scope}".Equals(Constant.ScopeStudent))
@@ -1136,7 +1138,10 @@ namespace TEAMModelOS.Controllers
                     }
                     else
                     {
-
+                        if (request.TryGetProperty("artId", out JsonElement artId) && request.TryGetProperty("quotaId", out JsonElement quotaId)) {
+                            await getArtInfoAsync(client, artId.GetString(), school, result.sum[newIndex], id.GetString(), subjectId.GetString(), quotaId.GetString(), userId, picture, name);
+                        };
+                        
                         if ($"{scope}".Equals(Constant.ScopeStudent))
                         {
                             StuActivity activity = await _azureCosmos.GetCosmosClient().GetContainer(Constant.TEAMModelOS, "Student").ReadItemAsync<StuActivity>(id.ToString(), new PartitionKey($"Activity-{school}-{userId}"));
@@ -1155,8 +1160,7 @@ namespace TEAMModelOS.Controllers
                             activity.taskStatus = 1;
                             await _azureCosmos.GetCosmosClient().GetContainer(Constant.TEAMModelOS, "Teacher").ReplaceItemAsync<StuActivity>(activity, id.ToString(), new PartitionKey($"Activity-{userId}"));
                         }
-                    }
-                    result.sum[newIndex] = result.studentScores[newIndex].Sum();
+                    }                   
                     classResult = await client.GetContainer(Constant.TEAMModelOS, "Common").ReplaceItemAsync(result, result.id, new PartitionKey($"{result.code}"));
                 }
                 await Task.WhenAll(tasks);
@@ -1170,11 +1174,12 @@ namespace TEAMModelOS.Controllers
                 return BadRequest();
             }
         }
-        private async Task getArtInfoAsync(CosmosClient client, string artId, string school, double score, string acId, string subject, string quotaId, string rId, string userid, string picture, string name)
+        private async Task getArtInfoAsync(CosmosClient client, string artId, string school, double score, string acId, string subject, string quotaId, string userid, string picture, string name)
         {
             var aresponse = await client.GetContainer("TEAMModelOS", "Common").ReadItemStreamAsync(artId, new PartitionKey($"Art-{school}"));
             ArtEvaluation art;
             StudentArtResult artResult;
+            string rId = string.Format("{0}{1}{2}", school, "-", userid);
             if (aresponse.Status == 200)
             {
                 using var json = await JsonDocument.ParseAsync(aresponse.ContentStream);