|
|
@ -847,194 +847,222 @@ public class Ghre_QuestionServices : BaseServices<Ghre_Question, Ghre_QuestionDt |
|
|
|
var x = types[jj]; |
|
|
|
var x = types[jj]; |
|
|
|
|
|
|
|
|
|
|
|
string questionType = ConvertQuestionType1(x); |
|
|
|
string questionType = ConvertQuestionType1(x); |
|
|
|
DataTable dt = NPOIHelper.ImportExcel(filepath, x); |
|
|
|
try |
|
|
|
if (dt.Columns["Comments"] == null) |
|
|
|
|
|
|
|
dt.Columns.Add("Comments", typeof(string)); |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
for (int i = 0; i < dt.Rows.Count; i++) |
|
|
|
|
|
|
|
{ |
|
|
|
{ |
|
|
|
var comments = new List<string>(); |
|
|
|
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("未查询到【课程(必填)】列!"); |
|
|
|
var comments = new List<string>(); |
|
|
|
data.ErrorCount++; |
|
|
|
|
|
|
|
dt.Rows[i]["Comments"] = string.Join(";", comments.Select(a => a)); |
|
|
|
|
|
|
|
isExistError = true; |
|
|
|
|
|
|
|
continue; |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
if (!dt.Columns.Contains("题目内容(必填)")) |
|
|
|
if (!dt.Columns.Contains("课程(必填)")) |
|
|
|
{ |
|
|
|
{ |
|
|
|
comments.Add("未查询到【题目内容(必填)】列!"); |
|
|
|
comments.Add("未查询到【课程(必填)】列!"); |
|
|
|
data.ErrorCount++; |
|
|
|
data.ErrorCount++; |
|
|
|
dt.Rows[i]["Comments"] = string.Join(";", comments.Select(a => a)); |
|
|
|
dt.Rows[i]["Comments"] = string.Join(";", comments.Select(a => a)); |
|
|
|
isExistError = true; |
|
|
|
isExistError = true; |
|
|
|
continue; |
|
|
|
continue; |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
if (questionType != "Completion" && questionType != "ShortAnswer") |
|
|
|
if (!dt.Columns.Contains("题目内容(必填)")) |
|
|
|
if (!dt.Columns.Contains("正确答案(必填)")) |
|
|
|
|
|
|
|
{ |
|
|
|
{ |
|
|
|
comments.Add("未查询到【正确答案(必填)】列!"); |
|
|
|
comments.Add("未查询到【题目内容(必填)】列!"); |
|
|
|
data.ErrorCount++; |
|
|
|
data.ErrorCount++; |
|
|
|
dt.Rows[i]["Comments"] = string.Join(";", comments.Select(a => a)); |
|
|
|
dt.Rows[i]["Comments"] = string.Join(";", comments.Select(a => a)); |
|
|
|
isExistError = true; |
|
|
|
isExistError = true; |
|
|
|
continue; |
|
|
|
continue; |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
if (!dt.Columns.Contains("课程(必填)")) |
|
|
|
if (questionType != "Completion" && questionType != "ShortAnswer") |
|
|
|
{ |
|
|
|
if (!dt.Columns.Contains("正确答案(必填)")) |
|
|
|
comments.Add("未查询到【课程(必填)】列!"); |
|
|
|
{ |
|
|
|
data.ErrorCount++; |
|
|
|
comments.Add("未查询到【正确答案(必填)】列!"); |
|
|
|
dt.Rows[i]["Comments"] = string.Join(";", comments.Select(a => a)); |
|
|
|
data.ErrorCount++; |
|
|
|
isExistError = true; |
|
|
|
dt.Rows[i]["Comments"] = string.Join(";", comments.Select(a => a)); |
|
|
|
continue; |
|
|
|
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(); |
|
|
|
if (!dt.Columns.Contains("课程(必填)")) |
|
|
|
var questionContent = dt.Rows[i]["题目内容(必填)"].ToString(); |
|
|
|
{ |
|
|
|
var correctAnswer = string.Empty; |
|
|
|
comments.Add("未查询到【课程(必填)】列!"); |
|
|
|
if (questionType != "Completion" && questionType != "ShortAnswer") |
|
|
|
data.ErrorCount++; |
|
|
|
correctAnswer = dt.Rows[i]["正确答案(必填)"].ToString(); |
|
|
|
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 courseName = dt.Rows[i]["课程(必填)"].ToString(); |
|
|
|
var difficultyLevel = dt.Rows[i]["难度"].ToString() ?? "普通"; |
|
|
|
var questionContent = dt.Rows[i]["题目内容(必填)"].ToString(); |
|
|
|
if (string.IsNullOrEmpty(questionContent)) |
|
|
|
var correctAnswer = string.Empty; |
|
|
|
comments.Add("题目内容为必填项!"); |
|
|
|
if (questionType != "Completion" && questionType != "ShortAnswer") |
|
|
|
|
|
|
|
correctAnswer = dt.Rows[i]["正确答案(必填)"].ToString(); |
|
|
|
|
|
|
|
|
|
|
|
var question = await base.Query(x => x.QuestionContent == questionContent && x.QuestionType == questionType); |
|
|
|
var questionAnalysis = dt.Rows[i]["解析"].ToString(); |
|
|
|
if (!question.Any()) |
|
|
|
var difficultyLevel = dt.Rows[i]["难度"].ToString() ?? "普通"; |
|
|
|
{ |
|
|
|
if (string.IsNullOrEmpty(questionContent)) |
|
|
|
|
|
|
|
comments.Add("题目内容为必填项!"); |
|
|
|
|
|
|
|
|
|
|
|
if (string.IsNullOrEmpty(courseName)) |
|
|
|
var question = await base.Query(x => x.QuestionContent == questionContent && x.QuestionType == questionType); |
|
|
|
comments.Add("课程为必填项!"); |
|
|
|
if (!question.Any()) |
|
|
|
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)) |
|
|
|
|
|
|
|
{ |
|
|
|
{ |
|
|
|
course = await _ghre_CourseServices.QuerySingleDto(x => x.CourseName == courseName); |
|
|
|
|
|
|
|
if (course is null) |
|
|
|
|
|
|
|
comments.Add("课程不存在,请修正!"); |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
var insert = new InsertGhre_QuestionInput() |
|
|
|
if (string.IsNullOrEmpty(courseName)) |
|
|
|
{ |
|
|
|
comments.Add("课程为必填项!"); |
|
|
|
CourseId = course?.Id, |
|
|
|
if (string.IsNullOrWhiteSpace(correctAnswer) && questionType != "Completion" && questionType != "ShortAnswer") |
|
|
|
QuestionNo = await GenerateContinuousSequence(questionType.Substring(0, 1)), |
|
|
|
comments.Add("正确答案未标记!"); |
|
|
|
DifficultyLevel = ConvertDifficultyLevel1(difficultyLevel), |
|
|
|
if (string.IsNullOrWhiteSpace(difficultyLevel)) |
|
|
|
QuestionType = questionType, |
|
|
|
comments.Add("难易程度必填!"); |
|
|
|
QuestionContent = questionContent, |
|
|
|
if (string.IsNullOrWhiteSpace(questionAnalysis)) |
|
|
|
QuestionAnalysis = questionAnalysis |
|
|
|
comments.Add("题目解析必填!"); |
|
|
|
}; |
|
|
|
|
|
|
|
var insertAnswers = new List<InsertGhre_QuestionAnswerInput>(); |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
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 (correctAnswer.Contains(a)) |
|
|
|
Ghre_CourseDto course = null; |
|
|
|
isCorrect = true; |
|
|
|
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<InsertGhre_QuestionAnswerInput>(); |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
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, |
|
|
|
var isCorrect = false; |
|
|
|
QuestionNo = a, |
|
|
|
|
|
|
|
//QuestionId = id, |
|
|
|
|
|
|
|
AnswerContent = answer, |
|
|
|
|
|
|
|
IsCorrect = isCorrect |
|
|
|
|
|
|
|
}); |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
j = j + 100; |
|
|
|
if (correctAnswer.Contains(a)) |
|
|
|
}); |
|
|
|
isCorrect = true; |
|
|
|
|
|
|
|
|
|
|
|
if (!insertAnswers.Any()) |
|
|
|
insertAnswers.Add(new InsertGhre_QuestionAnswerInput() |
|
|
|
comments.Add(questionType == "ShortAnswer" ? "关键词未填写!" : "答案选项必填!"); |
|
|
|
{ |
|
|
|
if (insertAnswers.Count < 2 && questionType != "ShortAnswer" && questionType != "Completion") |
|
|
|
TaxisNo = j, |
|
|
|
comments.Add("答案选项不能少于两个!"); |
|
|
|
QuestionNo = a, |
|
|
|
|
|
|
|
//QuestionId = id, |
|
|
|
|
|
|
|
AnswerContent = answer, |
|
|
|
|
|
|
|
IsCorrect = isCorrect |
|
|
|
|
|
|
|
}); |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
if ((questionType == "Single" || questionType == "Multiple" || questionType == "TrueOrFalse") && !insertAnswers.Any(o => o.IsCorrect == true)) |
|
|
|
j = j + 100; |
|
|
|
comments.Add("正确答案未标记!"); |
|
|
|
}); |
|
|
|
|
|
|
|
|
|
|
|
if (questionType == "Multiple" && insertAnswers.Where(o => o.IsCorrect == true).Count() < 2) |
|
|
|
if (!insertAnswers.Any()) |
|
|
|
comments.Add("答案至少需标记处两个正确答案!"); |
|
|
|
comments.Add(questionType == "ShortAnswer" ? "关键词未填写!" : "答案选项必填!"); |
|
|
|
#endregion |
|
|
|
if (insertAnswers.Count < 2 && questionType != "ShortAnswer" && questionType != "Completion") |
|
|
|
|
|
|
|
comments.Add("答案选项不能少于两个!"); |
|
|
|
|
|
|
|
|
|
|
|
} |
|
|
|
if ((questionType == "Single" || questionType == "Multiple" || questionType == "TrueOrFalse") && !insertAnswers.Any(o => o.IsCorrect == true)) |
|
|
|
else if (questionType == "TrueOrFalse") |
|
|
|
comments.Add("正确答案未标记!"); |
|
|
|
{ |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
#region 判断题 |
|
|
|
if (questionType == "Multiple" && insertAnswers.Where(o => o.IsCorrect == true).Count() < 2) |
|
|
|
insertAnswers.Add(new InsertGhre_QuestionAnswerInput() |
|
|
|
comments.Add("答案至少需标记处两个正确答案!"); |
|
|
|
{ |
|
|
|
#endregion |
|
|
|
TaxisNo = 100, |
|
|
|
|
|
|
|
QuestionNo = "A", |
|
|
|
} |
|
|
|
//QuestionId = id, |
|
|
|
else if (questionType == "TrueOrFalse") |
|
|
|
AnswerContent = "对", |
|
|
|
|
|
|
|
IsCorrect = correctAnswer == "正确" |
|
|
|
|
|
|
|
}); |
|
|
|
|
|
|
|
insertAnswers.Add(new InsertGhre_QuestionAnswerInput() |
|
|
|
|
|
|
|
{ |
|
|
|
{ |
|
|
|
TaxisNo = 200, |
|
|
|
|
|
|
|
QuestionNo = "B", |
|
|
|
|
|
|
|
//QuestionId = id, |
|
|
|
|
|
|
|
AnswerContent = "错", |
|
|
|
|
|
|
|
IsCorrect = correctAnswer == "错误" |
|
|
|
|
|
|
|
}); |
|
|
|
|
|
|
|
#endregion |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
else if (questionType == "Completion") |
|
|
|
|
|
|
|
{ |
|
|
|
|
|
|
|
questionContent = questionContent.Replace("()", "()"); |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
var completionCount = 0; |
|
|
|
#region 判断题 |
|
|
|
for (int ii = 1; ii < 11; ii++) |
|
|
|
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(); |
|
|
|
questionContent = questionContent.Replace("()", "()"); |
|
|
|
if (!string.IsNullOrWhiteSpace(answer)) |
|
|
|
|
|
|
|
|
|
|
|
var completionCount = 0; |
|
|
|
|
|
|
|
for (int ii = 1; ii < 11; ii++) |
|
|
|
{ |
|
|
|
{ |
|
|
|
completionCount++; |
|
|
|
var answer = dt.Rows[i]["答案" + ii].ToString(); |
|
|
|
int index = questionContent.IndexOf("()"); |
|
|
|
if (!string.IsNullOrWhiteSpace(answer)) |
|
|
|
if (index > -1) |
|
|
|
|
|
|
|
{ |
|
|
|
{ |
|
|
|
if (questionContent.Length > index + 4) |
|
|
|
completionCount++; |
|
|
|
|
|
|
|
int index = questionContent.IndexOf("()"); |
|
|
|
|
|
|
|
if (index > -1) |
|
|
|
{ |
|
|
|
{ |
|
|
|
if (questionContent.Substring(index + 2, 2) == "()") |
|
|
|
if (questionContent.Length > index + 4) |
|
|
|
questionContent = questionContent.Substring(0, index) + "____、" + questionContent.Substring(index + 2); |
|
|
|
{ |
|
|
|
|
|
|
|
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() |
|
|
|
insertAnswers.Add(new InsertGhre_QuestionAnswerInput() |
|
|
|
{ |
|
|
|
{ |
|
|
|
TaxisNo = ii * 100, |
|
|
|
TaxisNo = ii * 100, |
|
|
@ -1046,62 +1074,39 @@ public class Ghre_QuestionServices : BaseServices<Ghre_Question, Ghre_QuestionDt |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
if (comments.Any()) |
|
|
|
if (completionCount != insertAnswers.Count) |
|
|
|
{ |
|
|
|
comments.Add("题目内容填空个数与答案个数不匹配!"); |
|
|
|
data.ErrorCount++; |
|
|
|
|
|
|
|
dt.Rows[i]["Comments"] = string.Join(";", comments.Select(a => a)); |
|
|
|
|
|
|
|
isExistError = true; |
|
|
|
|
|
|
|
continue; |
|
|
|
|
|
|
|
} |
|
|
|
else |
|
|
|
else |
|
|
|
insert.QuestionContent = questionContent; |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
else if (questionType == "ShortAnswer") |
|
|
|
|
|
|
|
{ |
|
|
|
|
|
|
|
for (int ii = 1; ii < 11; ii++) |
|
|
|
|
|
|
|
{ |
|
|
|
{ |
|
|
|
if (!dt.Columns.Contains("关键词" + ii)) |
|
|
|
data.SuccessCount++; |
|
|
|
continue; |
|
|
|
id = await base.Add(insert); |
|
|
|
var answer = dt.Rows[i]["关键词" + ii].ToString(); |
|
|
|
insertAnswers.ForEach(x => x.QuestionId = id); |
|
|
|
if (!string.IsNullOrWhiteSpace(answer)) |
|
|
|
await _ghre_QuestionAnswerServices.Add(insertAnswers); |
|
|
|
{ |
|
|
|
|
|
|
|
insertAnswers.Add(new InsertGhre_QuestionAnswerInput() |
|
|
|
|
|
|
|
{ |
|
|
|
|
|
|
|
TaxisNo = ii * 100, |
|
|
|
|
|
|
|
QuestionNo = answer, |
|
|
|
|
|
|
|
//QuestionId = id, |
|
|
|
|
|
|
|
AnswerContent = answer, |
|
|
|
|
|
|
|
IsCorrect = true |
|
|
|
|
|
|
|
}); |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
if (comments.Any()) |
|
|
|
else |
|
|
|
{ |
|
|
|
{ |
|
|
|
|
|
|
|
dt.Rows[i]["Comments"] = "试题在系统中已存在!"; |
|
|
|
data.ErrorCount++; |
|
|
|
data.ErrorCount++; |
|
|
|
dt.Rows[i]["Comments"] = string.Join(";", comments.Select(a => a)); |
|
|
|
|
|
|
|
isExistError = true; |
|
|
|
isExistError = true; |
|
|
|
continue; |
|
|
|
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"] = "试题在系统中已存在!"; |
|
|
|
NPOIHelper.ExportExcel(dt, null, x, physicsPath + errorFileName); |
|
|
|
data.ErrorCount++; |
|
|
|
data.filePath = errorFileName; |
|
|
|
isExistError = true; |
|
|
|
|
|
|
|
continue; |
|
|
|
|
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
catch (Exception) |
|
|
|
|
|
|
|
|
|
|
|
if (isExistError) |
|
|
|
|
|
|
|
{ |
|
|
|
{ |
|
|
|
NPOIHelper.ExportExcel(dt, null, x, physicsPath + errorFileName); |
|
|
|
|
|
|
|
data.filePath = errorFileName; |
|
|
|
|
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|