fix:考试
This commit is contained in:
@@ -634,5 +634,73 @@ namespace WebAPI.Controllers
|
||||
|
||||
|
||||
#endregion
|
||||
|
||||
|
||||
#region 岗位交卷
|
||||
/// <summary>
|
||||
/// 岗位交卷
|
||||
/// <param name="testRecordId">试卷ID</param>
|
||||
/// </summary>
|
||||
public Model.ResponeData SaveSubmitTestRecord(string testRecordId,string Signature)
|
||||
{
|
||||
var responeData = new Model.ResponeData();
|
||||
try
|
||||
{
|
||||
using (Model.SUBQHSEDB db = new Model.SUBQHSEDB(Funs.ConnString))
|
||||
{
|
||||
string returnTestRecordId = string.Empty;
|
||||
decimal getTestScores = 0;
|
||||
var getTestRecord = db.Training_TestRecord.FirstOrDefault(e => e.TestRecordId == testRecordId);
|
||||
if (getTestRecord != null)
|
||||
{
|
||||
if (getTestRecord.TestStartTime.HasValue)
|
||||
{
|
||||
getTestRecord.Signature = Signature;
|
||||
getTestRecord.TestEndTime = DateTime.Now;
|
||||
getTestRecord.TestScores = db.Training_TestRecordItem.Where(x => x.TestRecordId == testRecordId).Sum(x => x.SubjectScore ?? 0);
|
||||
db.SubmitChanges();
|
||||
getTestScores = getTestRecord.TestScores ?? 0;
|
||||
}
|
||||
|
||||
////考试分数
|
||||
int getPassScores = 70;
|
||||
if (getTestScores < getPassScores)
|
||||
{
|
||||
int testCount = db.Training_TestRecord.Where(x => x.TestPlanId == getTestRecord.TestPlanId && x.TestManId == getTestRecord.TestManId).Count();
|
||||
if (testCount < 2)
|
||||
{
|
||||
////重新生成一条考试记录 以及考试试卷
|
||||
returnTestRecordId = APITestRecordService.getResitTestRecord(getTestRecord);
|
||||
responeData.message = "考试不合格!您的成绩为:【" + getTestScores.ToString() + "】,您将进入补考。";
|
||||
}
|
||||
else
|
||||
{
|
||||
// APITestRecordService.updateAll(getTestRecord.TestPlanId);
|
||||
responeData.message = "考试不合格!您的成绩为:【" + getTestScores.ToString() + "】,请再次参加培训后补考。";
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
// APITestRecordService.updateAll(getTestRecord.TestPlanId);
|
||||
responeData.message = "恭喜考试通过!您的成绩为:【" + getTestScores.ToString() + "】。";
|
||||
}
|
||||
|
||||
responeData.data = new { getTestScores, getPassScores, returnTestRecordId };
|
||||
}
|
||||
}
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
responeData.code = 0;
|
||||
responeData.message = ex.Message;
|
||||
}
|
||||
|
||||
return responeData;
|
||||
}
|
||||
|
||||
|
||||
#endregion
|
||||
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user