|
@@ -115,14 +115,16 @@ namespace Hotline.Application.Exam.Service.ExamManages
|
|
|
|
|
|
var questionDto = _mapper.Map<ExamManageDto>(entity);
|
|
|
|
|
|
- if(entity.Mode == Share.Enums.Exams.EExamMode.Random)
|
|
|
- {
|
|
|
- questionDto.TestPaperId = entity.ExtractRuleId;
|
|
|
- }
|
|
|
+
|
|
|
|
|
|
if (questionDto != null)
|
|
|
{
|
|
|
- questionDto.ExamQuestionScoreDtos = await GetExamQuestionScores(entityQueryRequest);
|
|
|
+ questionDto.ExamQuestionScoreDtos = await GetExamQuestionScores(entityQueryRequest, entity);
|
|
|
+ if (entity.Mode == Share.Enums.Exams.EExamMode.Random)
|
|
|
+ {
|
|
|
+ questionDto.TestPaperId = entity.ExtractRuleId;
|
|
|
+
|
|
|
+ }
|
|
|
|
|
|
questionDto.UserExamDtos = await GetUserExams(entityQueryRequest);
|
|
|
}
|
|
@@ -566,19 +568,56 @@ namespace Hotline.Application.Exam.Service.ExamManages
|
|
|
return await userExamDtos.ToListAsync();
|
|
|
}
|
|
|
|
|
|
- private async Task<List<ExamQuestionScoreDto>> GetExamQuestionScores(EntityQueryRequest entityQueryRequest)
|
|
|
+ private async Task<List<ExamQuestionScoreDto>> GetExamQuestionScores(EntityQueryRequest entityQueryRequest,ExamManage examManage)
|
|
|
{
|
|
|
var examQuestionScores = _examQuestionScoreRepository.Queryable().Where(x => x.ExamManageId == entityQueryRequest.Id);
|
|
|
|
|
|
-
|
|
|
var examQuestionScoreDtos = examQuestionScores.Select(q => new ExamQuestionScoreDto
|
|
|
{
|
|
|
Id = q.Id,
|
|
|
+ QuestionType = q.QuestionType,
|
|
|
ExamManageId = q.ExamManageId,
|
|
|
Score = q.Score
|
|
|
});
|
|
|
|
|
|
- return await examQuestionScoreDtos.ToListAsync();
|
|
|
+ if(examManage.Mode == Share.Enums.Exams.EExamMode.Random)
|
|
|
+ {
|
|
|
+ var tagQuestionRepository = new ExamRepository<TagQuestion>(_repository.UOW, _dataPermissionFilterBuilder, _serviceProvider);
|
|
|
+ var tagQuestionTable = tagQuestionRepository.Queryable().Where(x => x.RuleId == examManage.ExtractRuleId);
|
|
|
+
|
|
|
+ var result = examQuestionScoreDtos.InnerJoin(tagQuestionTable, (e, t) => e.QuestionType == t.QuestionType).Select((e, t) => new ExamQuestionScoreDto
|
|
|
+ {
|
|
|
+ Id = e.Id,
|
|
|
+ QuestionType = e.QuestionType,
|
|
|
+ ExamManageId = e.ExamManageId,
|
|
|
+ Score = e.Score,
|
|
|
+ Count = t.Count
|
|
|
+ });
|
|
|
+ return await result.ToListAsync();
|
|
|
+ }
|
|
|
+ else
|
|
|
+ {
|
|
|
+ var testPaperItemRepository = new ExamRepository<TestPaperItem>(_repository.UOW, _dataPermissionFilterBuilder, _serviceProvider);
|
|
|
+ var testPaperItemTable = testPaperItemRepository.Queryable().Where(x => x.TestPaperId == examManage.TestPaperId);
|
|
|
+
|
|
|
+ var result = examQuestionScoreDtos.InnerJoin(testPaperItemTable, (e, t) => e.QuestionType == t.QuestionType)
|
|
|
+ .GroupBy((e, t) => new
|
|
|
+ {
|
|
|
+ Id = e.Id,
|
|
|
+ QuestionType = e.QuestionType,
|
|
|
+ ExamManageId = e.ExamManageId,
|
|
|
+ Score = e.Score,
|
|
|
+ })
|
|
|
+ .Select((e, t) => new ExamQuestionScoreDto
|
|
|
+ {
|
|
|
+ Id = e.Id,
|
|
|
+ QuestionType = e.QuestionType,
|
|
|
+ ExamManageId = e.ExamManageId,
|
|
|
+ Score = e.Score,
|
|
|
+ Count = SqlFunc.AggregateCount(t.Id)
|
|
|
+ });
|
|
|
+ return await result.ToListAsync();
|
|
|
+ }
|
|
|
}
|
|
|
private void CalcuteTotalScore(AddExamManageDto actionRequest)
|
|
|
{
|