diff --git a/Model/Tiobon.Web.pdm b/Model/Tiobon.Web.pdm index 70ff58f8..72f380c8 100644 --- a/Model/Tiobon.Web.pdm +++ b/Model/Tiobon.Web.pdm @@ -1,5 +1,5 @@ - + @@ -108793,11 +108793,11 @@ LABL 0 Arial Unicode MS,8,N AnswerContent 1714100011 Administrator -1718094009 +1723191811 Administrator 答案内容 -nvarchar(64) -64 +nvarchar(2000) +2000 A52547CF-D5F2-40A4-AF47-7E613EE8DB7D diff --git a/Tiobon.Core.Common/Helper/NPOIHelper.cs b/Tiobon.Core.Common/Helper/NPOIHelper.cs index 1b06a914..289267f6 100644 --- a/Tiobon.Core.Common/Helper/NPOIHelper.cs +++ b/Tiobon.Core.Common/Helper/NPOIHelper.cs @@ -291,7 +291,16 @@ public class NPOIHelper } } } - sheet.SetColumnWidth(columnNum, columnWidth * 300); // 256 + try + { + sheet.SetColumnWidth(columnNum, columnWidth * 300); // 256 + + } + catch (Exception e) + { + + } + } rowIndex++; diff --git a/Tiobon.Core.Model/Base/Ghre/Ghre_QuestionAnswer.Dto.Base.cs b/Tiobon.Core.Model/Base/Ghre/Ghre_QuestionAnswer.Dto.Base.cs index 3d3847d9..52dca68f 100644 --- a/Tiobon.Core.Model/Base/Ghre/Ghre_QuestionAnswer.Dto.Base.cs +++ b/Tiobon.Core.Model/Base/Ghre/Ghre_QuestionAnswer.Dto.Base.cs @@ -40,7 +40,7 @@ namespace Tiobon.Core.Model.Models /// /// 答案内容 /// - [Display(Name = "AnswerContent"), Description("答案内容"), MaxLength(64, ErrorMessage = "答案内容 不能超过 64 个字符")] + [Display(Name = "AnswerContent"), Description("答案内容"), MaxLength(2000, ErrorMessage = "答案内容 不能超过 64 个字符")] public string AnswerContent { get; set; } /// diff --git a/Tiobon.Core.Model/Models/Ghre/Ghre_QuestionAnswer.cs b/Tiobon.Core.Model/Models/Ghre/Ghre_QuestionAnswer.cs index 84eb0e10..f544f7b9 100644 --- a/Tiobon.Core.Model/Models/Ghre/Ghre_QuestionAnswer.cs +++ b/Tiobon.Core.Model/Models/Ghre/Ghre_QuestionAnswer.cs @@ -42,7 +42,7 @@ namespace Tiobon.Core.Model.Models /// /// 答案内容 /// - [Display(Name = "AnswerContent"), Description("答案内容"), MaxLength(64, ErrorMessage = "答案内容 不能超过 64 个字符")] + [Display(Name = "AnswerContent"), Description("答案内容"), MaxLength(2000, ErrorMessage = "答案内容 不能超过 64 个字符")] public string AnswerContent { get; set; } /// diff --git a/Tiobon.Core.Model/View/Ghre/Ghre_ExamRecord.Dto.View.cs b/Tiobon.Core.Model/View/Ghre/Ghre_ExamRecord.Dto.View.cs index 15fbc742..23048a7a 100644 --- a/Tiobon.Core.Model/View/Ghre/Ghre_ExamRecord.Dto.View.cs +++ b/Tiobon.Core.Model/View/Ghre/Ghre_ExamRecord.Dto.View.cs @@ -38,6 +38,8 @@ public class Ghre_ExamRecordDto : Ghre_ExamRecord public string DeptNo { get; set; } public string DepteName { get; set; } + public string DeptFullPateName { get; set; } + public string TitleName { get; set; } public DateTime? Indate { get; set; } public string InStatus { get; set; } @@ -46,7 +48,10 @@ public class Ghre_ExamRecordDto : Ghre_ExamRecord public string ExamNo { get; set; } public string ExamName { get; set; } public string CourseName { get; set; } - + public string ScoreMethod { get; set; } + + public string ScoreMethodLabel { get; set; } + public decimal? TotalScore { get; set; } = 0; diff --git a/Tiobon.Core.Model/ViewModels/Extend/CoursePublicSearchField.cs b/Tiobon.Core.Model/ViewModels/Extend/CoursePublicSearchField.cs index 8e63d108..c0c4877c 100644 --- a/Tiobon.Core.Model/ViewModels/Extend/CoursePublicSearchField.cs +++ b/Tiobon.Core.Model/ViewModels/Extend/CoursePublicSearchField.cs @@ -39,9 +39,12 @@ public class CoursePublic public bool? DisableBtn { get; set; } public string BtnActionType { get; set; } = "Add"; + public string DateType { get; set; } public int AfterHowLong { get; set; } - + public string ExamDateString { get; set; } + public long? StudyRecordId { get; set; } + public long? ExamId { get; set; } } \ No newline at end of file diff --git a/Tiobon.Core.Model/ViewModels/Extend/Ghre_StudyRecordESS.cs b/Tiobon.Core.Model/ViewModels/Extend/Ghre_StudyRecordESS.cs index 21f9911d..e85545e1 100644 --- a/Tiobon.Core.Model/ViewModels/Extend/Ghre_StudyRecordESS.cs +++ b/Tiobon.Core.Model/ViewModels/Extend/Ghre_StudyRecordESS.cs @@ -44,6 +44,8 @@ public class Ghre_StudyRecordESS public string CourseDateString { get; set; } public string ExamDateString { get; set; } - public long? ExamId { get; set; } + public long? ExamId { get; set; } + public long? FeedbackOrderId { get; set; } + } diff --git a/Tiobon.Core.Services/Ghre/Ghre_CourseServices.cs b/Tiobon.Core.Services/Ghre/Ghre_CourseServices.cs index fa998efd..ec53e74b 100644 --- a/Tiobon.Core.Services/Ghre/Ghre_CourseServices.cs +++ b/Tiobon.Core.Services/Ghre/Ghre_CourseServices.cs @@ -756,9 +756,13 @@ public class Ghre_CourseServices : BaseServices { - if (x.ExamBeginDate != null && x.ExamEndDate != null) - x.ExamDateString = DateTimeHelper.ConvertToDayString(x.ExamBeginDate) + " ~ " + DateTimeHelper.ConvertToDayString(x.ExamEndDate); - else x.ExamDateString = $"学完{x.AfterHowLong}天"; + if (!x.ExamId.IsNull()) + { + if (x.ExamBeginDate != null && x.ExamEndDate != null && x.DateType == DicExamDateType.EXAM_DATE) + x.ExamDateString = DateTimeHelper.ConvertToDayString(x.ExamBeginDate) + " ~ " + DateTimeHelper.ConvertToDayString(x.ExamEndDate); + else if (x.DateType == DicExamDateType.AFTER_HOW_LONG) + x.ExamDateString = $"学完{x.AfterHowLong}天"; + } if (!x.StudyRecordId.IsNull()) x.DisableBtn = true; diff --git a/Tiobon.Core.Services/Ghre/Ghre_ExamRecordServices.cs b/Tiobon.Core.Services/Ghre/Ghre_ExamRecordServices.cs index f179fd8b..11933ca7 100644 --- a/Tiobon.Core.Services/Ghre/Ghre_ExamRecordServices.cs +++ b/Tiobon.Core.Services/Ghre/Ghre_ExamRecordServices.cs @@ -16,6 +16,7 @@ using Tiobon.Core.DataAccess; using System.Data; using static Tiobon.Core.Model.Consts; using Mysqlx.Crud; +using MongoDB.Driver.Linq; namespace Tiobon.Core.Services; @@ -109,6 +110,7 @@ public class Ghre_ExamRecordServices : BaseServices { + x.ScoreMethodLabel = await GetParaLabel("ScoreMethod", x.ScoreMethod); x.ScoreStatus = await GetParaLabel("TrainingExamScoreStatus", x.ScoreStatus); //x.CourseStatusLabel = await GetParaLabel("TrainingCourseStatus", x.CourseStatus); //x.StudyStatusLabel = await GetParaLabel("TrainingStudyStatus", x.StudyStatus); @@ -362,37 +364,31 @@ public class Ghre_ExamRecordServices : BaseServices().AnyAsync(x => x.Id == id)) - //{ - // var examRecord = await Db.Queryable().FirstAsync(x => x.ExamId == id); - // if (examRecord != null) - // examRecordId = examRecord.Id; - // else - // { - // var insrt = new InsertGhre_ExamRecordInput() - // { - - // }; - // examRecordId = await base.Add(insrt); - // } - //} - var staffId = GetStaffId(); - if (await Db.Queryable().AnyAsync(x => x.Id == id)) + + long? examRecordId = null; + Ghre_StudyRecord studyRecord = null; + if (await Db.Queryable().AnyAsync(x => x.Id == id)) + { + studyRecord = await Db.Queryable().FirstAsync(x => x.ExamId == id && x.StaffId == staffId); + if (studyRecord != null) + id = studyRecord.Id; + } + Ghre_Exam exam = null; + if (await Db.Queryable().AnyAsync(x => x.Id == id && x.StaffId == staffId)) { - var examRecord = await Db.Queryable().FirstAsync(x => x.StudyRecordId == id); + var examRecord = await Db.Queryable().FirstAsync(x => x.StudyRecordId == id && x.StaffId == staffId); if (!examRecord.IsNull()) examRecordId = examRecord.Id; else { - var studyRecord = await Db.Queryable().FirstAsync(x => x.Id == id); + studyRecord = await Db.Queryable().FirstAsync(x => x.Id == id && x.StaffId == staffId); - var exam = await Db.Queryable() - .Where(x => x.Id == studyRecord.ExamId) - .FirstAsync(x => x.Status == Consts.DIC_EXAM_STATUS.RELEASED); + exam = await Db.Queryable() + .Where(x => x.Id == studyRecord.ExamId) + .FirstAsync(x => x.Status == Consts.DIC_EXAM_STATUS.RELEASED); if (exam.IsNull()) exam = await Db.Queryable() .Where(x => x.Status == Consts.DIC_EXAM_STATUS.RELEASED @@ -429,20 +425,42 @@ public class Ghre_ExamRecordServices : BaseServices.OprateFailed("无效的考试ID!"); + return ServiceResult.OprateFailed("无效的考试链接!"); var record = records.result.DT_TableDataT1.FirstOrDefault(); + if (studyRecord.IsNull()) + studyRecord = await Db.Queryable().FirstAsync(x => x.Id == record.StudyRecordId); + + + if (studyRecord.StudyProgress.IsNull() || (!studyRecord.StudyProgress.IsNull() && studyRecord.StudyProgress < 100)) + return ServiceResult.OprateFailed("学习尚未结束暂不可考试!"); + + if (exam.IsNull()) + exam = await Db.Queryable() + .Where(x => x.Id == studyRecord.ExamId) + .FirstAsync(x => x.Status == Consts.DIC_EXAM_STATUS.RELEASED); + + + if (exam.IsNull()) + return ServiceResult.OprateFailed("该门课程尚未开启考试,请联系HR !"); + var dt = Db.GetDate(); + if (exam.DateType == Consts.DicExamDateType.AFTER_HOW_LONG) + { + record.BeginTime = studyRecord?.EndTime; + if (!record.BeginTime.IsNull()) + record.EndTime = record.BeginTime.Value.AddDays(exam.AfterHowLong ?? 7); + } if (!(record.BeginTime.Value.Date <= dt.Date && record.EndTime.Value.Date >= dt.Date)) return ServiceResult.OprateFailed("考试已结束!"); - var details = await Db.Queryable().Where(x => x.ExamRecordId == record.Id).ToListAsync(); var detailIds = details.Select(x => x.Id).ToList(); var recordAnswers = await Db.Queryable() @@ -640,8 +658,20 @@ public class Ghre_ExamRecordServices : BaseServices() + .Where(x => x.Id == entity.ExamId) + .FirstAsync(x => x.Status == Consts.DIC_EXAM_STATUS.RELEASED); + + var studyRecord = await Db.Queryable().FirstAsync(x => x.Id == entity.StudyRecordId); + if (exam.DateType == Consts.DicExamDateType.AFTER_HOW_LONG) + { + entity.BeginTime = studyRecord?.EndTime; + if (!entity.BeginTime.IsNull()) + entity.EndTime = entity.BeginTime.Value.AddDays(exam.AfterHowLong ?? 7); + } var dt = Db.GetDate(); - if (!(entity.BeginTime.Value <= dt.Date && entity.EndTime.Value >= dt.Date)) + if (!(entity.BeginTime.Value.Date <= dt.Date && entity.EndTime.Value.Date >= dt.Date)) return ServiceResult.OprateFailed("考试已结束!"); #region 试卷 引用次数 @@ -702,8 +732,21 @@ public class Ghre_ExamRecordServices : BaseServices().FirstAsync(x => x.Id == record.ExamPaperId); var dt = Db.GetDate(); + + var exam = await Db.Queryable() + .Where(x => x.Id == record.ExamId) + .FirstAsync(x => x.Status == Consts.DIC_EXAM_STATUS.RELEASED); + + var studyRecord = await Db.Queryable().FirstAsync(x => x.Id == record.StudyRecordId); + if (exam.DateType == Consts.DicExamDateType.AFTER_HOW_LONG) + { + record.BeginTime = studyRecord?.EndTime; + if (!record.BeginTime.IsNull()) + record.EndTime = record.BeginTime.Value.AddDays(exam.AfterHowLong ?? 7); + } + var endTime = record.EndTime.Value.AddDays(1).AddSeconds(9); - if (!(record.BeginTime <= dt && record.EndTime >= dt)) + if (!(record.BeginTime.Value.Date <= dt.Date && record.EndTime.Value.Date >= dt.Date)) return ServiceResult.OprateFailed("考试已结束!"); string sql = $@"UPDATE Ghre_ExamRecordDetail set IsEnable=0 where ExamRecordId='{record.Id}'; diff --git a/Tiobon.Core.Services/Ghre/Ghre_ExamServices.cs b/Tiobon.Core.Services/Ghre/Ghre_ExamServices.cs index d0be6f3b..0a8113a3 100644 --- a/Tiobon.Core.Services/Ghre/Ghre_ExamServices.cs +++ b/Tiobon.Core.Services/Ghre/Ghre_ExamServices.cs @@ -1332,7 +1332,7 @@ public class Ghre_ExamServices : BaseServices(); + DataTable dt = NPOIHelper.ImportExcel(filepath, x); + if (dt.Columns["Comments"] == null) + dt.Columns.Add("Comments", typeof(string)); - if (!dt.Columns.Contains("课程(必填)")) + for (int i = 0; i < dt.Rows.Count; i++) { - comments.Add("未查询到【课程(必填)】列!"); - data.ErrorCount++; - dt.Rows[i]["Comments"] = string.Join(";", comments.Select(a => a)); - isExistError = true; - continue; - } + var comments = new List(); - if (!dt.Columns.Contains("题目内容(必填)")) - { - comments.Add("未查询到【题目内容(必填)】列!"); - data.ErrorCount++; - dt.Rows[i]["Comments"] = string.Join(";", comments.Select(a => a)); - isExistError = true; - continue; - } + if (!dt.Columns.Contains("课程(必填)")) + { + comments.Add("未查询到【课程(必填)】列!"); + data.ErrorCount++; + dt.Rows[i]["Comments"] = string.Join(";", comments.Select(a => a)); + isExistError = true; + continue; + } - if (questionType != "Completion" && questionType != "ShortAnswer") - if (!dt.Columns.Contains("正确答案(必填)")) + if (!dt.Columns.Contains("题目内容(必填)")) { - comments.Add("未查询到【正确答案(必填)】列!"); + comments.Add("未查询到【题目内容(必填)】列!"); data.ErrorCount++; dt.Rows[i]["Comments"] = string.Join(";", comments.Select(a => a)); isExistError = true; continue; } - if (!dt.Columns.Contains("课程(必填)")) - { - comments.Add("未查询到【课程(必填)】列!"); - data.ErrorCount++; - dt.Rows[i]["Comments"] = string.Join(";", comments.Select(a => a)); - isExistError = true; - continue; - } - if (!dt.Columns.Contains("解析")) - { - comments.Add("未查询到【解析】列!"); - data.ErrorCount++; - dt.Rows[i]["Comments"] = string.Join(";", comments.Select(a => a)); - isExistError = true; - continue; - } - if (!dt.Columns.Contains("难度")) - { - comments.Add("未查询到【难度】列!"); - data.ErrorCount++; - dt.Rows[i]["Comments"] = string.Join(";", comments.Select(a => a)); - isExistError = true; - continue; - } + if (questionType != "Completion" && questionType != "ShortAnswer") + if (!dt.Columns.Contains("正确答案(必填)")) + { + comments.Add("未查询到【正确答案(必填)】列!"); + data.ErrorCount++; + dt.Rows[i]["Comments"] = string.Join(";", comments.Select(a => a)); + isExistError = true; + continue; + } - var courseName = dt.Rows[i]["课程(必填)"].ToString(); - var questionContent = dt.Rows[i]["题目内容(必填)"].ToString(); - var correctAnswer = string.Empty; - if (questionType != "Completion" && questionType != "ShortAnswer") - correctAnswer = dt.Rows[i]["正确答案(必填)"].ToString(); + if (!dt.Columns.Contains("课程(必填)")) + { + comments.Add("未查询到【课程(必填)】列!"); + data.ErrorCount++; + dt.Rows[i]["Comments"] = string.Join(";", comments.Select(a => a)); + isExistError = true; + continue; + } + if (!dt.Columns.Contains("解析")) + { + comments.Add("未查询到【解析】列!"); + data.ErrorCount++; + dt.Rows[i]["Comments"] = string.Join(";", comments.Select(a => a)); + isExistError = true; + continue; + } + if (!dt.Columns.Contains("难度")) + { + comments.Add("未查询到【难度】列!"); + data.ErrorCount++; + dt.Rows[i]["Comments"] = string.Join(";", comments.Select(a => a)); + isExistError = true; + continue; + } - var questionAnalysis = dt.Rows[i]["解析"].ToString(); - var difficultyLevel = dt.Rows[i]["难度"].ToString() ?? "普通"; - if (string.IsNullOrEmpty(questionContent)) - comments.Add("题目内容为必填项!"); + var courseName = dt.Rows[i]["课程(必填)"].ToString(); + var questionContent = dt.Rows[i]["题目内容(必填)"].ToString(); + var correctAnswer = string.Empty; + if (questionType != "Completion" && questionType != "ShortAnswer") + correctAnswer = dt.Rows[i]["正确答案(必填)"].ToString(); - var question = await base.Query(x => x.QuestionContent == questionContent && x.QuestionType == questionType); - if (!question.Any()) - { + var questionAnalysis = dt.Rows[i]["解析"].ToString(); + var difficultyLevel = dt.Rows[i]["难度"].ToString() ?? "普通"; + if (string.IsNullOrEmpty(questionContent)) + comments.Add("题目内容为必填项!"); - if (string.IsNullOrEmpty(courseName)) - comments.Add("课程为必填项!"); - if (string.IsNullOrWhiteSpace(correctAnswer) && questionType != "Completion" && questionType != "ShortAnswer") - comments.Add("正确答案未标记!"); - if (string.IsNullOrWhiteSpace(difficultyLevel)) - comments.Add("难易程度必填!"); - if (string.IsNullOrWhiteSpace(questionAnalysis)) - comments.Add("题目解析必填!"); - - Ghre_CourseDto course = null; - if (!string.IsNullOrEmpty(courseName)) + var question = await base.Query(x => x.QuestionContent == questionContent && x.QuestionType == questionType); + if (!question.Any()) { - course = await _ghre_CourseServices.QuerySingleDto(x => x.CourseName == courseName); - if (course is null) - comments.Add("课程不存在,请修正!"); - } - var insert = new InsertGhre_QuestionInput() - { - CourseId = course?.Id, - QuestionNo = await GenerateContinuousSequence(questionType.Substring(0, 1)), - DifficultyLevel = ConvertDifficultyLevel1(difficultyLevel), - QuestionType = questionType, - QuestionContent = questionContent, - QuestionAnalysis = questionAnalysis - }; - var insertAnswers = new List(); - - if (questionType == "Single" || questionType == "Multiple") - { - #region 单选题/多选题 - int j = 100; - answers.ForEach(a => - { - var answer = dt.Rows[i]["选项" + a].ToString(); - if (!string.IsNullOrWhiteSpace(answer)) - { - var isCorrect = false; + if (string.IsNullOrEmpty(courseName)) + comments.Add("课程为必填项!"); + if (string.IsNullOrWhiteSpace(correctAnswer) && questionType != "Completion" && questionType != "ShortAnswer") + comments.Add("正确答案未标记!"); + if (string.IsNullOrWhiteSpace(difficultyLevel)) + comments.Add("难易程度必填!"); + if (string.IsNullOrWhiteSpace(questionAnalysis)) + comments.Add("题目解析必填!"); - if (correctAnswer.Contains(a)) - isCorrect = true; + Ghre_CourseDto course = null; + if (!string.IsNullOrEmpty(courseName)) + { + course = await _ghre_CourseServices.QuerySingleDto(x => x.CourseName == courseName); + if (course is null) + comments.Add("课程不存在,请修正!"); + } - insertAnswers.Add(new InsertGhre_QuestionAnswerInput() + var insert = new InsertGhre_QuestionInput() + { + CourseId = course?.Id, + QuestionNo = await GenerateContinuousSequence(questionType.Substring(0, 1)), + DifficultyLevel = ConvertDifficultyLevel1(difficultyLevel), + QuestionType = questionType, + QuestionContent = questionContent, + QuestionAnalysis = questionAnalysis + }; + var insertAnswers = new List(); + + if (questionType == "Single" || questionType == "Multiple") + { + #region 单选题/多选题 + int j = 100; + answers.ForEach(a => + { + var answer = dt.Rows[i]["选项" + a].ToString(); + if (!string.IsNullOrWhiteSpace(answer)) { - TaxisNo = j, - QuestionNo = a, - //QuestionId = id, - AnswerContent = answer, - IsCorrect = isCorrect - }); - } + var isCorrect = false; - j = j + 100; - }); + if (correctAnswer.Contains(a)) + isCorrect = true; - if (!insertAnswers.Any()) - comments.Add(questionType == "ShortAnswer" ? "关键词未填写!" : "答案选项必填!"); - if (insertAnswers.Count < 2 && questionType != "ShortAnswer" && questionType != "Completion") - comments.Add("答案选项不能少于两个!"); + insertAnswers.Add(new InsertGhre_QuestionAnswerInput() + { + TaxisNo = j, + QuestionNo = a, + //QuestionId = id, + AnswerContent = answer, + IsCorrect = isCorrect + }); + } - if ((questionType == "Single" || questionType == "Multiple" || questionType == "TrueOrFalse") && !insertAnswers.Any(o => o.IsCorrect == true)) - comments.Add("正确答案未标记!"); + j = j + 100; + }); - if (questionType == "Multiple" && insertAnswers.Where(o => o.IsCorrect == true).Count() < 2) - comments.Add("答案至少需标记处两个正确答案!"); - #endregion + if (!insertAnswers.Any()) + comments.Add(questionType == "ShortAnswer" ? "关键词未填写!" : "答案选项必填!"); + if (insertAnswers.Count < 2 && questionType != "ShortAnswer" && questionType != "Completion") + comments.Add("答案选项不能少于两个!"); - } - else if (questionType == "TrueOrFalse") - { + if ((questionType == "Single" || questionType == "Multiple" || questionType == "TrueOrFalse") && !insertAnswers.Any(o => o.IsCorrect == true)) + comments.Add("正确答案未标记!"); - #region 判断题 - insertAnswers.Add(new InsertGhre_QuestionAnswerInput() - { - TaxisNo = 100, - QuestionNo = "A", - //QuestionId = id, - AnswerContent = "对", - IsCorrect = correctAnswer == "正确" - }); - insertAnswers.Add(new InsertGhre_QuestionAnswerInput() + if (questionType == "Multiple" && insertAnswers.Where(o => o.IsCorrect == true).Count() < 2) + comments.Add("答案至少需标记处两个正确答案!"); + #endregion + + } + else if (questionType == "TrueOrFalse") { - TaxisNo = 200, - QuestionNo = "B", - //QuestionId = id, - AnswerContent = "错", - IsCorrect = correctAnswer == "错误" - }); - #endregion - } - else if (questionType == "Completion") - { - questionContent = questionContent.Replace("()", "()"); - var completionCount = 0; - for (int ii = 1; ii < 11; ii++) + #region 判断题 + insertAnswers.Add(new InsertGhre_QuestionAnswerInput() + { + TaxisNo = 100, + QuestionNo = "A", + //QuestionId = id, + AnswerContent = "对", + IsCorrect = correctAnswer == "正确" + }); + insertAnswers.Add(new InsertGhre_QuestionAnswerInput() + { + TaxisNo = 200, + QuestionNo = "B", + //QuestionId = id, + AnswerContent = "错", + IsCorrect = correctAnswer == "错误" + }); + #endregion + } + else if (questionType == "Completion") { - var answer = dt.Rows[i]["答案" + ii].ToString(); - if (!string.IsNullOrWhiteSpace(answer)) + questionContent = questionContent.Replace("()", "()"); + + var completionCount = 0; + for (int ii = 1; ii < 11; ii++) { - completionCount++; - int index = questionContent.IndexOf("()"); - if (index > -1) + var answer = dt.Rows[i]["答案" + ii].ToString(); + if (!string.IsNullOrWhiteSpace(answer)) { - if (questionContent.Length > index + 4) + completionCount++; + int index = questionContent.IndexOf("()"); + if (index > -1) { - if (questionContent.Substring(index + 2, 2) == "()") - questionContent = questionContent.Substring(0, index) + "____、" + questionContent.Substring(index + 2); + if (questionContent.Length > index + 4) + { + if (questionContent.Substring(index + 2, 2) == "()") + questionContent = questionContent.Substring(0, index) + "____、" + questionContent.Substring(index + 2); + } + else + questionContent = questionContent.Substring(0, index) + "____" + questionContent.Substring(index + 2); + + insertAnswers.Add(new InsertGhre_QuestionAnswerInput() + { + TaxisNo = ii * 100, + QuestionNo = answer, + //QuestionId = id, + AnswerContent = answer, + IsCorrect = true + }); } - else - questionContent = questionContent.Substring(0, index) + "____" + questionContent.Substring(index + 2); + } + } + if (completionCount != insertAnswers.Count) + comments.Add("题目内容填空个数与答案个数不匹配!"); + else + insert.QuestionContent = questionContent; + } + else if (questionType == "ShortAnswer") + { + for (int ii = 1; ii < 11; ii++) + { + if (!dt.Columns.Contains("关键词" + ii)) + continue; + var answer = dt.Rows[i]["关键词" + ii].ToString(); + if (!string.IsNullOrWhiteSpace(answer)) + { insertAnswers.Add(new InsertGhre_QuestionAnswerInput() { TaxisNo = ii * 100, @@ -1046,62 +1074,39 @@ public class Ghre_QuestionServices : BaseServices a)); + isExistError = true; + continue; + } else - insert.QuestionContent = questionContent; - } - else if (questionType == "ShortAnswer") - { - for (int ii = 1; ii < 11; ii++) { - if (!dt.Columns.Contains("关键词" + ii)) - continue; - var answer = dt.Rows[i]["关键词" + ii].ToString(); - if (!string.IsNullOrWhiteSpace(answer)) - { - insertAnswers.Add(new InsertGhre_QuestionAnswerInput() - { - TaxisNo = ii * 100, - QuestionNo = answer, - //QuestionId = id, - AnswerContent = answer, - IsCorrect = true - }); - } + data.SuccessCount++; + id = await base.Add(insert); + insertAnswers.ForEach(x => x.QuestionId = id); + await _ghre_QuestionAnswerServices.Add(insertAnswers); } } - if (comments.Any()) + else { + dt.Rows[i]["Comments"] = "试题在系统中已存在!"; data.ErrorCount++; - dt.Rows[i]["Comments"] = string.Join(";", comments.Select(a => a)); isExistError = true; continue; } - else - { - data.SuccessCount++; - id = await base.Add(insert); - insertAnswers.ForEach(x => x.QuestionId = id); - await _ghre_QuestionAnswerServices.Add(insertAnswers); - } + } - else + + if (isExistError) { - dt.Rows[i]["Comments"] = "试题在系统中已存在!"; - data.ErrorCount++; - isExistError = true; - continue; + NPOIHelper.ExportExcel(dt, null, x, physicsPath + errorFileName); + data.filePath = errorFileName; } - } - - - if (isExistError) + catch (Exception) { - NPOIHelper.ExportExcel(dt, null, x, physicsPath + errorFileName); - data.filePath = errorFileName; } } diff --git a/Tiobon.Core.Services/Ghre/Ghre_StudyRecordServices.cs b/Tiobon.Core.Services/Ghre/Ghre_StudyRecordServices.cs index ff1ea021..a2b9ed9f 100644 --- a/Tiobon.Core.Services/Ghre/Ghre_StudyRecordServices.cs +++ b/Tiobon.Core.Services/Ghre/Ghre_StudyRecordServices.cs @@ -9,9 +9,7 @@ using Tiobon.Core.Common; using Tiobon.Core.Model; using Newtonsoft.Json; using Tiobon.Core.Common.Helper; -using MySqlX.XDevAPI.Common; using SqlSugar; -using Google.Protobuf.WellKnownTypes; using static Tiobon.Core.Model.Consts; namespace Tiobon.Core.Services @@ -193,7 +191,7 @@ namespace Tiobon.Core.Services A.DefaultCoverImageName, A.CourseName, A.StandardHour, - A.CreditPoints, + A.CourseCreditPoints CreditPoints, A.CourseBeginTime CourseBeginDate, A.CourseEndTime CourseEndDate, A.ExamDate, @@ -321,6 +319,8 @@ namespace Tiobon.Core.Services if (x.StudyProgress < 100 || x.ExamId.IsNull()) x.DisableExamBtn = true; + if (x.FeedbackOrderId.IsNull()) + x.ShowFeedbackBtn = false; }); return new ServicePageResult(filter.pageNum, total, filter.pageSize, entitys); @@ -491,12 +491,19 @@ namespace Tiobon.Core.Services var staffId = GetStaffId(); if (!await base.AnyAsync(x => x.CourseId == courseId && x.StaffId == staffId)) { - var course = await Db.Queryable().Where(x => x.Id == courseId && x.Status == Consts.DIC_COURSE_STATUS.RELEASED).FirstAsync(); + var course = await Db.Queryable().Where(x => x.Id == courseId && x.Status == DIC_COURSE_STATUS.RELEASED).FirstAsync(); if (course.IsNull()) return ServiceResult.OprateFailed("无效的课程!"); DateTime courseTime = Db.GetDate(); var snap = await Db.Queryable().FirstAsync(x => x.CourseId == courseId); + + var exam = await Db.Queryable() + .Where(x => x.Status == DIC_EXAM_STATUS.RELEASED && + x.CourseId == courseId + && ((x.DateType == DicExamDateType.EXAM_DATE + && x.BeginTime.Value.Date <= DateTime.Now.Date && x.EndTime.Value.Date >= DateTime.Now.Date) || x.DateType == DicExamDateType.AFTER_HOW_LONG)) + .FirstAsync(); await base.Add(new InsertGhre_StudyRecordInput { StaffId = staffId, @@ -506,8 +513,9 @@ namespace Tiobon.Core.Services CourseBeginTime = courseTime.Date, CourseEndTime = courseTime.Date.AddMonths(snap?.ValidityPeriod ?? 1), CourseType = "ManualElective", - CourseStatus = Consts.DIC_STUDY_RECORD_COURSE_STATUS_IN, - StudyStatus = Consts.DicStudyRecordStudyStatus.NO_JOIN + CourseStatus = DIC_STUDY_RECORD_COURSE_STATUS_IN, + StudyStatus = DicStudyRecordStudyStatus.NO_JOIN, + ExamId = exam?.Id }); } return ServiceResult.OprateSuccess("加入成功!");