diff --git a/Tiobon.Core.Services/Ghre/Ghre_QuestionServices.cs b/Tiobon.Core.Services/Ghre/Ghre_QuestionServices.cs index ee7eefdd..57877874 100644 --- a/Tiobon.Core.Services/Ghre/Ghre_QuestionServices.cs +++ b/Tiobon.Core.Services/Ghre/Ghre_QuestionServices.cs @@ -570,20 +570,14 @@ public class Ghre_QuestionServices : BaseServices 0) - { - //var course = await _ghre_CourseServices.QueryById(courseID); - //throw new Exception($"课程【{course.CourseName}】存在相同内容【{questionTypeName}】"); throw new Exception($"题库中存在相同题目"); - } } #endregion - - var data = await base.QueryById(Id); await _ghre_QuestionAnswerServices.Delete(x => x.QuestionId == Id); var edit = Mapper.Map(data).ToANew(); @@ -593,6 +587,7 @@ public class Ghre_QuestionServices : BaseServices new InsertGhre_QuestionAnswerInput() @@ -627,42 +622,42 @@ public class Ghre_QuestionServices : BaseServices new InsertGhre_QuestionAnswerInput() - { - QuestionNo = x.No, - AnswerContent = x.label, - ImageUrl = x.imageUrl, - ImageWidthPc = x.imgWidthPc, - ImageWidthApp = x.imgWidthApp, - }).ToList(); - i = 100; - insertAnswers.ForEach(x => - { - x.TaxisNo = i; - x.QuestionId = id; - if (questionType.detail.answer != null && questionType.detail.answer == x.QuestionNo && (insert.QuestionType == "Single" || insert.QuestionType == "TrueOrFalse")) - x.IsCorrect = true; - if (questionType.detail.answer1 != null && questionType.detail.answer1.Contains(x.QuestionNo) && (insert.QuestionType == "ShortAnswer" || insert.QuestionType == "Multiple" || insert.QuestionType == "Completion")) - x.IsCorrect = true; - i = i + 100; - }); - if (insertAnswers.Where(b => string.IsNullOrWhiteSpace(b.AnswerContent)).Any()) - throw new Exception(insert.QuestionType == "ShortAnswer" ? "关键词存在空值!" : "答案选项存在空值!"); - if (!insertAnswers.Where(b => b.IsCorrect == true).Any()) - throw new Exception(insert.QuestionType == "ShortAnswer" ? "关键词未填写!" : "正确答案未标记!"); - - await _ghre_QuestionAnswerServices.Add(insertAnswers); + //insertAnswers = questionType.detail.answerList.Select(x => new InsertGhre_QuestionAnswerInput() + //{ + // QuestionNo = x.No, + // AnswerContent = x.label, + // ImageUrl = x.imageUrl, + // ImageWidthPc = x.imgWidthPc, + // ImageWidthApp = x.imgWidthApp, + //}).ToList(); + //i = 100; + //insertAnswers.ForEach(x => + //{ + // x.TaxisNo = i; + // x.QuestionId = id; + // if (questionType.detail.answer != null && questionType.detail.answer == x.QuestionNo && (insert.QuestionType == "Single" || insert.QuestionType == "TrueOrFalse")) + // x.IsCorrect = true; + // if (questionType.detail.answer1 != null && questionType.detail.answer1.Contains(x.QuestionNo) && (insert.QuestionType == "ShortAnswer" || insert.QuestionType == "Multiple" || insert.QuestionType == "Completion")) + // x.IsCorrect = true; + // i = i + 100; + //}); + //if (insertAnswers.Where(b => string.IsNullOrWhiteSpace(b.AnswerContent)).Any()) + // throw new Exception(insert.QuestionType == "ShortAnswer" ? "关键词存在空值!" : "答案选项存在空值!"); + //if (!insertAnswers.Where(b => b.IsCorrect == true).Any()) + // throw new Exception(insert.QuestionType == "ShortAnswer" ? "关键词未填写!" : "正确答案未标记!"); + + //await _ghre_QuestionAnswerServices.Add(insertAnswers); //} await Db.Ado.CommitTranAsync();