zhouj1203@hotmail.com 1 سال پیش
والد
کامیت
2ab5781ead
1فایلهای تغییر یافته به همراه34 افزوده شده و 30 حذف شده
  1. 34 30
      TEAMModelOS/Controllers/Common/ExamController.cs

+ 34 - 30
TEAMModelOS/Controllers/Common/ExamController.cs

@@ -3706,8 +3706,8 @@ namespace TEAMModelOS.Controllers
                         break;
                     }
                 }
-                //var items = ids.GroupBy(x => x).Select(z => z.Key).ToList().Count;
-                return Ok(new { errorItems, token, ids.Count });
+                errorItems = errorItems.Where((x, i) => errorItems.FindIndex(z => z.id == x.id) == i).ToList();
+                return Ok(new { errorItems, token,ids.Count });
             }
             catch (Exception ex)
             {
@@ -4209,9 +4209,9 @@ namespace TEAMModelOS.Controllers
 
         //获取题目信息
         [ProducesDefaultResponseType]
-        [AuthToken(Roles = "teacher,admin,student")]
+        //[AuthToken(Roles = "teacher,admin,student")]
         [HttpPost("get-item")]
-        [Authorize(Roles = "IES")]
+        //[Authorize(Roles = "IES")]
         public async Task<IActionResult> getItemInfo(JsonElement request)
         {
             if (!request.TryGetProperty("errorItems", out JsonElement items)) return BadRequest();
@@ -4244,35 +4244,39 @@ namespace TEAMModelOS.Controllers
                     }
                     List<PaperSimple> simples = info.papers;
                     string blob = simples[index].blob;
-
-                    BlobDownloadResult index_item_json;
-                    if (info.scope.Equals("school"))
-                    {
-                        index_item_json = await _azureStorage.GetBlobContainerClient($"{info.school}").GetBlobClient($"{blob} /{itemInfo.qId}.json").DownloadContentAsync();
-                    }
-                    else
-                    {
-                        index_item_json = await _azureStorage.GetBlobContainerClient($"{info.creatorId}").GetBlobClient($"{blob}/{itemInfo.qId}.json").DownloadContentAsync();
-                    }
-                    JsonElement itemJson = JsonDocument.Parse(new MemoryStream(Encoding.UTF8.GetBytes(index_item_json.Content.ToString()))).RootElement;
-                    elements.Add(itemJson);
-                    if (itemJson.TryGetProperty("pid", out JsonElement pid))
-                    {
-                        if (!string.IsNullOrEmpty(pid.ToString()))
+                    try {
+                        BlobDownloadResult index_item_json;
+                        if (info.scope.Equals("school"))
                         {
-                            BlobDownloadResult index_pid_item_json;
-                            if (info.scope.Equals("school"))
-                            {
-                                index_pid_item_json = await _azureStorage.GetBlobContainerClient($"{info.school}").GetBlobClient($"{blob} /{pid}.json").DownloadContentAsync();
-                            }
-                            else
+                            index_item_json = await _azureStorage.GetBlobContainerClient($"{info.school}").GetBlobClient($"{blob}/{itemInfo.qId}.json").DownloadContentAsync();
+                        }
+                        else
+                        {
+                            index_item_json = await _azureStorage.GetBlobContainerClient($"{info.creatorId}").GetBlobClient($"{blob}/{itemInfo.qId}.json").DownloadContentAsync();
+                        }
+                        JsonElement itemJson = JsonDocument.Parse(new MemoryStream(Encoding.UTF8.GetBytes(index_item_json.Content.ToString()))).RootElement;
+                        elements.Add(itemJson);
+                        if (itemJson.TryGetProperty("pid", out JsonElement pid))
+                        {
+                            if (!string.IsNullOrEmpty(pid.ToString()))
                             {
-                                index_pid_item_json = await _azureStorage.GetBlobContainerClient($"{info.creatorId}").GetBlobClient($"{blob}/{pid}.json").DownloadContentAsync();
+                                BlobDownloadResult index_pid_item_json;
+                                if (info.scope.Equals("school"))
+                                {
+                                    index_pid_item_json = await _azureStorage.GetBlobContainerClient($"{info.school}").GetBlobClient($"{blob}/{pid}.json").DownloadContentAsync();
+                                }
+                                else
+                                {
+                                    index_pid_item_json = await _azureStorage.GetBlobContainerClient($"{info.creatorId}").GetBlobClient($"{blob}/{pid}.json").DownloadContentAsync();
+                                }
+                                JsonElement pidJson = JsonDocument.Parse(new MemoryStream(Encoding.UTF8.GetBytes(index_pid_item_json.Content.ToString()))).RootElement;
+                                elements.Add(pidJson);
                             }
-                            JsonElement pidJson = JsonDocument.Parse(new MemoryStream(Encoding.UTF8.GetBytes(index_pid_item_json.Content.ToString()))).RootElement;
-                            elements.Add(pidJson);
-                        }                       
-                    }                   
+                        }
+                    } catch (Exception e) {
+                        return BadRequest(new { msg = "blob 文件读取异常" });
+                    }
+                                    
                 }
             }
             else