|
@@ -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++;
|
|
|
}
|
|
@@ -4197,7 +4207,96 @@ namespace TEAMModelOS.Controllers
|
|
|
return Task.FromResult(wn);
|
|
|
}
|
|
|
|
|
|
+ //获取题目信息
|
|
|
+ [ProducesDefaultResponseType]
|
|
|
+ [AuthToken(Roles = "teacher,admin")]
|
|
|
+ [HttpPost("get-item")]
|
|
|
+ [Authorize(Roles = "IES")]
|
|
|
+ public async Task<IActionResult> getItemInfo(JsonElement request)
|
|
|
+ {
|
|
|
+ if (!request.TryGetProperty("activityId", out JsonElement id)) return BadRequest();
|
|
|
+ if (!request.TryGetProperty("qId", out JsonElement qId)) return BadRequest();
|
|
|
+ if (!request.TryGetProperty("unitId", out JsonElement subjectId)) return BadRequest();
|
|
|
+ var client = _azureCosmos.GetCosmosClient();
|
|
|
+ var queryClass = $"select value(c) from c where c.id = '{id}' and c.pk = 'Exam'";
|
|
|
+ List<ExamInfo> exams = new List<ExamInfo>();
|
|
|
+ await foreach (var item in client.GetContainer(Constant.TEAMModelOS, "Common").GetItemQueryIterator<ExamInfo>(queryText: queryClass))
|
|
|
+ {
|
|
|
+ exams.Add(item);
|
|
|
+ }
|
|
|
+ if (exams.Count > 0)
|
|
|
+ {
|
|
|
+ ExamInfo info = exams.FirstOrDefault();
|
|
|
+ List<ExamSubject> subjects = info.subjects;
|
|
|
+ int index = 0;
|
|
|
+ foreach (ExamSubject subject in subjects)
|
|
|
+ {
|
|
|
+ if (subject.id.Equals(subjectId.ToString()))
|
|
|
+ {
|
|
|
+ continue;
|
|
|
+ }
|
|
|
+ else
|
|
|
+ {
|
|
|
+ index++;
|
|
|
+ }
|
|
|
+ }
|
|
|
+ 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} /{qId}.json").DownloadContentAsync();
|
|
|
+ }
|
|
|
+ else
|
|
|
+ {
|
|
|
+ index_item_json = await _azureStorage.GetBlobContainerClient($"{info.creatorId}").GetBlobClient($"{blob}/{qId}.json").DownloadContentAsync();
|
|
|
+ }
|
|
|
+ JsonElement itemJson = JsonDocument.Parse(new MemoryStream(Encoding.UTF8.GetBytes(index_item_json.Content.ToString()))).RootElement;
|
|
|
+
|
|
|
+ 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;
|
|
|
+ return Ok(new { itemJson, pidJson });
|
|
|
+ }
|
|
|
+ else
|
|
|
+ {
|
|
|
+ return Ok(new { itemJson });
|
|
|
+ }
|
|
|
+
|
|
|
+ }
|
|
|
+ else
|
|
|
+ {
|
|
|
+ return Ok(new { itemJson });
|
|
|
+ }
|
|
|
+
|
|
|
+ /*JObject keys = JObject.Parse(index_item_json.Content.ToString());
|
|
|
+ string type = keys["exercise"].Value<string>("type");
|
|
|
+ int level = keys["exercise"].Value<int>("level");
|
|
|
+ var knowledge = keys["exercise"].Value<JArray>("knowledge")?.ToObject<List<string>>();
|
|
|
+ string pid = keys.Value<string>("pid");*/
|
|
|
+ }
|
|
|
+ else
|
|
|
+ {
|
|
|
+ return BadRequest(new { msg = "暂无数据" });
|
|
|
+ }
|
|
|
+
|
|
|
+ }
|
|
|
+
|
|
|
}
|
|
|
+
|
|
|
+
|
|
|
public class stus
|
|
|
{
|
|
|
public string id { get; set; }
|