|
@@ -42,6 +42,7 @@ using DocumentFormat.OpenXml.Office2013.Excel;
|
|
|
using Hotline.Share.Enums.Exams;
|
|
|
using DocumentFormat.OpenXml.Wordprocessing;
|
|
|
using Hotline.Repository.SqlSugar.Exam.Repositories.ExamManages;
|
|
|
+using Hotline.Exams.Questions;
|
|
|
|
|
|
namespace Hotline.Application.Exam.Service.ExamManages
|
|
|
{
|
|
@@ -90,17 +91,24 @@ namespace Hotline.Application.Exam.Service.ExamManages
|
|
|
public async Task<ExamQuestionDto> GetExamQuestionDto(ExamQuestionRequest examQuestionRequest)
|
|
|
{
|
|
|
var expression = examQuestionRequest.GetExpression();
|
|
|
- var quesetion = await new ExamRepository<Exams.ExamManages.ExamQuestionBak>(_uow, _dataPermissionFilterBuilder, _serviceProvider).Queryable().Where(expression).FirstAsync();
|
|
|
+ var question = await new ExamRepository<Exams.ExamManages.ExamQuestionBak>(_uow, _dataPermissionFilterBuilder, _serviceProvider).Queryable().Where(expression).FirstAsync();
|
|
|
|
|
|
- if (quesetion != null)
|
|
|
+ if (question != null)
|
|
|
{
|
|
|
- var examQuestionDto = _mapper.Map<ExamQuestionDto>(quesetion);
|
|
|
+ var examQuestionDto = _mapper.Map<ExamQuestionDto>(question);
|
|
|
+
|
|
|
+ var questionScore = await new ExamRepository<ExamQuestionScoreBak>(_uow, _dataPermissionFilterBuilder, _serviceProvider).GetAsync(x=>x.QuestionType == question.QuestionType);
|
|
|
+
|
|
|
+ if (questionScore != null)
|
|
|
+ {
|
|
|
+ examQuestionDto.Score = questionScore.Score;
|
|
|
+ }
|
|
|
|
|
|
if (examQuestionDto.QuestionType.CheckSelectType())
|
|
|
{
|
|
|
- var questionOptions = await new ExamRepository<ExamQuestionOptionsBak>(_uow, _dataPermissionFilterBuilder, _serviceProvider).Queryable().Where(x => x.ExamQuestionId == quesetion.Id).ToListAsync();
|
|
|
+ var questionOptions = await new ExamRepository<ExamQuestionOptionsBak>(_uow, _dataPermissionFilterBuilder, _serviceProvider).Queryable().Where(x => x.ExamQuestionId == question.Id).ToListAsync();
|
|
|
|
|
|
- List<ExamUserExamItemOptions> userItemItemOptions = await GetUserExteamItemOptios(quesetion);
|
|
|
+ List<ExamUserExamItemOptions> userItemItemOptions = await GetUserExteamItemOptios(question);
|
|
|
|
|
|
if (questionOptions != null)
|
|
|
{
|
|
@@ -163,7 +171,7 @@ namespace Hotline.Application.Exam.Service.ExamManages
|
|
|
var userItemItemOptions = await userExamItemOptionsTable
|
|
|
.InnerJoin(userExamItemTable, (o, u) => o.UserExamItemId == u.Id)
|
|
|
.InnerJoin(userExamTable, (o, u, e) => u.UserExamId == e.Id)
|
|
|
- .Where((o, u, e) => u.QuestionId == quesetion.QuestionId && e.UserId == _sessionContext.UserId).
|
|
|
+ .Where((o, u, e) => u.QuestionId == quesetion.QuestionId && e.UserId == _sessionContext.UserId && e.ExamStatus == EExamStatus.Executing).
|
|
|
Select((o, u, e) => o).ToListAsync();
|
|
|
return userItemItemOptions;
|
|
|
}
|
|
@@ -320,7 +328,7 @@ namespace Hotline.Application.Exam.Service.ExamManages
|
|
|
{
|
|
|
await UpdateExamAsync(_userExamItemRepository, updateUserExamItemDto, cancellationToken);
|
|
|
}
|
|
|
-
|
|
|
+
|
|
|
await CalcuteExamItemScore(_userExamItemRepository, updateUserExamItemDto, cancellationToken);
|
|
|
|
|
|
return startExamViewResponse;
|
|
@@ -344,7 +352,7 @@ namespace Hotline.Application.Exam.Service.ExamManages
|
|
|
IsJoin = false
|
|
|
};
|
|
|
|
|
|
- if (userExam.StartTime == null)
|
|
|
+ if (userExam.StartTime == null || userExam.ExamStatus == EExamStatus.Complete)
|
|
|
userExam.StartTime = DateTime.Now;
|
|
|
|
|
|
var startExamViewResponse = await CheckExamValid(userExam, cancellationToken);
|
|
@@ -365,6 +373,11 @@ namespace Hotline.Application.Exam.Service.ExamManages
|
|
|
await _repository.UpdateWithValidateAsync(userExam, cancellationToken);
|
|
|
|
|
|
}
|
|
|
+ // TODO: 删除之前选项和答案
|
|
|
+ else
|
|
|
+ {
|
|
|
+ await ReExam(userExam, cancellationToken);
|
|
|
+ }
|
|
|
var examManage = await _examManageRepository.GetAsync(x => x.Id == userExam.ExamId);
|
|
|
|
|
|
return new StartExamViewResponse
|
|
@@ -375,6 +388,29 @@ namespace Hotline.Application.Exam.Service.ExamManages
|
|
|
};
|
|
|
}
|
|
|
|
|
|
+ /// <summary>
|
|
|
+ /// 重考
|
|
|
+ /// </summary>
|
|
|
+ /// <param name="userExam"></param>
|
|
|
+ /// <param name="cancellationToken"></param>
|
|
|
+ /// <returns></returns>
|
|
|
+ private async Task ReExam(ExamUserExam userExam, CancellationToken cancellationToken)
|
|
|
+ {
|
|
|
+ //新增重考记录
|
|
|
+ var reExamUserExam = _mapper.Map<ExamUserExam, ExamUserExam>(userExam);
|
|
|
+
|
|
|
+ reExamUserExam.IsCheck = false;
|
|
|
+ reExamUserExam.IsSubmit = false;
|
|
|
+ reExamUserExam.IsSuccess = false;
|
|
|
+ reExamUserExam.IsReExam = true;
|
|
|
+ reExamUserExam.Score = 0;
|
|
|
+ reExamUserExam.ExamStatus = EExamStatus.Executing;
|
|
|
+
|
|
|
+ reExamUserExam.ToInsert(_sessionContext);
|
|
|
+
|
|
|
+ await _repository.AddWithValidateAsync(reExamUserExam, cancellationToken);
|
|
|
+ }
|
|
|
+
|
|
|
private async Task<StartExamViewResponse> CheckExamValid(ExamUserExam examUserExam, CancellationToken cancellationToken)
|
|
|
{
|
|
|
|
|
@@ -719,7 +755,7 @@ namespace Hotline.Application.Exam.Service.ExamManages
|
|
|
public async Task<GradingResultPageViewResponse> GetGradingResultPagedList(GradingPagedRequest gradingPagedRequest)
|
|
|
{
|
|
|
// 只要有阅卷记录就在已阅卷列表中,已阅卷和未阅卷会有重复数据,只有所有记录都已阅卷才会从未阅卷列表中排除
|
|
|
- var userExamTable = _repository.Queryable().Where(x=>x.IsSubmit);
|
|
|
+ var userExamTable = _repository.Queryable().Where(x => x.IsSubmit);
|
|
|
|
|
|
var examManageTable = new ExamRepository<ExamManage>(_uow, _dataPermissionFilterBuilder, _serviceProvider).Queryable();
|
|
|
|
|
@@ -1264,7 +1300,7 @@ namespace Hotline.Application.Exam.Service.ExamManages
|
|
|
Status = u.Status,
|
|
|
SortIndex = u.SortIndex,
|
|
|
ExamStatus = u.ExamStatus,
|
|
|
- IsSuccess = u.IsCheck? u.IsSuccess:null,
|
|
|
+ IsSuccess = u.IsCheck ? u.IsSuccess : null,
|
|
|
EndTime = e.EndTime,
|
|
|
StartTime = e.StartTime,
|
|
|
TimeSpan = e.TimeSpan,
|