|
@@ -106,12 +106,12 @@ namespace Hotline.Application.Exam.Service.ExamManages
|
|
|
{
|
|
|
var examQuestionDto = _mapper.Map<ExamQuestionDto>(question);
|
|
|
|
|
|
- var questionScore = await new ExamRepository<ExamQuestionScoreBak>(_uow, _dataPermissionFilterBuilder, _serviceProvider).GetAsync(x=>x.QuestionType == question.QuestionType && x.ExamManageId == question.ExamId);
|
|
|
+ var questionScore = await new ExamRepository<ExamQuestionScoreBak>(_uow, _dataPermissionFilterBuilder, _serviceProvider).GetAsync(x => x.QuestionType == question.QuestionType && x.ExamManageId == question.ExamId);
|
|
|
|
|
|
if (questionScore != null)
|
|
|
{
|
|
|
examQuestionDto.Score = questionScore.Score;
|
|
|
- }
|
|
|
+ }
|
|
|
|
|
|
if (examQuestionDto.QuestionType.CheckSelectType())
|
|
|
{
|
|
@@ -383,7 +383,7 @@ namespace Hotline.Application.Exam.Service.ExamManages
|
|
|
|
|
|
}
|
|
|
// TODO: 删除之前选项和答案
|
|
|
- else if(userExam.ExamStatus == EExamStatus.Complete)
|
|
|
+ else if (userExam.ExamStatus == EExamStatus.Complete)
|
|
|
{
|
|
|
await ReExam(userExam, cancellationToken);
|
|
|
}
|
|
@@ -646,9 +646,9 @@ namespace Hotline.Application.Exam.Service.ExamManages
|
|
|
return gradingExamQuestionDtos;
|
|
|
}
|
|
|
|
|
|
- private ISugarQueryable<GradingExamQuestionTempDto> GetViewExamQuestionTempDtos(Expression<Func<ExamUserExam,bool>> expression)
|
|
|
+ private ISugarQueryable<GradingExamQuestionTempDto> GetViewExamQuestionTempDtos(Expression<Func<ExamUserExam, bool>> expression)
|
|
|
{
|
|
|
-
|
|
|
+
|
|
|
var userExamTable = _repository.Queryable().Where(expression);
|
|
|
|
|
|
var questionScoreRepository = new ExamRepository<ExamQuestionScoreBak>(_uow, _dataPermissionFilterBuilder, _serviceProvider);
|
|
@@ -662,7 +662,7 @@ namespace Hotline.Application.Exam.Service.ExamManages
|
|
|
var questionScoreTable = questionScoreRepository.Queryable();
|
|
|
|
|
|
return userExamTable.InnerJoin(userExamItemTable, (e, i) => e.Id == i.UserExamId)
|
|
|
- .InnerJoin(questionTable, (e, i, q) => i.QuestionId == q.QuestionId && q.ExamId == e.ExamId )
|
|
|
+ .InnerJoin(questionTable, (e, i, q) => i.QuestionId == q.QuestionId && q.ExamId == e.ExamId)
|
|
|
.LeftJoin(userExamItemOptionTable, (e, i, q, o) => i.Id == o.UserExamItemId)
|
|
|
.LeftJoin(quesitonOptionTable, (e, i, q, o, qo) => o.QuestionOptionId == qo.Id)
|
|
|
.LeftJoin(examAnswerTable, (e, i, q, o, qo, a) => i.Id == a.UserExamItemId)
|
|
@@ -700,8 +700,8 @@ namespace Hotline.Application.Exam.Service.ExamManages
|
|
|
|
|
|
public async Task<UnExamUserPageViewResponse> GetUnExamUsers(UnExamUserReportPagedRequest unExamUserReportPagedRequest)
|
|
|
{
|
|
|
- if(unExamUserReportPagedRequest.EndTime == null)
|
|
|
- unExamUserReportPagedRequest.ResolveEndTime();
|
|
|
+ if (unExamUserReportPagedRequest.EndTime == null)
|
|
|
+ unExamUserReportPagedRequest.ResolveEndTime();
|
|
|
|
|
|
var examManageRepository = new ExamRepository<ExamManage>(_uow, _dataPermissionFilterBuilder, _serviceProvider);
|
|
|
var userRepository = new ExamRepository<User>(_uow, _dataPermissionFilterBuilder, _serviceProvider);
|
|
@@ -719,7 +719,9 @@ namespace Hotline.Application.Exam.Service.ExamManages
|
|
|
ExamName = e.Name,
|
|
|
OrgName = u.Organization.Name,
|
|
|
UserName = u.Name
|
|
|
- });
|
|
|
+ })
|
|
|
+ .MergeTable()
|
|
|
+ .OrderByPropertyNameIF(!string.IsNullOrEmpty(unExamUserReportPagedRequest.SortField), unExamUserReportPagedRequest.SortField, (OrderByType)(unExamUserReportPagedRequest.SortRule ?? 0));
|
|
|
|
|
|
var total = await queryResult.CountAsync();
|
|
|
var items = await queryResult.ToPageListAsync(unExamUserReportPagedRequest.PageIndex, unExamUserReportPagedRequest.PageSize);
|
|
@@ -734,8 +736,8 @@ namespace Hotline.Application.Exam.Service.ExamManages
|
|
|
|
|
|
public async Task<UserExamResultPageViewResponse> GetUserExamResults(UserExamResultReportPagedRequest userExamResultReportPagedRequest)
|
|
|
{
|
|
|
- if(userExamResultReportPagedRequest.EndTime == null)
|
|
|
- userExamResultReportPagedRequest.ResolveEndTime();
|
|
|
+ if (userExamResultReportPagedRequest.EndTime == null)
|
|
|
+ userExamResultReportPagedRequest.ResolveEndTime();
|
|
|
|
|
|
var examManageRepository = new ExamRepository<ExamManage>(_uow, _dataPermissionFilterBuilder, _serviceProvider);
|
|
|
var userRepository = new ExamRepository<User>(_uow, _dataPermissionFilterBuilder, _serviceProvider);
|
|
@@ -748,18 +750,20 @@ namespace Hotline.Application.Exam.Service.ExamManages
|
|
|
|
|
|
var queryResult = userExamTable.InnerJoin(examManageTable, (ue, e) => ue.ExamId == e.Id)
|
|
|
.InnerJoin(userTable, (ue, e, u) => ue.UserId == u.Id)
|
|
|
- .Select((ue, e, u) => new UserExamResultViewResponse
|
|
|
- {
|
|
|
- ExamName = e.Name,
|
|
|
- OrgName = u.Organization.Name,
|
|
|
- UserName = u.Name,
|
|
|
- TotalScore = e.TotalScore,
|
|
|
- CutoffScore = e.CutoffScore,
|
|
|
- Score = ue.Score ?? 0,
|
|
|
-
|
|
|
- })
|
|
|
+ .Select((ue, e, u) => new UserExamResultViewResponse
|
|
|
+ {
|
|
|
+ ExamName = e.Name,
|
|
|
+ OrgName = u.Organization.Name,
|
|
|
+ UserName = u.Name,
|
|
|
+ TotalScore = e.TotalScore,
|
|
|
+ CutoffScore = e.CutoffScore,
|
|
|
+ Score = ue.Score ?? 0,
|
|
|
+
|
|
|
+ })
|
|
|
.MergeTable()
|
|
|
- .OrderByDescending(x => x.Score);
|
|
|
+ .OrderByPropertyNameIF(!string.IsNullOrEmpty(userExamResultReportPagedRequest.SortField), userExamResultReportPagedRequest.SortField, (OrderByType)(userExamResultReportPagedRequest.SortRule ?? 0))
|
|
|
+ .OrderByDescending(x => x.Score)
|
|
|
+ ;
|
|
|
|
|
|
var total = await queryResult.CountAsync();
|
|
|
var items = await queryResult.ToPageListAsync(userExamResultReportPagedRequest.PageIndex, userExamResultReportPagedRequest.PageSize);
|
|
@@ -912,7 +916,7 @@ namespace Hotline.Application.Exam.Service.ExamManages
|
|
|
var userExamIds = addUserExamItemDtos.Select(x => x.UserExamId).ToList();
|
|
|
var questionTypes = addUserExamItemDtos.Select(x => x.QuestionType).ToList();
|
|
|
|
|
|
- List<ExamQuestionOptionsBak> examQuestionOptions = await GetQuestionOptionBaks(questionIds, userExamIds,true).ToListAsync();
|
|
|
+ List<ExamQuestionOptionsBak> examQuestionOptions = await GetQuestionOptionBaks(questionIds, userExamIds, true).ToListAsync();
|
|
|
|
|
|
var userExamItemOptionRepository = new ExamRepository<ExamUserExamItemOptions>(_uow, _dataPermissionFilterBuilder, _serviceProvider);
|
|
|
var examQuestionScoreRepository = new ExamRepository<ExamQuestionScoreBak>(_uow, _dataPermissionFilterBuilder, _serviceProvider);
|
|
@@ -943,7 +947,7 @@ namespace Hotline.Application.Exam.Service.ExamManages
|
|
|
await userExamItemRepository.UpdateWithValidateAsync(userExamItems, cancellationToken);
|
|
|
}
|
|
|
|
|
|
- private ISugarQueryable<ExamQuestionOptionsBak> GetQuestionOptionBaks(List<string> questionIds, List<string> userExamIds,bool isFilterAnswer)
|
|
|
+ private ISugarQueryable<ExamQuestionOptionsBak> GetQuestionOptionBaks(List<string> questionIds, List<string> userExamIds, bool isFilterAnswer)
|
|
|
{
|
|
|
var questionRepository = new ExamRepository<Exams.ExamManages.ExamQuestionBak>(_uow, _dataPermissionFilterBuilder, _serviceProvider);
|
|
|
var questionTable = questionRepository.Queryable().Where(x => x.QuestionType == EQuestionType.Single || x.QuestionType == EQuestionType.Multi || x.QuestionType == EQuestionType.Judge);
|
|
@@ -953,7 +957,7 @@ namespace Hotline.Application.Exam.Service.ExamManages
|
|
|
var examQuestionOptionsRepository = new ExamRepository<ExamQuestionOptionsBak>(_uow, _dataPermissionFilterBuilder, _serviceProvider);
|
|
|
var examQuestionOptionsTable = examQuestionOptionsRepository.Queryable()
|
|
|
.Where(x => questionIds.Contains(x.QuestionId))
|
|
|
- .WhereIF(isFilterAnswer,x=>x.IsAnswer);
|
|
|
+ .WhereIF(isFilterAnswer, x => x.IsAnswer);
|
|
|
var examQuestionOptions = examQuestionOptionsTable.InnerJoin(questionTable, (t, i) => t.ExamQuestionId == i.Id)
|
|
|
.InnerJoin(examManageTable, (t, i, e) => i.ExamId == e.Id)
|
|
|
.InnerJoin(userExamTable, (t, i, e, u) => e.Id == u.ExamId)
|
|
@@ -1349,15 +1353,15 @@ namespace Hotline.Application.Exam.Service.ExamManages
|
|
|
ExamId = e.Id,
|
|
|
IsCheck = u.IsCheck,
|
|
|
IsReExam = u.IsReExam,
|
|
|
- CanReExam = SqlFunc.Subqueryable<ExamUserExamItem>().Where(x=>x.UserExamId == u.Id).Count()< e.Count
|
|
|
+ CanReExam = SqlFunc.Subqueryable<ExamUserExamItem>().Where(x => x.UserExamId == u.Id).Count() < e.Count
|
|
|
});
|
|
|
return queryable;
|
|
|
}
|
|
|
|
|
|
public async Task<List<ViewExamQuestionDto>> View(string id)
|
|
|
{
|
|
|
-
|
|
|
- List<ViewExamQuestionDto> viewExamQuestionDtos = await GetViewExamQuestion(id,null);
|
|
|
+
|
|
|
+ List<ViewExamQuestionDto> viewExamQuestionDtos = await GetViewExamQuestion(id, null);
|
|
|
|
|
|
var examQuestionIds = viewExamQuestionDtos.Select(x => x.ExamQuestionId).ToList();
|
|
|
var questionIds = viewExamQuestionDtos.Select(x => x.QuestionId).ToList();
|
|
@@ -1414,12 +1418,12 @@ namespace Hotline.Application.Exam.Service.ExamManages
|
|
|
});
|
|
|
}
|
|
|
|
|
|
- private async Task<List<QuestionSourcewareDto>> GetSourcewares(List<string> questionIds)
|
|
|
+ private async Task<List<QuestionSourcewareDto>> GetSourcewares(List<string> questionIds)
|
|
|
{
|
|
|
var questionSourcewareTable = new ExamRepository<ExamQuestionSourcewareBak>(_uow, _dataPermissionFilterBuilder, _serviceProvider).Queryable();
|
|
|
var sourcewareTable = new ExamRepository<ExamSourceware>(_uow, _dataPermissionFilterBuilder, _serviceProvider).Queryable();
|
|
|
|
|
|
- var querable = questionSourcewareTable.InnerJoin<ExamQuestionSourceware>((qsb,qs)=>qsb.SourcewareId == qs.Id).InnerJoin(sourcewareTable, (qsb,qs, s) => qs.SourcewareId == s.Id).Select((qsb, qs, s) => new QuestionSourcewareDto
|
|
|
+ var querable = questionSourcewareTable.InnerJoin<ExamQuestionSourceware>((qsb, qs) => qsb.SourcewareId == qs.Id).InnerJoin(sourcewareTable, (qsb, qs, s) => qs.SourcewareId == s.Id).Select((qsb, qs, s) => new QuestionSourcewareDto
|
|
|
{
|
|
|
Id = qs.Id,
|
|
|
Name = s.Name,
|
|
@@ -1431,28 +1435,28 @@ namespace Hotline.Application.Exam.Service.ExamManages
|
|
|
return await querable.ToListAsync();
|
|
|
}
|
|
|
|
|
|
- private async Task<List<QuestionKnowladgeDto>> GetQuestionKnowladges(List<string> questionIds)
|
|
|
+ private async Task<List<QuestionKnowladgeDto>> GetQuestionKnowladges(List<string> questionIds)
|
|
|
{
|
|
|
var questionKnowladgeTable = new ExamRepository<ExamQuestionKnowladgeBak>(_uow, _dataPermissionFilterBuilder, _serviceProvider).Queryable();
|
|
|
-
|
|
|
+
|
|
|
|
|
|
return await questionKnowladgeTable.Where(x => questionIds.Contains(x.ExamQuestionId))
|
|
|
- .InnerJoin<ExamQuestionKnowladge>((kb,k)=>kb.KnowladgeId == k.Id).Select((kb, k) => new QuestionKnowladgeDto
|
|
|
- {
|
|
|
- Id = kb.Id,
|
|
|
- QuestionId = kb.ExamQuestionId,
|
|
|
- KnowladgeId = k.KnowladgeId,
|
|
|
- Title = kb.Title
|
|
|
- }).ToListAsync();
|
|
|
+ .InnerJoin<ExamQuestionKnowladge>((kb, k) => kb.KnowladgeId == k.Id).Select((kb, k) => new QuestionKnowladgeDto
|
|
|
+ {
|
|
|
+ Id = kb.Id,
|
|
|
+ QuestionId = kb.ExamQuestionId,
|
|
|
+ KnowladgeId = k.KnowladgeId,
|
|
|
+ Title = kb.Title
|
|
|
+ }).ToListAsync();
|
|
|
}
|
|
|
|
|
|
- private async Task<List<ViewQuestionOptionDto>> GetQuestionOptions(List<string> questionIds,List<string> userExamIds)
|
|
|
+ private async Task<List<ViewQuestionOptionDto>> GetQuestionOptions(List<string> questionIds, List<string> userExamIds)
|
|
|
{
|
|
|
- var selectQuestionOptions = GetQuestionOptionBaks(questionIds, userExamIds,false).MergeTable();
|
|
|
+ var selectQuestionOptions = GetQuestionOptionBaks(questionIds, userExamIds, false).MergeTable();
|
|
|
|
|
|
var userExamItemOptionTable = _userExamItemOptionRepository.Queryable();
|
|
|
|
|
|
- var querable = selectQuestionOptions
|
|
|
+ var querable = selectQuestionOptions
|
|
|
.LeftJoin(userExamItemOptionTable, (op, uio) => op.Id == uio.QuestionOptionId)
|
|
|
.Select((op, uio) => new ViewQuestionOptionDto
|
|
|
{
|
|
@@ -1468,7 +1472,7 @@ namespace Hotline.Application.Exam.Service.ExamManages
|
|
|
.ToListAsync();
|
|
|
}
|
|
|
|
|
|
- private async Task<List<ViewQuestionAnswerDto>> GetQuestionAnswers(string id, List<string> questionIds)
|
|
|
+ private async Task<List<ViewQuestionAnswerDto>> GetQuestionAnswers(string id, List<string> questionIds)
|
|
|
{
|
|
|
var userExamTable = _repository.Queryable().Where(x => x.Id == id);
|
|
|
var userExamItemTable = _userExamItemRepository.Queryable();
|
|
@@ -1477,11 +1481,11 @@ namespace Hotline.Application.Exam.Service.ExamManages
|
|
|
var questionAnswerTable = new ExamRepository<ExamQuestionAnswerBak>(_uow, _dataPermissionFilterBuilder, _serviceProvider).Queryable();
|
|
|
|
|
|
var querable = examAnswerTable
|
|
|
- .InnerJoin(userExamItemTable, (a, ui) => ui.Id == a.UserExamItemId && ui.UserExamId == id)
|
|
|
- .LeftJoin(questionAnswerTable, (a, ui, qab) => qab.QuestionId == ui.QuestionId )
|
|
|
- .LeftJoin<ExamQuestionAnswer>((a, ui, qab ,qa) => qab.QuestionAnswerId == qa.Id )
|
|
|
- .LeftJoin(questionTable, (a, ui, qab, qa,q)=>qab.QuestionId == q.QuestionId && questionIds.Contains(q.Id))
|
|
|
- .Select((a, ui, qab, qa,q) => new ViewQuestionAnswerDto
|
|
|
+ .InnerJoin(userExamItemTable, (a, ui) => ui.Id == a.UserExamItemId && ui.UserExamId == id)
|
|
|
+ .LeftJoin(questionAnswerTable, (a, ui, qab) => qab.QuestionId == ui.QuestionId)
|
|
|
+ .LeftJoin<ExamQuestionAnswer>((a, ui, qab, qa) => qab.QuestionAnswerId == qa.Id)
|
|
|
+ .LeftJoin(questionTable, (a, ui, qab, qa, q) => qab.QuestionId == q.QuestionId && questionIds.Contains(q.Id))
|
|
|
+ .Select((a, ui, qab, qa, q) => new ViewQuestionAnswerDto
|
|
|
{
|
|
|
Answer = a.Answer,
|
|
|
CorrectAnswer = qa.Answer != null ? qa.Answer : string.Empty,
|
|
@@ -1491,7 +1495,7 @@ namespace Hotline.Application.Exam.Service.ExamManages
|
|
|
return await querable.ToListAsync();
|
|
|
}
|
|
|
|
|
|
- private async Task<List<ViewExamQuestionDto>> GetViewExamQuestion(string id,string questionId)
|
|
|
+ private async Task<List<ViewExamQuestionDto>> GetViewExamQuestion(string id, string questionId)
|
|
|
{
|
|
|
var expression = ExpressionableUtility.CreateExpression<ExamUserExam>()
|
|
|
.And(x => x.Id == id).ToExpression();
|
|
@@ -1510,7 +1514,7 @@ namespace Hotline.Application.Exam.Service.ExamManages
|
|
|
{
|
|
|
Answer = g.FirstOrDefault().Answer,
|
|
|
QuestionType = g.Key.QuestionType,
|
|
|
- QuestionId= g.FirstOrDefault().QuestionId,
|
|
|
+ QuestionId = g.FirstOrDefault().QuestionId,
|
|
|
ExamQuestionId = g.FirstOrDefault().ExamQuestionId,
|
|
|
Id = g.Key.Id,
|
|
|
Score = g.FirstOrDefault().QuestionScore,
|