|
|
|
@ -14,6 +14,8 @@ using AgileObjects.AgileMapper.Extensions; |
|
|
|
|
using SqlSugar; |
|
|
|
|
using Tiobon.Core.DataAccess; |
|
|
|
|
using System.Data; |
|
|
|
|
using static Tiobon.Core.Model.Consts; |
|
|
|
|
using Mysqlx.Crud; |
|
|
|
|
|
|
|
|
|
namespace Tiobon.Core.Services; |
|
|
|
|
|
|
|
|
@ -459,7 +461,43 @@ public class Ghre_ExamRecordServices : BaseServices<Ghre_ExamRecord, Ghre_ExamRe |
|
|
|
|
extend.styleInfo.paperStyle = exampaper.Style; |
|
|
|
|
extend.styleInfo.coverBackGround = exampaper.CoverBackGround; |
|
|
|
|
|
|
|
|
|
var questions = await Db.Queryable<Ghre_ExamPaperQuestion>().Where(x => x.ExamPaperId == exampaper.Id).ToListAsync(); |
|
|
|
|
if (exampaper.SetMethod == DIC_EXAM_PAPER_SET_METHOD.RANDOM) |
|
|
|
|
{ |
|
|
|
|
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(); |
|
|
|
|
|
|
|
|
|
for (int i = 0; i < configs.Count; i++) |
|
|
|
|
{ |
|
|
|
|
var config = configs[i]; |
|
|
|
|
string sql = $@"SELECT TOP {config.Quantity} *,NEWID() AS GuidValue FROM Ghre_Question WHERE IsEnable=1"; |
|
|
|
|
if (!string.IsNullOrWhiteSpace(config.DifficultyLevel)) |
|
|
|
|
sql += $" AND DifficultyLevel='{config.DifficultyLevel}'"; |
|
|
|
|
if (!string.IsNullOrWhiteSpace(config.QuestionType)) |
|
|
|
|
sql += $" AND QuestionType='{config.QuestionType}'"; |
|
|
|
|
if (config.CourseId != null) |
|
|
|
|
sql += $" AND CourseId='{config.CourseId}'"; |
|
|
|
|
if (config.QuestionId != null) |
|
|
|
|
sql += $" AND Id='{config.QuestionId}'"; |
|
|
|
|
sql += $" ORDER BY GuidValue ASC"; |
|
|
|
|
var questions2 = await Db.Ado.SqlQueryAsync<Ghre_Question>(sql); |
|
|
|
|
|
|
|
|
|
var insertExamPaperQuestions = questions2.Select(x => new Ghre_ExamPaperQuestion |
|
|
|
|
{ |
|
|
|
|
Id = SnowFlakeSingle.instance.getID(), |
|
|
|
|
CreateTime = DateTime.Now, |
|
|
|
|
ExamPaperId = examRecordId, |
|
|
|
|
QuestionId = x.Id, |
|
|
|
|
ConfigId = x.Id, |
|
|
|
|
}).ToList(); |
|
|
|
|
|
|
|
|
|
Db.Insertable(insertExamPaperQuestions).ExecuteCommand(); |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
var questions = await Db.Queryable<Ghre_ExamPaperQuestion>() |
|
|
|
|
.Where(x => (x.ExamPaperId == exampaper.Id && exampaper.SetMethod == DIC_EXAM_PAPER_SET_METHOD.MANUAL) || (x.ExamPaperId == examRecordId && exampaper.SetMethod == DIC_EXAM_PAPER_SET_METHOD.RANDOM)) |
|
|
|
|
.ToListAsync(); |
|
|
|
|
var previews = questions.Where(x => x.QuestionId != null).Select(x => new DefaultGhre_ExamPaperPreview() |
|
|
|
|
{ |
|
|
|
|
Id = x.Id, |
|
|
|
|