|
@@ -61,12 +61,13 @@ namespace TEAMModelOS.Controllers
|
|
public async Task<IActionResult> Save(ExamInfo request)
|
|
public async Task<IActionResult> Save(ExamInfo request)
|
|
{
|
|
{
|
|
//新增
|
|
//新增
|
|
- string code = request.code;
|
|
|
|
|
|
+ //string code = request.code;
|
|
var client = _azureCosmos.GetCosmosClient();
|
|
var client = _azureCosmos.GetCosmosClient();
|
|
ExamInfo exam;
|
|
ExamInfo exam;
|
|
request.ttl = -1;
|
|
request.ttl = -1;
|
|
request.pk = "Exam";
|
|
request.pk = "Exam";
|
|
- request.createDate = DateTimeOffset.UtcNow.ToUnixTimeMilliseconds();
|
|
|
|
|
|
+ request.code = "Exam-" + request.code;
|
|
|
|
+ request.createTime = DateTimeOffset.UtcNow.ToUnixTimeMilliseconds();
|
|
/* if (request.publish.Equals("0"))
|
|
/* if (request.publish.Equals("0"))
|
|
{
|
|
{
|
|
request.progress = "going";
|
|
request.progress = "going";
|
|
@@ -84,10 +85,9 @@ namespace TEAMModelOS.Controllers
|
|
{
|
|
{
|
|
request.id = Guid.NewGuid().ToString();
|
|
request.id = Guid.NewGuid().ToString();
|
|
request.progress = "pending";
|
|
request.progress = "pending";
|
|
- request.code = "Exam-" + request.code;
|
|
|
|
int count = 0;
|
|
int count = 0;
|
|
for (int i =0; i < request.targetClassIds.Count;i++) {
|
|
for (int i =0; i < request.targetClassIds.Count;i++) {
|
|
- var sresponse = await client.GetContainer("TEAMModelOS", "School").ReadItemStreamAsync(request.targetClassIds[i], new PartitionKey($"Class-{code}"));
|
|
|
|
|
|
+ var sresponse = await client.GetContainer("TEAMModelOS", "School").ReadItemStreamAsync(request.targetClassIds[i], new PartitionKey($"{request.code}"));
|
|
if (sresponse.Status == 200) {
|
|
if (sresponse.Status == 200) {
|
|
using var json = await JsonDocument.ParseAsync(sresponse.ContentStream);
|
|
using var json = await JsonDocument.ParseAsync(sresponse.ContentStream);
|
|
Classroom classroom = json.ToObject<Classroom>();
|
|
Classroom classroom = json.ToObject<Classroom>();
|
|
@@ -95,9 +95,8 @@ namespace TEAMModelOS.Controllers
|
|
}
|
|
}
|
|
}
|
|
}
|
|
request.stuCount = count;
|
|
request.stuCount = count;
|
|
- exam = await client.GetContainer("TEAMModelOS", "Common").CreateItemAsync(request, new PartitionKey($"Exam-{code}"));
|
|
|
|
- string msgId = _snowflakeId.NextId().ToString();
|
|
|
|
- await _serviceBus.GetServiceBusClient().SendLeamMessage<ExamInfo>(Constants.TopicName, request.id, request.code, request.startTime, "going", msgId);
|
|
|
|
|
|
+ exam = await client.GetContainer("TEAMModelOS", "Common").CreateItemAsync(request, new PartitionKey($"{request.code}"));
|
|
|
|
+ await _serviceBus.GetServiceBusClient().SendLeamMessage<ExamInfo>(Constants.TopicName, request.id, request.code, request.startTime);
|
|
//request.sequenceNumber = SequenceNumber;
|
|
//request.sequenceNumber = SequenceNumber;
|
|
}
|
|
}
|
|
else
|
|
else
|
|
@@ -107,13 +106,18 @@ namespace TEAMModelOS.Controllers
|
|
{
|
|
{
|
|
return Ok(new { v = "活动正在进行中" });
|
|
return Ok(new { v = "活动正在进行中" });
|
|
}
|
|
}
|
|
|
|
+ request.progress = info.progress;
|
|
|
|
+ await _serviceBus.GetServiceBusClient().cancelMessage(Constants.TopicName, info.sequenceNumber);
|
|
|
|
+ long SequenceNumber = await _serviceBus.GetServiceBusClient().SendLeamMessage<ExamInfo>(Constants.TopicName, request.id, request.code, request.startTime);
|
|
|
|
+ request.sequenceNumber = SequenceNumber;
|
|
exam = await client.GetContainer("TEAMModelOS", "Common").ReplaceItemAsync(request, request.id, new PartitionKey($"{request.code}"));
|
|
exam = await client.GetContainer("TEAMModelOS", "Common").ReplaceItemAsync(request, request.id, new PartitionKey($"{request.code}"));
|
|
|
|
+ //await _serviceBus.GetServiceBusClient().SendLeamMessage<ExamInfo>(Constants.TopicName, request.id, request.code, request.startTime);
|
|
}
|
|
}
|
|
//Survey homeWork = await _azureCosmos.SaveOrUpdate<Survey>(request.survey);
|
|
//Survey homeWork = await _azureCosmos.SaveOrUpdate<Survey>(request.survey);
|
|
|
|
|
|
//设定结束时间
|
|
//设定结束时间
|
|
- string msgEndId = _snowflakeId.NextId() + "";
|
|
|
|
- await _serviceBus.GetServiceBusClient().SendLeamMessage<ExamInfo>(Constants.TopicName, request.id, request.code, request.endTime, "finish", msgEndId);
|
|
|
|
|
|
+ //string msgEndId = _snowflakeId.NextId() + "";
|
|
|
|
+ await _serviceBus.GetServiceBusClient().SendLeamMessage<ExamInfo>(Constants.TopicName, request.id, request.code, request.endTime);
|
|
return Ok(new{ exam });
|
|
return Ok(new{ exam });
|
|
}
|
|
}
|
|
/// <summary>
|
|
/// <summary>
|
|
@@ -308,116 +312,163 @@ namespace TEAMModelOS.Controllers
|
|
public async Task<IActionResult> upsertRecord(JsonElement request)
|
|
public async Task<IActionResult> upsertRecord(JsonElement request)
|
|
{
|
|
{
|
|
if (!request.TryGetProperty("id", out JsonElement id)) return BadRequest();
|
|
if (!request.TryGetProperty("id", out JsonElement id)) return BadRequest();
|
|
- if (!request.TryGetProperty("code", out JsonElement code)) return BadRequest();
|
|
|
|
|
|
+ //if (!request.TryGetProperty("code", out JsonElement code)) return BadRequest();
|
|
if (!request.TryGetProperty("answer", out JsonElement answer)) return BadRequest();
|
|
if (!request.TryGetProperty("answer", out JsonElement answer)) return BadRequest();
|
|
if (!request.TryGetProperty("studentId", out JsonElement studentId)) return BadRequest();
|
|
if (!request.TryGetProperty("studentId", out JsonElement studentId)) return BadRequest();
|
|
|
|
+ if (!request.TryGetProperty("subjectId", out JsonElement subjectId)) return BadRequest();
|
|
|
|
+ if (!request.TryGetProperty("classId", out JsonElement classId)) return BadRequest();
|
|
if (!request.TryGetProperty("multipleRule", out JsonElement multipleRule)) return BadRequest();
|
|
if (!request.TryGetProperty("multipleRule", out JsonElement multipleRule)) return BadRequest();
|
|
- if (!request.TryGetProperty("answers ", out JsonElement tandardAnswer)) return BadRequest();
|
|
|
|
- if (!request.TryGetProperty("point", out JsonElement point)) return BadRequest();
|
|
|
|
- var client = _azureCosmos.GetCosmosClient();
|
|
|
|
- ExamClassResult classResult = await client.GetContainer("TEAMModelOS", "Common").ReadItemAsync<ExamClassResult>(id.ToString(), new PartitionKey($"{code}"));
|
|
|
|
|
|
+ //if (!request.TryGetProperty("answers ", out JsonElement tandardAnswer)) return BadRequest();
|
|
|
|
+ if (!request.TryGetProperty("paperId", out JsonElement paperId)) return BadRequest();
|
|
|
|
+ if (!request.TryGetProperty("school", out JsonElement school)) return BadRequest();
|
|
|
|
+ var client = _azureCosmos.GetCosmosClient();
|
|
|
|
+ List<ExamClassResult> examClassResults = new List<ExamClassResult>();
|
|
|
|
+ await foreach (var item in client.GetContainer("TEAMModelOS", "Common").GetItemQueryStreamIterator(
|
|
|
|
+ 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}") }))
|
|
|
|
+ {
|
|
|
|
+ using var json = await JsonDocument.ParseAsync(item.ContentStream);
|
|
|
|
+ if (json.RootElement.TryGetProperty("_count", out JsonElement count) && count.GetUInt16() > 0)
|
|
|
|
+ {
|
|
|
|
+ foreach (var obj in json.RootElement.GetProperty("Documents").EnumerateArray())
|
|
|
|
+ {
|
|
|
|
+ examClassResults.Add(obj.ToObject<ExamClassResult>());
|
|
|
|
+ }
|
|
|
|
+ }
|
|
|
|
+ }
|
|
|
|
+ ExamClassResult classResult;
|
|
|
|
+ List<PaperSimple> standerAnswers = new List<PaperSimple>();
|
|
|
|
+ await foreach (var item in client.GetContainer("TEAMModelOS", "Common").GetItemQueryStreamIterator(
|
|
|
|
+ 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($"Exam-{school}") }))
|
|
|
|
+ {
|
|
|
|
+ using var json = await JsonDocument.ParseAsync(item.ContentStream);
|
|
|
|
+ if (json.RootElement.TryGetProperty("_count", out JsonElement count) && count.GetUInt16() > 0)
|
|
|
|
+ {
|
|
|
|
+ foreach (var obj in json.RootElement.GetProperty("Documents").EnumerateArray())
|
|
|
|
+ {
|
|
|
|
+ standerAnswers.Add(obj.ToObject<PaperSimple>());
|
|
|
|
+ }
|
|
|
|
+ }
|
|
|
|
+ }
|
|
List<List<string>> ans = answer.ToObject<List<List<string>>>();
|
|
List<List<string>> ans = answer.ToObject<List<List<string>>>();
|
|
- List<List<string>> standard = tandardAnswer.ToObject<List<List<string>>>();
|
|
|
|
- List<double> points = point.ToObject<List<double>>();
|
|
|
|
- int index = classResult.studentIds.IndexOf(studentId.ToString());
|
|
|
|
|
|
+ List<List<string>> standard = standerAnswers[0].answers;
|
|
|
|
+ List<double> points = standerAnswers[0].point;
|
|
|
|
+ int index = examClassResults[0].studentIds.IndexOf(studentId.ToString());
|
|
int rule = int.Parse(multipleRule.ToString());
|
|
int rule = int.Parse(multipleRule.ToString());
|
|
//classResult.studentAnswers[index] = ans;
|
|
//classResult.studentAnswers[index] = ans;
|
|
|
|
+ if (index == -1) {
|
|
|
|
+ examClassResults[0].studentIds.Add(studentId.ToString());
|
|
|
|
+ examClassResults[0].studentScores.Add(new List<double>());
|
|
|
|
+ examClassResults[0].studentAnswers.Add(new List<List<string>>());
|
|
|
|
+ }
|
|
for (int i = 0;i < ans.Count;i++) {
|
|
for (int i = 0;i < ans.Count;i++) {
|
|
- classResult.studentAnswers[index].Add(ans[i]);
|
|
|
|
|
|
+ examClassResults[0].studentAnswers[index][i] = ans[i];
|
|
//算分处理
|
|
//算分处理
|
|
if (standard[i].Count > 0) {
|
|
if (standard[i].Count > 0) {
|
|
if (ans[i].Count == standard[i].Count && standard[i].Count == 1)
|
|
if (ans[i].Count == standard[i].Count && standard[i].Count == 1)
|
|
{
|
|
{
|
|
- if (ans[i].Equals(standard[i]))
|
|
|
|
- {
|
|
|
|
- classResult.studentScores[index][i] = points[i];
|
|
|
|
- }
|
|
|
|
- else
|
|
|
|
- {
|
|
|
|
- classResult.studentScores[index][i] = 0;
|
|
|
|
|
|
+ foreach (string right in standard[i]) {
|
|
|
|
+ if (standard[i].Contains(right))
|
|
|
|
+ {
|
|
|
|
+ examClassResults[0].studentScores[index][i] = points[i];
|
|
|
|
+ }
|
|
|
|
+ else
|
|
|
|
+ {
|
|
|
|
+ examClassResults[0].studentScores[index][i] = 0;
|
|
|
|
+ }
|
|
}
|
|
}
|
|
|
|
+
|
|
}
|
|
}
|
|
else {
|
|
else {
|
|
- int falseCount = 0;
|
|
|
|
- foreach (string obj in ans[i])
|
|
|
|
- {
|
|
|
|
- if (!standard[i].Contains(obj))
|
|
|
|
|
|
+ if (rule > 0) {
|
|
|
|
+ int falseCount = 0;
|
|
|
|
+ foreach (string obj in ans[i])
|
|
{
|
|
{
|
|
- falseCount++;
|
|
|
|
- }
|
|
|
|
- }
|
|
|
|
- switch (rule)
|
|
|
|
- {
|
|
|
|
- case 1:
|
|
|
|
- if (ans[i].Count == standard[i].Count)
|
|
|
|
|
|
+ if (!standard[i].Contains(obj))
|
|
{
|
|
{
|
|
- if (falseCount == 0)
|
|
|
|
- {
|
|
|
|
- classResult.studentScores[index][i] = points[i];
|
|
|
|
- }
|
|
|
|
- else {
|
|
|
|
- classResult.studentScores[index][i] = 0;
|
|
|
|
- }
|
|
|
|
|
|
+ falseCount++;
|
|
}
|
|
}
|
|
- else
|
|
|
|
- {
|
|
|
|
- classResult.studentScores[index][i] = 0;
|
|
|
|
- }
|
|
|
|
- break;
|
|
|
|
- case 2:
|
|
|
|
- if (falseCount > 0) {
|
|
|
|
- classResult.studentScores[index][i] = 0;
|
|
|
|
- }
|
|
|
|
- else
|
|
|
|
- {
|
|
|
|
|
|
+ }
|
|
|
|
+ switch (rule)
|
|
|
|
+ {
|
|
|
|
+ case 1:
|
|
if (ans[i].Count == standard[i].Count)
|
|
if (ans[i].Count == standard[i].Count)
|
|
{
|
|
{
|
|
- classResult.studentScores[index][i] = points[i];
|
|
|
|
|
|
+ if (falseCount == 0)
|
|
|
|
+ {
|
|
|
|
+ examClassResults[0].studentScores[index][i] = points[i];
|
|
|
|
+ }
|
|
|
|
+ else
|
|
|
|
+ {
|
|
|
|
+ examClassResults[0].studentScores[index][i] = 0;
|
|
|
|
+ }
|
|
}
|
|
}
|
|
- else {
|
|
|
|
- classResult.studentScores[index][i] = points[i] / 2;
|
|
|
|
|
|
+ else
|
|
|
|
+ {
|
|
|
|
+ examClassResults[0].studentScores[index][i] = 0;
|
|
}
|
|
}
|
|
-
|
|
|
|
- }
|
|
|
|
- break;
|
|
|
|
- case 3:
|
|
|
|
- if (falseCount > 0)
|
|
|
|
- {
|
|
|
|
- classResult.studentScores[index][i] = 0;
|
|
|
|
- }
|
|
|
|
- else
|
|
|
|
- {
|
|
|
|
- if (ans[i].Count == standard[i].Count)
|
|
|
|
|
|
+ break;
|
|
|
|
+ case 2:
|
|
|
|
+ if (falseCount > 0)
|
|
{
|
|
{
|
|
- classResult.studentScores[index][i] = points[i];
|
|
|
|
|
|
+ examClassResults[0].studentScores[index][i] = 0;
|
|
}
|
|
}
|
|
else
|
|
else
|
|
{
|
|
{
|
|
- classResult.studentScores[index][i] = System.Math.Round(ans[i].Count / standard[i].Count * points[i],1);
|
|
|
|
|
|
+ if (ans[i].Count == standard[i].Count)
|
|
|
|
+ {
|
|
|
|
+ examClassResults[0].studentScores[index][i] = points[i];
|
|
|
|
+ }
|
|
|
|
+ else
|
|
|
|
+ {
|
|
|
|
+ examClassResults[0].studentScores[index][i] = points[i] / 2;
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ }
|
|
|
|
+ break;
|
|
|
|
+ case 3:
|
|
|
|
+ if (falseCount > 0)
|
|
|
|
+ {
|
|
|
|
+ examClassResults[0].studentScores[index][i] = 0;
|
|
}
|
|
}
|
|
|
|
+ else
|
|
|
|
+ {
|
|
|
|
+ if (ans[i].Count == standard[i].Count)
|
|
|
|
+ {
|
|
|
|
+ examClassResults[0].studentScores[index][i] = points[i];
|
|
|
|
+ }
|
|
|
|
+ else
|
|
|
|
+ {
|
|
|
|
+ examClassResults[0].studentScores[index][i] = System.Math.Round(ans[i].Count / standard[i].Count * points[i], 1);
|
|
|
|
+ }
|
|
|
|
|
|
- }
|
|
|
|
- break;
|
|
|
|
- case 4:
|
|
|
|
- if (ans[i].Count == standard[i].Count)
|
|
|
|
- {
|
|
|
|
- classResult.studentScores[index][i] = points[i];
|
|
|
|
- } else {
|
|
|
|
- double persent = (standard[i].Count - 2 * falseCount) / standard[i].Count;
|
|
|
|
- if (persent <= 0)
|
|
|
|
|
|
+ }
|
|
|
|
+ break;
|
|
|
|
+ case 4:
|
|
|
|
+ if (ans[i].Count == standard[i].Count)
|
|
{
|
|
{
|
|
- classResult.studentScores[index][i] = 0;
|
|
|
|
|
|
+ examClassResults[0].studentScores[index][i] = points[i];
|
|
}
|
|
}
|
|
- else {
|
|
|
|
- classResult.studentScores[index][i] = System.Math.Round(persent * points[i], 1);
|
|
|
|
|
|
+ else
|
|
|
|
+ {
|
|
|
|
+ double persent = (standard[i].Count - 2 * falseCount) / standard[i].Count;
|
|
|
|
+ if (persent <= 0)
|
|
|
|
+ {
|
|
|
|
+ examClassResults[0].studentScores[index][i] = 0;
|
|
|
|
+ }
|
|
|
|
+ else
|
|
|
|
+ {
|
|
|
|
+ examClassResults[0].studentScores[index][i] = System.Math.Round(persent * points[i], 1);
|
|
|
|
+ }
|
|
}
|
|
}
|
|
- }
|
|
|
|
- break;
|
|
|
|
|
|
+ break;
|
|
|
|
+ }
|
|
}
|
|
}
|
|
}
|
|
}
|
|
}
|
|
}
|
|
}
|
|
}
|
|
- classResult = await client.GetContainer("TEAMModelOS", "Common").ReplaceItemAsync(classResult, classResult.id, new PartitionKey($"{classResult.code}"));
|
|
|
|
|
|
+ classResult = await client.GetContainer("TEAMModelOS", "Common").ReplaceItemAsync(examClassResults[0], examClassResults[0].id, new PartitionKey($"{examClassResults[0].code}"));
|
|
return Ok(new { classResult });
|
|
return Ok(new { classResult });
|
|
/*ResponseBuilder builder = ResponseBuilder.custom();
|
|
/*ResponseBuilder builder = ResponseBuilder.custom();
|
|
//要先处理状态,判断卷子是否存在,并判断卷子归属的考试是否允许再次提交
|
|
//要先处理状态,判断卷子是否存在,并判断卷子归属的考试是否允许再次提交
|
|
@@ -452,19 +503,37 @@ namespace TEAMModelOS.Controllers
|
|
if (!request.TryGetProperty("code", out JsonElement code)) return BadRequest();
|
|
if (!request.TryGetProperty("code", out JsonElement code)) return BadRequest();
|
|
if (!request.TryGetProperty("point", out JsonElement point)) return BadRequest();
|
|
if (!request.TryGetProperty("point", out JsonElement point)) return BadRequest();
|
|
if (!request.TryGetProperty("studentId", out JsonElement studentId)) return BadRequest();
|
|
if (!request.TryGetProperty("studentId", out JsonElement studentId)) return BadRequest();
|
|
|
|
+ if (!request.TryGetProperty("classId", out JsonElement classId)) return BadRequest();
|
|
|
|
+ if (!request.TryGetProperty("school", out JsonElement school)) return BadRequest();
|
|
//要先处理状态,判断卷子是否存在,并判断卷子归属的考试是否允许再次提交
|
|
//要先处理状态,判断卷子是否存在,并判断卷子归属的考试是否允许再次提交
|
|
//List<ExamInfo> exams = await _azureCosmos.FindByDict<ExamInfo>(new Dictionary<string, object> { { "id", request.examCode } });
|
|
//List<ExamInfo> exams = await _azureCosmos.FindByDict<ExamInfo>(new Dictionary<string, object> { { "id", request.examCode } });
|
|
List<double> ans = point.ToObject<List<double>>();
|
|
List<double> ans = point.ToObject<List<double>>();
|
|
var client = _azureCosmos.GetCosmosClient();
|
|
var client = _azureCosmos.GetCosmosClient();
|
|
- ExamClassResult classResult = await client.GetContainer("TEAMModelOS", "Common").ReadItemAsync<ExamClassResult>(id.ToString(), new PartitionKey($"{code}"));
|
|
|
|
|
|
+ List<ExamClassResult> examClassResults = new List<ExamClassResult>();
|
|
|
|
+ await foreach (var item in client.GetContainer("TEAMModelOS", "Common").GetItemQueryStreamIterator(
|
|
|
|
+ queryText: $"select value(c) from c where c.examId = '{id}' and c.subjectId = {studentId} and c.info.id = '{classId}'",
|
|
|
|
+ requestOptions: new QueryRequestOptions() { PartitionKey = new PartitionKey($"ExamClassResult-{school}") }))
|
|
|
|
+ {
|
|
|
|
+ using var json = await JsonDocument.ParseAsync(item.ContentStream);
|
|
|
|
+ if (json.RootElement.TryGetProperty("_count", out JsonElement count) && count.GetUInt16() > 0)
|
|
|
|
+ {
|
|
|
|
+ foreach (var obj in json.RootElement.GetProperty("Documents").EnumerateArray())
|
|
|
|
+ {
|
|
|
|
+ examClassResults.Add(obj.ToObject<ExamClassResult>());
|
|
|
|
+ }
|
|
|
|
+ }
|
|
|
|
+ }
|
|
|
|
+ ExamClassResult classResult;
|
|
|
|
+ //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}"));
|
|
/*foreach (double index in ans) {
|
|
/*foreach (double index in ans) {
|
|
classResult.studentScores.in
|
|
classResult.studentScores.in
|
|
}*/
|
|
}*/
|
|
- int index = classResult.studentIds.IndexOf(studentId.ToString());
|
|
|
|
|
|
+ int index = examClassResults[0].studentIds.IndexOf(studentId.ToString());
|
|
for (int i = 0;i < ans.Count;i++) {
|
|
for (int i = 0;i < ans.Count;i++) {
|
|
- classResult.studentScores[index][i] = ans[i];
|
|
|
|
|
|
+ examClassResults[0].studentScores[index][i] = ans[i];
|
|
}
|
|
}
|
|
- classResult = await client.GetContainer("TEAMModelOS", "Common").ReplaceItemAsync(classResult, classResult.id, new PartitionKey($"{classResult.code}"));
|
|
|
|
|
|
+ classResult = await client.GetContainer("TEAMModelOS", "Common").ReplaceItemAsync(examClassResults[0], examClassResults[0].id, new PartitionKey($"{examClassResults[0].code}"));
|
|
return Ok( new { classResult });
|
|
return Ok( new { classResult });
|
|
} catch (Exception ex) {
|
|
} catch (Exception ex) {
|
|
await _dingDing.SendBotMsg($"CoreAPI2,{_option.Location},exam/upsertRecordByTeacher()\n{ex.Message}", GroupNames.醍摩豆服務運維群組);
|
|
await _dingDing.SendBotMsg($"CoreAPI2,{_option.Location},exam/upsertRecordByTeacher()\n{ex.Message}", GroupNames.醍摩豆服務運維群組);
|
|
@@ -492,7 +561,7 @@ namespace TEAMModelOS.Controllers
|
|
}
|
|
}
|
|
|
|
|
|
/// <summary>
|
|
/// <summary>
|
|
- /// 查询作答摘要信息
|
|
|
|
|
|
+ /// 查询评测详细信息(教师或者学生通用)
|
|
/// </summary>
|
|
/// </summary>
|
|
/// <param name="request"></param>
|
|
/// <param name="request"></param>
|
|
/// <returns></returns>
|
|
/// <returns></returns>
|
|
@@ -512,7 +581,8 @@ namespace TEAMModelOS.Controllers
|
|
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("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 from c where c.examId = '{id}' and c.subjectId = '{subjectId}'", requestOptions: new QueryRequestOptions() { PartitionKey = new PartitionKey($"ExamClassResult-{code}") }))
|
|
|
|
|
|
+ await foreach (var item in client.GetContainer("TEAMModelOS", "Common").GetItemQueryStreamIterator(queryText: $"select c.id, c.code,c.info,c.studentIds,c.studentAnswers from c where c.examId = '{id}' and c.subjectId = '{subjectId}'",
|
|
|
|
+ requestOptions: new QueryRequestOptions() { PartitionKey = new PartitionKey($"ExamClassResult-{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)
|
|
@@ -568,9 +638,10 @@ namespace TEAMModelOS.Controllers
|
|
}
|
|
}
|
|
|
|
|
|
}
|
|
}
|
|
|
|
+ //学生端查询评测列表
|
|
[ProducesDefaultResponseType]
|
|
[ProducesDefaultResponseType]
|
|
//[AuthToken(Roles = "Student")]
|
|
//[AuthToken(Roles = "Student")]
|
|
- [HttpPost("find-by-student")]
|
|
|
|
|
|
+ [HttpPost("find-summary-by-student")]
|
|
public async Task<IActionResult> findSummaryStudent(JsonElement requert)
|
|
public async Task<IActionResult> findSummaryStudent(JsonElement requert)
|
|
{
|
|
{
|
|
//ResponseBuilder builder = ResponseBuilder.custom();
|
|
//ResponseBuilder builder = ResponseBuilder.custom();
|
|
@@ -578,11 +649,87 @@ namespace TEAMModelOS.Controllers
|
|
try
|
|
try
|
|
{
|
|
{
|
|
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();
|
|
|
|
+ if (!requert.TryGetProperty("studentId", out JsonElement studentId)) return BadRequest();
|
|
|
|
+ if (!requert.TryGetProperty("school", out JsonElement school)) return BadRequest();
|
|
|
|
+ var client = _azureCosmos.GetCosmosClient();
|
|
|
|
+ var query = $"select c.id,c.code,A0.id paperId,A0.code paperCode,A0.name paperName,A0.multipleRule,A0.scope,A0.blob from c join A0 in c.papers where c.id ='{id}' and c.progress = 'going'";
|
|
|
|
+ List<object> props = new List<object>();
|
|
|
|
+ await foreach (var item in client.GetContainer("TEAMModelOS", "Common").GetItemQueryStreamIterator(queryText:query, requestOptions: new QueryRequestOptions() { PartitionKey = new PartitionKey($"{code}") }))
|
|
|
|
+ {
|
|
|
|
+ using var json = await JsonDocument.ParseAsync(item.ContentStream);
|
|
|
|
+ if (json.RootElement.TryGetProperty("_count", out JsonElement count) && count.GetUInt16() > 0)
|
|
|
|
+ {
|
|
|
|
+ foreach (var obj in json.RootElement.GetProperty("Documents").EnumerateArray())
|
|
|
|
+ {
|
|
|
|
+ props.Add(obj.ToObject<object>());
|
|
|
|
+ }
|
|
|
|
+ }
|
|
|
|
+ }
|
|
|
|
+ var querySubject = $"select c.subjects from c where c.id ='{id}' and c.progress = 'going'";
|
|
|
|
+ //List<object> props = new List<object>();
|
|
|
|
+ await foreach (var item in client.GetContainer("TEAMModelOS", "Common").GetItemQueryStreamIterator(queryText: querySubject, requestOptions: new QueryRequestOptions() { PartitionKey = new PartitionKey($"{code}") }))
|
|
|
|
+ {
|
|
|
|
+ using var json = await JsonDocument.ParseAsync(item.ContentStream);
|
|
|
|
+ if (json.RootElement.TryGetProperty("_count", out JsonElement count) && count.GetUInt16() > 0)
|
|
|
|
+ {
|
|
|
|
+ foreach (var obj in json.RootElement.GetProperty("Documents").EnumerateArray())
|
|
|
|
+ {
|
|
|
|
+ props.Add(obj.ToObject<object>());
|
|
|
|
+ }
|
|
|
|
+ }
|
|
|
|
+ }
|
|
|
|
+ var queryAnswers = $"select c.id,c.code,c.studentIds,c.subjectId,c.studentAnswers from c where c.examId ='{id}' and c.progress = 'going' and array_contains(c.studentIds,'{studentId}')";
|
|
|
|
+ List<ExamClassResult> answers = new List<ExamClassResult>();
|
|
|
|
+ await foreach (var item in client.GetContainer("TEAMModelOS", "Common").GetItemQueryStreamIterator(queryText: queryAnswers,
|
|
|
|
+ requestOptions: new QueryRequestOptions() { PartitionKey = new PartitionKey($"ExamClassResult-{school}") }))
|
|
|
|
+ {
|
|
|
|
+ using var json = await JsonDocument.ParseAsync(item.ContentStream);
|
|
|
|
+ if (json.RootElement.TryGetProperty("_count", out JsonElement count) && count.GetUInt16() > 0)
|
|
|
|
+ {
|
|
|
|
+ foreach (var obj in json.RootElement.GetProperty("Documents").EnumerateArray())
|
|
|
|
+ {
|
|
|
|
+ answers.Add(obj.ToObject<ExamClassResult>());
|
|
|
|
+ }
|
|
|
|
+ }
|
|
|
|
+ }
|
|
|
|
+ List<List<List<string>>> stuAns = new List<List<List<string>>>();
|
|
|
|
+ if (answers.Count > 0) {
|
|
|
|
+ for (int i = 0; i < answers.Count; i++)
|
|
|
|
+ {
|
|
|
|
+ int index = answers[i].studentIds.IndexOf(studentId.ToString());
|
|
|
|
+ if (index == -1) {
|
|
|
|
+ break;
|
|
|
|
+ }
|
|
|
|
+ stuAns.Add(answers[i].studentAnswers[index]);
|
|
|
|
+ }
|
|
|
|
+ }
|
|
|
|
+ return Ok(new { props , stuAns});
|
|
|
|
+ }
|
|
|
|
+ catch (Exception ex)
|
|
|
|
+ {
|
|
|
|
+ await _dingDing.SendBotMsg($"CoreAPI2,{_option.Location},exam/find-summary-by-student()\n{ex.Message}", GroupNames.醍摩豆服務運維群組);
|
|
|
|
+ return BadRequest();
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ //查询学生活动列表
|
|
|
|
+ [ProducesDefaultResponseType]
|
|
|
|
+ //[AuthToken(Roles = "Student")]
|
|
|
|
+ [HttpPost("find-all-by-student")]
|
|
|
|
+ public async Task<IActionResult> findAllStudent(JsonElement requert)
|
|
|
|
+ {
|
|
|
|
+ //ResponseBuilder builder = ResponseBuilder.custom();
|
|
|
|
+ //var (id, school) = HttpContext.GetAuthTokenInfo();
|
|
|
|
+ try
|
|
|
|
+ {
|
|
|
|
+ if (!requert.TryGetProperty("id", out JsonElement id)) return BadRequest();
|
|
|
|
+ //if (!requert.TryGetProperty("code", out JsonElement code)) return BadRequest();
|
|
var client = _azureCosmos.GetCosmosClient();
|
|
var client = _azureCosmos.GetCosmosClient();
|
|
- var query = $"select c.id,c.code,c.startTime,c.stuCount,c.type,c.progress from c where array_contains(c.targetClassIds,'{id}') and c.progress = 'going'";
|
|
|
|
|
|
+ var query = $"select c.id,c.code,c.name,c.startTime,c.endTime,c.type,c.progress,c.school from c where array_contains(c.targetClassIds,'{id}') and c.progress = 'going'";
|
|
List<object> props = new List<object>();
|
|
List<object> props = new List<object>();
|
|
- await foreach (var item in client.GetContainer("TEAMModelOS", "Common").GetItemQueryStreamIterator(queryText:query, requestOptions: new QueryRequestOptions() { PartitionKey = new PartitionKey($"ExamRecord-{code}") }))
|
|
|
|
|
|
+ await foreach (var item in client.GetContainer("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)
|
|
@@ -593,16 +740,20 @@ namespace TEAMModelOS.Controllers
|
|
}
|
|
}
|
|
}
|
|
}
|
|
}
|
|
}
|
|
-
|
|
|
|
|
|
+
|
|
return Ok(props);
|
|
return Ok(props);
|
|
}
|
|
}
|
|
catch (Exception ex)
|
|
catch (Exception ex)
|
|
{
|
|
{
|
|
- await _dingDing.SendBotMsg($"CoreAPI2,{_option.Location},exam/find-by-student()\n{ex.Message}", GroupNames.醍摩豆服務運維群組);
|
|
|
|
|
|
+ await _dingDing.SendBotMsg($"CoreAPI2,{_option.Location},exam/find-all-by-student\n{ex.Message}", GroupNames.醍摩豆服務運維群組);
|
|
return BadRequest();
|
|
return BadRequest();
|
|
}
|
|
}
|
|
|
|
|
|
}
|
|
}
|
|
|
|
+ private class StanderAnswers {
|
|
|
|
+ List<List<string>> standard { get; set; }
|
|
|
|
+ List<double> points { get; set; }
|
|
|
|
+ }
|
|
/// <summary>
|
|
/// <summary>
|
|
/// 查询单个作答信息 试卷id ,
|
|
/// 查询单个作答信息 试卷id ,
|
|
/// </summary>
|
|
/// </summary>
|