xiaochanghai 11 months ago
parent a73decbcad
commit 3ecd458f1b
  1. 8
      Model/Tiobon.Web.pdm
  2. 11
      Tiobon.Core.Common/Helper/NPOIHelper.cs
  3. 2
      Tiobon.Core.Model/Base/Ghre/Ghre_QuestionAnswer.Dto.Base.cs
  4. 2
      Tiobon.Core.Model/Models/Ghre/Ghre_QuestionAnswer.cs
  5. 7
      Tiobon.Core.Model/View/Ghre/Ghre_ExamRecord.Dto.View.cs
  6. 5
      Tiobon.Core.Model/ViewModels/Extend/CoursePublicSearchField.cs
  7. 4
      Tiobon.Core.Model/ViewModels/Extend/Ghre_StudyRecordESS.cs
  8. 10
      Tiobon.Core.Services/Ghre/Ghre_CourseServices.cs
  9. 95
      Tiobon.Core.Services/Ghre/Ghre_ExamRecordServices.cs
  10. 2
      Tiobon.Core.Services/Ghre/Ghre_ExamServices.cs
  11. 395
      Tiobon.Core.Services/Ghre/Ghre_QuestionServices.cs
  12. 20
      Tiobon.Core.Services/Ghre/Ghre_StudyRecordServices.cs

@ -1,5 +1,5 @@
<?xml version="1.0" encoding="UTF-8"?>
<?PowerDesigner AppLocale="UTF16" ID="{C294868A-C3F3-41AD-98CC-78B6D4E0CC40}" Label="" LastModificationDate="1723168103" Name="Tiobon" Objects="7364" Symbols="309" Target="Microsoft SQL Server 2008" Type="{CDE44E21-9669-11D1-9914-006097355D9B}" signature="PDM_DATA_MODEL_XML" version="15.0.0.2613"?>
<?PowerDesigner AppLocale="UTF16" ID="{C294868A-C3F3-41AD-98CC-78B6D4E0CC40}" Label="" LastModificationDate="1723191811" Name="Tiobon" Objects="7364" Symbols="309" Target="Microsoft SQL Server 2008" Type="{CDE44E21-9669-11D1-9914-006097355D9B}" signature="PDM_DATA_MODEL_XML" version="15.0.0.2613"?>
<!-- do not edit this file -->
<Model xmlns:a="attribute" xmlns:c="collection" xmlns:o="object">
@ -108793,11 +108793,11 @@ LABL 0 Arial Unicode MS,8,N</a:FontList>
<a:Code>AnswerContent</a:Code>
<a:CreationDate>1714100011</a:CreationDate>
<a:Creator>Administrator</a:Creator>
<a:ModificationDate>1718094009</a:ModificationDate>
<a:ModificationDate>1723191811</a:ModificationDate>
<a:Modifier>Administrator</a:Modifier>
<a:Comment>答案内容</a:Comment>
<a:DataType>nvarchar(64)</a:DataType>
<a:Length>64</a:Length>
<a:DataType>nvarchar(2000)</a:DataType>
<a:Length>2000</a:Length>
</o:Column>
<o:Column Id="o6595">
<a:ObjectID>A52547CF-D5F2-40A4-AF47-7E613EE8DB7D</a:ObjectID>

@ -291,7 +291,16 @@ public class NPOIHelper
}
}
}
sheet.SetColumnWidth(columnNum, columnWidth * 300); // 256
try
{
sheet.SetColumnWidth(columnNum, columnWidth * 300); // 256
}
catch (Exception e)
{
}
}
rowIndex++;

@ -40,7 +40,7 @@ namespace Tiobon.Core.Model.Models
/// <summary>
/// 答案内容
/// </summary>
[Display(Name = "AnswerContent"), Description("答案内容"), MaxLength(64, ErrorMessage = "答案内容 不能超过 64 个字符")]
[Display(Name = "AnswerContent"), Description("答案内容"), MaxLength(2000, ErrorMessage = "答案内容 不能超过 64 个字符")]
public string AnswerContent { get; set; }
/// <summary>

@ -42,7 +42,7 @@ namespace Tiobon.Core.Model.Models
/// <summary>
/// 答案内容
/// </summary>
[Display(Name = "AnswerContent"), Description("答案内容"), MaxLength(64, ErrorMessage = "答案内容 不能超过 64 个字符")]
[Display(Name = "AnswerContent"), Description("答案内容"), MaxLength(2000, ErrorMessage = "答案内容 不能超过 64 个字符")]
public string AnswerContent { get; set; }
/// <summary>

@ -38,6 +38,8 @@ public class Ghre_ExamRecordDto : Ghre_ExamRecord
public string DeptNo { get; set; }
public string DepteName { get; set; }
public string DeptFullPateName { get; set; }
public string TitleName { get; set; }
public DateTime? Indate { get; set; }
public string InStatus { get; set; }
@ -46,7 +48,10 @@ public class Ghre_ExamRecordDto : Ghre_ExamRecord
public string ExamNo { get; set; }
public string ExamName { get; set; }
public string CourseName { get; set; }
public string ScoreMethod { get; set; }
public string ScoreMethodLabel { get; set; }
public decimal? TotalScore { get; set; } = 0;

@ -39,9 +39,12 @@ public class CoursePublic
public bool? DisableBtn { get; set; }
public string BtnActionType { get; set; } = "Add";
public string DateType { get; set; }
public int AfterHowLong { get; set; }
public string ExamDateString { get; set; }
public long? StudyRecordId { get; set; }
public long? ExamId { get; set; }
}

@ -44,6 +44,8 @@ public class Ghre_StudyRecordESS
public string CourseDateString { get; set; }
public string ExamDateString { get; set; }
public long? ExamId { get; set; }
public long? ExamId { get; set; }
public long? FeedbackOrderId { get; set; }
}

@ -756,9 +756,13 @@ public class Ghre_CourseServices : BaseServices<Ghre_Course, Ghre_CourseDto, Ins
data.ForEach(x =>
{
if (x.ExamBeginDate != null && x.ExamEndDate != null)
x.ExamDateString = DateTimeHelper.ConvertToDayString(x.ExamBeginDate) + " ~ " + DateTimeHelper.ConvertToDayString(x.ExamEndDate);
else x.ExamDateString = $"学完{x.AfterHowLong}天";
if (!x.ExamId.IsNull())
{
if (x.ExamBeginDate != null && x.ExamEndDate != null && x.DateType == DicExamDateType.EXAM_DATE)
x.ExamDateString = DateTimeHelper.ConvertToDayString(x.ExamBeginDate) + " ~ " + DateTimeHelper.ConvertToDayString(x.ExamEndDate);
else if (x.DateType == DicExamDateType.AFTER_HOW_LONG)
x.ExamDateString = $"学完{x.AfterHowLong}天";
}
if (!x.StudyRecordId.IsNull())
x.DisableBtn = true;

@ -16,6 +16,7 @@ using Tiobon.Core.DataAccess;
using System.Data;
using static Tiobon.Core.Model.Consts;
using Mysqlx.Crud;
using MongoDB.Driver.Linq;
namespace Tiobon.Core.Services;
@ -109,6 +110,7 @@ public class Ghre_ExamRecordServices : BaseServices<Ghre_ExamRecord, Ghre_ExamRe
entitys.ForEach(async x =>
{
x.ScoreMethodLabel = await GetParaLabel("ScoreMethod", x.ScoreMethod);
x.ScoreStatus = await GetParaLabel("TrainingExamScoreStatus", x.ScoreStatus);
//x.CourseStatusLabel = await GetParaLabel("TrainingCourseStatus", x.CourseStatus);
//x.StudyStatusLabel = await GetParaLabel("TrainingStudyStatus", x.StudyStatus);
@ -362,37 +364,31 @@ public class Ghre_ExamRecordServices : BaseServices<Ghre_ExamRecord, Ghre_ExamRe
body.pageNum = 1;
body.pageSize = 10000;
long examRecordId = 0;
//if (await Db.Queryable<Ghre_Exam>().AnyAsync(x => x.Id == id))
//{
// var examRecord = await Db.Queryable<Ghre_ExamRecord>().FirstAsync(x => x.ExamId == id);
// if (examRecord != null)
// examRecordId = examRecord.Id;
// else
// {
// var insrt = new InsertGhre_ExamRecordInput()
// {
// };
// examRecordId = await base.Add(insrt);
// }
//}
var staffId = GetStaffId();
if (await Db.Queryable<Ghre_StudyRecord>().AnyAsync(x => x.Id == id))
long? examRecordId = null;
Ghre_StudyRecord studyRecord = null;
if (await Db.Queryable<Ghre_Exam>().AnyAsync(x => x.Id == id))
{
studyRecord = await Db.Queryable<Ghre_StudyRecord>().FirstAsync(x => x.ExamId == id && x.StaffId == staffId);
if (studyRecord != null)
id = studyRecord.Id;
}
Ghre_Exam exam = null;
if (await Db.Queryable<Ghre_StudyRecord>().AnyAsync(x => x.Id == id && x.StaffId == staffId))
{
var examRecord = await Db.Queryable<Ghre_ExamRecord>().FirstAsync(x => x.StudyRecordId == id);
var examRecord = await Db.Queryable<Ghre_ExamRecord>().FirstAsync(x => x.StudyRecordId == id && x.StaffId == staffId);
if (!examRecord.IsNull())
examRecordId = examRecord.Id;
else
{
var studyRecord = await Db.Queryable<Ghre_StudyRecord>().FirstAsync(x => x.Id == id);
studyRecord = await Db.Queryable<Ghre_StudyRecord>().FirstAsync(x => x.Id == id && x.StaffId == staffId);
var exam = await Db.Queryable<Ghre_Exam>()
.Where(x => x.Id == studyRecord.ExamId)
.FirstAsync(x => x.Status == Consts.DIC_EXAM_STATUS.RELEASED);
exam = await Db.Queryable<Ghre_Exam>()
.Where(x => x.Id == studyRecord.ExamId)
.FirstAsync(x => x.Status == Consts.DIC_EXAM_STATUS.RELEASED);
if (exam.IsNull())
exam = await Db.Queryable<Ghre_Exam>()
.Where(x => x.Status == Consts.DIC_EXAM_STATUS.RELEASED
@ -429,20 +425,42 @@ public class Ghre_ExamRecordServices : BaseServices<Ghre_ExamRecord, Ghre_ExamRe
}
}
if (examRecordId == 0) examRecordId = id;
var records = await QueryFilterPage(body, $"Id='{examRecordId}' AND StaffId='{staffId}'");
if (!records.result.DT_TableDataT1.Any())
return ServiceResult<QueryExam>.OprateFailed("无效的考试ID!");
return ServiceResult<QueryExam>.OprateFailed("无效的考试链接!");
var record = records.result.DT_TableDataT1.FirstOrDefault();
if (studyRecord.IsNull())
studyRecord = await Db.Queryable<Ghre_StudyRecord>().FirstAsync(x => x.Id == record.StudyRecordId);
if (studyRecord.StudyProgress.IsNull() || (!studyRecord.StudyProgress.IsNull() && studyRecord.StudyProgress < 100))
return ServiceResult<QueryExam>.OprateFailed("学习尚未结束暂不可考试!");
if (exam.IsNull())
exam = await Db.Queryable<Ghre_Exam>()
.Where(x => x.Id == studyRecord.ExamId)
.FirstAsync(x => x.Status == Consts.DIC_EXAM_STATUS.RELEASED);
if (exam.IsNull())
return ServiceResult<QueryExam>.OprateFailed("该门课程尚未开启考试,请联系HR !");
var dt = Db.GetDate();
if (exam.DateType == Consts.DicExamDateType.AFTER_HOW_LONG)
{
record.BeginTime = studyRecord?.EndTime;
if (!record.BeginTime.IsNull())
record.EndTime = record.BeginTime.Value.AddDays(exam.AfterHowLong ?? 7);
}
if (!(record.BeginTime.Value.Date <= dt.Date && record.EndTime.Value.Date >= dt.Date))
return ServiceResult<QueryExam>.OprateFailed("考试已结束!");
var details = await Db.Queryable<Ghre_ExamRecordDetail>().Where(x => x.ExamRecordId == record.Id).ToListAsync();
var detailIds = details.Select(x => x.Id).ToList();
var recordAnswers = await Db.Queryable<Ghre_ExamRecordAnswer>()
@ -640,8 +658,20 @@ public class Ghre_ExamRecordServices : BaseServices<Ghre_ExamRecord, Ghre_ExamRe
if (entity is null)
return ServiceResult.OprateFailed("无效的考试ID!");
var exam = await Db.Queryable<Ghre_Exam>()
.Where(x => x.Id == entity.ExamId)
.FirstAsync(x => x.Status == Consts.DIC_EXAM_STATUS.RELEASED);
var studyRecord = await Db.Queryable<Ghre_StudyRecord>().FirstAsync(x => x.Id == entity.StudyRecordId);
if (exam.DateType == Consts.DicExamDateType.AFTER_HOW_LONG)
{
entity.BeginTime = studyRecord?.EndTime;
if (!entity.BeginTime.IsNull())
entity.EndTime = entity.BeginTime.Value.AddDays(exam.AfterHowLong ?? 7);
}
var dt = Db.GetDate();
if (!(entity.BeginTime.Value <= dt.Date && entity.EndTime.Value >= dt.Date))
if (!(entity.BeginTime.Value.Date <= dt.Date && entity.EndTime.Value.Date >= dt.Date))
return ServiceResult.OprateFailed("考试已结束!");
#region 试卷 引用次数
@ -702,8 +732,21 @@ public class Ghre_ExamRecordServices : BaseServices<Ghre_ExamRecord, Ghre_ExamRe
var exampaper = await Db.Queryable<Ghre_ExamPaper>().FirstAsync(x => x.Id == record.ExamPaperId);
var dt = Db.GetDate();
var exam = await Db.Queryable<Ghre_Exam>()
.Where(x => x.Id == record.ExamId)
.FirstAsync(x => x.Status == Consts.DIC_EXAM_STATUS.RELEASED);
var studyRecord = await Db.Queryable<Ghre_StudyRecord>().FirstAsync(x => x.Id == record.StudyRecordId);
if (exam.DateType == Consts.DicExamDateType.AFTER_HOW_LONG)
{
record.BeginTime = studyRecord?.EndTime;
if (!record.BeginTime.IsNull())
record.EndTime = record.BeginTime.Value.AddDays(exam.AfterHowLong ?? 7);
}
var endTime = record.EndTime.Value.AddDays(1).AddSeconds(9);
if (!(record.BeginTime <= dt && record.EndTime >= dt))
if (!(record.BeginTime.Value.Date <= dt.Date && record.EndTime.Value.Date >= dt.Date))
return ServiceResult.OprateFailed("考试已结束!");
string sql = $@"UPDATE Ghre_ExamRecordDetail set IsEnable=0 where ExamRecordId='{record.Id}';

@ -1332,7 +1332,7 @@ public class Ghre_ExamServices : BaseServices<Ghre_Exam, Ghre_ExamDto, InsertGhr
else if (status == Consts.DIC_EXAM_STATUS.DRAFT)
return ServiceResult.OprateSuccess("取消发布成功!");
else
return ServiceResult.OprateSuccess("停用成功!");
return ServiceResult.OprateSuccess("归档成功!");
}

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

@ -9,9 +9,7 @@ using Tiobon.Core.Common;
using Tiobon.Core.Model;
using Newtonsoft.Json;
using Tiobon.Core.Common.Helper;
using MySqlX.XDevAPI.Common;
using SqlSugar;
using Google.Protobuf.WellKnownTypes;
using static Tiobon.Core.Model.Consts;
namespace Tiobon.Core.Services
@ -193,7 +191,7 @@ namespace Tiobon.Core.Services
A.DefaultCoverImageName,
A.CourseName,
A.StandardHour,
A.CreditPoints,
A.CourseCreditPoints CreditPoints,
A.CourseBeginTime CourseBeginDate,
A.CourseEndTime CourseEndDate,
A.ExamDate,
@ -321,6 +319,8 @@ namespace Tiobon.Core.Services
if (x.StudyProgress < 100 || x.ExamId.IsNull())
x.DisableExamBtn = true;
if (x.FeedbackOrderId.IsNull())
x.ShowFeedbackBtn = false;
});
return new ServicePageResult<Ghre_StudyRecordESS>(filter.pageNum, total, filter.pageSize, entitys);
@ -491,12 +491,19 @@ namespace Tiobon.Core.Services
var staffId = GetStaffId();
if (!await base.AnyAsync(x => x.CourseId == courseId && x.StaffId == staffId))
{
var course = await Db.Queryable<Ghre_Course>().Where(x => x.Id == courseId && x.Status == Consts.DIC_COURSE_STATUS.RELEASED).FirstAsync();
var course = await Db.Queryable<Ghre_Course>().Where(x => x.Id == courseId && x.Status == DIC_COURSE_STATUS.RELEASED).FirstAsync();
if (course.IsNull())
return ServiceResult.OprateFailed("无效的课程!");
DateTime courseTime = Db.GetDate();
var snap = await Db.Queryable<Ghre_CourseSnap>().FirstAsync(x => x.CourseId == courseId);
var exam = await Db.Queryable<Ghre_Exam>()
.Where(x => x.Status == DIC_EXAM_STATUS.RELEASED &&
x.CourseId == courseId
&& ((x.DateType == DicExamDateType.EXAM_DATE
&& x.BeginTime.Value.Date <= DateTime.Now.Date && x.EndTime.Value.Date >= DateTime.Now.Date) || x.DateType == DicExamDateType.AFTER_HOW_LONG))
.FirstAsync();
await base.Add(new InsertGhre_StudyRecordInput
{
StaffId = staffId,
@ -506,8 +513,9 @@ namespace Tiobon.Core.Services
CourseBeginTime = courseTime.Date,
CourseEndTime = courseTime.Date.AddMonths(snap?.ValidityPeriod ?? 1),
CourseType = "ManualElective",
CourseStatus = Consts.DIC_STUDY_RECORD_COURSE_STATUS_IN,
StudyStatus = Consts.DicStudyRecordStudyStatus.NO_JOIN
CourseStatus = DIC_STUDY_RECORD_COURSE_STATUS_IN,
StudyStatus = DicStudyRecordStudyStatus.NO_JOIN,
ExamId = exam?.Id
});
}
return ServiceResult.OprateSuccess("加入成功!");

Loading…
Cancel
Save