|
@@ -329,18 +329,21 @@ namespace Hotline.Application.Exam.Service.TestPapers
|
|
|
var questionTagTable = questionTagRepository.Queryable();
|
|
|
var questionTable = questionRepository.Queryable();
|
|
|
|
|
|
- var questions = await questionTable.InnerJoin(questionTagTable, (q, qt) => q.Id == qt.QuestionId)
|
|
|
- .Where((q, qt) => q.DifficultyLevel == testPaperQuestionRequest.DifficultyLevel
|
|
|
- && q.QuestionType == testPaperQuestionRequest.QuestionType
|
|
|
+ var questions = await questionTable.LeftJoin(questionTagTable, (q, qt) => q.Id == qt.QuestionId)
|
|
|
+ .Where((q, qt) => q.QuestionType == testPaperQuestionRequest.QuestionType
|
|
|
).WhereIF(testPaperQuestionRequest.DifficultyLevel.IsNotNull(), (q, qt) => q.DifficultyLevel == testPaperQuestionRequest.DifficultyLevel)
|
|
|
.WhereIF(testPaperQuestionRequest.TagIds.IsNotNull(), (q, qt) => testPaperQuestionRequest.TagIds.Contains(qt.TagId))
|
|
|
- .Select((q, qt) => q).Take(testPaperQuestionRequest.Count).OrderBy(SqlFunc.GetRandom()).ToListAsync();
|
|
|
+ .Select((q, qt) => q).Take(testPaperQuestionRequest.Count).ToListAsync();
|
|
|
|
|
|
var questionDtos = new List<SimpleQuestionViewResponse>();
|
|
|
|
|
|
questions.ForEach(item =>
|
|
|
{
|
|
|
var questionDto = _mapper.Map<SimpleQuestionViewResponse>(item);
|
|
|
+ if (questionDto != null)
|
|
|
+ {
|
|
|
+ questionDtos.Add(questionDto);
|
|
|
+ }
|
|
|
});
|
|
|
|
|
|
return questionDtos;
|