diff --git a/Tiobon.Core.Services/Ghre/Ghre_QuestionServices.cs b/Tiobon.Core.Services/Ghre/Ghre_QuestionServices.cs index b72d5aec..c6006763 100644 --- a/Tiobon.Core.Services/Ghre/Ghre_QuestionServices.cs +++ b/Tiobon.Core.Services/Ghre/Ghre_QuestionServices.cs @@ -879,6 +879,7 @@ public class Ghre_QuestionServices : BaseServices x.CourseName == courseName); - var question = await base.Query(x => x.QuestionContent == questionContent && x.QuestionType == questionType && x.CourseId == course.Id); + var question = await base.Query(x => + x.QuestionContent == questionContent && + x.DifficultyLevel == difficultyLevel && + x.QuestionType == questionType); if (!question.Any()) { - var insert = new InsertGhre_QuestionInput() { CourseId = course?.Id, + CourseIds = "[" + course?.Id + "]", QuestionNo = await GenerateContinuousSequence(questionType.Substring(0, 1)), - DifficultyLevel = ConvertDifficultyLevel1(difficultyLevel), + DifficultyLevel = difficultyLevel, QuestionType = questionType, QuestionContent = questionContent, QuestionAnalysis = questionAnalysis @@ -1127,10 +1133,28 @@ public class Ghre_QuestionServices : BaseServices x.CourseIds != null && x.CourseIds.Contains(course.Id.ObjToString())).Any()) + { + dt.Rows[i]["Comments"] = "试题在系统中已存在!"; + data.ErrorCount++; + isExistError = true; + continue; + } + else + { + var coursIds = question.FirstOrDefault()?.CourseIds; + var coursIds1 = new List(); + if (coursIds.IsNotEmptyOrNull()) + coursIds1 = JsonHelper.JsonToObj>(coursIds); + coursIds1.Add(course.Id); + + + var question1 = question.FirstOrDefault(); + question1.CourseIds = JsonHelper.ObjToJson(coursIds1); + await base.Update(question1, ["CourseIds"]); + } + } }