fix:考试
This commit is contained in:
@@ -429,5 +429,104 @@ namespace WebAPI.Controllers
|
||||
}
|
||||
#endregion
|
||||
|
||||
|
||||
#region 根据PersonId的岗位获取试卷
|
||||
|
||||
/// <summary>
|
||||
/// 根据PersonId的岗位获取试卷
|
||||
/// </summary>
|
||||
/// <param name="personId">人员ID</param>
|
||||
/// <returns></returns>
|
||||
public Model.ResponeData getTestPlanRecordItemByPersonId(string personId, string projectId)
|
||||
{
|
||||
var responeData = new Model.ResponeData();
|
||||
try
|
||||
{
|
||||
var person = Funs.DB.View_SitePerson_Person.FirstOrDefault(x => x.PersonId == personId);
|
||||
if (person != null)
|
||||
{
|
||||
Model.Training_TestRecord newTestRecord = new Model.Training_TestRecord
|
||||
{
|
||||
TestRecordId = SQLHelper.GetNewID(),
|
||||
ProjectId = projectId,
|
||||
TestManId = person.PersonId
|
||||
};
|
||||
TestRecordService.AddTestRecord(newTestRecord);
|
||||
|
||||
var testRecordId = CreateTestRecordItemNew(newTestRecord.TestRecordId, person);
|
||||
responeData.code = 1;
|
||||
responeData.data = new { testRecordId };
|
||||
}
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
responeData.code = 0;
|
||||
responeData.message = ex.Message;
|
||||
}
|
||||
|
||||
return responeData;
|
||||
}
|
||||
|
||||
|
||||
public static string CreateTestRecordItemNew(string testRecordId, Model.View_SitePerson_Person person)
|
||||
{
|
||||
using (Model.SUBQHSEDB db = new Model.SUBQHSEDB(Funs.ConnString))
|
||||
{
|
||||
var getTestTrainingItemList = (from x in Funs.DB.Training_TestTrainingItem
|
||||
where x.TrainingId == "99ccf4c8-6f8e-47da-a900-53b12a278f25" &&
|
||||
x.WorkPostNames.Contains(person.WorkPostName)
|
||||
orderby x.TestType, x.TrainingItemCode
|
||||
select new
|
||||
{
|
||||
x.TrainingItemId,
|
||||
x.TrainingId,
|
||||
x.TrainingItemName,
|
||||
x.TrainingItemCode,
|
||||
x.Abstracts,
|
||||
x.AttachUrl,
|
||||
x.TestType,
|
||||
x.WorkPostIds,
|
||||
x.WorkPostNames,
|
||||
x.AItem,
|
||||
x.BItem,
|
||||
x.CItem,
|
||||
x.DItem,
|
||||
x.EItem,
|
||||
x.AnswerItems,
|
||||
x.Score
|
||||
}).ToList();
|
||||
|
||||
|
||||
if (getTestTrainingItemList.Count() > 0)
|
||||
{
|
||||
var getItems = from x in getTestTrainingItemList
|
||||
select new Model.Training_TestRecordItem
|
||||
{
|
||||
TestRecordItemId = SQLHelper.GetNewID(),
|
||||
TestRecordId = testRecordId,
|
||||
TrainingItemName = x.TrainingItemName,
|
||||
TrainingItemCode = x.TrainingItemCode,
|
||||
Abstracts = x.Abstracts,
|
||||
AttachUrl = x.AttachUrl,
|
||||
TestType = x.TestType,
|
||||
AItem = x.AItem,
|
||||
BItem = x.BItem,
|
||||
CItem = x.CItem,
|
||||
DItem = x.DItem,
|
||||
EItem = x.EItem,
|
||||
AnswerItems = x.AnswerItems,
|
||||
Score = x.Score,
|
||||
};
|
||||
|
||||
db.Training_TestRecordItem.InsertAllOnSubmit(getItems);
|
||||
db.SubmitChanges();
|
||||
}
|
||||
|
||||
return testRecordId;
|
||||
}
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
@@ -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
|
||||
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1158,15 +1158,24 @@ namespace WebAPI.Controllers
|
||||
{
|
||||
if (person != null && !string.IsNullOrEmpty(person.IdentityCard))
|
||||
{
|
||||
var getPerson = db.SitePerson_Person.FirstOrDefault(x => x.IdentityCard == person.IdentityCard.Trim() && x.ProjectId == person.ProjectId);
|
||||
var getPerson = db.SitePerson_Person.FirstOrDefault(x => x.IdentityCard == person.IdentityCard.Trim() && x.UnitId == person.UnitId);
|
||||
if (getPerson != null)
|
||||
{
|
||||
responeData.code = -1;
|
||||
responeData.message = "该身份证号码已存在两条记录,请联系管理员处理!";
|
||||
responeData.message = "该身份证号码在次单位下已存在两条记录,请联系管理员处理!";
|
||||
}
|
||||
else
|
||||
{
|
||||
|
||||
var items = db.SitePerson_Person.Where(x => x.IdentityCard == person.IdentityCard.Trim()).ToList();
|
||||
if (items.Count > 0)
|
||||
{
|
||||
foreach (var item in items)
|
||||
{
|
||||
item.IsUsedType = "0";
|
||||
PersonService.UpdatePerson(item);
|
||||
}
|
||||
}
|
||||
|
||||
Model.SitePerson_Person newPerson = new Model.SitePerson_Person
|
||||
{
|
||||
PersonId = SQLHelper.GetNewID(),
|
||||
|
||||
Reference in New Issue
Block a user