|
@@ -69,17 +69,14 @@ namespace TEAMModelOS.Controllers
|
|
|
//if (!HttpContext.Items.TryGetValue("Scope", out object _scope)) return BadRequest();
|
|
|
(List<StuActivity> datas, string continuationToken) = await ActivityStudentService.FindActivity(request, id, school, _azureCosmos, _azureRedis);
|
|
|
List<(string id, string scope, string name, string source, List<string> cIds, int qamode, string createId, Dictionary<string, JsonElement> ext,long time,string owner)> eIds = new();
|
|
|
- List<(string id, string scope, string name, List<string> cIds, string createId,long time)> wIds = new();
|
|
|
+ //List<(string id, string scope, string name, List<string> cIds, string createId,long time)> wIds = new();
|
|
|
foreach (var data in datas)
|
|
|
{
|
|
|
if (data.type.Equals("Exam"))
|
|
|
{
|
|
|
eIds.Add((data.id, data.scope, data.name, data.source, data.classIds, data.qamode, data.creatorId, data.ext,data.createTime,data.owner));
|
|
|
}
|
|
|
- if (data.type.Equals("Homework"))
|
|
|
- {
|
|
|
- wIds.Add((data.id, data.scope, data.name, data.classIds, data.creatorId,data.createTime));
|
|
|
- }
|
|
|
+
|
|
|
}
|
|
|
var client = _azureCosmos.GetCosmosClient();
|
|
|
List<(string eId, string sub, string cId, string cname, List<string> sIds, List<double> sum)> classResults = await getExamClassResult(eIds,client);
|
|
@@ -96,9 +93,29 @@ namespace TEAMModelOS.Controllers
|
|
|
e.owner,
|
|
|
result = classResults.Where(c => c.eId == e.id).Select(s => new { s.sub, s.cId, s.cname, s.sum, s.sIds })
|
|
|
});
|
|
|
- var result = exam.Where(e => e.result.Any());
|
|
|
-
|
|
|
+ var result = exam.Where(e => e.result.Any());
|
|
|
+ return Ok(new { result, continuationToken });
|
|
|
+ }
|
|
|
|
|
|
+ [ProducesDefaultResponseType]
|
|
|
+ [HttpPost("stu-hw-score")]
|
|
|
+ [Authorize(Roles = "IES")]
|
|
|
+ [AuthToken(Roles = "teacher,student,admin")]
|
|
|
+ public async Task<IActionResult> StuHwScore(JsonElement request)
|
|
|
+ {
|
|
|
+ var (id, name, pic, school) = HttpContext.GetAuthTokenInfo();
|
|
|
+ //if (!HttpContext.Items.TryGetValue("Scope", out object _scope)) return BadRequest();
|
|
|
+ (List<StuActivity> datas, string continuationToken) = await ActivityStudentService.FindActivity(request, id, school, _azureCosmos, _azureRedis);
|
|
|
+ //List<(string id, string scope, string name, string source, List<string> cIds, int qamode, string createId, Dictionary<string, JsonElement> ext, long time, string owner)> eIds = new();
|
|
|
+ List<(string id, string scope, string name, List<string> cIds, string createId, long time)> wIds = new();
|
|
|
+ foreach (var data in datas)
|
|
|
+ {
|
|
|
+ if (data.type.Equals("Homework"))
|
|
|
+ {
|
|
|
+ wIds.Add((data.id, data.scope, data.name, data.classIds, data.creatorId, data.createTime));
|
|
|
+ }
|
|
|
+ }
|
|
|
+ var client = _azureCosmos.GetCosmosClient();
|
|
|
string partitionKey = String.Empty;
|
|
|
if (string.IsNullOrWhiteSpace(id))
|
|
|
{
|
|
@@ -115,7 +132,7 @@ namespace TEAMModelOS.Controllers
|
|
|
{
|
|
|
partitionKey = $"HomeworkRecord-{school}-{id}";
|
|
|
}
|
|
|
- List<(string id,double score, List<HomeworkComment> comments)> work = new();
|
|
|
+ List<(string id, double score, List<HomeworkComment> comments)> work = new();
|
|
|
await foreach (var item in client.GetContainer(Constant.TEAMModelOS, "Student").GetItemQueryStreamIterator(
|
|
|
queryText: $"select c.id,c.score,c.comments from c where c.id in ({string.Join(",", wIds.Select(o => $"'{o.id}'"))})",
|
|
|
requestOptions: new QueryRequestOptions() { PartitionKey = new PartitionKey(partitionKey) }))
|
|
@@ -132,29 +149,30 @@ namespace TEAMModelOS.Controllers
|
|
|
if (account.TryGetProperty("score", out JsonElement score))
|
|
|
{
|
|
|
sc = score.GetDouble();
|
|
|
- if (sc == -1) {
|
|
|
+ if (sc == -1)
|
|
|
+ {
|
|
|
sc = 0;
|
|
|
}
|
|
|
}
|
|
|
if (account.TryGetProperty("comments", out JsonElement comments))
|
|
|
{
|
|
|
- hc = comments.ToObject<List<HomeworkComment>>();
|
|
|
+ hc = comments.ToObject<List<HomeworkComment>>();
|
|
|
}
|
|
|
|
|
|
work.Add((account.GetProperty("id").GetString(), sc, hc));
|
|
|
}
|
|
|
}
|
|
|
}
|
|
|
- var works = wIds.Select(w => new {
|
|
|
+ var works = wIds.Select(w => new {
|
|
|
w.id,
|
|
|
w.name,
|
|
|
w.cIds,
|
|
|
w.createId,
|
|
|
w.time,
|
|
|
- score = work.Where(x => x.id == w.id ).Select(s => new { s.score,s.comments})
|
|
|
+ score = work.Where(x => x.id == w.id).Select(s => new { s.score, s.comments })
|
|
|
});
|
|
|
|
|
|
- return Ok(new { result, works, continuationToken });
|
|
|
+ return Ok(new {works, continuationToken });
|
|
|
}
|
|
|
|
|
|
private async Task<List<(string eId, string sub, string cId, string cname, List<string> sIds, List<double> sum)>> getExamClassResult(List<(string id, string scope, string name, string source, List<string> cIds, int qamode, string createId, Dictionary<string, JsonElement> ext, long time, string owner)> eIds, CosmosClient client) {
|