|
@@ -332,8 +332,8 @@ namespace Hotline.Application.Exam.Service.TestPapers
|
|
|
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).ToListAsync();
|
|
|
+ .WhereIF(testPaperQuestionRequest.TagIds.IsNotNull() && testPaperQuestionRequest.TagIds.Any(), (q, qt) => testPaperQuestionRequest.TagIds.Contains(qt.TagId))
|
|
|
+ .Select((q, qt) => q).Take(testPaperQuestionRequest.Count).OrderBy(q => SqlFunc.GetRandom()).ToListAsync();
|
|
|
|
|
|
var questionDtos = new List<SimpleQuestionViewResponse>();
|
|
|
|
|
@@ -360,11 +360,11 @@ namespace Hotline.Application.Exam.Service.TestPapers
|
|
|
|
|
|
var count = await testPaperRuleTable.Select(x => x.Count).FirstAsync();
|
|
|
|
|
|
- var questions = await questionTable.InnerJoin(questionTagTable, (q, qt) => q.Id == qt.QuestionId)
|
|
|
- .InnerJoin(testPaperTagTable, (q, qt, tt) => qt.TagId == tt.TagId)
|
|
|
- .InnerJoin(testPaperRuleTable, (q, qt, tt, tpr) => tt.TestPaperRuleId == tpr.Id)
|
|
|
+ var questions = await questionTable.LeftJoin(questionTagTable, (q, qt) => q.Id == qt.QuestionId)
|
|
|
+ .LeftJoin(testPaperTagTable, (q, qt, tt) => qt.TagId == tt.TagId)
|
|
|
+ .LeftJoin(testPaperRuleTable, (q, qt, tt, tpr) => tt.TestPaperRuleId == tpr.Id)
|
|
|
.Where((q, qt, tt, tpr) => q.QuestionType == tpr.QuestionType)
|
|
|
- .Select((q, qt, tt, tpr) => q).Take(count).OrderBy(SqlFunc.GetRandom()).ToListAsync();
|
|
|
+ .Select((q, qt, tt, tpr) => q).Take(count).OrderBy(q => SqlFunc.GetRandom()).ToListAsync();
|
|
|
|
|
|
|
|
|
return questions;
|