diff --git a/Tiobon.Core.Api/Tiobon.Core.Model.xml b/Tiobon.Core.Api/Tiobon.Core.Model.xml index a829e5df..8165e36a 100644 --- a/Tiobon.Core.Api/Tiobon.Core.Model.xml +++ b/Tiobon.Core.Api/Tiobon.Core.Model.xml @@ -1940,6 +1940,226 @@ 预留字段12 + + + Ghre_ExamRecord (Dto.Base) + + + + + 试卷ID + + + + + 用户ID + + + + + 试卷ID + + + + + 得分 + + + + + 开始答题时间 + + + + + 结束答题时间 + + + + + 实际开始时间 + + + + + 实际结束时间 + + + + + 备注 + + + + + 默认标志 + + + + + 预留字段1 + + + + + 预留字段2 + + + + + 预留字段3 + + + + + 预留字段4 + + + + + 预留字段5 + + + + + 预留字段6 + + + + + 预留字段7 + + + + + 预留字段8 + + + + + 预留字段9 + + + + + 预留字段10 + + + + + 预留字段11 + + + + + 预留字段12 + + + + + Ghre_ExamRecordDetail (Dto.Base) + + + + + 试卷ID + + + + + 答题记录ID + + + + + 题目ID + + + + + 用户ID + + + + + 题目答案ID + + + + + 答案内容 + + + + + 备注 + + + + + 默认标志 + + + + + 预留字段1 + + + + + 预留字段2 + + + + + 预留字段3 + + + + + 预留字段4 + + + + + 预留字段5 + + + + + 预留字段6 + + + + + 预留字段7 + + + + + 预留字段8 + + + + + 预留字段9 + + + + + 预留字段10 + + + + + 预留字段11 + + + + + 预留字段12 + + Ghre_ExamStaff (Dto.Base) @@ -2604,6 +2824,16 @@ 试卷题目 (Dto.EditInput) + + + Ghre_ExamRecord (Dto.EditInput) + + + + + Ghre_ExamRecordDetail (Dto.EditInput) + + Ghre_ExamStaff (Dto.EditInput) @@ -2694,6 +2924,16 @@ 试卷题目 (Dto.InsertInput) + + + Ghre_ExamRecord (Dto.InsertInput) + + + + + Ghre_ExamRecordDetail (Dto.InsertInput) + + Ghre_ExamStaff (Dto.InsertInput) @@ -4828,6 +5068,226 @@ 预留字段12 + + + Ghre_ExamRecord (Model) + + + + + 试卷ID + + + + + 用户ID + + + + + 试卷ID + + + + + 得分 + + + + + 开始答题时间 + + + + + 结束答题时间 + + + + + 实际开始时间 + + + + + 实际结束时间 + + + + + 备注 + + + + + 默认标志 + + + + + 预留字段1 + + + + + 预留字段2 + + + + + 预留字段3 + + + + + 预留字段4 + + + + + 预留字段5 + + + + + 预留字段6 + + + + + 预留字段7 + + + + + 预留字段8 + + + + + 预留字段9 + + + + + 预留字段10 + + + + + 预留字段11 + + + + + 预留字段12 + + + + + Ghre_ExamRecordDetail (Model) + + + + + 试卷ID + + + + + 答题记录ID + + + + + 题目ID + + + + + 用户ID + + + + + 题目答案ID + + + + + 答案内容 + + + + + 备注 + + + + + 默认标志 + + + + + 预留字段1 + + + + + 预留字段2 + + + + + 预留字段3 + + + + + 预留字段4 + + + + + 预留字段5 + + + + + 预留字段6 + + + + + 预留字段7 + + + + + 预留字段8 + + + + + 预留字段9 + + + + + 预留字段10 + + + + + 预留字段11 + + + + + 预留字段12 + + Ghre_ExamStaff (Model) @@ -6401,6 +6861,36 @@ 试卷题目(Dto.View) + + + Ghre_ExamRecord(Dto.View) + + + + + 创建信息 + + + + + 修改信息 + + + + + Ghre_ExamRecordDetail(Dto.View) + + + + + 创建信息 + + + + + 修改信息 + + Ghre_ExamStaff(Dto.View) diff --git a/Tiobon.Core.Api/Tiobon.Core.xml b/Tiobon.Core.Api/Tiobon.Core.xml index 287de0fc..096ef652 100644 --- a/Tiobon.Core.Api/Tiobon.Core.xml +++ b/Tiobon.Core.Api/Tiobon.Core.xml @@ -377,6 +377,17 @@ 主键ID + + + 分片上传 + + + + + + + + 登录管理【无权限】 @@ -626,6 +637,28 @@ pageData + + + 更新考试状态接口 + + + + + + + + 获取考试状态接口 + + + + + + + 开始考试 + + 考试ID + + 试卷配置(Controller) @@ -685,6 +718,16 @@ 试卷题目(Controller) + + + Ghre_ExamRecord(Controller) + + + + + Ghre_ExamRecordDetail(Controller) + + Ghre_ExamStaff(Controller) diff --git a/Tiobon.Core.Services/Ghre/Ghre_ExamServices.cs b/Tiobon.Core.Services/Ghre/Ghre_ExamServices.cs index 1f0be6b2..83b4d392 100644 --- a/Tiobon.Core.Services/Ghre/Ghre_ExamServices.cs +++ b/Tiobon.Core.Services/Ghre/Ghre_ExamServices.cs @@ -14,6 +14,7 @@ using SqlSugar; using Tiobon.Core.Common.Helper; using Microsoft.AspNetCore.Http; using Tiobon.Core.Common.UserManager; +using MathNet.Numerics.Distributions; namespace Tiobon.Core.Services; @@ -287,17 +288,32 @@ public class Ghre_ExamServices : BaseServices(sql) .OrderBy(filter.orderBy) .ToPageListAsync(filter.pageNum, filter.pageSize, totalCount); - //data.ForEach(async x => - //{ - // x.DifficultyLevelLabel = await GetParaLabel("DifficultyLevel", x.DifficultyLevel); - // x.QuestionTypeLabel = await GetParaLabel("QuestionType", x.QuestionType); - //}); + data.ForEach(x => + { + x.ExamName = x.ExamName + "(" + x.ExamNo + ")"; + + if (x.Status == "Released" || x.Status == "Disabled") + { + x.canEdit = 0; + x.canDelete = 0; + } + + if (x.Status == "Disabled") + { + x.canClose = 0; + x.canPreview = 0; + } + }); return new ServicePageResult(filter.pageNum, totalCount, filter.pageSize, data); } @@ -554,6 +570,15 @@ public class Ghre_ExamServices : BaseServices().Where(it => it.Id == pageData.ExamPaperId).FirstAsync(); + pageData.CoverUrl = course?.CoverUrl; + } + + if (string.IsNullOrWhiteSpace(pageData.ExamNo)) + pageData.ExamNo = await GenerateContinuousSequence(); + if (id == 0) { if (string.IsNullOrEmpty(pageData.Status)) @@ -561,6 +586,7 @@ public class Ghre_ExamServices : BaseServices(); id = await base.Add(insert); + var insertStaffs = pageData.staffTableData.Select(x => new InsertGhre_ExamStaffInput() { ExamId = id, @@ -570,10 +596,18 @@ public class Ghre_ExamServices : BaseServices().SetColumns(it => it.LinkTimes == it.LinkTimes + 1).Where(it => it.Id == insert.ExamPaperId).ExecuteCommand(); + return ServiceResult.OprateSuccess("添加成功!", id); } else { + var exam = await base.QueryById(id); + if (exam.ExamPaperId != pageData.ExamPaperId) + { + Db.Updateable().SetColumns(it => it.LinkTimes == it.LinkTimes - 1).Where(it => it.Id == exam.ExamPaperId && it.LinkTimes > 0).ExecuteCommand(); + Db.Updateable().SetColumns(it => it.LinkTimes == it.LinkTimes + 1).Where(it => it.Id == pageData.ExamPaperId).ExecuteCommand(); + } var insert = Mapper.Map(pageData).ToANew(); await base.Update(id, insert); await _ghre_ExamStaffServices.Delete(x => x.ExamId == id); @@ -645,12 +679,23 @@ public class Ghre_ExamServices : BaseServices x.ExamId == id)) { + var dt = DateTime.Now; var exam = await base.QueryById(id); + + + if (exam.DateType == "ExamDate") + { + if (exam.BeginTime > dt) + return ServiceResult.OprateFailed("考试尚未开始!"); + + if (exam.EndTime < dt) + return ServiceResult.OprateFailed("考试已结束!"); + } var insrt = new InsertGhre_ExamRecordInput() { ExamId = id, UserId = UserContext.Current.User_Id, - ActualBeginTime = DateTime.Now, + ActualBeginTime = dt, ExamPaperId = exam.ExamPaperId }; await _ghre_ExamRecordServices.Add(insrt); @@ -659,4 +704,68 @@ public class Ghre_ExamServices : BaseServices GenerateContinuousSequence() + { + try + { + string prefixTemp = "E"; + string result = string.Empty; + string tableCode = "Ghre_Exam"; + string columnCode = "ExamNo"; + int length = 6; + int tempLength = 5; + int sequence; + + #region 查询 + DbSelect dbSelect = new DbSelect(tableCode + " A", "A", null); + dbSelect.IsInitDefaultValue = false; + + if (!string.IsNullOrEmpty(prefixTemp)) + dbSelect.Select("MAX(SUBSTRING(A." + columnCode + "," + (prefixTemp.Length + 1).ToString() + "," + tempLength.ToString() + "))"); + else + dbSelect.Select("MAX(A." + columnCode + ")"); + //} + //dbSelect.Select("MAX(CONVERT(DECIMAL,SUBSTRING(A.ISSUE_NO," + (prefix.Length + dateString.Length + 1).ToString() + "," + tempLength.ToString() + ")))"); + if (!string.IsNullOrEmpty(prefixTemp)) + dbSelect.Where("SUBSTRING(A." + columnCode + ",1," + (prefixTemp.Length).ToString() + ")", " = ", prefixTemp); + dbSelect.Where("LEN(A." + columnCode + ")", "=", length); + string sql = dbSelect.GetSql(); + //await Db.Ado.GetScalarAsync(sql) + string maxSequence = Convert.ToString(await Db.Ado.GetScalarAsync(sql)); + #endregion + //tempLength = tempLength - dateString.Length; + if (string.IsNullOrEmpty(maxSequence)) + result = prefixTemp + Convert.ToString(1).PadLeft(tempLength, '0'); + else + { + if (!string.IsNullOrEmpty(prefixTemp)) + { + if (int.TryParse(maxSequence, out sequence)) + { + sequence += 1; + if (sequence.ToString().Length > tempLength) + throw new Exception("自动生成字串长度已经超过设定长度!"); + } + else + throw new Exception("表中的数据无法进行自动编号,请联系软件开发商!"); + result = prefixTemp + sequence.ToString().PadLeft(tempLength, '0'); + } + else + { + if (int.TryParse(maxSequence, out sequence)) + { + sequence += 1; + if (sequence.ToString().Length > length) + throw new Exception("自动生成字串长度已经超过设定长度!"); + } + else + throw new Exception("表中的数据无法进行自动编号,请联系软件开发商!"); + result = sequence.ToString().PadLeft(length, '0'); + } + } + return result; + } + catch (Exception) { throw; } + } } \ No newline at end of file diff --git a/Tiobon.Core/Tiobon.Core.Model.xml b/Tiobon.Core/Tiobon.Core.Model.xml index a829e5df..8165e36a 100644 --- a/Tiobon.Core/Tiobon.Core.Model.xml +++ b/Tiobon.Core/Tiobon.Core.Model.xml @@ -1940,6 +1940,226 @@ 预留字段12 + + + Ghre_ExamRecord (Dto.Base) + + + + + 试卷ID + + + + + 用户ID + + + + + 试卷ID + + + + + 得分 + + + + + 开始答题时间 + + + + + 结束答题时间 + + + + + 实际开始时间 + + + + + 实际结束时间 + + + + + 备注 + + + + + 默认标志 + + + + + 预留字段1 + + + + + 预留字段2 + + + + + 预留字段3 + + + + + 预留字段4 + + + + + 预留字段5 + + + + + 预留字段6 + + + + + 预留字段7 + + + + + 预留字段8 + + + + + 预留字段9 + + + + + 预留字段10 + + + + + 预留字段11 + + + + + 预留字段12 + + + + + Ghre_ExamRecordDetail (Dto.Base) + + + + + 试卷ID + + + + + 答题记录ID + + + + + 题目ID + + + + + 用户ID + + + + + 题目答案ID + + + + + 答案内容 + + + + + 备注 + + + + + 默认标志 + + + + + 预留字段1 + + + + + 预留字段2 + + + + + 预留字段3 + + + + + 预留字段4 + + + + + 预留字段5 + + + + + 预留字段6 + + + + + 预留字段7 + + + + + 预留字段8 + + + + + 预留字段9 + + + + + 预留字段10 + + + + + 预留字段11 + + + + + 预留字段12 + + Ghre_ExamStaff (Dto.Base) @@ -2604,6 +2824,16 @@ 试卷题目 (Dto.EditInput) + + + Ghre_ExamRecord (Dto.EditInput) + + + + + Ghre_ExamRecordDetail (Dto.EditInput) + + Ghre_ExamStaff (Dto.EditInput) @@ -2694,6 +2924,16 @@ 试卷题目 (Dto.InsertInput) + + + Ghre_ExamRecord (Dto.InsertInput) + + + + + Ghre_ExamRecordDetail (Dto.InsertInput) + + Ghre_ExamStaff (Dto.InsertInput) @@ -4828,6 +5068,226 @@ 预留字段12 + + + Ghre_ExamRecord (Model) + + + + + 试卷ID + + + + + 用户ID + + + + + 试卷ID + + + + + 得分 + + + + + 开始答题时间 + + + + + 结束答题时间 + + + + + 实际开始时间 + + + + + 实际结束时间 + + + + + 备注 + + + + + 默认标志 + + + + + 预留字段1 + + + + + 预留字段2 + + + + + 预留字段3 + + + + + 预留字段4 + + + + + 预留字段5 + + + + + 预留字段6 + + + + + 预留字段7 + + + + + 预留字段8 + + + + + 预留字段9 + + + + + 预留字段10 + + + + + 预留字段11 + + + + + 预留字段12 + + + + + Ghre_ExamRecordDetail (Model) + + + + + 试卷ID + + + + + 答题记录ID + + + + + 题目ID + + + + + 用户ID + + + + + 题目答案ID + + + + + 答案内容 + + + + + 备注 + + + + + 默认标志 + + + + + 预留字段1 + + + + + 预留字段2 + + + + + 预留字段3 + + + + + 预留字段4 + + + + + 预留字段5 + + + + + 预留字段6 + + + + + 预留字段7 + + + + + 预留字段8 + + + + + 预留字段9 + + + + + 预留字段10 + + + + + 预留字段11 + + + + + 预留字段12 + + Ghre_ExamStaff (Model) @@ -6401,6 +6861,36 @@ 试卷题目(Dto.View) + + + Ghre_ExamRecord(Dto.View) + + + + + 创建信息 + + + + + 修改信息 + + + + + Ghre_ExamRecordDetail(Dto.View) + + + + + 创建信息 + + + + + 修改信息 + + Ghre_ExamStaff(Dto.View) diff --git a/Tiobon.Core/Tiobon.Core.xml b/Tiobon.Core/Tiobon.Core.xml index 287de0fc..096ef652 100644 --- a/Tiobon.Core/Tiobon.Core.xml +++ b/Tiobon.Core/Tiobon.Core.xml @@ -377,6 +377,17 @@ 主键ID + + + 分片上传 + + + + + + + + 登录管理【无权限】 @@ -626,6 +637,28 @@ pageData + + + 更新考试状态接口 + + + + + + + + 获取考试状态接口 + + + + + + + 开始考试 + + 考试ID + + 试卷配置(Controller) @@ -685,6 +718,16 @@ 试卷题目(Controller) + + + Ghre_ExamRecord(Controller) + + + + + Ghre_ExamRecordDetail(Controller) + + Ghre_ExamStaff(Controller)