|
@@ -1251,6 +1251,30 @@ namespace TEAMModelOS.Controllers
|
|
|
var client = _azureCosmos.GetCosmosClient();
|
|
|
ExamInfo info = await client.GetContainer("TEAMModelOS", "Common").ReadItemAsync<ExamInfo>(id.ToString(), new PartitionKey($"Exam-{code}"));
|
|
|
info.progress = "finish";
|
|
|
+ info.endTime = DateTimeOffset.UtcNow.ToUnixTimeMilliseconds();
|
|
|
+ List<ExamClassResult> classResults = new();
|
|
|
+ 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}'",
|
|
|
+ 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}'",
|
|
|
+ requestOptions: new QueryRequestOptions() { PartitionKey = new PartitionKey($"ExamClassResult-{info.creatorId}") }))
|
|
|
+ {
|
|
|
+ classResults.Add(item);
|
|
|
+ }
|
|
|
+ }
|
|
|
+ foreach (ExamClassResult examClass in classResults) {
|
|
|
+ examClass.progress = true;
|
|
|
+ await client.GetContainer("TEAMModelOS", "Common").ReplaceItemAsync(examClass, examClass.id, new PartitionKey($"{examClass.code}"));
|
|
|
+ }
|
|
|
info = await client.GetContainer("TEAMModelOS", "Common").ReplaceItemAsync(info, info.id, new PartitionKey($"Exam-{code}"));
|
|
|
return Ok(info);
|
|
|
}
|