|
@@ -423,18 +423,17 @@ namespace TEAMModelOS.Controllers.Learn
|
|
|
{
|
|
|
//作答记录
|
|
|
case bool when $"{_opt}".Equals("AnswerRecord", StringComparison.OrdinalIgnoreCase):
|
|
|
- if (!request.TryGetProperty("userid", out JsonElement _userid)) return BadRequest();
|
|
|
- if (!request.TryGetProperty("userType", out JsonElement _userType)) return BadRequest();
|
|
|
-
|
|
|
- string partition = $"HomeworkRecord-{userid}";
|
|
|
- if ($"{_userType}".Equals("student"))
|
|
|
- {
|
|
|
- request.TryGetProperty("userSchool", out JsonElement _userSchool);
|
|
|
- partition = $"HomeworkRecord-{_userSchool}-{userid}";
|
|
|
- }
|
|
|
-
|
|
|
try
|
|
|
- {
|
|
|
+ { // userType 为student 时,userid 为校内账号,且userSchool 需要有学校编码。
|
|
|
+ //userType 为tmdid 时,userid 为醍摩豆账号,且userSchool 可以为空。
|
|
|
+ if (!request.TryGetProperty("userid", out JsonElement _userid)) return BadRequest();
|
|
|
+ if (!request.TryGetProperty("userType", out JsonElement _userType)) return BadRequest();
|
|
|
+ string partition = $"HomeworkRecord-{_userid}";
|
|
|
+ if ($"{_userType}".Equals("student"))
|
|
|
+ {
|
|
|
+ request.TryGetProperty("userSchool", out JsonElement _userSchool);
|
|
|
+ partition = $"HomeworkRecord-{_userSchool}-{_userid}";
|
|
|
+ }
|
|
|
HomeworkRecord record = await client.GetContainer(Constant.TEAMModelOS, tbname).ReadItemAsync<HomeworkRecord>($"{_id}", new PartitionKey(partition));
|
|
|
await client.GetContainer(Constant.TEAMModelOS, tbname).ReplaceItemAsync<HomeworkRecord>(record, $"{_id}", new PartitionKey(partition));
|
|
|
return Ok(new { record });
|
|
@@ -479,13 +478,15 @@ namespace TEAMModelOS.Controllers.Learn
|
|
|
pk = "HomeworkRecord",
|
|
|
ttl = -1,
|
|
|
time = now,
|
|
|
- submitCount = 1
|
|
|
+ submitCount = 1,
|
|
|
+ comid = Guid.NewGuid().ToString()
|
|
|
};
|
|
|
record = await client.GetContainer(Constant.TEAMModelOS, tbname).CreateItemAsync<HomeworkRecord>(record, new PartitionKey(partitionKey));
|
|
|
taskStatus = 1;
|
|
|
msgid = 1;
|
|
|
}
|
|
|
}
|
|
|
+ //TODO TODO TODO TODO TODO TODO TODO TODO TODO TODO TODO TODO TODO TODO TODO TODO
|
|
|
try
|
|
|
{
|
|
|
if ($"{_scope}".Equals(Constant.ScopeStudent)) {
|
|
@@ -516,11 +517,25 @@ namespace TEAMModelOS.Controllers.Learn
|
|
|
return Ok(new { msgid, taskStatus ,error =400});
|
|
|
}
|
|
|
//评论
|
|
|
- case bool when $"{_opt}".Equals("Comment", StringComparison.OrdinalIgnoreCase):
|
|
|
+ case bool when $"{_opt}".Equals("CommentAndStar", StringComparison.OrdinalIgnoreCase):
|
|
|
try
|
|
|
{
|
|
|
- string partitionkey = "";
|
|
|
- HomeworkRecord record = await client.GetContainer(Constant.TEAMModelOS, tbname).ReadItemAsync<HomeworkRecord>($"{_id}", new PartitionKey(partitionkey));
|
|
|
+
|
|
|
+ // userType 为student 时,userid 为校内账号,且userSchool 需要有学校编码。
|
|
|
+ //userType 为tmdid 时,userid 为醍摩豆账号,且userSchool 可以为空。
|
|
|
+ if (!request.TryGetProperty("userid", out JsonElement __userid)) return BadRequest();
|
|
|
+ if (!request.TryGetProperty("userType", out JsonElement __userType)) return BadRequest();
|
|
|
+ string _partition = $"HomeworkRecord-{__userid}";
|
|
|
+ if ($"{__userType}".Equals("student"))
|
|
|
+ {
|
|
|
+ request.TryGetProperty("userSchool", out JsonElement _userSchool);
|
|
|
+ _partition = $"HomeworkRecord-{_userSchool}-{__userid}";
|
|
|
+ }
|
|
|
+ if (!request.TryGetProperty("comment", out JsonElement _comment)) return BadRequest();
|
|
|
+ if (!request.TryGetProperty("star", out JsonElement _star)) return BadRequest();
|
|
|
+ HomeworkRecord record = await client.GetContainer(Constant.TEAMModelOS, tbname).ReadItemAsync<HomeworkRecord>($"{_id}", new PartitionKey(_partition));
|
|
|
+ ///话题对象,id为学生的作答记录的comid ,根据scope确定, code 为Debate-{schoolId},作业活动所在的学校编码|Debate-{teacherId},作业活动所在的教师编码
|
|
|
+
|
|
|
return Ok(new { error = 404 });
|
|
|
}
|
|
|
catch (CosmosException ex)
|
|
@@ -533,12 +548,21 @@ namespace TEAMModelOS.Controllers.Learn
|
|
|
//打分
|
|
|
case bool when $"{_opt}".Equals("MarkScore", StringComparison.OrdinalIgnoreCase):
|
|
|
try
|
|
|
- {
|
|
|
- string pkey = "";
|
|
|
- HomeworkRecord record = await client.GetContainer(Constant.TEAMModelOS, tbname).ReadItemAsync<HomeworkRecord>($"{_id}", new PartitionKey(pkey));
|
|
|
+ {
|
|
|
+ // userType 为student 时,userid 为校内账号,且userSchool 需要有学校编码。
|
|
|
+ //userType 为tmdid 时,userid 为醍摩豆账号,且userSchool 可以为空。
|
|
|
+ if (!request.TryGetProperty("userid", out JsonElement __userid)) return BadRequest();
|
|
|
+ if (!request.TryGetProperty("userType", out JsonElement __userType)) return BadRequest();
|
|
|
+ string _partition = $"HomeworkRecord-{__userid}";
|
|
|
+ if ($"{__userType}".Equals("student"))
|
|
|
+ {
|
|
|
+ request.TryGetProperty("userSchool", out JsonElement _userSchool);
|
|
|
+ _partition = $"HomeworkRecord-{_userSchool}-{__userid}";
|
|
|
+ }
|
|
|
+ HomeworkRecord record = await client.GetContainer(Constant.TEAMModelOS, tbname).ReadItemAsync<HomeworkRecord>($"{_id}", new PartitionKey(_partition));
|
|
|
if (!request.TryGetProperty("score", out JsonElement _score)) return BadRequest();
|
|
|
record.score = double.Parse($"{_score}");
|
|
|
- await client.GetContainer(Constant.TEAMModelOS, tbname).ReplaceItemAsync<HomeworkRecord>(record, $"{_id}", new PartitionKey(pkey));
|
|
|
+ await client.GetContainer(Constant.TEAMModelOS, tbname).ReplaceItemAsync<HomeworkRecord>(record, $"{_id}", new PartitionKey(_partition));
|
|
|
return Ok(new { status = true });
|
|
|
}
|
|
|
catch (CosmosException ex)
|