diff --git a/Tiobon.Core.Api/Tiobon.Core.Model.xml b/Tiobon.Core.Api/Tiobon.Core.Model.xml
index 6c54ee96..af668d64 100644
--- a/Tiobon.Core.Api/Tiobon.Core.Model.xml
+++ b/Tiobon.Core.Api/Tiobon.Core.Model.xml
@@ -12624,7 +12624,7 @@
- 考试管理-状态
+ 试卷管理-状态
@@ -12642,6 +12642,21 @@
已停用
+
+
+ 试卷管理-出题方式
+
+
+
+
+ 人工出题
+
+
+
+
+ 随机出题
+
+
考试管理-状态
diff --git a/Tiobon.Core.Model/Consts.cs b/Tiobon.Core.Model/Consts.cs
index c0ec4cdb..d94e737a 100644
--- a/Tiobon.Core.Model/Consts.cs
+++ b/Tiobon.Core.Model/Consts.cs
@@ -29,9 +29,9 @@ public class Consts
}
#endregion
- #region 考试管理
+ #region 试卷管理
///
- /// 考试管理-状态
+ /// 试卷管理-状态
///
public static class DIC_EXAM_PAPER_STATUS
{
@@ -49,6 +49,23 @@ public class Consts
///
public const string DISABLED = "Disabled";
+ }
+
+ ///
+ /// 试卷管理-出题方式
+ ///
+ public static class DIC_EXAM_PAPER_SET_METHOD
+ {
+ ///
+ /// 人工出题
+ ///
+ public const string MANUAL = "manual";
+
+ ///
+ /// 随机出题
+ ///
+ public const string RANDOM = "random";
+
}
#endregion
diff --git a/Tiobon.Core.Services/Ghre/Ghre_ExamRecordServices.cs b/Tiobon.Core.Services/Ghre/Ghre_ExamRecordServices.cs
index 35eeafa1..a864d5bf 100644
--- a/Tiobon.Core.Services/Ghre/Ghre_ExamRecordServices.cs
+++ b/Tiobon.Core.Services/Ghre/Ghre_ExamRecordServices.cs
@@ -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().Where(x => x.ExamPaperId == exampaper.Id).ToListAsync();
+ if (exampaper.SetMethod == DIC_EXAM_PAPER_SET_METHOD.RANDOM)
+ {
+ await Db.Deleteable().Where(x => x.ExamPaperId == examRecordId).ExecuteCommandAsync();
+ var configs = await Db.Queryable().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(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()
+ .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,
diff --git a/Tiobon.Core/Tiobon.Core.Model.xml b/Tiobon.Core/Tiobon.Core.Model.xml
index 6c54ee96..af668d64 100644
--- a/Tiobon.Core/Tiobon.Core.Model.xml
+++ b/Tiobon.Core/Tiobon.Core.Model.xml
@@ -12624,7 +12624,7 @@
- 考试管理-状态
+ 试卷管理-状态
@@ -12642,6 +12642,21 @@
已停用
+
+
+ 试卷管理-出题方式
+
+
+
+
+ 人工出题
+
+
+
+
+ 随机出题
+
+
考试管理-状态