|
@@ -1573,7 +1573,7 @@ namespace TEAMModelOS.Controllers
|
|
|
{
|
|
|
recs.Add(new { stuId = rcd.Name.ToString(), ans = value });
|
|
|
}
|
|
|
- if (string.IsNullOrEmpty(tmdId.ToString()))
|
|
|
+ if (string.IsNullOrEmpty(tmdId.ToString()))
|
|
|
{
|
|
|
all.Add(new { stuId = rcd.Name.ToString(), ans = value });
|
|
|
}
|
|
@@ -1594,11 +1594,12 @@ namespace TEAMModelOS.Controllers
|
|
|
{
|
|
|
if (recs.Count == count.GetInt32())
|
|
|
{
|
|
|
- return Ok( new { msg = "分配人数已到上限"});
|
|
|
+ return Ok(new { msg = "分配人数已到上限" });
|
|
|
}
|
|
|
else
|
|
|
{
|
|
|
- if (all.Count == 0) {
|
|
|
+ if (all.Count == 0)
|
|
|
+ {
|
|
|
return Ok(new { msg = "暂无可选学生" });
|
|
|
}
|
|
|
//随机选取一名学生打分
|
|
@@ -1616,40 +1617,42 @@ namespace TEAMModelOS.Controllers
|
|
|
await redisClient.HashSetAsync($"Exam:Scoring:{id}-{subjectId}", sId.ToString(), new { ans = blob, score = sc, tmdId = tId }.ToJsonString());
|
|
|
return Ok(item);
|
|
|
}
|
|
|
-
|
|
|
+
|
|
|
}
|
|
|
|
|
|
//var json = JsonDocument.Parse(record);
|
|
|
- /*if (info.scope.Equals("school"))
|
|
|
- {
|
|
|
-
|
|
|
- await foreach (var item in client.GetContainer("TEAMModelOS", "Common").GetItemQueryIterator<ExamClassResult>(
|
|
|
- queryText: $"select value(c) from c where c.examId = '{id}' and c.subjectId = '{subjectId}'",
|
|
|
- requestOptions: new QueryRequestOptions() { PartitionKey = new PartitionKey($"ExamClassResult-{info.school}") }))
|
|
|
- {
|
|
|
- classResults.Add(item);
|
|
|
- }
|
|
|
- }
|
|
|
- else
|
|
|
- {
|
|
|
- await foreach (var item in client.GetContainer("TEAMModelOS", "Common").GetItemQueryIterator<ExamClassResult>(
|
|
|
- queryText: $"select value(c) from c where c.examId = '{id}' and c.subjectId = '{subjectId}'",
|
|
|
- requestOptions: new QueryRequestOptions() { PartitionKey = new PartitionKey($"ExamClassResult-{info.creatorId}") }))
|
|
|
- {
|
|
|
- classResults.Add(item);
|
|
|
- }
|
|
|
- }
|
|
|
- List<Task<bool>> tasks = new List<Task<bool>>();
|
|
|
- foreach (ExamClassResult examClass in classResults)
|
|
|
- {
|
|
|
- foreach (string stuId in examClass.studentIds)
|
|
|
- {
|
|
|
- int index = examClass.studentIds.IndexOf(stuId);
|
|
|
- tasks.Add(redisClient.HashSetAsync($"Exam:Scoring:{id}-{subjectId}", stuId, new { ans = examClass.studentAnswers[index].Count > 0 ? examClass.studentAnswers[index][0]: "", score = examClass.studentScores[index] }.ToJsonString()));
|
|
|
- }
|
|
|
-
|
|
|
- }
|
|
|
- await Task.WhenAll(tasks);*/
|
|
|
+ /*ExamInfo info = await client.GetContainer("TEAMModelOS", "Common").ReadItemAsync<ExamInfo>(id.ToString(), new Azure.Cosmos.PartitionKey($"Exam-hbcn"));
|
|
|
+ if (info.scope.Equals("school"))
|
|
|
+ {
|
|
|
+
|
|
|
+ await foreach (var item in client.GetContainer("TEAMModelOS", "Common").GetItemQueryIterator<ExamClassResult>(
|
|
|
+ queryText: $"select value(c) from c where c.examId = '{id}' and c.subjectId = '{subjectId}'",
|
|
|
+ requestOptions: new QueryRequestOptions() { PartitionKey = new PartitionKey($"ExamClassResult-{info.school}") }))
|
|
|
+ {
|
|
|
+ classResults.Add(item);
|
|
|
+ }
|
|
|
+ }
|
|
|
+ else
|
|
|
+ {
|
|
|
+ await foreach (var item in client.GetContainer("TEAMModelOS", "Common").GetItemQueryIterator<ExamClassResult>(
|
|
|
+ queryText: $"select value(c) from c where c.examId = '{id}' and c.subjectId = '{subjectId}'",
|
|
|
+ requestOptions: new QueryRequestOptions() { PartitionKey = new PartitionKey($"ExamClassResult-{info.creatorId}") }))
|
|
|
+ {
|
|
|
+ classResults.Add(item);
|
|
|
+ }
|
|
|
+ }
|
|
|
+ List<Task<bool>> tasks = new List<Task<bool>>();
|
|
|
+ foreach (ExamClassResult examClass in classResults)
|
|
|
+ {
|
|
|
+ foreach (string stuId in examClass.studentIds)
|
|
|
+ {
|
|
|
+ int index = examClass.studentIds.IndexOf(stuId);
|
|
|
+ tasks.Add(redisClient.HashSetAsync($"Exam:Scoring:{id}-{subjectId}", stuId, new { ans = examClass.studentAnswers[index].Count > 0 ? examClass.studentAnswers[index][0] : "", score = examClass.studentScores[index] }.ToJsonString()));
|
|
|
+ }
|
|
|
+
|
|
|
+ }
|
|
|
+ await Task.WhenAll(tasks);
|
|
|
+ return Ok();*/
|
|
|
//info = await client.GetContainer("TEAMModelOS", "Common").ReplaceItemAsync(info, info.id, new PartitionKey($"Exam-{code}"));
|
|
|
}
|
|
|
catch (Exception ex)
|