|
@@ -21,6 +21,7 @@ using TEAMModelOS.SDK.Extension;
|
|
using TEAMModelOS.SDK.Helper.Common.CollectionHelper;
|
|
using TEAMModelOS.SDK.Helper.Common.CollectionHelper;
|
|
using TEAMModelOS.SDK.Helper.Common.StringHelper;
|
|
using TEAMModelOS.SDK.Helper.Common.StringHelper;
|
|
using TEAMModelOS.SDK.Models.Cosmos.Common;
|
|
using TEAMModelOS.SDK.Models.Cosmos.Common;
|
|
|
|
+using TEAMModelOS.SDK.Models.Table;
|
|
|
|
|
|
namespace TEAMModelOS.Controllers
|
|
namespace TEAMModelOS.Controllers
|
|
{
|
|
{
|
|
@@ -98,7 +99,7 @@ namespace TEAMModelOS.Controllers
|
|
}
|
|
}
|
|
if (request.scope.Equals("private"))
|
|
if (request.scope.Equals("private"))
|
|
{
|
|
{
|
|
-
|
|
|
|
|
|
+
|
|
//处理发布对象为自选名单(个人)
|
|
//处理发布对象为自选名单(个人)
|
|
List<StuList> stuLists = new List<StuList>();
|
|
List<StuList> stuLists = new List<StuList>();
|
|
await foreach (var item in client.GetContainer("TEAMModelOS", "Teacher").GetItemQueryIterator<StuList>(queryText: $"select value(c) from c where c.id = '{request.classes[i]}'", requestOptions: new QueryRequestOptions() { PartitionKey = new PartitionKey($"StuList") }))
|
|
await foreach (var item in client.GetContainer("TEAMModelOS", "Teacher").GetItemQueryIterator<StuList>(queryText: $"select value(c) from c where c.id = '{request.classes[i]}'", requestOptions: new QueryRequestOptions() { PartitionKey = new PartitionKey($"StuList") }))
|
|
@@ -183,7 +184,8 @@ namespace TEAMModelOS.Controllers
|
|
{
|
|
{
|
|
request.size = await _azureStorage.GetBlobContainerClient(request.school).GetBlobsSize($"exam/{request.id}");
|
|
request.size = await _azureStorage.GetBlobContainerClient(request.school).GetBlobsSize($"exam/{request.id}");
|
|
}
|
|
}
|
|
- else {
|
|
|
|
|
|
+ else
|
|
|
|
+ {
|
|
request.size = await _azureStorage.GetBlobContainerClient(request.creatorId).GetBlobsSize($"exam/{request.id}");
|
|
request.size = await _azureStorage.GetBlobContainerClient(request.creatorId).GetBlobsSize($"exam/{request.id}");
|
|
}
|
|
}
|
|
int n = 0;
|
|
int n = 0;
|
|
@@ -266,7 +268,7 @@ namespace TEAMModelOS.Controllers
|
|
//string school_code = code.ToString().Substring(typeof(ExamClassResult).Name.Length + 1);
|
|
//string school_code = code.ToString().Substring(typeof(ExamClassResult).Name.Length + 1);
|
|
var response = await client.GetContainer("TEAMModelOS", "Common").DeleteItemStreamAsync(id.ToString(), new PartitionKey($"Exam-{code}"));
|
|
var response = await client.GetContainer("TEAMModelOS", "Common").DeleteItemStreamAsync(id.ToString(), new PartitionKey($"Exam-{code}"));
|
|
//删除blob 相关资料
|
|
//删除blob 相关资料
|
|
- await _azureStorage.GetBlobServiceClient().DelectBlobs(code.ToString(),$"exam/{id}");
|
|
|
|
|
|
+ await _azureStorage.GetBlobServiceClient().DelectBlobs(code.ToString(), $"exam/{id}");
|
|
List<ExamClassResult> examClassResults = new List<ExamClassResult>();
|
|
List<ExamClassResult> examClassResults = new List<ExamClassResult>();
|
|
await foreach (var item in client.GetContainer("TEAMModelOS", "Common").GetItemQueryIterator<ExamClassResult>(queryText: $"select c.id from c where c.examId = '{id}'", requestOptions: new QueryRequestOptions() { PartitionKey = new PartitionKey($"ExamClassResult-{code}") }))
|
|
await foreach (var item in client.GetContainer("TEAMModelOS", "Common").GetItemQueryIterator<ExamClassResult>(queryText: $"select c.id from c where c.examId = '{id}'", requestOptions: new QueryRequestOptions() { PartitionKey = new PartitionKey($"ExamClassResult-{code}") }))
|
|
{
|
|
{
|
|
@@ -320,6 +322,39 @@ namespace TEAMModelOS.Controllers
|
|
try
|
|
try
|
|
{
|
|
{
|
|
if (!requert.TryGetProperty("code", out JsonElement code)) return BadRequest();
|
|
if (!requert.TryGetProperty("code", out JsonElement code)) return BadRequest();
|
|
|
|
+ var client = _azureCosmos.GetCosmosClient();
|
|
|
|
+ List<SchoolYear> years = await _azureStorage.FindListByDict<SchoolYear>(new Dictionary<string, object>() { { "RowKey", code}, { "PartitionKey", "Exam" } });
|
|
|
|
+ int year = 0;
|
|
|
|
+ if (years.Count > 0)
|
|
|
|
+ {
|
|
|
|
+ year = years[0].year;
|
|
|
|
+ }
|
|
|
|
+ else
|
|
|
|
+ {
|
|
|
|
+ long ct = 0;
|
|
|
|
+ await foreach (var item in client.GetContainer("TEAMModelOS", "Common").GetItemQueryStreamIterator(queryText: "SELECT top 1 c.createTime FROM c order by c.createTime ", requestOptions: new QueryRequestOptions() { PartitionKey = new PartitionKey($"Exam-{code}") }))
|
|
|
|
+ {
|
|
|
|
+
|
|
|
|
+ using var json = await JsonDocument.ParseAsync(item.ContentStream);
|
|
|
|
+ if (json.RootElement.TryGetProperty("_count", out JsonElement count) && count.GetUInt16() > 0)
|
|
|
|
+ {
|
|
|
|
+ var accounts = json.RootElement.GetProperty("Documents").EnumerateArray();
|
|
|
|
+ while (accounts.MoveNext())
|
|
|
|
+ {
|
|
|
|
+ JsonElement account = accounts.Current;
|
|
|
|
+ ct = account.GetProperty("createTime").GetInt64();
|
|
|
|
+ }
|
|
|
|
+ }
|
|
|
|
+ }
|
|
|
|
+ year = DateTimeOffset.FromUnixTimeMilliseconds(ct).Year;
|
|
|
|
+ SchoolYear sy = new()
|
|
|
|
+ {
|
|
|
|
+ RowKey = code.ToString(),
|
|
|
|
+ PartitionKey = "Exam",
|
|
|
|
+ year = year
|
|
|
|
+ };
|
|
|
|
+ await _azureStorage.Save<SchoolYear>(sy);
|
|
|
|
+ }
|
|
var query = $"select c.id,c.name,c.code,c.period,c.startTime,c.endTime,c.stuCount,c.type,c.progress,c.examType,c.createTime,c.source, c.subjects, c.grades, c.scope,c.classes,c.sRate,c.lostStu from c ";
|
|
var query = $"select c.id,c.name,c.code,c.period,c.startTime,c.endTime,c.stuCount,c.type,c.progress,c.examType,c.createTime,c.source, c.subjects, c.grades, c.scope,c.classes,c.sRate,c.lostStu from c ";
|
|
if (requert.TryGetProperty("classIds", out JsonElement classIds))
|
|
if (requert.TryGetProperty("classIds", out JsonElement classIds))
|
|
{
|
|
{
|
|
@@ -359,7 +394,7 @@ namespace TEAMModelOS.Controllers
|
|
topcout = data;
|
|
topcout = data;
|
|
}
|
|
}
|
|
}
|
|
}
|
|
- var client = _azureCosmos.GetCosmosClient();
|
|
|
|
|
|
+
|
|
List<ExamInfo> examInfo = new List<ExamInfo>();
|
|
List<ExamInfo> examInfo = new List<ExamInfo>();
|
|
await foreach (var item in client.GetContainer("TEAMModelOS", "Common").GetItemQueryStreamIterator(queryText: query, continuationToken: token, requestOptions: new QueryRequestOptions() { MaxItemCount = topcout, PartitionKey = new PartitionKey($"Exam-{code}") }))
|
|
await foreach (var item in client.GetContainer("TEAMModelOS", "Common").GetItemQueryStreamIterator(queryText: query, continuationToken: token, requestOptions: new QueryRequestOptions() { MaxItemCount = topcout, PartitionKey = new PartitionKey($"Exam-{code}") }))
|
|
{
|
|
{
|
|
@@ -431,7 +466,7 @@ namespace TEAMModelOS.Controllers
|
|
score = listExamInfo.FirstOrDefault(c => c.id == o.id).scores,
|
|
score = listExamInfo.FirstOrDefault(c => c.id == o.id).scores,
|
|
}
|
|
}
|
|
);*/
|
|
);*/
|
|
- return Ok(new { examInfo, token = continuationToken });
|
|
|
|
|
|
+ return Ok(new { examInfo, token = continuationToken, year });
|
|
}
|
|
}
|
|
catch (Exception e)
|
|
catch (Exception e)
|
|
{
|
|
{
|
|
@@ -1459,7 +1494,7 @@ namespace TEAMModelOS.Controllers
|
|
{
|
|
{
|
|
attr.Add(new { stuId = rcd.Name.ToString(), info = value });
|
|
attr.Add(new { stuId = rcd.Name.ToString(), info = value });
|
|
}
|
|
}
|
|
-
|
|
|
|
|
|
+
|
|
|
|
|
|
|
|
|
|
}
|
|
}
|
|
@@ -1618,15 +1653,17 @@ namespace TEAMModelOS.Controllers
|
|
var stuAns = await redisClient.HashGetAsync($"Exam:Scoring:{id}-{subjectId}", sId.ToString());
|
|
var stuAns = await redisClient.HashGetAsync($"Exam:Scoring:{id}-{subjectId}", sId.ToString());
|
|
var value = JsonDocument.Parse(stuAns.ToString());
|
|
var value = JsonDocument.Parse(stuAns.ToString());
|
|
value.RootElement.TryGetProperty("ans", out JsonElement blob);
|
|
value.RootElement.TryGetProperty("ans", out JsonElement blob);
|
|
- await redisClient.HashSetAsync($"Exam:Scoring:{id}-{subjectId}", sId.ToString(), new {ans = blob ,score = score, tmdId = tId, mark = mark }.ToJsonString());
|
|
|
|
- if (recs.Count == count.GetInt32()) {
|
|
|
|
|
|
+ await redisClient.HashSetAsync($"Exam:Scoring:{id}-{subjectId}", sId.ToString(), new { ans = blob, score = score, tmdId = tId, mark = mark }.ToJsonString());
|
|
|
|
+ if (recs.Count == count.GetInt32())
|
|
|
|
+ {
|
|
await foreach (var item in client.GetContainer("TEAMModelOS", "Common").GetItemQueryIterator<ExamClassResult>(
|
|
await foreach (var item in client.GetContainer("TEAMModelOS", "Common").GetItemQueryIterator<ExamClassResult>(
|
|
queryText: $"select value(c) from c where c.examId = '{id}' and c.subjectId = '{subjectId}'",
|
|
queryText: $"select value(c) from c where c.examId = '{id}' and c.subjectId = '{subjectId}'",
|
|
requestOptions: new QueryRequestOptions() { PartitionKey = new PartitionKey($"ExamClassResult-{code}") }))
|
|
requestOptions: new QueryRequestOptions() { PartitionKey = new PartitionKey($"ExamClassResult-{code}") }))
|
|
{
|
|
{
|
|
classResults.Add(item);
|
|
classResults.Add(item);
|
|
}
|
|
}
|
|
- foreach (ExamClassResult exam in classResults) {
|
|
|
|
|
|
+ foreach (ExamClassResult exam in classResults)
|
|
|
|
+ {
|
|
foreach (dynamic re in recs)
|
|
foreach (dynamic re in recs)
|
|
{
|
|
{
|
|
var cs = JsonSerializer.Serialize(re);
|
|
var cs = JsonSerializer.Serialize(re);
|
|
@@ -1636,15 +1673,16 @@ namespace TEAMModelOS.Controllers
|
|
ans.TryGetProperty("score", out JsonElement sc);
|
|
ans.TryGetProperty("score", out JsonElement sc);
|
|
ans.TryGetProperty("mark", out JsonElement marks);
|
|
ans.TryGetProperty("mark", out JsonElement marks);
|
|
int index = exam.studentIds.IndexOf(stuId.ToString());
|
|
int index = exam.studentIds.IndexOf(stuId.ToString());
|
|
- if (index != -1) {
|
|
|
|
|
|
+ if (index != -1)
|
|
|
|
+ {
|
|
exam.studentScores[index] = sc.ToObject<List<double>>();
|
|
exam.studentScores[index] = sc.ToObject<List<double>>();
|
|
exam.mark[index] = marks.ToString();
|
|
exam.mark[index] = marks.ToString();
|
|
}
|
|
}
|
|
-
|
|
|
|
|
|
+
|
|
}
|
|
}
|
|
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}"));
|
|
}
|
|
}
|
|
-
|
|
|
|
|
|
+
|
|
}
|
|
}
|
|
|
|
|
|
return Ok(new { code = 200 });
|
|
return Ok(new { code = 200 });
|