|
@@ -629,6 +629,7 @@ namespace TEAMModelOS.Controllers
|
|
|
if (!requert.TryGetProperty("id", out JsonElement id)) 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>();
|
|
@@ -643,9 +644,9 @@ namespace TEAMModelOS.Controllers
|
|
|
}
|
|
|
}
|
|
|
}
|
|
|
- var querySubject = $"select A0.id subjectId,A0.name subjectName from c join A0 in c.subjects where c.id ='{id}' and c.progress = 'going'";
|
|
|
+ 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: query, requestOptions: new QueryRequestOptions() { PartitionKey = new PartitionKey($"{code}") }))
|
|
|
+ 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)
|
|
@@ -655,22 +656,33 @@ namespace TEAMModelOS.Controllers
|
|
|
props.Add(obj.ToObject<object>());
|
|
|
}
|
|
|
}
|
|
|
- }
|
|
|
- /*var queryAnswers = $"select c.id,c.code from c where c.examid ='{id}' and c.progress = 'going' and c.subjectId";
|
|
|
- List<object> answers = 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)
|
|
|
+ }
|
|
|
+ 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++)
|
|
|
{
|
|
|
- foreach (var obj in json.RootElement.GetProperty("Documents").EnumerateArray())
|
|
|
- {
|
|
|
- answers.Add(obj.ToObject<object>());
|
|
|
+ int index = answers[i].studentIds.IndexOf(studentId.ToString());
|
|
|
+ if (index == -1) {
|
|
|
+ break;
|
|
|
}
|
|
|
+ stuAns.Add(answers[i].studentAnswers[index]);
|
|
|
}
|
|
|
- }*/
|
|
|
-
|
|
|
- return Ok(props);
|
|
|
+ }
|
|
|
+ return Ok(new { props , stuAns});
|
|
|
}
|
|
|
catch (Exception ex)
|
|
|
{
|
|
@@ -693,7 +705,7 @@ namespace TEAMModelOS.Controllers
|
|
|
if (!requert.TryGetProperty("id", out JsonElement id)) return BadRequest();
|
|
|
//if (!requert.TryGetProperty("code", out JsonElement code)) return BadRequest();
|
|
|
var client = _azureCosmos.GetCosmosClient();
|
|
|
- var query = $"select c.id,c.code,c.name,c.startTime,c.endTime,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>();
|
|
|
await foreach (var item in client.GetContainer("TEAMModelOS", "Common").GetItemQueryStreamIterator(queryText: query))
|
|
|
{
|