|
@@ -33,7 +33,91 @@ namespace IES.ExamServer.Controllers
|
|
|
_connectionService=connectionService;
|
|
|
_liteDBFactory=liteDBFactory;
|
|
|
}
|
|
|
+ /// <summary>
|
|
|
+ /// 学生提交音乐作答
|
|
|
+ /// </summary>
|
|
|
+ /// <param name="json"></param>
|
|
|
+ /// <returns></returns>
|
|
|
+ [HttpPost("submit-music-ai-result")]
|
|
|
+ [AuthToken("student")]
|
|
|
+ public IActionResult SubmitMusicAIResult(JsonNode json)
|
|
|
+ {
|
|
|
+ int finished = int.Parse($"{json["finished"]}");
|
|
|
+ string evaluationId = $"{json["evaluationId"]}";
|
|
|
+ string taskId = $"{json["taskId"]}";
|
|
|
+ string questionId = $"{json["questionId"]}";
|
|
|
+ long costTime = int.Parse($"{json["costTime"]}");
|
|
|
+ string settingId = $"{json["settingId"]}";
|
|
|
+ var token = GetAuthTokenInfo();
|
|
|
+ EvaluationRoundSetting? setting = _liteDBFactory.GetLiteDatabase().GetCollection<EvaluationRoundSetting>().FindOne(x => x.id!.Equals(settingId) && evaluationId.Equals(x.evaluationId) && x.activate==1);
|
|
|
+ EvaluationClient? evaluationClient = _liteDBFactory.GetLiteDatabase().GetCollection<EvaluationClient>().FindOne(x => evaluationId.Equals(x.id));
|
|
|
+ if (evaluationClient!=null && setting!=null && setting.activate==1)
|
|
|
+ {
|
|
|
+ string resultId = ShaHashHelper.GetSHA1(evaluationId+_connectionService?.serverDevice?.school?.id+token.id);
|
|
|
+ EvaluationStudentResult studentResult = _liteDBFactory.GetLiteDatabase().GetCollection<EvaluationStudentResult>()
|
|
|
+ .FindOne(x => resultId.Equals(x.id) && token.id.Equals(x.studentId) && evaluationId.Equals(x.evaluationId));
|
|
|
+ if (studentResult!=null)
|
|
|
+ {
|
|
|
+ long now = DateTimeOffset.Now.ToUnixTimeMilliseconds();
|
|
|
+ //判断开始时间
|
|
|
+ if ((setting.startline>0 && setting.startline>now)|| evaluationClient.stime>now)
|
|
|
+ {
|
|
|
+ //未到开始时间
|
|
|
+ return Ok(new { msg = "未到开始时间。", code = 1 });
|
|
|
+ }
|
|
|
+
|
|
|
+ //判断截止时间
|
|
|
+ long deadline;
|
|
|
+ if (setting.countdownType==2)
|
|
|
+ {
|
|
|
+
|
|
|
+ deadline= studentResult.startTime+setting.countdown;
|
|
|
+ }
|
|
|
+ else
|
|
|
+ {
|
|
|
+ deadline= setting.startline+setting.countdown;
|
|
|
|
|
|
+ }
|
|
|
+ deadline+= 10*60*1000;//漂移10分钟,允许学生延迟提交,但是前端页面显示的截止时间是准的,时间一到,可自动提交。
|
|
|
+ //已过截止时间
|
|
|
+ //if ((deadline>0&&deadline<now)|| evaluationClient.etime<now)
|
|
|
+ //{
|
|
|
+ // return Ok(new { msg = "已过截止时间。", code = 2 });
|
|
|
+ //}
|
|
|
+ if (!string.IsNullOrWhiteSpace(questionId) && !string.IsNullOrWhiteSpace(taskId) && costTime>0)
|
|
|
+ {
|
|
|
+ var result = new EvaluationMusicAIResult()
|
|
|
+ {
|
|
|
+ taskId = taskId,
|
|
|
+ questionId = questionId,
|
|
|
+ costTime = costTime,
|
|
|
+ finished = finished,
|
|
|
+ submitTime = now,
|
|
|
+ questionName=!string.IsNullOrWhiteSpace(evaluationClient?.music?.questionName) ? evaluationClient.music.questionName : null,
|
|
|
+ evaluationId=evaluationId,
|
|
|
+ createTime=now,
|
|
|
+ pushed=0//强制重新推送
|
|
|
+ };
|
|
|
+ studentResult.musicAIResult= result;
|
|
|
+ _liteDBFactory.GetLiteDatabase().GetCollection<EvaluationMusicAIResult>().Upsert(result);
|
|
|
+ _liteDBFactory.GetLiteDatabase().GetCollection<EvaluationStudentResult>().Upsert(studentResult);
|
|
|
+ return Ok(new { code = 200, studentResult = studentResult, msg = "提交成功!" });
|
|
|
+ }
|
|
|
+ else
|
|
|
+ {
|
|
|
+ return Ok(new { msg = "提交失败,请检查参数。", code = 3 });
|
|
|
+ }
|
|
|
+ }
|
|
|
+ else
|
|
|
+ {
|
|
|
+ return Ok(new { msg = "未找到该学生的作答信息。", code = 4 });
|
|
|
+ }
|
|
|
+ }
|
|
|
+ else {
|
|
|
+ return Ok(new { msg = "未匹配到正则开考的评测。", code = 5 });
|
|
|
+ }
|
|
|
+
|
|
|
+ }
|
|
|
/// <summary>
|
|
|
/// 学生提交科目作答
|
|
|
/// </summary>
|
|
@@ -48,7 +132,7 @@ namespace IES.ExamServer.Controllers
|
|
|
string examId = $"{json["examId"]}";
|
|
|
string subjectId = $"{json["subjectId"]}";
|
|
|
string paperId = $"{json["paperId"]}";
|
|
|
- int costTime = int.Parse($"{json["costTime"]}");
|
|
|
+ long costTime = int.Parse($"{json["costTime"]}");
|
|
|
string settingId = $"{json["settingId"]}";
|
|
|
var token = GetAuthTokenInfo();
|
|
|
EvaluationRoundSetting? setting = _liteDBFactory.GetLiteDatabase().GetCollection<EvaluationRoundSetting>().FindOne(x => x.id!.Equals(settingId) && evaluationId.Equals(x.evaluationId) && x.activate==1);
|
|
@@ -81,11 +165,12 @@ namespace IES.ExamServer.Controllers
|
|
|
|
|
|
}
|
|
|
deadline+= 10*60*1000;//漂移10分钟,允许学生延迟提交,但是前端页面显示的截止时间是准的,时间一到,可自动提交。
|
|
|
- if ((deadline>0&&deadline<now)|| evaluationClient.etime<now)
|
|
|
- {
|
|
|
- //已过截止时间
|
|
|
- return Ok(new { msg = "已过截止时间。", code = 2 });
|
|
|
- }
|
|
|
+ //已过截止时间
|
|
|
+ //if ((deadline>0&&deadline<now)|| evaluationClient.etime<now)
|
|
|
+ //{
|
|
|
+
|
|
|
+ // return Ok(new { msg = "已过截止时间。", code = 2 });
|
|
|
+ //}
|
|
|
if (!string.IsNullOrWhiteSpace(subjectId) && !string.IsNullOrWhiteSpace(examId) && !string.IsNullOrWhiteSpace(paperId)&& costTime>0)
|
|
|
{
|
|
|
|
|
@@ -226,7 +311,7 @@ namespace IES.ExamServer.Controllers
|
|
|
{
|
|
|
if (evaluationId.Equals(member.evaluationId))
|
|
|
{
|
|
|
- string x_auth_token = JwtAuthExtension.CreateAuthToken("www.teammodel.cn", studentId, studentName, picture: string.Empty, ExamConstant.JwtSecretKey, ExamConstant.ScopeStudent, 8, schoolID: school?.id, new string[] { "student" }, expire: 1);
|
|
|
+ string x_auth_token = JwtAuthExtension.CreateAuthToken("www.teammodel.cn", studentId, studentName, picture: string.Empty, ExamConstant.JwtSecretKey, ExamConstant.ScopeStudent, 8, schoolID: school?.id, new string[] { "student" },expire: 1, year: member.year);
|
|
|
return Ok(new { code = 200, x_auth_token = x_auth_token });
|
|
|
}
|
|
|
else
|