diff --git a/Tiobon.Core.Common/Helper/ExamHelper.cs b/Tiobon.Core.Common/Helper/ExamHelper.cs index c51a6eec..9a68ad04 100644 --- a/Tiobon.Core.Common/Helper/ExamHelper.cs +++ b/Tiobon.Core.Common/Helper/ExamHelper.cs @@ -22,6 +22,7 @@ public class ExamHelper var answers = await Db.Queryable() .Where(x => x.QuestionId != null && questionIds.Contains(x.QuestionId.Value) && x.IsCorrect == true) .ToListAsync(); + var answerIds = answers.Select(x => x.Id).ToList(); decimal? score = 0; details.ForEach(detail => @@ -72,7 +73,7 @@ public class ExamHelper break; default: - var questionAnswerIds = recordAnswers.Where(x => x.ExamRecordDetailId == detail.Id && x.QuestionAnswerId != null).Select(m => m.QuestionAnswerId).ToList(); + var questionAnswerIds = recordAnswers.Where(x => x.ExamRecordDetailId == detail.Id && x.QuestionAnswerId != null && answerIds.Contains(x.QuestionAnswerId.Value)).Select(m => m.QuestionAnswerId).ToList(); if (questionAnswerIds.Count == answers.Where(x => x.QuestionId == detail.QuestionId).Count()) { diff --git a/Tiobon.Core.Services/Ghre/Ghre_QuestionServices.cs b/Tiobon.Core.Services/Ghre/Ghre_QuestionServices.cs index 250f0deb..fa9aa864 100644 --- a/Tiobon.Core.Services/Ghre/Ghre_QuestionServices.cs +++ b/Tiobon.Core.Services/Ghre/Ghre_QuestionServices.cs @@ -444,13 +444,14 @@ public class Ghre_QuestionServices : BaseServices 0) { - var course = await _ghre_CourseServices.QueryById(courseID); - throw new Exception($"课程【{course.CourseName}】存在相同内容【{questionTypeName}】"); + //var course = await _ghre_CourseServices.QueryById(courseID); + //throw new Exception($"课程【{course.CourseName}】存在相同内容【{questionTypeName}】"); + throw new Exception($"题库中存在相同题目"); } } #endregion @@ -536,13 +537,14 @@ public class Ghre_QuestionServices : BaseServices 0) { - var course = await _ghre_CourseServices.QueryById(courseID); - throw new Exception($"课程【{course.CourseName}】存在相同内容【{questionTypeName}】"); + //var course = await _ghre_CourseServices.QueryById(courseID); + //throw new Exception($"课程【{course.CourseName}】存在相同内容【{questionTypeName}】"); + throw new Exception($"题库中存在相同题目"); } } #endregion @@ -852,6 +854,59 @@ public class Ghre_QuestionServices : BaseServices(); + + 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 (!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 courseName = dt.Rows[i]["课程(必填)"].ToString(); var questionContent = dt.Rows[i]["题目内容(必填)"].ToString(); var correctAnswer = string.Empty; @@ -1028,7 +1083,7 @@ public class Ghre_QuestionServices : BaseServices x.QuestionId = id); - await _ghre_QuestionAnswerServices.Add(insertAnswers); + //await _ghre_QuestionAnswerServices.Add(insertAnswers); } } else