|
|
|
@ -836,108 +836,104 @@ public class Ghre_QuestionServices : BaseServices<Ghre_Question, Ghre_QuestionDt |
|
|
|
|
string questionType = ConvertQuestionType1(x); |
|
|
|
|
try |
|
|
|
|
{ |
|
|
|
|
DataTable dt = NPOIHelper.ImportExcel(filepath, x); |
|
|
|
|
var dt = NPOIHelper.ImportExcel(filepath, x); |
|
|
|
|
if (dt.Columns["Comments"] == null) |
|
|
|
|
dt.Columns.Add("Comments", typeof(string)); |
|
|
|
|
var comments = new List<string>(); |
|
|
|
|
|
|
|
|
|
var filds = new List<string> |
|
|
|
|
{ |
|
|
|
|
"课程", |
|
|
|
|
"题目内容", |
|
|
|
|
"课程", |
|
|
|
|
"解析", |
|
|
|
|
"难度", |
|
|
|
|
"课程" |
|
|
|
|
}; |
|
|
|
|
for (int i = 0; i < dt.Rows.Count; i++) |
|
|
|
|
{ |
|
|
|
|
var comments = new List<string>(); |
|
|
|
|
|
|
|
|
|
if (!dt.Columns.Contains("课程(必填)")) |
|
|
|
|
comments = new List<string>(); |
|
|
|
|
for (int j = 0; j < filds.Count; j++) |
|
|
|
|
{ |
|
|
|
|
comments.Add("未查询到【课程(必填)】列!"); |
|
|
|
|
data.ErrorCount++; |
|
|
|
|
dt.Rows[i]["Comments"] = string.Join(";", comments.Select(a => a)); |
|
|
|
|
isExistError = true; |
|
|
|
|
continue; |
|
|
|
|
if (!dt.Columns.Contains(filds[j])) |
|
|
|
|
comments.Add("未查询到【" + filds[j] + "】列!"); |
|
|
|
|
} |
|
|
|
|
if (questionType != "Completion" && questionType != "ShortAnswer") |
|
|
|
|
if (!dt.Columns.Contains("正确答案")) |
|
|
|
|
comments.Add("未查询到【正确答案】列!"); |
|
|
|
|
|
|
|
|
|
var courseName = dt.Rows[i]["课程"].ToString(); |
|
|
|
|
var questionContent = dt.Rows[i]["题目内容"].ToString(); |
|
|
|
|
|
|
|
|
|
if (!dt.Columns.Contains("题目内容(必填)")) |
|
|
|
|
if (string.IsNullOrEmpty(questionContent)) |
|
|
|
|
comments.Add("题目内容为必填项!"); |
|
|
|
|
|
|
|
|
|
if (courseName.IsNullOrEmpty()) |
|
|
|
|
comments.Add("课程为必填项!"); |
|
|
|
|
else |
|
|
|
|
{ |
|
|
|
|
comments.Add("未查询到【题目内容(必填)】列!"); |
|
|
|
|
data.ErrorCount++; |
|
|
|
|
dt.Rows[i]["Comments"] = string.Join(";", comments.Select(a => a)); |
|
|
|
|
isExistError = true; |
|
|
|
|
continue; |
|
|
|
|
if (!await _ghre_CourseServices.AnyAsync(x => x.CourseName == courseName)) |
|
|
|
|
comments.Add("课程不存在,请修正!"); |
|
|
|
|
else |
|
|
|
|
{ |
|
|
|
|
Ghre_CourseDto course = await _ghre_CourseServices.QuerySingleDto(x => x.CourseName == courseName); |
|
|
|
|
if (course != null) |
|
|
|
|
{ |
|
|
|
|
var question = await base.Query(x => x.QuestionContent == questionContent && x.QuestionType == questionType && x.CourseId == course.Id); |
|
|
|
|
if (question.Any()) |
|
|
|
|
comments.Add("试题在系统中已存在!"); |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
var correctAnswer = string.Empty; |
|
|
|
|
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; |
|
|
|
|
} |
|
|
|
|
correctAnswer = dt.Rows[i]["正确答案"].ToString(); |
|
|
|
|
if (string.IsNullOrWhiteSpace(correctAnswer) && questionType != "Completion" && questionType != "ShortAnswer") |
|
|
|
|
comments.Add("正确答案未标记!"); |
|
|
|
|
var difficultyLevel = dt.Rows[i]["难度"].ToString() ?? "普通"; |
|
|
|
|
var questionAnalysis = dt.Rows[i]["解析"].ToString(); |
|
|
|
|
if (string.IsNullOrWhiteSpace(difficultyLevel)) |
|
|
|
|
comments.Add("难易程度必填!"); |
|
|
|
|
if (string.IsNullOrWhiteSpace(questionAnalysis)) |
|
|
|
|
comments.Add("题目解析必填!"); |
|
|
|
|
|
|
|
|
|
if (!dt.Columns.Contains("课程(必填)")) |
|
|
|
|
if (comments.Any()) |
|
|
|
|
{ |
|
|
|
|
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++; |
|
|
|
|
if (dt.Rows[i]["Comments"].ToString().IsNullOrEmpty()) |
|
|
|
|
dt.Rows[i]["Comments"] = string.Join(";", comments.Select(a => a)); |
|
|
|
|
isExistError = true; |
|
|
|
|
continue; |
|
|
|
|
else |
|
|
|
|
dt.Rows[i]["Comments"] += string.Join(";", comments.Select(a => a)); |
|
|
|
|
} |
|
|
|
|
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(); |
|
|
|
|
//if (isExistError) |
|
|
|
|
//{ |
|
|
|
|
// NPOIHelper.ExportExcel(dt, null, x, physicsPath + errorFileName); |
|
|
|
|
// data.filePath = "/Advanced" + errorFileName; |
|
|
|
|
// continue; |
|
|
|
|
//} |
|
|
|
|
|
|
|
|
|
for (int i = 0; i < dt.Rows.Count; i++) |
|
|
|
|
{ |
|
|
|
|
comments = new List<string>(); |
|
|
|
|
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(); |
|
|
|
|
correctAnswer = dt.Rows[i]["正确答案"].ToString(); |
|
|
|
|
|
|
|
|
|
var questionAnalysis = dt.Rows[i]["解析"].ToString(); |
|
|
|
|
var difficultyLevel = dt.Rows[i]["难度"].ToString() ?? "普通"; |
|
|
|
|
if (string.IsNullOrEmpty(questionContent)) |
|
|
|
|
comments.Add("题目内容为必填项!"); |
|
|
|
|
|
|
|
|
|
if (courseName.IsNullOrEmpty()) |
|
|
|
|
{ |
|
|
|
|
comments.Add("课程为必填项!"); |
|
|
|
|
continue; |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
Ghre_CourseDto course = null; |
|
|
|
|
if (!string.IsNullOrEmpty(courseName)) |
|
|
|
|
{ |
|
|
|
|
course = await _ghre_CourseServices.QuerySingleDto(x => x.CourseName == courseName); |
|
|
|
|
if (course is null) |
|
|
|
|
{ |
|
|
|
|
comments.Add("课程不存在,请修正!"); |
|
|
|
|
continue; |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
Ghre_CourseDto course = await _ghre_CourseServices.QuerySingleDto(x => x.CourseName == courseName); |
|
|
|
|
|
|
|
|
|
var question = await base.Query(x => x.QuestionContent == questionContent && x.QuestionType == questionType && x.CourseId == course.Id); |
|
|
|
|
if (!question.Any()) |
|
|
|
|
{ |
|
|
|
|
|
|
|
|
|
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("题目解析必填!"); |
|
|
|
|
|
|
|
|
|
var insert = new InsertGhre_QuestionInput() |
|
|
|
|
{ |
|
|
|
|
CourseId = course?.Id, |
|
|
|
@ -1092,7 +1088,6 @@ public class Ghre_QuestionServices : BaseServices<Ghre_Question, Ghre_QuestionDt |
|
|
|
|
isExistError = true; |
|
|
|
|
continue; |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
if (isExistError) |
|
|
|
@ -1101,7 +1096,7 @@ public class Ghre_QuestionServices : BaseServices<Ghre_Question, Ghre_QuestionDt |
|
|
|
|
data.filePath = "/Advanced" + errorFileName; |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
catch (Exception) |
|
|
|
|
catch (Exception E) |
|
|
|
|
{ |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|