|
|
|
@ -554,10 +554,23 @@ public class Ghre_ExamRecordServices : BaseServices<Ghre_ExamRecord, Ghre_ExamRe |
|
|
|
|
extend.ExamStatus = record.Status; |
|
|
|
|
extend.TotalScore = record.TotalScore; |
|
|
|
|
extend.Id = record.Id; |
|
|
|
|
extend.CourseName = record.CourseName; |
|
|
|
|
extend.CanRetake = true; |
|
|
|
|
|
|
|
|
|
if (extend.ExamStatus == "ExamEnd") |
|
|
|
|
extend.ScoreOut = false; |
|
|
|
|
|
|
|
|
|
TimeSpan timeDifference = record.EndTime.Value - DateTime.Now; |
|
|
|
|
extend.RemainingSecond = Convert.ToInt32(timeDifference.TotalSeconds); |
|
|
|
|
if (extend.RemainingSecond < 0) extend.RemainingSecond = 0; |
|
|
|
|
|
|
|
|
|
if (record.ActualEndTime != null) |
|
|
|
|
{ |
|
|
|
|
timeDifference = record.ActualEndTime.Value - record.ActualBeginTime.Value; |
|
|
|
|
|
|
|
|
|
extend.UsageTime = $"{timeDifference.Minutes}分{timeDifference.Seconds}秒"; |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
return ServiceResult<QueryExam>.OprateSuccess("查询成功!", extend); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
@ -593,6 +606,25 @@ public class Ghre_ExamRecordServices : BaseServices<Ghre_ExamRecord, Ghre_ExamRe |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
public async Task<ServiceResult> RetakeExamAsync(long examRecordId) |
|
|
|
|
{ |
|
|
|
|
var entity = await base.QuerySingle(examRecordId); |
|
|
|
|
|
|
|
|
|
if (entity is null) |
|
|
|
|
return ServiceResult.OprateFailed("无效的考试ID!"); |
|
|
|
|
|
|
|
|
|
if (entity.Status == "ExamEnd") |
|
|
|
|
entity.Status = "Examing"; |
|
|
|
|
|
|
|
|
|
entity.RetakeTimes = entity.RetakeTimes is null ? 1 : entity.RetakeTimes + 1; |
|
|
|
|
|
|
|
|
|
await Update(entity, new List<string>() |
|
|
|
|
{ |
|
|
|
|
"Status","RetakeTimes" |
|
|
|
|
}); |
|
|
|
|
|
|
|
|
|
return ServiceResult.OprateSuccess("成功!"); |
|
|
|
|
} |
|
|
|
|
public async Task<ServiceResult> AnswerExamAsync(List<DefaultGhre_ExamPaperPreview> answers, long studyRecordId) |
|
|
|
|
{ |
|
|
|
|
var record = await base.QuerySingle(x => x.Id == studyRecordId); |
|
|
|
@ -690,8 +722,21 @@ public class Ghre_ExamRecordServices : BaseServices<Ghre_ExamRecord, Ghre_ExamRe |
|
|
|
|
|
|
|
|
|
await _context.Ghre_ExamRecordDetail.AddRangeAsync(recordDetails); |
|
|
|
|
await _context.Ghre_ExamRecordAnswer.AddRangeAsync(recordDetailAnswers); |
|
|
|
|
|
|
|
|
|
await _context.SaveChangesAsync(); |
|
|
|
|
|
|
|
|
|
record.Status = "ExamEnd"; |
|
|
|
|
record.ActualEndTime = DateTime.Now; |
|
|
|
|
|
|
|
|
|
#region 打分 |
|
|
|
|
if (record.ScoreStatus == "NoScore" && record.Status == "ExamEnd") |
|
|
|
|
await ExamHelper.SystemMarkAsync(Db, record, recordDetails, recordDetailAnswers); |
|
|
|
|
_context.Ghre_ExamRecordDetail.UpdateRange(recordDetails); |
|
|
|
|
_context.Ghre_ExamRecordAnswer.UpdateRange(recordDetailAnswers); |
|
|
|
|
await _context.SaveChangesAsync(); |
|
|
|
|
#endregion |
|
|
|
|
|
|
|
|
|
await Update(record, new List<string> { "Status", "Score", "ActualEndTime" }, null, $"Id='{record.Id}'"); |
|
|
|
|
return ServiceResult.OprateSuccess("提交成功!"); |
|
|
|
|
} |
|
|
|
|
} |