|
|
|
@ -559,6 +559,8 @@ public class Ghre_ExamRecordServices : BaseServices<Ghre_ExamRecord, Ghre_ExamRe |
|
|
|
|
await Db.Deleteable<Ghre_ExamPaperQuestion>().Where(x => x.ExamPaperId == examRecordId).ExecuteCommandAsync(); |
|
|
|
|
var configs = await Db.Queryable<Ghre_ExamPaperConfig>().OrderBy(x => x.TaxisNo).Where(x => x.ExamPaperId == exampaper.Id).ToListAsync(); |
|
|
|
|
|
|
|
|
|
var examPaperQuestionIds = new List<long>(); |
|
|
|
|
|
|
|
|
|
for (int i = 0; i < configs.Count; i++) |
|
|
|
|
{ |
|
|
|
|
var config = configs[i]; |
|
|
|
@ -571,20 +573,28 @@ public class Ghre_ExamRecordServices : BaseServices<Ghre_ExamRecord, Ghre_ExamRe |
|
|
|
|
sql += $" AND CourseId='{config.CourseId}'"; |
|
|
|
|
if (config.QuestionId != null) |
|
|
|
|
sql += $" AND Id='{config.QuestionId}'"; |
|
|
|
|
if(examPaperQuestionIds.Any()) |
|
|
|
|
sql += $" AND Id NOT IN ('{string.Join(",", examPaperQuestionIds)}')"; |
|
|
|
|
|
|
|
|
|
sql += $" ORDER BY GuidValue ASC"; |
|
|
|
|
var questions2 = await Db.Ado.SqlQueryAsync<Ghre_Question>(sql); |
|
|
|
|
|
|
|
|
|
var insertExamPaperQuestions = questions2.Select(x => new Ghre_ExamPaperQuestion |
|
|
|
|
if (questions2.Any()) |
|
|
|
|
{ |
|
|
|
|
Id = SnowFlakeSingle.instance.getID(), |
|
|
|
|
CreateTime = DateTime.Now, |
|
|
|
|
ExamPaperId = examRecordId, |
|
|
|
|
QuestionId = x.Id, |
|
|
|
|
ConfigId = x.Id, |
|
|
|
|
Score = config.Score |
|
|
|
|
}).ToList(); |
|
|
|
|
examPaperQuestionIds.AddRange(questions2.Select(x => x.Id)); |
|
|
|
|
|
|
|
|
|
var insertExamPaperQuestions = questions2.Select(x => new Ghre_ExamPaperQuestion |
|
|
|
|
{ |
|
|
|
|
Id = SnowFlakeSingle.instance.getID(), |
|
|
|
|
CreateTime = DateTime.Now, |
|
|
|
|
ExamPaperId = examRecordId, |
|
|
|
|
QuestionId = x.Id, |
|
|
|
|
ConfigId = x.Id, |
|
|
|
|
Score = config.Score |
|
|
|
|
}).ToList(); |
|
|
|
|
|
|
|
|
|
Db.Insertable(insertExamPaperQuestions).ExecuteCommand(); |
|
|
|
|
await Db.Insertable(insertExamPaperQuestions).ExecuteCommandAsync(); |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|