|
@@ -1525,25 +1525,6 @@ namespace TEAMModelOS.Controllers
|
|
|
{
|
|
|
attr.Add(item);
|
|
|
}
|
|
|
- /*var record = await redisClient.HashGetAllAsync($"Exam:Scoring:{id}-{subjectId}");
|
|
|
- foreach (var rcd in record)
|
|
|
- {
|
|
|
- var value = JsonDocument.Parse(rcd.Value.ToString());
|
|
|
- value.RootElement.TryGetProperty("info", out JsonElement json);
|
|
|
- List<tmdInfo> tmds = json.ToObject<List<tmdInfo>>();
|
|
|
- foreach (tmdInfo tmd in tmds)
|
|
|
- {
|
|
|
- if (!string.IsNullOrEmpty(tmd.tmdId) && tmd.tmdId.Equals(tId.ToString()))
|
|
|
- {
|
|
|
- attr.Add(new { stuId = rcd.Name.ToString(), info = value });
|
|
|
- break;
|
|
|
- }
|
|
|
- }
|
|
|
- *//* if (tId.ToString().Equals(tmdId.ToString()))
|
|
|
- {
|
|
|
- attr.Add(new { stuId = rcd.Name.ToString(), info = value });
|
|
|
- }*//*
|
|
|
- }*/
|
|
|
int index = 0;
|
|
|
foreach (ExamSubject subject in info.subjects)
|
|
|
{
|
|
@@ -1561,20 +1542,15 @@ namespace TEAMModelOS.Controllers
|
|
|
return Ok(new { attr, paper = info.papers[index].blob });
|
|
|
}*/
|
|
|
List<SDK.Models.Cosmos.Common.Scoring> errs = new();
|
|
|
- List<SDK.Models.Cosmos.Common.Scoring> arbs = new();
|
|
|
+ //List<SDK.Models.Cosmos.Common.Scoring> arbs = new();
|
|
|
foreach (SDK.Models.Cosmos.Common.Scoring ss in attr)
|
|
|
{
|
|
|
- List<Qs> qs = ss.qs.Where(s => !string.IsNullOrEmpty(s.err)).ToList();
|
|
|
- if (qs.Count > 0) {
|
|
|
- ss.qs = qs;
|
|
|
- errs.Add(ss);
|
|
|
- }
|
|
|
- List<Item> arb = ss.items.Where(s => s.flag == false).ToList();
|
|
|
+/* List<Item> arb = ss.items.Where(s => s.flag == false).ToList();
|
|
|
if (arb.Count > 0)
|
|
|
{
|
|
|
ss.items = arb;
|
|
|
arbs.Add(ss);
|
|
|
- }
|
|
|
+ }*/
|
|
|
//var obj = new { stuId = ss.stuId, examId = ss.examId, subjectId = ss.subjectId, };
|
|
|
//ss.items.Add(ss.items.Where(x => x.scores.))
|
|
|
//var scc = ss.items.SelectMany(p => p.scores, (p, d) => new { p.ssc, d.sc, d.tmdId }).Where(x => x.tmdId.Equals(tId.GetString())).Select(m => new { m.sc ,m.ssc});
|
|
@@ -1599,7 +1575,125 @@ namespace TEAMModelOS.Controllers
|
|
|
var obj = new { ss.id,ss.stuId, ss.examId, ss.subjectId, item = sc,ss.qs, ss.blob, ss.tIds, ss.marks, ss.scores, ss.model, ss.mode };
|
|
|
objs.Add(obj);
|
|
|
}
|
|
|
- return Ok(new { errs, arbs, objs, paper = info.papers[index].blob });
|
|
|
+ return Ok(new { errs, objs, paper = info.papers[index].blob });
|
|
|
+ }
|
|
|
+ catch (Exception ex)
|
|
|
+ {
|
|
|
+ await _dingDing.SendBotMsg($"OS,{_option.Location},exam/scoring\n{ex.Message}", GroupNames.醍摩豆服務運維群組);
|
|
|
+ return BadRequest();
|
|
|
+ }
|
|
|
+
|
|
|
+ }
|
|
|
+ //查找异常卷
|
|
|
+ [ProducesDefaultResponseType]
|
|
|
+ //[AuthToken(Roles = "Student")]
|
|
|
+ [HttpPost("find-err")]
|
|
|
+ public async Task<IActionResult> findErr(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();
|
|
|
+ if (!requert.TryGetProperty("subjectId", out JsonElement subjectId)) return BadRequest();
|
|
|
+ //if (!requert.TryGetProperty("tmdId", out JsonElement tId)) return BadRequest();
|
|
|
+ var client = _azureCosmos.GetCosmosClient();
|
|
|
+ ExamInfo info = await client.GetContainer("TEAMModelOS", "Common").ReadItemAsync<ExamInfo>(id.ToString(), new PartitionKey($"Exam-{code}"));
|
|
|
+ List<ExamClassResult> classResults = new();
|
|
|
+ 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>(
|
|
|
+ queryText: $"select value(c) from c where c.examId = '{id}' and c.subjectId = '{subjectId}'",
|
|
|
+ requestOptions: new QueryRequestOptions() { PartitionKey = new PartitionKey($"Scoring-{code}") }))
|
|
|
+ {
|
|
|
+ attr.Add(item);
|
|
|
+ }
|
|
|
+ int index = 0;
|
|
|
+ foreach (ExamSubject subject in info.subjects)
|
|
|
+ {
|
|
|
+ if (!subject.id.Equals(subjectId.ToString()))
|
|
|
+ {
|
|
|
+ index++;
|
|
|
+ }
|
|
|
+ else
|
|
|
+ {
|
|
|
+ break;
|
|
|
+ }
|
|
|
+ }
|
|
|
+ List<dynamic> objs = new List<dynamic>();
|
|
|
+
|
|
|
+ List<SDK.Models.Cosmos.Common.Scoring> errs = new();
|
|
|
+ foreach (SDK.Models.Cosmos.Common.Scoring ss in attr)
|
|
|
+ {
|
|
|
+ List<Qs> qs = ss.qs.Where(s => !string.IsNullOrEmpty(s.err)).ToList();
|
|
|
+ if (qs.Count > 0)
|
|
|
+ {
|
|
|
+ ss.qs = qs;
|
|
|
+ errs.Add(ss);
|
|
|
+ }
|
|
|
+ }
|
|
|
+ return Ok(new { errs, paper = info.papers[index].blob });
|
|
|
+ }
|
|
|
+ catch (Exception ex)
|
|
|
+ {
|
|
|
+ await _dingDing.SendBotMsg($"OS,{_option.Location},exam/scoring\n{ex.Message}", GroupNames.醍摩豆服務運維群組);
|
|
|
+ return BadRequest();
|
|
|
+ }
|
|
|
+
|
|
|
+ }
|
|
|
+ [ProducesDefaultResponseType]
|
|
|
+ //[AuthToken(Roles = "Student")]
|
|
|
+ [HttpPost("find-arb")]
|
|
|
+ public async Task<IActionResult> findArb(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();
|
|
|
+ if (!requert.TryGetProperty("subjectId", out JsonElement subjectId)) return BadRequest();
|
|
|
+ //if (!requert.TryGetProperty("type", out JsonElement type)) return BadRequest();
|
|
|
+ //if (!requert.TryGetProperty("tmdId", out JsonElement tId)) return BadRequest();
|
|
|
+ var client = _azureCosmos.GetCosmosClient();
|
|
|
+ long time = DateTimeOffset.UtcNow.ToUnixTimeMilliseconds();
|
|
|
+ ExamInfo info = await client.GetContainer("TEAMModelOS", "Common").ReadItemAsync<ExamInfo>(id.ToString(), new PartitionKey($"Exam-{code}"));
|
|
|
+ List<ExamClassResult> classResults = new();
|
|
|
+ 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>(
|
|
|
+ queryText: $"select value(c) from c where c.examId = '{id}' and c.subjectId = '{subjectId}' and c.endTime < {time}",
|
|
|
+ requestOptions: new QueryRequestOptions() { PartitionKey = new PartitionKey($"Scoring-{code}") }))
|
|
|
+ {
|
|
|
+ attr.Add(item);
|
|
|
+ }
|
|
|
+ int index = 0;
|
|
|
+ foreach (ExamSubject subject in info.subjects)
|
|
|
+ {
|
|
|
+ if (!subject.id.Equals(subjectId.ToString()))
|
|
|
+ {
|
|
|
+ index++;
|
|
|
+ }
|
|
|
+ else
|
|
|
+ {
|
|
|
+ break;
|
|
|
+ }
|
|
|
+ }
|
|
|
+ List<dynamic> objs = new List<dynamic>();
|
|
|
+ /*if (type.GetInt32() != 1) {
|
|
|
+ return Ok(new { attr, paper = info.papers[index].blob });
|
|
|
+ }*/
|
|
|
+ //List<SDK.Models.Cosmos.Common.Scoring> errs = new();
|
|
|
+ List<SDK.Models.Cosmos.Common.Scoring> arbs = new();
|
|
|
+ foreach (SDK.Models.Cosmos.Common.Scoring ss in attr)
|
|
|
+ {
|
|
|
+ List<Item> arb = ss.items.Where(s => s.flag == false).ToList();
|
|
|
+ if (arb.Count > 0)
|
|
|
+ {
|
|
|
+ ss.items = arb;
|
|
|
+ arbs.Add(ss);
|
|
|
+ }
|
|
|
+ }
|
|
|
+ return Ok(new {objs, paper = info.papers[index].blob });
|
|
|
}
|
|
|
catch (Exception ex)
|
|
|
{
|
|
@@ -2112,7 +2206,7 @@ namespace TEAMModelOS.Controllers
|
|
|
return Ok(attr);
|
|
|
}
|
|
|
|
|
|
- //查询阅卷类型数据
|
|
|
+ //处理异常卷内容
|
|
|
[ProducesDefaultResponseType]
|
|
|
//[AuthToken(Roles = "Student")]
|
|
|
[HttpPost("save-err")]
|
|
@@ -2147,6 +2241,48 @@ namespace TEAMModelOS.Controllers
|
|
|
return Ok( new { sc });
|
|
|
}
|
|
|
|
|
|
+ //处理仲裁卷内容
|
|
|
+ [ProducesDefaultResponseType]
|
|
|
+ //[AuthToken(Roles = "Student")]
|
|
|
+ [HttpPost("save-arb")]
|
|
|
+ public async Task<IActionResult> saveArb(JsonElement requert)
|
|
|
+ {
|
|
|
+ if (!requert.TryGetProperty("id", out JsonElement id)) return BadRequest();
|
|
|
+ if (!requert.TryGetProperty("score", out JsonElement score)) return BadRequest();
|
|
|
+ if (!requert.TryGetProperty("code", out JsonElement code)) return BadRequest();
|
|
|
+ var client = _azureCosmos.GetCosmosClient();
|
|
|
+ List<double> scs = score.ToObject<List<double>>();
|
|
|
+ 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}"));
|
|
|
+ if (null != scoring)
|
|
|
+ {
|
|
|
+ scoring.scores = scs;
|
|
|
+ await foreach (var item in client.GetContainer("TEAMModelOS", "Common").GetItemQueryIterator<ExamClassResult>(
|
|
|
+ queryText: $"select value(c) from c where c.examId = '{id}' and c.subjectId = '{scoring.subjectId}'",
|
|
|
+ requestOptions: new QueryRequestOptions() { PartitionKey = new PartitionKey($"ExamClassResult-{code}") }))
|
|
|
+ {
|
|
|
+ classResults.Add(item);
|
|
|
+ }
|
|
|
+ foreach (ExamClassResult exam in classResults)
|
|
|
+ {
|
|
|
+ int index = exam.studentIds.IndexOf(scoring.stuId);
|
|
|
+ if (index != -1)
|
|
|
+ {
|
|
|
+ exam.studentScores[index] = scoring.scores;
|
|
|
+ exam.mark[index] = scoring.marks;
|
|
|
+ }
|
|
|
+
|
|
|
+ await client.GetContainer("TEAMModelOS", "Common").ReplaceItemAsync(exam, exam.id, new PartitionKey($"{exam.code}"));
|
|
|
+ }
|
|
|
+ }
|
|
|
+ else
|
|
|
+ {
|
|
|
+ return Ok(new { code = 404 });
|
|
|
+ }
|
|
|
+ var sc = await client.GetContainer("TEAMModelOS", "Teacher").ReplaceItemAsync(scoring, scoring.id, new PartitionKey($"{scoring.code}"));
|
|
|
+ return Ok(new { sc });
|
|
|
+ }
|
|
|
+
|
|
|
//阅卷信息统计
|
|
|
[ProducesDefaultResponseType]
|
|
|
//[AuthToken(Roles = "Student")]
|