20220802新增考试记录页 校正考题重复按钮,优化交卷功能

This commit is contained in:
2022-08-02 14:59:32 +08:00
parent 5767f8d259
commit 019e2fc83e
12 changed files with 174 additions and 81 deletions
@@ -192,59 +192,62 @@ namespace WebAPI.Controllers
var responeData = new Model.ResponeData();
try
{
var getTestPlan = Funs.DB.Training_TestPlan.FirstOrDefault(e => e.TestPlanId == testPlanId && e.States != "3" && e.TestStartTime <= DateTime.Now && e.TestEndTime >= DateTime.Now);
if (getTestPlan != null)
using (Model.SGGLDB db = new Model.SGGLDB(Funs.ConnString))
{
var person = PersonService.GetPersonByUserId(personId, getTestPlan.ProjectId);
if (person != null )
var getTestPlan = db.Training_TestPlan.FirstOrDefault(e => e.TestPlanId == testPlanId && e.States != "3" && e.TestStartTime <= DateTime.Now && e.TestEndTime >= DateTime.Now);
if (getTestPlan != null)
{
//2-考试中;生成考试试卷
if (getTestPlan.States == "2" )
var person = PersonService.GetPersonByUserId(personId, getTestPlan.ProjectId);
if (person != null)
{
var testRecord = Funs.DB.Training_TestRecord.FirstOrDefault(x => x.TestPlanId == getTestPlan.TestPlanId && x.TestManId == person.PersonId && !x.TestEndTime.HasValue);
if (testRecord != null)
//2-考试中;生成考试试卷
if (getTestPlan.States == "2")
{
string testRecordId = APITestRecordService.CreateTestRecordItem(getTestPlan, testRecord.TestRecordId, person);
responeData.code = 2;
responeData.data = new { testRecordId };
}
}
else
{
if (string.IsNullOrEmpty(getTestPlan.PlanId) && getTestPlan.UnitIds.Contains(person.UnitId) && (getTestPlan.WorkPostIds == null || getTestPlan.WorkPostIds.Contains(person.WorkPostId)))
{
//0-待提交;1-已发布未考试 将人员添加进考试记录
var testTRecord = Funs.DB.Training_TestRecord.FirstOrDefault(x => x.TestPlanId == testPlanId && x.TestManId == personId);
if ((getTestPlan.States == "0" || getTestPlan.States == "1") && testTRecord == null && !string.IsNullOrEmpty(personId))
var testRecord = db.Training_TestRecord.FirstOrDefault(x => x.TestPlanId == getTestPlan.TestPlanId && x.TestManId == person.PersonId && !x.TestEndTime.HasValue);
if (testRecord != null)
{
Model.Training_TestRecord newTestRecord = new Model.Training_TestRecord
string testRecordId = APITestRecordService.CreateTestRecordItem(getTestPlan, testRecord.TestRecordId, person);
responeData.code = 2;
responeData.data = new { testRecordId };
}
}
else
{
if (string.IsNullOrEmpty(getTestPlan.PlanId) && getTestPlan.UnitIds.Contains(person.UnitId) && (getTestPlan.WorkPostIds == null || getTestPlan.WorkPostIds.Contains(person.WorkPostId)))
{
//0-待提交;1-已发布未考试 将人员添加进考试记录
var testTRecord = db.Training_TestRecord.FirstOrDefault(x => x.TestPlanId == testPlanId && x.TestManId == personId);
if ((getTestPlan.States == "0" || getTestPlan.States == "1") && testTRecord == null && !string.IsNullOrEmpty(personId))
{
TestRecordId = SQLHelper.GetNewID(),
ProjectId = getTestPlan.ProjectId,
TestPlanId = getTestPlan.TestPlanId,
TestManId = personId,
};
if (string.IsNullOrEmpty(newTestRecord.TestType))
{
var getTrainTypeName = Funs.DB.Training_TestPlan.FirstOrDefault(x => x.TestPlanId == newTestRecord.TestPlanId);
if (getTrainTypeName != null)
Model.Training_TestRecord newTestRecord = new Model.Training_TestRecord
{
newTestRecord.TestType = getTrainTypeName.PlanName;
TestRecordId = SQLHelper.GetNewID(),
ProjectId = getTestPlan.ProjectId,
TestPlanId = getTestPlan.TestPlanId,
TestManId = personId,
};
if (string.IsNullOrEmpty(newTestRecord.TestType))
{
var getTrainTypeName = db.Training_TestPlan.FirstOrDefault(x => x.TestPlanId == newTestRecord.TestPlanId);
if (getTrainTypeName != null)
{
newTestRecord.TestType = getTrainTypeName.PlanName;
}
}
TestRecordService.AddTestRecord(newTestRecord);
responeData.code = 3;
responeData.message = "您已加入考试计划!";
}
TestRecordService.AddTestRecord(newTestRecord);
responeData.code = 3;
responeData.message = "您已加入考试计划!";
}
}
}
}
}
}
if (responeData.code == 1)
{
//其他状态时 查看考试计划详细页
responeData.data = APITestPlanService.getTestPlanByTestPlanId(testPlanId);
if (responeData.code == 1)
{
//其他状态时 查看考试计划详细页
responeData.data = APITestPlanService.getTestPlanByTestPlanId(testPlanId);
}
}
}
catch (Exception ex)
@@ -374,6 +374,37 @@ namespace WebAPI.Controllers
return responeData;
}
#endregion
#endregion
/// <summary>
/// 重考
/// </summary>
/// <param name="testRecordId">试卷ID</param>
public Model.ResponeData getRetakeTestRecordByTestRecordId(string testRecordId)
{
var responeData = new Model.ResponeData();
try
{
using (Model.SGGLDB db = new Model.SGGLDB(Funs.ConnString))
{
string returnTestRecordId = string.Empty;
var getTestRecord = db.Training_TestRecord.FirstOrDefault(e => e.TestRecordId == testRecordId);
if (getTestRecord != null)
{
////重新生成一条考试记录 以及考试试卷
returnTestRecordId = APITestRecordService.getResitTestRecord(getTestRecord);
responeData.data = new { returnTestRecordId };
}
}
}
catch (Exception ex)
{
responeData.code = 0;
responeData.message = ex.Message;
}
return responeData;
}
}
}