|
@@ -39,6 +39,15 @@ using DocumentFormat.OpenXml.Drawing.Charts;
|
|
|
using ClouDASLibx;
|
|
|
using HTEXLib.Helpers.ShapeHelpers;
|
|
|
using TEAMModelOS.SDK.Helper.Common.DateTimeHelper;
|
|
|
+using Microsoft.Extensions.Hosting;
|
|
|
+using System.Configuration;
|
|
|
+using DocumentFormat.OpenXml.Presentation;
|
|
|
+using static SKIT.FlurlHttpClient.Wechat.TenpayV3.Models.CreateApplyForSubjectApplymentRequest.Types;
|
|
|
+using TEAMModelOS.Controllers.Core;
|
|
|
+using Azure.Storage.Blobs.Models;
|
|
|
+using Top.Api;
|
|
|
+using Newtonsoft.Json.Linq;
|
|
|
+using System.IO;
|
|
|
|
|
|
namespace TEAMModelOS.Controllers
|
|
|
{
|
|
@@ -272,7 +281,8 @@ namespace TEAMModelOS.Controllers
|
|
|
{
|
|
|
simple.blob = $"/exam/{request.id}/paper/{simple.subjectId}/{simple.id}";
|
|
|
}
|
|
|
- else {
|
|
|
+ else
|
|
|
+ {
|
|
|
simple.blob = $"/exam/{request.id}/paper/{request.subjects[n].id}";
|
|
|
n++;
|
|
|
}
|
|
@@ -3696,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)
|
|
|
{
|
|
@@ -4197,7 +4207,88 @@ namespace TEAMModelOS.Controllers
|
|
|
return Task.FromResult(wn);
|
|
|
}
|
|
|
|
|
|
+ //获取题目信息
|
|
|
+ [ProducesDefaultResponseType]
|
|
|
+ //[AuthToken(Roles = "teacher,admin,student")]
|
|
|
+ [HttpPost("get-item")]
|
|
|
+ //[Authorize(Roles = "IES")]
|
|
|
+ public async Task<IActionResult> getItemInfo(JsonElement request)
|
|
|
+ {
|
|
|
+ if (!request.TryGetProperty("errorItems", out JsonElement items)) return BadRequest();
|
|
|
+ List<errorItemInfo> errors = items.ToObject<List<errorItemInfo>>();
|
|
|
+ var client = _azureCosmos.GetCosmosClient();
|
|
|
+ List<string> ids = errors.Select(c => c.activityId).ToList();
|
|
|
+ var queryClass = $"select value(c) from c where c.id in ({string.Join(",", ids.Select(o => $"'{o}'"))}) and c.pk = 'Exam'";
|
|
|
+ List<ExamInfo> exams = new();
|
|
|
+ await foreach (var item in client.GetContainer(Constant.TEAMModelOS, "Common").GetItemQueryIterator<ExamInfo>(queryText: queryClass))
|
|
|
+ {
|
|
|
+ exams.Add(item);
|
|
|
+ }
|
|
|
+ List<JsonElement> elements = new();
|
|
|
+ if (exams.Count > 0)
|
|
|
+ {
|
|
|
+ foreach (errorItemInfo itemInfo in errors) {
|
|
|
+ ExamInfo info = exams.Where(c => c.id.Equals(itemInfo.activityId)).FirstOrDefault();
|
|
|
+ List<ExamSubject> subjects = info.subjects;
|
|
|
+ int index = 0;
|
|
|
+ foreach (ExamSubject subject in subjects)
|
|
|
+ {
|
|
|
+ if (subject.id.Equals(itemInfo.unitId))
|
|
|
+ {
|
|
|
+ continue;
|
|
|
+ }
|
|
|
+ else
|
|
|
+ {
|
|
|
+ index++;
|
|
|
+ }
|
|
|
+ }
|
|
|
+ List<PaperSimple> simples = info.papers;
|
|
|
+ string blob = simples[index].blob;
|
|
|
+ try {
|
|
|
+ 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()))
|
|
|
+ {
|
|
|
+ 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);
|
|
|
+ }
|
|
|
+ }
|
|
|
+ } catch (Exception e) {
|
|
|
+ return BadRequest(new { msg = "blob 文件读取异常" });
|
|
|
+ }
|
|
|
+
|
|
|
+ }
|
|
|
+ }
|
|
|
+ else
|
|
|
+ {
|
|
|
+ return BadRequest(new { msg = "暂无数据" });
|
|
|
+ }
|
|
|
+ return Ok(elements);
|
|
|
+ }
|
|
|
+
|
|
|
}
|
|
|
+
|
|
|
+
|
|
|
public class stus
|
|
|
{
|
|
|
public string id { get; set; }
|
|
@@ -4214,4 +4305,9 @@ namespace TEAMModelOS.Controllers
|
|
|
public string subjectId { get; set; }
|
|
|
public int number { get; set; }
|
|
|
}
|
|
|
+ public class errorItemInfo {
|
|
|
+ public string activityId { get; set; }
|
|
|
+ public string qId { get; set; }
|
|
|
+ public string unitId { get; set; }
|
|
|
+ }
|
|
|
}
|