修改人工时校正方法

This commit is contained in:
2022-04-01 23:00:24 +08:00
parent 274010da92
commit 3e4410437c
9 changed files with 510 additions and 366 deletions
@@ -107,51 +107,60 @@ namespace BLL
/// <returns></returns>
public static string EndTestPlan(string testPlanId)
{
Model.SGGLDB db = Funs.DB;
string info = string.Empty;
var getTestPlans = from x in db.Test_TestPlan
where x.States == Const.State_2 && x.TestEndTime.Value.AddMinutes(x.Duration.Value) < DateTime.Now
&& (testPlanId == null || x.TestPlanId == testPlanId)
select x;
foreach (var getTestPlan in getTestPlans)
using (Model.SGGLDB db = new Model.SGGLDB(Funs.ConnString))
{
string itemInfo = string.Empty;
var getTestRecords = from x in db.Test_TestRecord
where x.TestPlanId == testPlanId && (!x.TotalScore.HasValue || !x.TestEndTime.HasValue)
select x;
//// 考试下所有考试都交卷
if (getTestRecords.Count() > 0)
try
{
//// 扫码结束时间 + 考试时长 小于当前时间 考试结束 所有人自动交卷
if (getTestPlan.TestStartTime.Value.AddMinutes(getTestPlan.Duration.Value) < DateTime.Now)
string info = string.Empty;
var getTestPlans = from x in db.Test_TestPlan
where x.States == Const.State_2 && x.TestEndTime.Value.AddMinutes(x.Duration.Value) < DateTime.Now
&& (testPlanId == null || x.TestPlanId == testPlanId)
select x;
foreach (var getTestPlan in getTestPlans)
{
foreach (var itemRecord in getTestRecords)
string itemInfo = string.Empty;
var getTestRecords = from x in db.Test_TestRecord
where x.TestPlanId == testPlanId && (!x.TotalScore.HasValue || !x.TestEndTime.HasValue)
select x;
//// 考试下所有考试都交卷
if (getTestRecords.Count() > 0)
{
DateTime rdateTime = itemRecord.TestStartTime.HasValue ? itemRecord.TestStartTime.Value : getTestPlan.TestStartTime.Value;
itemRecord.TestEndTime = rdateTime.AddMinutes(itemRecord.Duration.Value);
itemRecord.TestScores = db.Test_TestRecordItem.Where(x => x.TestRecordId == itemRecord.TestRecordId).Sum(x => x.SubjectScore) ?? 0;
//// 扫码结束时间 + 考试时长 小于当前时间 考试结束 所有人自动交卷
if (getTestPlan.TestStartTime.Value.AddMinutes(getTestPlan.Duration.Value) < DateTime.Now)
{
foreach (var itemRecord in getTestRecords)
{
DateTime rdateTime = itemRecord.TestStartTime.HasValue ? itemRecord.TestStartTime.Value : getTestPlan.TestStartTime.Value;
itemRecord.TestEndTime = rdateTime.AddMinutes(itemRecord.Duration.Value);
itemRecord.TestScores = db.Test_TestRecordItem.Where(x => x.TestRecordId == itemRecord.TestRecordId).Sum(x => x.SubjectScore) ?? 0;
db.SubmitChanges();
}
}
else
{
itemInfo = getTestPlan.PlanCode + "竞赛中还有未交卷人员,且未达到考试结束时间!";
info += itemInfo;
}
}
if (string.IsNullOrEmpty(itemInfo))
{
getTestPlan.States = Const.State_3;
getTestPlan.ActualTime = DateTime.Now;
db.SubmitChanges();
}
}
else
if (getTestPlans.Count() == 0 && !string.IsNullOrEmpty(testPlanId))
{
itemInfo = getTestPlan.PlanCode + "竞赛中还有未交卷人员,且未达到考试结束时间!";
info += itemInfo;
info = "当前竞赛还不到结束时间!";
}
return info;
}
if (string.IsNullOrEmpty(itemInfo))
catch (Exception ex)
{
getTestPlan.States = Const.State_3;
getTestPlan.ActualTime = DateTime.Now;
db.SubmitChanges();
return null;
}
}
if (getTestPlans.Count() == 0 && !string.IsNullOrEmpty(testPlanId))
{
info = "当前竞赛还不到结束时间!";
}
return info;
}
/// <summary>