|
@@ -14,7 +14,6 @@ using System.Threading.Tasks;
|
|
using TEAMModelOS.Models;
|
|
using TEAMModelOS.Models;
|
|
using TEAMModelOS.SDK.Models;
|
|
using TEAMModelOS.SDK.Models;
|
|
using TEAMModelOS.SDK;
|
|
using TEAMModelOS.SDK;
|
|
-using TEAMModelOS.SDK.Context.Constant.Common;
|
|
|
|
using TEAMModelOS.SDK.DI;
|
|
using TEAMModelOS.SDK.DI;
|
|
using TEAMModelOS.SDK.DI.AzureCosmos.Inner;
|
|
using TEAMModelOS.SDK.DI.AzureCosmos.Inner;
|
|
using TEAMModelOS.SDK.Extension;
|
|
using TEAMModelOS.SDK.Extension;
|
|
@@ -27,6 +26,7 @@ using Microsoft.Extensions.Configuration;
|
|
using TEAMModelOS.Filter;
|
|
using TEAMModelOS.Filter;
|
|
using TEAMModelOS.SDK.Models.Service;
|
|
using TEAMModelOS.SDK.Models.Service;
|
|
using TEAMModelOS.SDK.Models.Cosmos;
|
|
using TEAMModelOS.SDK.Models.Cosmos;
|
|
|
|
+using HTEXLib.COMM.Helpers;
|
|
|
|
|
|
namespace TEAMModelOS.Controllers
|
|
namespace TEAMModelOS.Controllers
|
|
{
|
|
{
|
|
@@ -87,7 +87,7 @@ namespace TEAMModelOS.Controllers
|
|
//查询所有学生名单
|
|
//查询所有学生名单
|
|
List<string> sids = new List<string>();
|
|
List<string> sids = new List<string>();
|
|
//List<Student> students = new List<Student>();
|
|
//List<Student> students = new List<Student>();
|
|
- await foreach (var item in client.GetContainer("TEAMModelOS", "Student").GetItemQueryStreamIterator(queryText: $"select c.id from c", requestOptions: new QueryRequestOptions() { PartitionKey = new PartitionKey($"Base-{request.school}") }))
|
|
|
|
|
|
+ await foreach (var item in client.GetContainer(Constant.TEAMModelOS, "Student").GetItemQueryStreamIterator(queryText: $"select c.id from c", requestOptions: new QueryRequestOptions() { PartitionKey = new PartitionKey($"Base-{request.school}") }))
|
|
{
|
|
{
|
|
using var json = await JsonDocument.ParseAsync(item.ContentStream);
|
|
using var json = await JsonDocument.ParseAsync(item.ContentStream);
|
|
if (json.RootElement.TryGetProperty("_count", out JsonElement count) && count.GetUInt16() > 0)
|
|
if (json.RootElement.TryGetProperty("_count", out JsonElement count) && count.GetUInt16() > 0)
|
|
@@ -107,7 +107,7 @@ namespace TEAMModelOS.Controllers
|
|
List<string> ids = new List<string>();
|
|
List<string> ids = new List<string>();
|
|
//处理班级人数(公共部分的校本名单)
|
|
//处理班级人数(公共部分的校本名单)
|
|
//List<Student> students = new List<Student>();
|
|
//List<Student> students = new List<Student>();
|
|
- await foreach (var item in client.GetContainer("TEAMModelOS", "Student").GetItemQueryStreamIterator(queryText: $"select c.id from c where c.classId = '{classes[i]}'", requestOptions: new QueryRequestOptions() { PartitionKey = new PartitionKey($"Base-{request.school}") }))
|
|
|
|
|
|
+ await foreach (var item in client.GetContainer(Constant.TEAMModelOS, "Student").GetItemQueryStreamIterator(queryText: $"select c.id from c where c.classId = '{classes[i]}'", requestOptions: new QueryRequestOptions() { PartitionKey = new PartitionKey($"Base-{request.school}") }))
|
|
{
|
|
{
|
|
using var json = await JsonDocument.ParseAsync(item.ContentStream);
|
|
using var json = await JsonDocument.ParseAsync(item.ContentStream);
|
|
if (json.RootElement.TryGetProperty("_count", out JsonElement count) && count.GetUInt16() > 0)
|
|
if (json.RootElement.TryGetProperty("_count", out JsonElement count) && count.GetUInt16() > 0)
|
|
@@ -125,7 +125,7 @@ namespace TEAMModelOS.Controllers
|
|
|
|
|
|
//处理发布对象为自选名单(个人)
|
|
//处理发布对象为自选名单(个人)
|
|
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 = '{classes[i]}'", requestOptions: new QueryRequestOptions() { PartitionKey = new PartitionKey($"StuList") }))
|
|
|
|
|
|
+ await foreach (var item in client.GetContainer(Constant.TEAMModelOS, "Teacher").GetItemQueryIterator<StuList>(queryText: $"select value(c) from c where c.id = '{classes[i]}'", requestOptions: new QueryRequestOptions() { PartitionKey = new PartitionKey($"StuList") }))
|
|
{
|
|
{
|
|
stuLists.Add(item);
|
|
stuLists.Add(item);
|
|
}
|
|
}
|
|
@@ -170,7 +170,7 @@ namespace TEAMModelOS.Controllers
|
|
ids.Add(tid);
|
|
ids.Add(tid);
|
|
}
|
|
}
|
|
}
|
|
}
|
|
- await _azureCosmos.GetCosmosClient().GetContainer("TEAMModelOS", "Teacher").ReplaceItemAsync(stuList, stuList.id, new PartitionKey(stuList.code));
|
|
|
|
|
|
+ await _azureCosmos.GetCosmosClient().GetContainer(Constant.TEAMModelOS, "Teacher").ReplaceItemAsync(stuList, stuList.id, new PartitionKey(stuList.code));
|
|
}
|
|
}
|
|
|
|
|
|
}
|
|
}
|
|
@@ -180,7 +180,7 @@ 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}");
|
|
//发布对象为自选名单(校本)
|
|
//发布对象为自选名单(校本)
|
|
List<StuList> stuLists = new List<StuList>();
|
|
List<StuList> stuLists = new List<StuList>();
|
|
- await foreach (var item in client.GetContainer("TEAMModelOS", "School").GetItemQueryIterator<StuList>(queryText: $"select value(c) from c where c.id = '{classes[i]}'", requestOptions: new QueryRequestOptions() { PartitionKey = new PartitionKey($"StuList-{request.school}") }))
|
|
|
|
|
|
+ await foreach (var item in client.GetContainer(Constant.TEAMModelOS, "School").GetItemQueryIterator<StuList>(queryText: $"select value(c) from c where c.id = '{classes[i]}'", requestOptions: new QueryRequestOptions() { PartitionKey = new PartitionKey($"StuList-{request.school}") }))
|
|
{
|
|
{
|
|
stuLists.Add(item);
|
|
stuLists.Add(item);
|
|
}
|
|
}
|
|
@@ -203,7 +203,7 @@ namespace TEAMModelOS.Controllers
|
|
stuList.students.RemoveAt(j);
|
|
stuList.students.RemoveAt(j);
|
|
}
|
|
}
|
|
}
|
|
}
|
|
- await _azureCosmos.GetCosmosClient().GetContainer("TEAMModelOS", "School").ReplaceItemAsync(stuList, stuList.id, new PartitionKey(stuList.code));
|
|
|
|
|
|
+ await _azureCosmos.GetCosmosClient().GetContainer(Constant.TEAMModelOS, "School").ReplaceItemAsync(stuList, stuList.id, new PartitionKey(stuList.code));
|
|
}
|
|
}
|
|
|
|
|
|
}
|
|
}
|
|
@@ -244,11 +244,11 @@ namespace TEAMModelOS.Controllers
|
|
n++;
|
|
n++;
|
|
simple.sheet = null;
|
|
simple.sheet = null;
|
|
}
|
|
}
|
|
- exam = await client.GetContainer("TEAMModelOS", "Common").CreateItemAsync(request, new PartitionKey($"{request.code}"));
|
|
|
|
|
|
+ exam = await client.GetContainer(Constant.TEAMModelOS, "Common").CreateItemAsync(request, new PartitionKey($"{request.code}"));
|
|
}
|
|
}
|
|
else
|
|
else
|
|
{
|
|
{
|
|
- ExamInfo info = await client.GetContainer("TEAMModelOS", "Common").ReadItemAsync<ExamInfo>(request.id, new PartitionKey($"{request.code}"));
|
|
|
|
|
|
+ ExamInfo info = await client.GetContainer(Constant.TEAMModelOS, "Common").ReadItemAsync<ExamInfo>(request.id, new PartitionKey($"{request.code}"));
|
|
if (info.progress.Equals("going"))
|
|
if (info.progress.Equals("going"))
|
|
{
|
|
{
|
|
return Ok(new { v = "活动正在进行中" });
|
|
return Ok(new { v = "活动正在进行中" });
|
|
@@ -276,7 +276,7 @@ namespace TEAMModelOS.Controllers
|
|
simple.blob = "/exam/" + request.id + "/paper/" + request.subjects[n].id;
|
|
simple.blob = "/exam/" + request.id + "/paper/" + request.subjects[n].id;
|
|
n++;
|
|
n++;
|
|
}
|
|
}
|
|
- exam = await client.GetContainer("TEAMModelOS", "Common").ReplaceItemAsync(request, request.id, new PartitionKey($"{request.code}"));
|
|
|
|
|
|
+ exam = await client.GetContainer(Constant.TEAMModelOS, "Common").ReplaceItemAsync(request, request.id, new PartitionKey($"{request.code}"));
|
|
}
|
|
}
|
|
return Ok(new { exam });
|
|
return Ok(new { exam });
|
|
}
|
|
}
|
|
@@ -309,7 +309,7 @@ namespace TEAMModelOS.Controllers
|
|
if (!request.TryGetProperty("scope", out JsonElement scope)) return BadRequest();
|
|
if (!request.TryGetProperty("scope", out JsonElement scope)) return BadRequest();
|
|
var client = _azureCosmos.GetCosmosClient();
|
|
var client = _azureCosmos.GetCosmosClient();
|
|
//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(Constant.TEAMModelOS, "Common").DeleteItemStreamAsync(id.ToString(), new PartitionKey($"Exam-{code}"));
|
|
//删除blob 相关资料
|
|
//删除blob 相关资料
|
|
await _azureStorage.GetBlobServiceClient().DeleteBlobs(_dingDing, code.ToString(), new List<string> { $"exam/{id}" });
|
|
await _azureStorage.GetBlobServiceClient().DeleteBlobs(_dingDing, code.ToString(), new List<string> { $"exam/{id}" });
|
|
//通知评测删除信息
|
|
//通知评测删除信息
|
|
@@ -318,7 +318,7 @@ namespace TEAMModelOS.Controllers
|
|
var ActiveTask = _configuration.GetValue<string>("Azure:ServiceBus:ActiveTask");
|
|
var ActiveTask = _configuration.GetValue<string>("Azure:ServiceBus:ActiveTask");
|
|
await _serviceBus.GetServiceBusClient().SendMessageAsync(ActiveTask, messageBlob);
|
|
await _serviceBus.GetServiceBusClient().SendMessageAsync(ActiveTask, messageBlob);
|
|
//删除阅卷配置
|
|
//删除阅卷配置
|
|
- var cresponse = await client.GetContainer("TEAMModelOS", "Common").ReadItemStreamAsync(id.ToString(), new PartitionKey($"Correct-{code}"));
|
|
|
|
|
|
+ var cresponse = await client.GetContainer(Constant.TEAMModelOS, "Common").ReadItemStreamAsync(id.ToString(), new PartitionKey($"Correct-{code}"));
|
|
if (cresponse.Status == 200)
|
|
if (cresponse.Status == 200)
|
|
{
|
|
{
|
|
using var json = await JsonDocument.ParseAsync(response.ContentStream);
|
|
using var json = await JsonDocument.ParseAsync(response.ContentStream);
|
|
@@ -351,16 +351,16 @@ namespace TEAMModelOS.Controllers
|
|
}
|
|
}
|
|
}
|
|
}
|
|
}
|
|
}
|
|
- await client.GetContainer("TEAMModelOS", "Common").DeleteItemStreamAsync(id.GetString(), new PartitionKey($"Correct-{code}"));
|
|
|
|
|
|
+ await client.GetContainer(Constant.TEAMModelOS, "Common").DeleteItemStreamAsync(id.GetString(), new PartitionKey($"Correct-{code}"));
|
|
}
|
|
}
|
|
|
|
|
|
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(Constant.TEAMModelOS, "Common").GetItemQueryIterator<ExamClassResult>(queryText: $"select c.id from c where c.examId = '{id}'", requestOptions: new QueryRequestOptions() { PartitionKey = new PartitionKey($"ExamClassResult-{code}") }))
|
|
{
|
|
{
|
|
examClassResults.Add(item);
|
|
examClassResults.Add(item);
|
|
}
|
|
}
|
|
List<string> resultIds = new List<string>();
|
|
List<string> resultIds = new List<string>();
|
|
- await foreach (var item in client.GetContainer("TEAMModelOS", "Common").GetItemQueryStreamIterator(queryText: $"select c.id from c ", requestOptions: new QueryRequestOptions() { PartitionKey = new PartitionKey($"ExamResult-{id}") }))
|
|
|
|
|
|
+ await foreach (var item in client.GetContainer(Constant.TEAMModelOS, "Common").GetItemQueryStreamIterator(queryText: $"select c.id from c ", requestOptions: new QueryRequestOptions() { PartitionKey = new PartitionKey($"ExamResult-{id}") }))
|
|
{
|
|
{
|
|
using var json = await JsonDocument.ParseAsync(item.ContentStream);
|
|
using var json = await JsonDocument.ParseAsync(item.ContentStream);
|
|
if (json.RootElement.TryGetProperty("_count", out JsonElement count) && count.GetUInt16() > 0)
|
|
if (json.RootElement.TryGetProperty("_count", out JsonElement count) && count.GetUInt16() > 0)
|
|
@@ -375,12 +375,12 @@ namespace TEAMModelOS.Controllers
|
|
}
|
|
}
|
|
foreach (ExamClassResult classResult in examClassResults)
|
|
foreach (ExamClassResult classResult in examClassResults)
|
|
{
|
|
{
|
|
- await client.GetContainer("TEAMModelOS", "Common").DeleteItemStreamAsync(classResult.id, new PartitionKey($"ExamClassResult-{code}"));
|
|
|
|
|
|
+ await client.GetContainer(Constant.TEAMModelOS, "Common").DeleteItemStreamAsync(classResult.id, new PartitionKey($"ExamClassResult-{code}"));
|
|
}
|
|
}
|
|
- await client.GetContainer("TEAMModelOS", "Common").DeleteItemsStreamAsync(resultIds, $"ExamResult-{id}");
|
|
|
|
|
|
+ await client.GetContainer(Constant.TEAMModelOS, "Common").DeleteItemsStreamAsync(resultIds, $"ExamResult-{id}");
|
|
/*foreach (ExamResult result in results)
|
|
/*foreach (ExamResult result in results)
|
|
{
|
|
{
|
|
- await client.GetContainer("TEAMModelOS", "Common").DeleteItemStreamAsync(result.id, new PartitionKey($"ExamResult-{id}"));
|
|
|
|
|
|
+ await client.GetContainer(Constant.TEAMModelOS, "Common").DeleteItemStreamAsync(result.id, new PartitionKey($"ExamResult-{id}"));
|
|
}*/
|
|
}*/
|
|
//await _azureCosmos.DeleteAll(examClassResults);
|
|
//await _azureCosmos.DeleteAll(examClassResults);
|
|
return Ok(new { id });
|
|
return Ok(new { id });
|
|
@@ -417,7 +417,7 @@ namespace TEAMModelOS.Controllers
|
|
else
|
|
else
|
|
{
|
|
{
|
|
long ct = 0;
|
|
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}") }))
|
|
|
|
|
|
+ await foreach (var item in client.GetContainer(Constant.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);
|
|
using var json = await JsonDocument.ParseAsync(item.ContentStream);
|
|
@@ -481,7 +481,7 @@ namespace TEAMModelOS.Controllers
|
|
}
|
|
}
|
|
|
|
|
|
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(Constant.TEAMModelOS, "Common").GetItemQueryStreamIterator(queryText: query, continuationToken: token, requestOptions: new QueryRequestOptions() { MaxItemCount = topcout, PartitionKey = new PartitionKey($"Exam-{code}") }))
|
|
{
|
|
{
|
|
|
|
|
|
using var json = await JsonDocument.ParseAsync(item.ContentStream);
|
|
using var json = await JsonDocument.ParseAsync(item.ContentStream);
|
|
@@ -503,7 +503,7 @@ namespace TEAMModelOS.Controllers
|
|
//List<string> examIds = new List<string>();
|
|
//List<string> examIds = new List<string>();
|
|
/* List<ExamResult> examResults = new List<ExamResult>();
|
|
/* List<ExamResult> examResults = new List<ExamResult>();
|
|
foreach (ExamInfo info in examInfos) {
|
|
foreach (ExamInfo info in examInfos) {
|
|
- await foreach (var item in client.GetContainer("TEAMModelOS", "Common").GetItemQueryIterator<ExamResult>(
|
|
|
|
|
|
+ await foreach (var item in client.GetContainer(Constant.TEAMModelOS, "Common").GetItemQueryIterator<ExamResult>(
|
|
queryText: $"select value(c) from c where c.examId = '{info.id}'", requestOptions: new QueryRequestOptions() { PartitionKey = new PartitionKey($"ExamResult-{info.id}") }))
|
|
queryText: $"select value(c) from c where c.examId = '{info.id}'", requestOptions: new QueryRequestOptions() { PartitionKey = new PartitionKey($"ExamResult-{info.id}") }))
|
|
{
|
|
{
|
|
examResults.Add(item);
|
|
examResults.Add(item);
|
|
@@ -578,7 +578,7 @@ namespace TEAMModelOS.Controllers
|
|
var client = _azureCosmos.GetCosmosClient();
|
|
var client = _azureCosmos.GetCosmosClient();
|
|
List<ExamInfo> examInfo = new List<ExamInfo>();
|
|
List<ExamInfo> examInfo = new List<ExamInfo>();
|
|
//var query = $"select value(c) from c ";
|
|
//var query = $"select value(c) from c ";
|
|
- await foreach (var item in client.GetContainer("TEAMModelOS", "Common").GetItemQueryStreamIterator(queryText: $"select value(c) from c where c.id = '{id}'", requestOptions: new QueryRequestOptions() { PartitionKey = new PartitionKey($"{code}") }))
|
|
|
|
|
|
+ await foreach (var item in client.GetContainer(Constant.TEAMModelOS, "Common").GetItemQueryStreamIterator(queryText: $"select value(c) from c where c.id = '{id}'", requestOptions: new QueryRequestOptions() { PartitionKey = new PartitionKey($"{code}") }))
|
|
{
|
|
{
|
|
using var json = await JsonDocument.ParseAsync(item.ContentStream);
|
|
using var json = await JsonDocument.ParseAsync(item.ContentStream);
|
|
if (json.RootElement.TryGetProperty("_count", out JsonElement count) && count.GetUInt16() > 0)
|
|
if (json.RootElement.TryGetProperty("_count", out JsonElement count) && count.GetUInt16() > 0)
|
|
@@ -629,7 +629,7 @@ namespace TEAMModelOS.Controllers
|
|
ids = classId.ToObject<List<string>>();
|
|
ids = classId.ToObject<List<string>>();
|
|
var client = _azureCosmos.GetCosmosClient();
|
|
var client = _azureCosmos.GetCosmosClient();
|
|
List<ExamClassResult> examClassResults = new List<ExamClassResult>();
|
|
List<ExamClassResult> examClassResults = new List<ExamClassResult>();
|
|
- await foreach (var item in client.GetContainer("TEAMModelOS", "Common").GetItemQueryStreamIterator(
|
|
|
|
|
|
+ await foreach (var item in client.GetContainer(Constant.TEAMModelOS, "Common").GetItemQueryStreamIterator(
|
|
queryText: $"select value(c) from c where c.examId = '{id}' and c.subjectId = '{subjectId}' and c.info.id in ({string.Join(",", ids.Select(o => $"'{o}'"))})",
|
|
queryText: $"select value(c) from c where c.examId = '{id}' and c.subjectId = '{subjectId}' and c.info.id in ({string.Join(",", ids.Select(o => $"'{o}'"))})",
|
|
requestOptions: new QueryRequestOptions() { PartitionKey = new PartitionKey($"ExamClassResult-{school}") }))
|
|
requestOptions: new QueryRequestOptions() { PartitionKey = new PartitionKey($"ExamClassResult-{school}") }))
|
|
{
|
|
{
|
|
@@ -645,7 +645,7 @@ namespace TEAMModelOS.Controllers
|
|
|
|
|
|
ExamClassResult classResult = new ExamClassResult();
|
|
ExamClassResult classResult = new ExamClassResult();
|
|
List<PaperSimple> standerAnswers = new List<PaperSimple>();
|
|
List<PaperSimple> standerAnswers = new List<PaperSimple>();
|
|
- await foreach (var item in client.GetContainer("TEAMModelOS", "Common").GetItemQueryStreamIterator(
|
|
|
|
|
|
+ await foreach (var item in client.GetContainer(Constant.TEAMModelOS, "Common").GetItemQueryStreamIterator(
|
|
queryText: $"select A0.point,A0.answers from c join A0 in c.papers where c.id = '{id}'and A0.id = '{paperId}'",
|
|
queryText: $"select A0.point,A0.answers from c join A0 in c.papers where c.id = '{id}'and A0.id = '{paperId}'",
|
|
requestOptions: new QueryRequestOptions() { PartitionKey = new PartitionKey($"{scode}") }))
|
|
requestOptions: new QueryRequestOptions() { PartitionKey = new PartitionKey($"{scode}") }))
|
|
{
|
|
{
|
|
@@ -863,7 +863,7 @@ namespace TEAMModelOS.Controllers
|
|
}
|
|
}
|
|
if (flag)
|
|
if (flag)
|
|
{
|
|
{
|
|
- ExamInfo exam = await client.GetContainer("TEAMModelOS", "Common").ReadItemAsync<ExamInfo>(id.ToString(), new PartitionKey($"{scode}"));
|
|
|
|
|
|
+ ExamInfo exam = await client.GetContainer(Constant.TEAMModelOS, "Common").ReadItemAsync<ExamInfo>(id.ToString(), new PartitionKey($"{scode}"));
|
|
result.progress = true;
|
|
result.progress = true;
|
|
/*//标记单科单班总得分
|
|
/*//标记单科单班总得分
|
|
double score = 0;
|
|
double score = 0;
|
|
@@ -887,10 +887,10 @@ namespace TEAMModelOS.Controllers
|
|
s.classCount += 1;
|
|
s.classCount += 1;
|
|
}
|
|
}
|
|
});
|
|
});
|
|
- await client.GetContainer("TEAMModelOS", "Common").ReplaceItemAsync(exam, id.ToString(), new PartitionKey($"{scode}"));
|
|
|
|
|
|
+ await client.GetContainer(Constant.TEAMModelOS, "Common").ReplaceItemAsync(exam, id.ToString(), new PartitionKey($"{scode}"));
|
|
}
|
|
}
|
|
result.sum[newIndex] = result.studentScores[newIndex].Sum();
|
|
result.sum[newIndex] = result.studentScores[newIndex].Sum();
|
|
- classResult = await client.GetContainer("TEAMModelOS", "Common").ReplaceItemAsync(result, result.id, new PartitionKey($"{result.code}"));
|
|
|
|
|
|
+ classResult = await client.GetContainer(Constant.TEAMModelOS, "Common").ReplaceItemAsync(result, result.id, new PartitionKey($"{result.code}"));
|
|
}
|
|
}
|
|
await Task.WhenAll(tasks);
|
|
await Task.WhenAll(tasks);
|
|
|
|
|
|
@@ -927,7 +927,7 @@ namespace TEAMModelOS.Controllers
|
|
List<ExamClassResult> examClassResults = new List<ExamClassResult>();
|
|
List<ExamClassResult> examClassResults = new List<ExamClassResult>();
|
|
if (request.TryGetProperty("classId", out JsonElement classId))
|
|
if (request.TryGetProperty("classId", out JsonElement classId))
|
|
{
|
|
{
|
|
- await foreach (var item in client.GetContainer("TEAMModelOS", "Common").GetItemQueryIterator<ExamClassResult>(
|
|
|
|
|
|
+ await foreach (var item in client.GetContainer(Constant.TEAMModelOS, "Common").GetItemQueryIterator<ExamClassResult>(
|
|
queryText: $"select value(c) from c where c.examId = '{id}' and c.subjectId = '{subjectId}' and c.info.id = '{classId}'",
|
|
queryText: $"select value(c) from c where c.examId = '{id}' and c.subjectId = '{subjectId}' and c.info.id = '{classId}'",
|
|
requestOptions: new QueryRequestOptions() { PartitionKey = new PartitionKey($"ExamClassResult-{school}") }))
|
|
requestOptions: new QueryRequestOptions() { PartitionKey = new PartitionKey($"ExamClassResult-{school}") }))
|
|
{
|
|
{
|
|
@@ -936,7 +936,7 @@ namespace TEAMModelOS.Controllers
|
|
}
|
|
}
|
|
else
|
|
else
|
|
{
|
|
{
|
|
- await foreach (var item in client.GetContainer("TEAMModelOS", "Common").GetItemQueryIterator<ExamClassResult>(
|
|
|
|
|
|
+ await foreach (var item in client.GetContainer(Constant.TEAMModelOS, "Common").GetItemQueryIterator<ExamClassResult>(
|
|
queryText: $"select value(c) from c where c.examId = '{id}' and c.subjectId = '{subjectId}' and array_contains(c.studentIds,'{studentId}')",
|
|
queryText: $"select value(c) from c where c.examId = '{id}' and c.subjectId = '{subjectId}' and array_contains(c.studentIds,'{studentId}')",
|
|
requestOptions: new QueryRequestOptions() { PartitionKey = new PartitionKey($"ExamClassResult-{school}") }))
|
|
requestOptions: new QueryRequestOptions() { PartitionKey = new PartitionKey($"ExamClassResult-{school}") }))
|
|
{
|
|
{
|
|
@@ -945,8 +945,8 @@ namespace TEAMModelOS.Controllers
|
|
}
|
|
}
|
|
|
|
|
|
ExamClassResult classResult = new ExamClassResult();
|
|
ExamClassResult classResult = new ExamClassResult();
|
|
- //ExamInfo classResult = await client.GetContainer("TEAMModelOS", "Common").ReadItemAsync<ExamInfo>(id.ToString(), new PartitionKey($"{code}"));
|
|
|
|
- //ExamClassResult classResult = await client.GetContainer("TEAMModelOS", "Common").ReadItemAsync<ExamClassResult>(id.ToString(), new PartitionKey($"{code}"));
|
|
|
|
|
|
+ //ExamInfo classResult = await client.GetContainer(Constant.TEAMModelOS, "Common").ReadItemAsync<ExamInfo>(id.ToString(), new PartitionKey($"{code}"));
|
|
|
|
+ //ExamClassResult classResult = await client.GetContainer(Constant.TEAMModelOS, "Common").ReadItemAsync<ExamClassResult>(id.ToString(), new PartitionKey($"{code}"));
|
|
/*foreach (double index in ans) {
|
|
/*foreach (double index in ans) {
|
|
classResult.studentScores.in
|
|
classResult.studentScores.in
|
|
}*/
|
|
}*/
|
|
@@ -973,7 +973,7 @@ namespace TEAMModelOS.Controllers
|
|
}
|
|
}
|
|
if (flag)
|
|
if (flag)
|
|
{
|
|
{
|
|
- ExamInfo exam = await client.GetContainer("TEAMModelOS", "Common").ReadItemAsync<ExamInfo>(id.ToString(), new PartitionKey($"Exam-{code}"));
|
|
|
|
|
|
+ ExamInfo exam = await client.GetContainer(Constant.TEAMModelOS, "Common").ReadItemAsync<ExamInfo>(id.ToString(), new PartitionKey($"Exam-{code}"));
|
|
result.progress = true;
|
|
result.progress = true;
|
|
exam.subjects.ForEach(s =>
|
|
exam.subjects.ForEach(s =>
|
|
{
|
|
{
|
|
@@ -982,17 +982,17 @@ namespace TEAMModelOS.Controllers
|
|
s.classCount += 1;
|
|
s.classCount += 1;
|
|
}
|
|
}
|
|
});
|
|
});
|
|
- await client.GetContainer("TEAMModelOS", "Common").ReplaceItemAsync(exam, id.ToString(), new PartitionKey($"Exam-{code}"));
|
|
|
|
|
|
+ await client.GetContainer(Constant.TEAMModelOS, "Common").ReplaceItemAsync(exam, id.ToString(), new PartitionKey($"Exam-{code}"));
|
|
}
|
|
}
|
|
}
|
|
}
|
|
else
|
|
else
|
|
{
|
|
{
|
|
- ExamInfo exam = await client.GetContainer("TEAMModelOS", "Common").ReadItemAsync<ExamInfo>(id.ToString(), new PartitionKey($"Exam-{code}"));
|
|
|
|
|
|
+ ExamInfo exam = await client.GetContainer(Constant.TEAMModelOS, "Common").ReadItemAsync<ExamInfo>(id.ToString(), new PartitionKey($"Exam-{code}"));
|
|
exam.updateTime = DateTimeOffset.UtcNow.ToUnixTimeMilliseconds();
|
|
exam.updateTime = DateTimeOffset.UtcNow.ToUnixTimeMilliseconds();
|
|
- await client.GetContainer("TEAMModelOS", "Common").ReplaceItemAsync(exam, id.ToString(), new PartitionKey($"Exam-{code}"));
|
|
|
|
|
|
+ await client.GetContainer(Constant.TEAMModelOS, "Common").ReplaceItemAsync(exam, id.ToString(), new PartitionKey($"Exam-{code}"));
|
|
}
|
|
}
|
|
result.sum[index] = result.studentScores[index].Sum();
|
|
result.sum[index] = result.studentScores[index].Sum();
|
|
- classResult = await client.GetContainer("TEAMModelOS", "Common").ReplaceItemAsync(result, result.id, new PartitionKey($"{result.code}"));
|
|
|
|
|
|
+ classResult = await client.GetContainer(Constant.TEAMModelOS, "Common").ReplaceItemAsync(result, result.id, new PartitionKey($"{result.code}"));
|
|
}
|
|
}
|
|
|
|
|
|
return Ok(new { classResult });
|
|
return Ok(new { classResult });
|
|
@@ -1044,9 +1044,9 @@ namespace TEAMModelOS.Controllers
|
|
// 如果只有学生id则返回学生参加过的考试 只返回相关摘要信息
|
|
// 如果只有学生id则返回学生参加过的考试 只返回相关摘要信息
|
|
var client = _azureCosmos.GetCosmosClient();
|
|
var client = _azureCosmos.GetCosmosClient();
|
|
//string code = school_code.ToString().Substring(5);
|
|
//string code = school_code.ToString().Substring(5);
|
|
- //ExamInfo info = await client.GetContainer("TEAMModelOS", "Common").ReadItemAsync<ExamInfo>(id.ToString(), new PartitionKey($"{school_code}"));
|
|
|
|
|
|
+ //ExamInfo info = await client.GetContainer(Constant.TEAMModelOS, "Common").ReadItemAsync<ExamInfo>(id.ToString(), new PartitionKey($"{school_code}"));
|
|
List<object> examClassResults = new List<object>();
|
|
List<object> examClassResults = new List<object>();
|
|
- await foreach (var item in client.GetContainer("TEAMModelOS", "Common").GetItemQueryStreamIterator(queryText: $"select c.id, c.code,c.info,c.studentIds,c.studentAnswers,c.studentScores,c.mark from c where c.examId = '{id}' and c.subjectId = '{subjectId}' and c.info.id = '{classId}'",
|
|
|
|
|
|
+ await foreach (var item in client.GetContainer(Constant.TEAMModelOS, "Common").GetItemQueryStreamIterator(queryText: $"select c.id, c.code,c.info,c.studentIds,c.studentAnswers,c.studentScores,c.mark from c where c.examId = '{id}' and c.subjectId = '{subjectId}' and c.info.id = '{classId}'",
|
|
requestOptions: new QueryRequestOptions() { PartitionKey = new PartitionKey($"ExamClassResult-{school_code}") }))
|
|
requestOptions: new QueryRequestOptions() { PartitionKey = new PartitionKey($"ExamClassResult-{school_code}") }))
|
|
{
|
|
{
|
|
using var json = await JsonDocument.ParseAsync(item.ContentStream);
|
|
using var json = await JsonDocument.ParseAsync(item.ContentStream);
|
|
@@ -1061,7 +1061,7 @@ namespace TEAMModelOS.Controllers
|
|
/*if (StringHelper.getKeyCount(requert) == 1 && requert.TryGetProperty("code", out JsonElement code))
|
|
/*if (StringHelper.getKeyCount(requert) == 1 && requert.TryGetProperty("code", out JsonElement code))
|
|
{
|
|
{
|
|
List<object> props = new List<object>();
|
|
List<object> props = new List<object>();
|
|
- await foreach (var item in client.GetContainer("TEAMModelOS", "Student").GetItemQueryStreamIterator(queryText: $"select c.id, c.code, c.examCode, c.status ,c.mark, c.score from c where c.id = {id}", requestOptions: new QueryRequestOptions() { PartitionKey = new PartitionKey($"ExamRecord-{school_code}") }))
|
|
|
|
|
|
+ await foreach (var item in client.GetContainer(Constant.TEAMModelOS, "Student").GetItemQueryStreamIterator(queryText: $"select c.id, c.code, c.examCode, c.status ,c.mark, c.score from c where c.id = {id}", requestOptions: new QueryRequestOptions() { PartitionKey = new PartitionKey($"ExamRecord-{school_code}") }))
|
|
{
|
|
{
|
|
using var json = await JsonDocument.ParseAsync(item.ContentStream);
|
|
using var json = await JsonDocument.ParseAsync(item.ContentStream);
|
|
if (json.RootElement.TryGetProperty("_count", out JsonElement count) && count.GetUInt16() > 0)
|
|
if (json.RootElement.TryGetProperty("_count", out JsonElement count) && count.GetUInt16() > 0)
|
|
@@ -1082,7 +1082,7 @@ namespace TEAMModelOS.Controllers
|
|
//List<ExamRecord> examRecords = await _azureCosmos.FindByDict<ExamRecord>(request, props);
|
|
//List<ExamRecord> examRecords = await _azureCosmos.FindByDict<ExamRecord>(request, props);
|
|
//return builder.Data(examRecords).Extend(new Dictionary<string, object> { { "props", props } }).build();
|
|
//return builder.Data(examRecords).Extend(new Dictionary<string, object> { { "props", props } }).build();
|
|
List<object> props = new List<object>();
|
|
List<object> props = new List<object>();
|
|
- await foreach (var item in client.GetContainer("TEAMModelOS", "Student").GetItemQueryStreamIterator(queryText: $"select c.id, c.code, c.examCode, c.status ,c.mark, c.score from c ", requestOptions: new QueryRequestOptions() { PartitionKey = new PartitionKey($"ExamRecord-{school_code}") }))
|
|
|
|
|
|
+ await foreach (var item in client.GetContainer(Constant.TEAMModelOS, "Student").GetItemQueryStreamIterator(queryText: $"select c.id, c.code, c.examCode, c.status ,c.mark, c.score from c ", requestOptions: new QueryRequestOptions() { PartitionKey = new PartitionKey($"ExamRecord-{school_code}") }))
|
|
{
|
|
{
|
|
using var json = await JsonDocument.ParseAsync(item.ContentStream);
|
|
using var json = await JsonDocument.ParseAsync(item.ContentStream);
|
|
if (json.RootElement.TryGetProperty("_count", out JsonElement count) && count.GetUInt16() > 0)
|
|
if (json.RootElement.TryGetProperty("_count", out JsonElement count) && count.GetUInt16() > 0)
|
|
@@ -1130,7 +1130,7 @@ namespace TEAMModelOS.Controllers
|
|
//List<string> ids = new List<string>();
|
|
//List<string> ids = new List<string>();
|
|
//处理班级人数(公共部分的校本名单)
|
|
//处理班级人数(公共部分的校本名单)
|
|
//List<Student> students = new List<Student>();
|
|
//List<Student> students = new List<Student>();
|
|
- await foreach (var item in client.GetContainer("TEAMModelOS", "Student").GetItemQueryStreamIterator(queryText: $"select c.classId id from c where c.id = '{studentId}'", requestOptions: new QueryRequestOptions() { PartitionKey = new PartitionKey($"Base-{school}") }))
|
|
|
|
|
|
+ await foreach (var item in client.GetContainer(Constant.TEAMModelOS, "Student").GetItemQueryStreamIterator(queryText: $"select c.classId id from c where c.id = '{studentId}'", requestOptions: new QueryRequestOptions() { PartitionKey = new PartitionKey($"Base-{school}") }))
|
|
{
|
|
{
|
|
using var json = await JsonDocument.ParseAsync(item.ContentStream);
|
|
using var json = await JsonDocument.ParseAsync(item.ContentStream);
|
|
if (json.RootElement.TryGetProperty("_count", out JsonElement count) && count.GetUInt16() > 0)
|
|
if (json.RootElement.TryGetProperty("_count", out JsonElement count) && count.GetUInt16() > 0)
|
|
@@ -1145,12 +1145,12 @@ namespace TEAMModelOS.Controllers
|
|
}
|
|
}
|
|
//获取自定义名单信息
|
|
//获取自定义名单信息
|
|
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 c.id from c join A0 in c.students where A0.id = '{studentId}'",
|
|
|
|
|
|
+ await foreach (var item in client.GetContainer(Constant.TEAMModelOS, "Teacher").GetItemQueryIterator<StuList>(queryText: $"select c.id from c join A0 in c.students where A0.id = '{studentId}'",
|
|
requestOptions: new QueryRequestOptions() { PartitionKey = new PartitionKey($"StuList") }))
|
|
requestOptions: new QueryRequestOptions() { PartitionKey = new PartitionKey($"StuList") }))
|
|
{
|
|
{
|
|
stuLists.Add(item);
|
|
stuLists.Add(item);
|
|
}
|
|
}
|
|
- await foreach (var item in client.GetContainer("TEAMModelOS", "School").GetItemQueryIterator<StuList>(queryText: $"select c.id from c join A0 in c.students where A0.id = '{studentId}'",
|
|
|
|
|
|
+ await foreach (var item in client.GetContainer(Constant.TEAMModelOS, "School").GetItemQueryIterator<StuList>(queryText: $"select c.id from c join A0 in c.students where A0.id = '{studentId}'",
|
|
requestOptions: new QueryRequestOptions() { PartitionKey = new PartitionKey($"StuList-{school}") }))
|
|
requestOptions: new QueryRequestOptions() { PartitionKey = new PartitionKey($"StuList-{school}") }))
|
|
{
|
|
{
|
|
stuLists.Add(item);
|
|
stuLists.Add(item);
|
|
@@ -1164,7 +1164,7 @@ namespace TEAMModelOS.Controllers
|
|
|
|
|
|
}
|
|
}
|
|
var queryClassId = $"select c.classes id from c where c.id ='{id}'";
|
|
var queryClassId = $"select c.classes id from c where c.id ='{id}'";
|
|
- await foreach (var item in client.GetContainer("TEAMModelOS", "Common").GetItemQueryStreamIterator(queryText: queryClassId, requestOptions: new QueryRequestOptions() { PartitionKey = new PartitionKey($"{scode}") }))
|
|
|
|
|
|
+ await foreach (var item in client.GetContainer(Constant.TEAMModelOS, "Common").GetItemQueryStreamIterator(queryText: queryClassId, requestOptions: new QueryRequestOptions() { PartitionKey = new PartitionKey($"{scode}") }))
|
|
{
|
|
{
|
|
using var json = await JsonDocument.ParseAsync(item.ContentStream);
|
|
using var json = await JsonDocument.ParseAsync(item.ContentStream);
|
|
if (json.RootElement.TryGetProperty("_count", out JsonElement count) && count.GetUInt16() > 0)
|
|
if (json.RootElement.TryGetProperty("_count", out JsonElement count) && count.GetUInt16() > 0)
|
|
@@ -1188,7 +1188,7 @@ namespace TEAMModelOS.Controllers
|
|
infoIds.Add(ids);
|
|
infoIds.Add(ids);
|
|
}
|
|
}
|
|
}
|
|
}
|
|
- await foreach (var item in client.GetContainer("TEAMModelOS", "Common").GetItemQueryStreamIterator(queryText: query, requestOptions: new QueryRequestOptions() { PartitionKey = new PartitionKey($"{scode}") }))
|
|
|
|
|
|
+ await foreach (var item in client.GetContainer(Constant.TEAMModelOS, "Common").GetItemQueryStreamIterator(queryText: query, requestOptions: new QueryRequestOptions() { PartitionKey = new PartitionKey($"{scode}") }))
|
|
{
|
|
{
|
|
using var json = await JsonDocument.ParseAsync(item.ContentStream);
|
|
using var json = await JsonDocument.ParseAsync(item.ContentStream);
|
|
if (json.RootElement.TryGetProperty("_count", out JsonElement count) && count.GetUInt16() > 0)
|
|
if (json.RootElement.TryGetProperty("_count", out JsonElement count) && count.GetUInt16() > 0)
|
|
@@ -1201,7 +1201,7 @@ namespace TEAMModelOS.Controllers
|
|
}
|
|
}
|
|
var querySubject = $"select A0.id,A0.name from c join A0 in c.subjects where c.id ='{id}'";
|
|
var querySubject = $"select A0.id,A0.name from c join A0 in c.subjects where c.id ='{id}'";
|
|
//List<object> props = new List<object>();
|
|
//List<object> props = new List<object>();
|
|
- await foreach (var item in client.GetContainer("TEAMModelOS", "Common").GetItemQueryStreamIterator(queryText: querySubject, requestOptions: new QueryRequestOptions() { PartitionKey = new PartitionKey($"{scode}") }))
|
|
|
|
|
|
+ await foreach (var item in client.GetContainer(Constant.TEAMModelOS, "Common").GetItemQueryStreamIterator(queryText: querySubject, requestOptions: new QueryRequestOptions() { PartitionKey = new PartitionKey($"{scode}") }))
|
|
{
|
|
{
|
|
using var json = await JsonDocument.ParseAsync(item.ContentStream);
|
|
using var json = await JsonDocument.ParseAsync(item.ContentStream);
|
|
if (json.RootElement.TryGetProperty("_count", out JsonElement count) && count.GetUInt16() > 0)
|
|
if (json.RootElement.TryGetProperty("_count", out JsonElement count) && count.GetUInt16() > 0)
|
|
@@ -1214,7 +1214,7 @@ namespace TEAMModelOS.Controllers
|
|
}
|
|
}
|
|
var queryAnswers = $"select c.id,c.code,c.studentIds,c.subjectId,c.studentAnswers,c.studentScores,c.sum,c.mark from c where c.examId ='{id}' and array_contains(c.studentIds,'{studentId}') and c.pk = 'ExamClassResult' ";
|
|
var queryAnswers = $"select c.id,c.code,c.studentIds,c.subjectId,c.studentAnswers,c.studentScores,c.sum,c.mark from c where c.examId ='{id}' and array_contains(c.studentIds,'{studentId}') and c.pk = 'ExamClassResult' ";
|
|
List<ExamClassResult> answers = new List<ExamClassResult>();
|
|
List<ExamClassResult> answers = new List<ExamClassResult>();
|
|
- await foreach (var item in client.GetContainer("TEAMModelOS", "Common").GetItemQueryStreamIterator(queryText: queryAnswers,
|
|
|
|
|
|
+ await foreach (var item in client.GetContainer(Constant.TEAMModelOS, "Common").GetItemQueryStreamIterator(queryText: queryAnswers,
|
|
requestOptions: new QueryRequestOptions() { PartitionKey = new PartitionKey($"ExamClassResult-{school}") }))
|
|
requestOptions: new QueryRequestOptions() { PartitionKey = new PartitionKey($"ExamClassResult-{school}") }))
|
|
{
|
|
{
|
|
using var json = await JsonDocument.ParseAsync(item.ContentStream);
|
|
using var json = await JsonDocument.ParseAsync(item.ContentStream);
|
|
@@ -1282,7 +1282,7 @@ namespace TEAMModelOS.Controllers
|
|
List<string> resultIds = new List<string>();
|
|
List<string> resultIds = new List<string>();
|
|
var client = _azureCosmos.GetCosmosClient();
|
|
var client = _azureCosmos.GetCosmosClient();
|
|
//查询校本班级ID
|
|
//查询校本班级ID
|
|
- await foreach (var item in client.GetContainer("TEAMModelOS", "School").GetItemQueryStreamIterator(
|
|
|
|
|
|
+ await foreach (var item in client.GetContainer(Constant.TEAMModelOS, "School").GetItemQueryStreamIterator(
|
|
queryText: $"select c.id from c join A0 in c.students where A0.id = '{studentId}' and c.pk = 'Class' "))
|
|
queryText: $"select c.id from c join A0 in c.students where A0.id = '{studentId}' and c.pk = 'Class' "))
|
|
{
|
|
{
|
|
using var json = await JsonDocument.ParseAsync(item.ContentStream);
|
|
using var json = await JsonDocument.ParseAsync(item.ContentStream);
|
|
@@ -1297,7 +1297,7 @@ namespace TEAMModelOS.Controllers
|
|
}
|
|
}
|
|
}
|
|
}
|
|
//查询私人班级ID
|
|
//查询私人班级ID
|
|
- await foreach (var item in client.GetContainer("TEAMModelOS", "Teacher").GetItemQueryStreamIterator(
|
|
|
|
|
|
+ await foreach (var item in client.GetContainer(Constant.TEAMModelOS, "Teacher").GetItemQueryStreamIterator(
|
|
queryText: $"select c.id from c join A0 in c.students where A0.id = '{studentId}' and c.pk = 'Class' "))
|
|
queryText: $"select c.id from c join A0 in c.students where A0.id = '{studentId}' and c.pk = 'Class' "))
|
|
{
|
|
{
|
|
using var json = await JsonDocument.ParseAsync(item.ContentStream);
|
|
using var json = await JsonDocument.ParseAsync(item.ContentStream);
|
|
@@ -1334,7 +1334,7 @@ namespace TEAMModelOS.Controllers
|
|
|
|
|
|
var query = $"select c.id,c.code,c.name,c.startTime,c.endTime,c.type,c.progress,c.school,c.scope from c where ({ss}) and c.progress != 'pending' ";
|
|
var query = $"select c.id,c.code,c.name,c.startTime,c.endTime,c.type,c.progress,c.school,c.scope from c where ({ss}) and c.progress != 'pending' ";
|
|
List<object> props = new List<object>();
|
|
List<object> props = new List<object>();
|
|
- await foreach (var item in client.GetContainer("TEAMModelOS", "Common").GetItemQueryStreamIterator(queryText: query))
|
|
|
|
|
|
+ await foreach (var item in client.GetContainer(Constant.TEAMModelOS, "Common").GetItemQueryStreamIterator(queryText: query))
|
|
{
|
|
{
|
|
using var json = await JsonDocument.ParseAsync(item.ContentStream);
|
|
using var json = await JsonDocument.ParseAsync(item.ContentStream);
|
|
if (json.RootElement.TryGetProperty("_count", out JsonElement count) && count.GetUInt16() > 0)
|
|
if (json.RootElement.TryGetProperty("_count", out JsonElement count) && count.GetUInt16() > 0)
|
|
@@ -1347,7 +1347,7 @@ namespace TEAMModelOS.Controllers
|
|
}
|
|
}
|
|
var queryClass = $"select c.examId,c.subjectId,c.studentIds,c.studentAnswers,c.studentScores from c where array_contains(c.studentIds,'{studentId}') and c.pk = 'ExamClassResult'";
|
|
var queryClass = $"select c.examId,c.subjectId,c.studentIds,c.studentAnswers,c.studentScores from c where array_contains(c.studentIds,'{studentId}') and c.pk = 'ExamClassResult'";
|
|
List<ExamClassResult> Classes = new List<ExamClassResult>();
|
|
List<ExamClassResult> Classes = new List<ExamClassResult>();
|
|
- await foreach (var item in client.GetContainer("TEAMModelOS", "Common").GetItemQueryStreamIterator(queryText: queryClass))
|
|
|
|
|
|
+ await foreach (var item in client.GetContainer(Constant.TEAMModelOS, "Common").GetItemQueryStreamIterator(queryText: queryClass))
|
|
{
|
|
{
|
|
using var json = await JsonDocument.ParseAsync(item.ContentStream);
|
|
using var json = await JsonDocument.ParseAsync(item.ContentStream);
|
|
if (json.RootElement.TryGetProperty("_count", out JsonElement count) && count.GetUInt16() > 0)
|
|
if (json.RootElement.TryGetProperty("_count", out JsonElement count) && count.GetUInt16() > 0)
|
|
@@ -1395,7 +1395,7 @@ namespace TEAMModelOS.Controllers
|
|
var client = _azureCosmos.GetCosmosClient();
|
|
var client = _azureCosmos.GetCosmosClient();
|
|
var query = $"select c.examId,c.subjectId,c.studentScores from c where array_contains(c.studentIds,'{id}') ";
|
|
var query = $"select c.examId,c.subjectId,c.studentScores from c where array_contains(c.studentIds,'{id}') ";
|
|
List<object> props = new List<object>();
|
|
List<object> props = new List<object>();
|
|
- await foreach (var item in client.GetContainer("TEAMModelOS", "Common").GetItemQueryStreamIterator(queryText: query))
|
|
|
|
|
|
+ await foreach (var item in client.GetContainer(Constant.TEAMModelOS, "Common").GetItemQueryStreamIterator(queryText: query))
|
|
{
|
|
{
|
|
using var json = await JsonDocument.ParseAsync(item.ContentStream);
|
|
using var json = await JsonDocument.ParseAsync(item.ContentStream);
|
|
if (json.RootElement.TryGetProperty("_count", out JsonElement count) && count.GetUInt16() > 0)
|
|
if (json.RootElement.TryGetProperty("_count", out JsonElement count) && count.GetUInt16() > 0)
|
|
@@ -1431,14 +1431,14 @@ namespace TEAMModelOS.Controllers
|
|
if (!requert.TryGetProperty("id", out JsonElement id)) return BadRequest();
|
|
if (!requert.TryGetProperty("id", out JsonElement id)) return BadRequest();
|
|
if (!requert.TryGetProperty("code", out JsonElement code)) return BadRequest();
|
|
if (!requert.TryGetProperty("code", out JsonElement code)) return BadRequest();
|
|
var client = _azureCosmos.GetCosmosClient();
|
|
var client = _azureCosmos.GetCosmosClient();
|
|
- ExamInfo info = await client.GetContainer("TEAMModelOS", "Common").ReadItemAsync<ExamInfo>(id.ToString(), new PartitionKey($"Exam-{code}"));
|
|
|
|
|
|
+ ExamInfo info = await client.GetContainer(Constant.TEAMModelOS, "Common").ReadItemAsync<ExamInfo>(id.ToString(), new PartitionKey($"Exam-{code}"));
|
|
info.progress = "finish";
|
|
info.progress = "finish";
|
|
info.endTime = DateTimeOffset.UtcNow.ToUnixTimeMilliseconds();
|
|
info.endTime = DateTimeOffset.UtcNow.ToUnixTimeMilliseconds();
|
|
List<ExamClassResult> classResults = new();
|
|
List<ExamClassResult> classResults = new();
|
|
if (info.scope.Equals("school"))
|
|
if (info.scope.Equals("school"))
|
|
{
|
|
{
|
|
|
|
|
|
- await foreach (var item in client.GetContainer("TEAMModelOS", "Common").GetItemQueryIterator<ExamClassResult>(
|
|
|
|
|
|
+ await foreach (var item in client.GetContainer(Constant.TEAMModelOS, "Common").GetItemQueryIterator<ExamClassResult>(
|
|
queryText: $"select value(c) from c where c.examId = '{id}'",
|
|
queryText: $"select value(c) from c where c.examId = '{id}'",
|
|
requestOptions: new QueryRequestOptions() { PartitionKey = new PartitionKey($"ExamClassResult-{info.school}") }))
|
|
requestOptions: new QueryRequestOptions() { PartitionKey = new PartitionKey($"ExamClassResult-{info.school}") }))
|
|
{
|
|
{
|
|
@@ -1447,7 +1447,7 @@ namespace TEAMModelOS.Controllers
|
|
}
|
|
}
|
|
else
|
|
else
|
|
{
|
|
{
|
|
- await foreach (var item in client.GetContainer("TEAMModelOS", "Common").GetItemQueryIterator<ExamClassResult>(
|
|
|
|
|
|
+ await foreach (var item in client.GetContainer(Constant.TEAMModelOS, "Common").GetItemQueryIterator<ExamClassResult>(
|
|
queryText: $"select value(c) from c where c.examId = '{id}'",
|
|
queryText: $"select value(c) from c where c.examId = '{id}'",
|
|
requestOptions: new QueryRequestOptions() { PartitionKey = new PartitionKey($"ExamClassResult-{info.creatorId}") }))
|
|
requestOptions: new QueryRequestOptions() { PartitionKey = new PartitionKey($"ExamClassResult-{info.creatorId}") }))
|
|
{
|
|
{
|
|
@@ -1457,9 +1457,9 @@ namespace TEAMModelOS.Controllers
|
|
foreach (ExamClassResult examClass in classResults)
|
|
foreach (ExamClassResult examClass in classResults)
|
|
{
|
|
{
|
|
examClass.progress = true;
|
|
examClass.progress = true;
|
|
- await client.GetContainer("TEAMModelOS", "Common").ReplaceItemAsync(examClass, examClass.id, new PartitionKey($"{examClass.code}"));
|
|
|
|
|
|
+ await client.GetContainer(Constant.TEAMModelOS, "Common").ReplaceItemAsync(examClass, examClass.id, new PartitionKey($"{examClass.code}"));
|
|
}
|
|
}
|
|
- info = await client.GetContainer("TEAMModelOS", "Common").ReplaceItemAsync(info, info.id, new PartitionKey($"Exam-{code}"));
|
|
|
|
|
|
+ info = await client.GetContainer(Constant.TEAMModelOS, "Common").ReplaceItemAsync(info, info.id, new PartitionKey($"Exam-{code}"));
|
|
return Ok(info);
|
|
return Ok(info);
|
|
}
|
|
}
|
|
catch (Exception ex)
|
|
catch (Exception ex)
|
|
@@ -1485,7 +1485,7 @@ namespace TEAMModelOS.Controllers
|
|
if (!requert.TryGetProperty("code", out JsonElement code)) return BadRequest();
|
|
if (!requert.TryGetProperty("code", out JsonElement code)) return BadRequest();
|
|
if (!requert.TryGetProperty("subjectId", out JsonElement subjectId)) return BadRequest();
|
|
if (!requert.TryGetProperty("subjectId", out JsonElement subjectId)) return BadRequest();
|
|
var client = _azureCosmos.GetCosmosClient();
|
|
var client = _azureCosmos.GetCosmosClient();
|
|
- ExamInfo info = await client.GetContainer("TEAMModelOS", "Common").ReadItemAsync<ExamInfo>(id.ToString(), new PartitionKey($"Exam-{code}"));
|
|
|
|
|
|
+ ExamInfo info = await client.GetContainer(Constant.TEAMModelOS, "Common").ReadItemAsync<ExamInfo>(id.ToString(), new PartitionKey($"Exam-{code}"));
|
|
int index = 0;
|
|
int index = 0;
|
|
foreach (ExamSubject subject in info.subjects) {
|
|
foreach (ExamSubject subject in info.subjects) {
|
|
if (!subject.id.Equals(subjectId.ToString()))
|
|
if (!subject.id.Equals(subjectId.ToString()))
|
|
@@ -1502,7 +1502,7 @@ namespace TEAMModelOS.Controllers
|
|
if (info.scope.Equals("school"))
|
|
if (info.scope.Equals("school"))
|
|
{
|
|
{
|
|
|
|
|
|
- await foreach (var item in client.GetContainer("TEAMModelOS", "Common").GetItemQueryIterator<ExamClassResult>(
|
|
|
|
|
|
+ await foreach (var item in client.GetContainer(Constant.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-{info.school}") }))
|
|
requestOptions: new QueryRequestOptions() { PartitionKey = new PartitionKey($"ExamClassResult-{info.school}") }))
|
|
{
|
|
{
|
|
@@ -1511,7 +1511,7 @@ namespace TEAMModelOS.Controllers
|
|
}
|
|
}
|
|
else
|
|
else
|
|
{
|
|
{
|
|
- await foreach (var item in client.GetContainer("TEAMModelOS", "Common").GetItemQueryIterator<ExamClassResult>(
|
|
|
|
|
|
+ await foreach (var item in client.GetContainer(Constant.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-{info.creatorId}") }))
|
|
requestOptions: new QueryRequestOptions() { PartitionKey = new PartitionKey($"ExamClassResult-{info.creatorId}") }))
|
|
{
|
|
{
|
|
@@ -1545,7 +1545,7 @@ namespace TEAMModelOS.Controllers
|
|
}
|
|
}
|
|
}
|
|
}
|
|
}
|
|
}
|
|
- //info = await client.GetContainer("TEAMModelOS", "Common").ReplaceItemAsync(info, info.id, new PartitionKey($"Exam-{code}"));
|
|
|
|
|
|
+ //info = await client.GetContainer(Constant.TEAMModelOS, "Common").ReplaceItemAsync(info, info.id, new PartitionKey($"Exam-{code}"));
|
|
return Ok(new { score = itemScore , stuAns, paper = info.papers });
|
|
return Ok(new { score = itemScore , stuAns, paper = info.papers });
|
|
}
|
|
}
|
|
catch (Exception ex)
|
|
catch (Exception ex)
|
|
@@ -1572,10 +1572,10 @@ namespace TEAMModelOS.Controllers
|
|
if (!requert.TryGetProperty("tmdId", out JsonElement tId)) return BadRequest();
|
|
if (!requert.TryGetProperty("tmdId", out JsonElement tId)) return BadRequest();
|
|
var client = _azureCosmos.GetCosmosClient();
|
|
var client = _azureCosmos.GetCosmosClient();
|
|
//var redisClient = _azureRedis.GetRedisClient(8);
|
|
//var redisClient = _azureRedis.GetRedisClient(8);
|
|
- ExamInfo info = await client.GetContainer("TEAMModelOS", "Common").ReadItemAsync<ExamInfo>(id.ToString(), new PartitionKey($"Exam-{code}"));
|
|
|
|
|
|
+ ExamInfo info = await client.GetContainer(Constant.TEAMModelOS, "Common").ReadItemAsync<ExamInfo>(id.ToString(), new PartitionKey($"Exam-{code}"));
|
|
List<ExamClassResult> classResults = new();
|
|
List<ExamClassResult> classResults = new();
|
|
List<SDK.Models.Cosmos.Common.Scoring> attr = new List<SDK.Models.Cosmos.Common.Scoring>();
|
|
List<SDK.Models.Cosmos.Common.Scoring> attr = new List<SDK.Models.Cosmos.Common.Scoring>();
|
|
- await foreach (var item in client.GetContainer("TEAMModelOS", "Teacher").GetItemQueryIterator<SDK.Models.Cosmos.Common.Scoring>(
|
|
|
|
|
|
+ await foreach (var item in client.GetContainer(Constant.TEAMModelOS, "Teacher").GetItemQueryIterator<SDK.Models.Cosmos.Common.Scoring>(
|
|
queryText: $"select value(c) from c where c.examId = '{id}' and c.subjectId = '{subjectId}' and array_contains(c.tIds,'{tId}') ",
|
|
queryText: $"select value(c) from c where c.examId = '{id}' and c.subjectId = '{subjectId}' and array_contains(c.tIds,'{tId}') ",
|
|
requestOptions: new QueryRequestOptions() { PartitionKey = new PartitionKey($"Scoring-{code}") }))
|
|
requestOptions: new QueryRequestOptions() { PartitionKey = new PartitionKey($"Scoring-{code}") }))
|
|
{
|
|
{
|
|
@@ -1649,15 +1649,15 @@ namespace TEAMModelOS.Controllers
|
|
if (!requert.TryGetProperty("subjectId", out JsonElement subjectId)) return BadRequest();
|
|
if (!requert.TryGetProperty("subjectId", out JsonElement subjectId)) return BadRequest();
|
|
//if (!requert.TryGetProperty("tmdId", out JsonElement tId)) return BadRequest();
|
|
//if (!requert.TryGetProperty("tmdId", out JsonElement tId)) return BadRequest();
|
|
var client = _azureCosmos.GetCosmosClient();
|
|
var client = _azureCosmos.GetCosmosClient();
|
|
- var response = await client.GetContainer("TEAMModelOS", "Common").ReadItemStreamAsync(id.ToString(), new PartitionKey($"Exam-{code}"));
|
|
|
|
|
|
+ var response = await client.GetContainer(Constant.TEAMModelOS, "Common").ReadItemStreamAsync(id.ToString(), new PartitionKey($"Exam-{code}"));
|
|
if (response.Status == 200)
|
|
if (response.Status == 200)
|
|
{
|
|
{
|
|
using var json = await JsonDocument.ParseAsync(response.ContentStream);
|
|
using var json = await JsonDocument.ParseAsync(response.ContentStream);
|
|
ExamInfo info = json.ToObject<ExamInfo>();
|
|
ExamInfo info = json.ToObject<ExamInfo>();
|
|
- //ExamInfo info = await client.GetContainer("TEAMModelOS", "Common").ReadItemAsync<ExamInfo>(id.ToString(), new PartitionKey($"Exam-{code}"));
|
|
|
|
|
|
+ //ExamInfo info = await client.GetContainer(Constant.TEAMModelOS, "Common").ReadItemAsync<ExamInfo>(id.ToString(), new PartitionKey($"Exam-{code}"));
|
|
List<ExamClassResult> classResults = new();
|
|
List<ExamClassResult> classResults = new();
|
|
List<SDK.Models.Cosmos.Common.Scoring> attr = new List<SDK.Models.Cosmos.Common.Scoring>();
|
|
List<SDK.Models.Cosmos.Common.Scoring> attr = new List<SDK.Models.Cosmos.Common.Scoring>();
|
|
- await foreach (var item in client.GetContainer("TEAMModelOS", "Teacher").GetItemQueryIterator<SDK.Models.Cosmos.Common.Scoring>(
|
|
|
|
|
|
+ await foreach (var item in client.GetContainer(Constant.TEAMModelOS, "Teacher").GetItemQueryIterator<SDK.Models.Cosmos.Common.Scoring>(
|
|
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($"Scoring-{code}") }))
|
|
requestOptions: new QueryRequestOptions() { PartitionKey = new PartitionKey($"Scoring-{code}") }))
|
|
{
|
|
{
|
|
@@ -1722,10 +1722,10 @@ namespace TEAMModelOS.Controllers
|
|
{
|
|
{
|
|
return Ok(new { msg = "还在进行中", code = 202 });
|
|
return Ok(new { msg = "还在进行中", code = 202 });
|
|
}
|
|
}
|
|
- ExamInfo info = await client.GetContainer("TEAMModelOS", "Common").ReadItemAsync<ExamInfo>(id.ToString(), new PartitionKey($"Exam-{code}"));
|
|
|
|
|
|
+ ExamInfo info = await client.GetContainer(Constant.TEAMModelOS, "Common").ReadItemAsync<ExamInfo>(id.ToString(), new PartitionKey($"Exam-{code}"));
|
|
List<ExamClassResult> classResults = new();
|
|
List<ExamClassResult> classResults = new();
|
|
List<SDK.Models.Cosmos.Common.Scoring> attr = new List<SDK.Models.Cosmos.Common.Scoring>();
|
|
List<SDK.Models.Cosmos.Common.Scoring> attr = new List<SDK.Models.Cosmos.Common.Scoring>();
|
|
- await foreach (var item in client.GetContainer("TEAMModelOS", "Teacher").GetItemQueryIterator<SDK.Models.Cosmos.Common.Scoring>(
|
|
|
|
|
|
+ await foreach (var item in client.GetContainer(Constant.TEAMModelOS, "Teacher").GetItemQueryIterator<SDK.Models.Cosmos.Common.Scoring>(
|
|
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($"Scoring-{code}") }))
|
|
requestOptions: new QueryRequestOptions() { PartitionKey = new PartitionKey($"Scoring-{code}") }))
|
|
{
|
|
{
|
|
@@ -1789,7 +1789,7 @@ namespace TEAMModelOS.Controllers
|
|
List<SDK.Models.Cosmos.Common.Scoring> recs = new();
|
|
List<SDK.Models.Cosmos.Common.Scoring> recs = new();
|
|
List<SDK.Models.Cosmos.Common.Scoring> all = new();
|
|
List<SDK.Models.Cosmos.Common.Scoring> all = new();
|
|
List<SDK.Models.Cosmos.Common.Scoring> attr = new();
|
|
List<SDK.Models.Cosmos.Common.Scoring> attr = new();
|
|
- await foreach (var item in client.GetContainer("TEAMModelOS", "Teacher").GetItemQueryIterator<SDK.Models.Cosmos.Common.Scoring>(
|
|
|
|
|
|
+ await foreach (var item in client.GetContainer(Constant.TEAMModelOS, "Teacher").GetItemQueryIterator<SDK.Models.Cosmos.Common.Scoring>(
|
|
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($"Scoring-{code}") }))
|
|
requestOptions: new QueryRequestOptions() { PartitionKey = new PartitionKey($"Scoring-{code}") }))
|
|
{
|
|
{
|
|
@@ -1838,7 +1838,7 @@ namespace TEAMModelOS.Controllers
|
|
{
|
|
{
|
|
|
|
|
|
List<SDK.Models.Cosmos.Common.Scoring> value = new();
|
|
List<SDK.Models.Cosmos.Common.Scoring> value = new();
|
|
- await foreach (var item in client.GetContainer("TEAMModelOS", "Teacher").GetItemQueryIterator<SDK.Models.Cosmos.Common.Scoring>(
|
|
|
|
|
|
+ await foreach (var item in client.GetContainer(Constant.TEAMModelOS, "Teacher").GetItemQueryIterator<SDK.Models.Cosmos.Common.Scoring>(
|
|
queryText: $"select value(c) from c where c.examId = '{id}' and c.subjectId = '{subjectId}' and c.stuId = '{stuId}' ",
|
|
queryText: $"select value(c) from c where c.examId = '{id}' and c.subjectId = '{subjectId}' and c.stuId = '{stuId}' ",
|
|
requestOptions: new QueryRequestOptions() { PartitionKey = new PartitionKey($"Scoring-{code}") }))
|
|
requestOptions: new QueryRequestOptions() { PartitionKey = new PartitionKey($"Scoring-{code}") }))
|
|
{
|
|
{
|
|
@@ -1855,7 +1855,7 @@ namespace TEAMModelOS.Controllers
|
|
else
|
|
else
|
|
{
|
|
{
|
|
scoring.tIds.Add(tId.ToString());
|
|
scoring.tIds.Add(tId.ToString());
|
|
- await client.GetContainer("TEAMModelOS", "Teacher").ReplaceItemAsync(scoring, scoring.id, new PartitionKey(scoring.code));
|
|
|
|
|
|
+ await client.GetContainer(Constant.TEAMModelOS, "Teacher").ReplaceItemAsync(scoring, scoring.id, new PartitionKey(scoring.code));
|
|
}
|
|
}
|
|
}
|
|
}
|
|
}
|
|
}
|
|
@@ -1935,7 +1935,7 @@ namespace TEAMModelOS.Controllers
|
|
{
|
|
{
|
|
item.tIds.Add(tId.ToString());
|
|
item.tIds.Add(tId.ToString());
|
|
}
|
|
}
|
|
- await client.GetContainer("TEAMModelOS", "Teacher").ReplaceItemAsync(item, item.id, new PartitionKey(item.code));
|
|
|
|
|
|
+ await client.GetContainer(Constant.TEAMModelOS, "Teacher").ReplaceItemAsync(item, item.id, new PartitionKey(item.code));
|
|
//序列化单个学生作答记录、得分情况、批注情况
|
|
//序列化单个学生作答记录、得分情况、批注情况
|
|
/*var cs = JsonSerializer.Serialize(item);
|
|
/*var cs = JsonSerializer.Serialize(item);
|
|
var json = JsonDocument.Parse(cs);
|
|
var json = JsonDocument.Parse(cs);
|
|
@@ -1987,11 +1987,11 @@ namespace TEAMModelOS.Controllers
|
|
}
|
|
}
|
|
|
|
|
|
//var json = JsonDocument.Parse(record);
|
|
//var json = JsonDocument.Parse(record);
|
|
- /*ExamInfo info = await client.GetContainer("TEAMModelOS", "Common").ReadItemAsync<ExamInfo>(id.ToString(), new Azure.Cosmos.PartitionKey($"Exam-hbcn"));
|
|
|
|
|
|
+ /*ExamInfo info = await client.GetContainer(Constant.TEAMModelOS, "Common").ReadItemAsync<ExamInfo>(id.ToString(), new Azure.Cosmos.PartitionKey($"Exam-hbcn"));
|
|
if (info.scope.Equals("school"))
|
|
if (info.scope.Equals("school"))
|
|
{
|
|
{
|
|
|
|
|
|
- await foreach (var item in client.GetContainer("TEAMModelOS", "Common").GetItemQueryIterator<ExamClassResult>(
|
|
|
|
|
|
+ await foreach (var item in client.GetContainer(Constant.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-{info.school}") }))
|
|
requestOptions: new QueryRequestOptions() { PartitionKey = new PartitionKey($"ExamClassResult-{info.school}") }))
|
|
{
|
|
{
|
|
@@ -2000,7 +2000,7 @@ namespace TEAMModelOS.Controllers
|
|
}
|
|
}
|
|
else
|
|
else
|
|
{
|
|
{
|
|
- await foreach (var item in client.GetContainer("TEAMModelOS", "Common").GetItemQueryIterator<ExamClassResult>(
|
|
|
|
|
|
+ await foreach (var item in client.GetContainer(Constant.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-{info.creatorId}") }))
|
|
requestOptions: new QueryRequestOptions() { PartitionKey = new PartitionKey($"ExamClassResult-{info.creatorId}") }))
|
|
{
|
|
{
|
|
@@ -2019,7 +2019,7 @@ namespace TEAMModelOS.Controllers
|
|
}
|
|
}
|
|
await Task.WhenAll(tasks);
|
|
await Task.WhenAll(tasks);
|
|
return Ok();*/
|
|
return Ok();*/
|
|
- //info = await client.GetContainer("TEAMModelOS", "Common").ReplaceItemAsync(info, info.id, new PartitionKey($"Exam-{code}"));
|
|
|
|
|
|
+ //info = await client.GetContainer(Constant.TEAMModelOS, "Common").ReplaceItemAsync(info, info.id, new PartitionKey($"Exam-{code}"));
|
|
}
|
|
}
|
|
catch (Exception ex)
|
|
catch (Exception ex)
|
|
{
|
|
{
|
|
@@ -2053,7 +2053,7 @@ namespace TEAMModelOS.Controllers
|
|
//var redisClient = _azureRedis.GetRedisClient(8);
|
|
//var redisClient = _azureRedis.GetRedisClient(8);
|
|
List<ExamClassResult> classResults = new();
|
|
List<ExamClassResult> classResults = new();
|
|
List<SDK.Models.Cosmos.Common.Scoring> attr = new();
|
|
List<SDK.Models.Cosmos.Common.Scoring> attr = new();
|
|
- await foreach (var item in client.GetContainer("TEAMModelOS", "Teacher").GetItemQueryIterator<SDK.Models.Cosmos.Common.Scoring>(
|
|
|
|
|
|
+ await foreach (var item in client.GetContainer(Constant.TEAMModelOS, "Teacher").GetItemQueryIterator<SDK.Models.Cosmos.Common.Scoring>(
|
|
queryText: $"select value(c) from c where c.examId = '{id}' and c.subjectId = '{subjectId}' and c.stuId = '{sId}' and array_contains(c.tIds,'{tId}') ",
|
|
queryText: $"select value(c) from c where c.examId = '{id}' and c.subjectId = '{subjectId}' and c.stuId = '{sId}' and array_contains(c.tIds,'{tId}') ",
|
|
requestOptions: new QueryRequestOptions() { PartitionKey = new PartitionKey($"Scoring-{code}") }))
|
|
requestOptions: new QueryRequestOptions() { PartitionKey = new PartitionKey($"Scoring-{code}") }))
|
|
{
|
|
{
|
|
@@ -2193,7 +2193,7 @@ namespace TEAMModelOS.Controllers
|
|
}
|
|
}
|
|
}
|
|
}
|
|
|
|
|
|
- await client.GetContainer("TEAMModelOS", "Teacher").ReplaceItemAsync(scoring, scoring.id, new PartitionKey(scoring.code));
|
|
|
|
|
|
+ await client.GetContainer(Constant.TEAMModelOS, "Teacher").ReplaceItemAsync(scoring, scoring.id, new PartitionKey(scoring.code));
|
|
|
|
|
|
}
|
|
}
|
|
}
|
|
}
|
|
@@ -2205,7 +2205,7 @@ namespace TEAMModelOS.Controllers
|
|
if (attr.Count == count.GetInt32())
|
|
if (attr.Count == count.GetInt32())
|
|
{
|
|
{
|
|
|
|
|
|
- await foreach (var item in client.GetContainer("TEAMModelOS", "Common").GetItemQueryIterator<ExamClassResult>(
|
|
|
|
|
|
+ await foreach (var item in client.GetContainer(Constant.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}") }))
|
|
{
|
|
{
|
|
@@ -2229,7 +2229,7 @@ namespace TEAMModelOS.Controllers
|
|
if (!item.flag)
|
|
if (!item.flag)
|
|
{
|
|
{
|
|
//scoring.type = 3;
|
|
//scoring.type = 3;
|
|
- await client.GetContainer("TEAMModelOS", "Teacher").ReplaceItemAsync(scoring, scoring.id, new PartitionKey(scoring.code));
|
|
|
|
|
|
+ await client.GetContainer(Constant.TEAMModelOS, "Teacher").ReplaceItemAsync(scoring, scoring.id, new PartitionKey(scoring.code));
|
|
return Ok(new { msg = "试题分数差异过大" });
|
|
return Ok(new { msg = "试题分数差异过大" });
|
|
}
|
|
}
|
|
double sc = item.scores.Select(x => x.sc).ToList().Aggregate((i, j) => (i + j) / item.scores.Count);
|
|
double sc = item.scores.Select(x => x.sc).ToList().Aggregate((i, j) => (i + j) / item.scores.Count);
|
|
@@ -2271,7 +2271,7 @@ namespace TEAMModelOS.Controllers
|
|
}
|
|
}
|
|
|
|
|
|
}
|
|
}
|
|
- await client.GetContainer("TEAMModelOS", "Common").ReplaceItemAsync(exam, exam.id, new PartitionKey($"{exam.code}"));
|
|
|
|
|
|
+ await client.GetContainer(Constant.TEAMModelOS, "Common").ReplaceItemAsync(exam, exam.id, new PartitionKey($"{exam.code}"));
|
|
}
|
|
}
|
|
|
|
|
|
}
|
|
}
|
|
@@ -2300,7 +2300,7 @@ namespace TEAMModelOS.Controllers
|
|
if (!requert.TryGetProperty("code", out JsonElement code)) return BadRequest();
|
|
if (!requert.TryGetProperty("code", out JsonElement code)) return BadRequest();
|
|
var client = _azureCosmos.GetCosmosClient();
|
|
var client = _azureCosmos.GetCosmosClient();
|
|
List<SDK.Models.Cosmos.Common.Scoring> attr = new();
|
|
List<SDK.Models.Cosmos.Common.Scoring> attr = new();
|
|
- await foreach (var item in client.GetContainer("TEAMModelOS", "Teacher").GetItemQueryIterator<SDK.Models.Cosmos.Common.Scoring>(
|
|
|
|
|
|
+ await foreach (var item in client.GetContainer(Constant.TEAMModelOS, "Teacher").GetItemQueryIterator<SDK.Models.Cosmos.Common.Scoring>(
|
|
queryText: $"select value(c) from c where c.examId = '{id}' and c.subjectId = '{subjectId}' and c.stuId = '{sId}' and c.type = '{type}' and array_contains(c.tIds,'{tId}') ",
|
|
queryText: $"select value(c) from c where c.examId = '{id}' and c.subjectId = '{subjectId}' and c.stuId = '{sId}' and c.type = '{type}' and array_contains(c.tIds,'{tId}') ",
|
|
requestOptions: new QueryRequestOptions() { PartitionKey = new PartitionKey($"Scoring-{code}") }))
|
|
requestOptions: new QueryRequestOptions() { PartitionKey = new PartitionKey($"Scoring-{code}") }))
|
|
{
|
|
{
|
|
@@ -2321,7 +2321,7 @@ namespace TEAMModelOS.Controllers
|
|
if (!requert.TryGetProperty("index", out JsonElement index)) return BadRequest();
|
|
if (!requert.TryGetProperty("index", out JsonElement index)) return BadRequest();
|
|
if (!requert.TryGetProperty("tId", out JsonElement tId)) return BadRequest();
|
|
if (!requert.TryGetProperty("tId", out JsonElement tId)) return BadRequest();
|
|
var client = _azureCosmos.GetCosmosClient();
|
|
var client = _azureCosmos.GetCosmosClient();
|
|
- SDK.Models.Cosmos.Common.Scoring scoring = await client.GetContainer("TEAMModelOS", "Teacher").ReadItemAsync<SDK.Models.Cosmos.Common.Scoring>(id.GetString(), new PartitionKey($"Scoring-{code}"));
|
|
|
|
|
|
+ SDK.Models.Cosmos.Common.Scoring scoring = await client.GetContainer(Constant.TEAMModelOS, "Teacher").ReadItemAsync<SDK.Models.Cosmos.Common.Scoring>(id.GetString(), new PartitionKey($"Scoring-{code}"));
|
|
if (null != scoring)
|
|
if (null != scoring)
|
|
{
|
|
{
|
|
if (string.IsNullOrEmpty(scoring.qs[index.GetInt32()].tId))
|
|
if (string.IsNullOrEmpty(scoring.qs[index.GetInt32()].tId))
|
|
@@ -2342,7 +2342,7 @@ namespace TEAMModelOS.Controllers
|
|
{
|
|
{
|
|
return Ok(new { code = 404 });
|
|
return Ok(new { code = 404 });
|
|
}
|
|
}
|
|
- var sc = await client.GetContainer("TEAMModelOS", "Teacher").ReplaceItemAsync(scoring, scoring.id, new PartitionKey($"{scoring.code}"));
|
|
|
|
|
|
+ var sc = await client.GetContainer(Constant.TEAMModelOS, "Teacher").ReplaceItemAsync(scoring, scoring.id, new PartitionKey($"{scoring.code}"));
|
|
return Ok(new { sc });
|
|
return Ok(new { sc });
|
|
}
|
|
}
|
|
|
|
|
|
@@ -2358,7 +2358,7 @@ namespace TEAMModelOS.Controllers
|
|
if (!requert.TryGetProperty("index", out JsonElement index)) return BadRequest();
|
|
if (!requert.TryGetProperty("index", out JsonElement index)) return BadRequest();
|
|
//if (!requert.TryGetProperty("tId", out JsonElement tId)) return BadRequest();
|
|
//if (!requert.TryGetProperty("tId", out JsonElement tId)) return BadRequest();
|
|
var client = _azureCosmos.GetCosmosClient();
|
|
var client = _azureCosmos.GetCosmosClient();
|
|
- SDK.Models.Cosmos.Common.Scoring scoring = await client.GetContainer("TEAMModelOS", "Teacher").ReadItemAsync<SDK.Models.Cosmos.Common.Scoring>(id.GetString(), new PartitionKey($"Scoring-{code}"));
|
|
|
|
|
|
+ SDK.Models.Cosmos.Common.Scoring scoring = await client.GetContainer(Constant.TEAMModelOS, "Teacher").ReadItemAsync<SDK.Models.Cosmos.Common.Scoring>(id.GetString(), new PartitionKey($"Scoring-{code}"));
|
|
if (null != scoring)
|
|
if (null != scoring)
|
|
{
|
|
{
|
|
if (string.IsNullOrEmpty(scoring.qs[index.GetInt32()].improve))
|
|
if (string.IsNullOrEmpty(scoring.qs[index.GetInt32()].improve))
|
|
@@ -2379,7 +2379,7 @@ namespace TEAMModelOS.Controllers
|
|
{
|
|
{
|
|
return Ok(new { code = 404 });
|
|
return Ok(new { code = 404 });
|
|
}
|
|
}
|
|
- var sc = await client.GetContainer("TEAMModelOS", "Teacher").ReplaceItemAsync(scoring, scoring.id, new PartitionKey($"{scoring.code}"));
|
|
|
|
|
|
+ var sc = await client.GetContainer(Constant.TEAMModelOS, "Teacher").ReplaceItemAsync(scoring, scoring.id, new PartitionKey($"{scoring.code}"));
|
|
return Ok(new { sc });
|
|
return Ok(new { sc });
|
|
}
|
|
}
|
|
|
|
|
|
@@ -2395,11 +2395,11 @@ namespace TEAMModelOS.Controllers
|
|
var client = _azureCosmos.GetCosmosClient();
|
|
var client = _azureCosmos.GetCosmosClient();
|
|
List<double> scs = score.ToObject<List<double>>();
|
|
List<double> scs = score.ToObject<List<double>>();
|
|
List<ExamClassResult> classResults = new();
|
|
List<ExamClassResult> classResults = new();
|
|
- SDK.Models.Cosmos.Common.Scoring scoring = await client.GetContainer("TEAMModelOS", "Teacher").ReadItemAsync<SDK.Models.Cosmos.Common.Scoring>(id.GetString(), new PartitionKey($"Scoring-{code}"));
|
|
|
|
|
|
+ SDK.Models.Cosmos.Common.Scoring scoring = await client.GetContainer(Constant.TEAMModelOS, "Teacher").ReadItemAsync<SDK.Models.Cosmos.Common.Scoring>(id.GetString(), new PartitionKey($"Scoring-{code}"));
|
|
if (null != scoring)
|
|
if (null != scoring)
|
|
{
|
|
{
|
|
scoring.scores = scs;
|
|
scoring.scores = scs;
|
|
- await foreach (var item in client.GetContainer("TEAMModelOS", "Common").GetItemQueryIterator<ExamClassResult>(
|
|
|
|
|
|
+ await foreach (var item in client.GetContainer(Constant.TEAMModelOS, "Common").GetItemQueryIterator<ExamClassResult>(
|
|
queryText: $"select value(c) from c where c.examId = '{id}' and c.subjectId = '{scoring.subjectId}'",
|
|
queryText: $"select value(c) from c where c.examId = '{id}' and c.subjectId = '{scoring.subjectId}'",
|
|
requestOptions: new QueryRequestOptions() { PartitionKey = new PartitionKey($"ExamClassResult-{code}") }))
|
|
requestOptions: new QueryRequestOptions() { PartitionKey = new PartitionKey($"ExamClassResult-{code}") }))
|
|
{
|
|
{
|
|
@@ -2414,14 +2414,14 @@ namespace TEAMModelOS.Controllers
|
|
//exam.mark[index] = scoring.marks;
|
|
//exam.mark[index] = scoring.marks;
|
|
}
|
|
}
|
|
|
|
|
|
- await client.GetContainer("TEAMModelOS", "Common").ReplaceItemAsync(exam, exam.id, new PartitionKey($"{exam.code}"));
|
|
|
|
|
|
+ await client.GetContainer(Constant.TEAMModelOS, "Common").ReplaceItemAsync(exam, exam.id, new PartitionKey($"{exam.code}"));
|
|
}
|
|
}
|
|
}
|
|
}
|
|
else
|
|
else
|
|
{
|
|
{
|
|
return Ok(new { code = 404 });
|
|
return Ok(new { code = 404 });
|
|
}
|
|
}
|
|
- var sc = await client.GetContainer("TEAMModelOS", "Teacher").ReplaceItemAsync(scoring, scoring.id, new PartitionKey($"{scoring.code}"));
|
|
|
|
|
|
+ var sc = await client.GetContainer(Constant.TEAMModelOS, "Teacher").ReplaceItemAsync(scoring, scoring.id, new PartitionKey($"{scoring.code}"));
|
|
return Ok(new { sc });
|
|
return Ok(new { sc });
|
|
}
|
|
}
|
|
|
|
|
|
@@ -2437,7 +2437,7 @@ namespace TEAMModelOS.Controllers
|
|
private async Task deleteAsync(CosmosClient client, string id, string tId)
|
|
private async Task deleteAsync(CosmosClient client, string id, string tId)
|
|
{
|
|
{
|
|
List<string> correctIds = new List<string>();
|
|
List<string> correctIds = new List<string>();
|
|
- await foreach (var item in client.GetContainer("TEAMModelOS", "Teacher").GetItemQueryStreamIterator(queryText: $"select c.id from c where c.cid = '{id}' ", requestOptions: new QueryRequestOptions() { PartitionKey = new PartitionKey($"CorrectTask-{tId}") }))
|
|
|
|
|
|
+ await foreach (var item in client.GetContainer(Constant.TEAMModelOS, "Teacher").GetItemQueryStreamIterator(queryText: $"select c.id from c where c.cid = '{id}' ", requestOptions: new QueryRequestOptions() { PartitionKey = new PartitionKey($"CorrectTask-{tId}") }))
|
|
{
|
|
{
|
|
using var jsonTask = await JsonDocument.ParseAsync(item.ContentStream);
|
|
using var jsonTask = await JsonDocument.ParseAsync(item.ContentStream);
|
|
if (jsonTask.RootElement.TryGetProperty("_count", out JsonElement count) && count.GetUInt16() > 0)
|
|
if (jsonTask.RootElement.TryGetProperty("_count", out JsonElement count) && count.GetUInt16() > 0)
|
|
@@ -2452,7 +2452,7 @@ namespace TEAMModelOS.Controllers
|
|
}
|
|
}
|
|
if (correctIds.Count > 0)
|
|
if (correctIds.Count > 0)
|
|
{
|
|
{
|
|
- await client.GetContainer("TEAMModelOS", "Teacher").DeleteItemsStreamAsync(correctIds, $"CorrectTask-{tId}");
|
|
|
|
|
|
+ await client.GetContainer(Constant.TEAMModelOS, "Teacher").DeleteItemsStreamAsync(correctIds, $"CorrectTask-{tId}");
|
|
}
|
|
}
|
|
}
|
|
}
|
|
}
|
|
}
|