合并最新
This commit is contained in:
@@ -192,45 +192,89 @@ namespace WebAPI.Controllers
|
||||
var responeData = new Model.ResponeData();
|
||||
try
|
||||
{
|
||||
var getTestPlan = new Model.SGGLDB(Funs.ConnString).Training_TestPlan.FirstOrDefault(e => e.TestPlanId == testPlanId && e.States != "3" && e.TestStartTime <= DateTime.Now && e.TestEndTime >= DateTime.Now);
|
||||
if (getTestPlan != null)
|
||||
using (var 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 user = db.Sys_User.FirstOrDefault(x=>x.UserId==personId);
|
||||
Model.SitePerson_Person person;
|
||||
if (user != null)
|
||||
{
|
||||
var testRecord = new Model.SGGLDB(Funs.ConnString).Training_TestRecord.FirstOrDefault(x => x.TestPlanId == getTestPlan.TestPlanId && x.TestManId == person.PersonId && !x.TestEndTime.HasValue);
|
||||
if (testRecord != null)
|
||||
{
|
||||
string testRecordId = APITestRecordService.CreateTestRecordItem(getTestPlan, testRecord.TestRecordId, person);
|
||||
responeData.code = 2;
|
||||
responeData.data = new { testRecordId };
|
||||
}
|
||||
person = Funs.DB.SitePerson_Person.FirstOrDefault(e => (e.PersonId == personId || e.IdentityCard == user.IdentityCard) && e.ProjectId == getTestPlan.ProjectId);// PersonService.GetPersonByUserId(personId, getTestPlan.ProjectId);
|
||||
}
|
||||
else
|
||||
{
|
||||
if (string.IsNullOrEmpty(getTestPlan.PlanId) && getTestPlan.UnitIds.Contains(person.UnitId) && (getTestPlan.WorkPostIds == null || getTestPlan.WorkPostIds.Contains(person.WorkPostId)))
|
||||
person = Funs.DB.SitePerson_Person.FirstOrDefault(e => e.PersonId == personId && e.ProjectId == getTestPlan.ProjectId);// PersonService.GetPersonByUserId(personId, getTestPlan.ProjectId);
|
||||
|
||||
}
|
||||
if (person != null || user != null)
|
||||
{
|
||||
//2-考试中;生成考试试卷
|
||||
if (getTestPlan.States == "2")
|
||||
{
|
||||
//0-待提交;1-已发布未考试 将人员添加进考试记录
|
||||
var testTRecord = new Model.SGGLDB(Funs.ConnString).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 == personId && !x.TestEndTime.HasValue);
|
||||
if (testRecord != null)
|
||||
{
|
||||
Model.Training_TestRecord newTestRecord = new Model.Training_TestRecord
|
||||
string testRecordId = APITestRecordService.CreateTestRecordItem(getTestPlan, testRecord.TestRecordId, person,user);
|
||||
responeData.code = 2;
|
||||
responeData.data = new { testRecordId };
|
||||
}
|
||||
else if(person !=null)
|
||||
{
|
||||
var testRecord2 = db.Training_TestRecord.FirstOrDefault(x => x.TestPlanId == getTestPlan.TestPlanId && x.TestManId == person.PersonId && !x.TestEndTime.HasValue);
|
||||
if (testRecord2 != null)
|
||||
{
|
||||
TestRecordId = SQLHelper.GetNewID(),
|
||||
ProjectId = getTestPlan.ProjectId,
|
||||
TestPlanId = getTestPlan.TestPlanId,
|
||||
TestManId = personId,
|
||||
};
|
||||
TestRecordService.AddTestRecord(newTestRecord);
|
||||
responeData.code = 3;
|
||||
responeData.message = "您已加入考试计划!";
|
||||
string testRecordId = APITestRecordService.CreateTestRecordItem(getTestPlan, testRecord2.TestRecordId, person, user);
|
||||
responeData.code = 2;
|
||||
responeData.data = new { testRecordId };
|
||||
}
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
if (person!=null&&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 == person.PersonId);
|
||||
if ((getTestPlan.States == "0" || getTestPlan.States == "1") && testTRecord == null && !string.IsNullOrEmpty(personId))
|
||||
{
|
||||
Model.Training_TestRecord newTestRecord = new Model.Training_TestRecord
|
||||
{
|
||||
TestRecordId = SQLHelper.GetNewID(),
|
||||
ProjectId = getTestPlan.ProjectId,
|
||||
TestPlanId = getTestPlan.TestPlanId,
|
||||
TestManId = personId,
|
||||
};
|
||||
TestRecordService.AddTestRecord(newTestRecord);
|
||||
responeData.code = 3;
|
||||
responeData.message = "您已加入考试计划!";
|
||||
}
|
||||
}
|
||||
|
||||
if (user != null && string.IsNullOrEmpty(getTestPlan.PlanId) && getTestPlan.UnitIds.Contains(user.UnitId) && (getTestPlan.DepartIds == null || getTestPlan.DepartIds.Contains(user.DepartId)))
|
||||
{
|
||||
//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))
|
||||
{
|
||||
Model.Training_TestRecord newTestRecord = new Model.Training_TestRecord
|
||||
{
|
||||
TestRecordId = SQLHelper.GetNewID(),
|
||||
ProjectId = getTestPlan.ProjectId,
|
||||
TestPlanId = getTestPlan.TestPlanId,
|
||||
TestManId = personId,
|
||||
};
|
||||
TestRecordService.AddTestRecord(newTestRecord);
|
||||
responeData.code = 3;
|
||||
responeData.message = "您已加入考试计划!";
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (responeData.code == 1)
|
||||
|
||||
@@ -218,18 +218,34 @@ namespace WebAPI.Controllers
|
||||
/// <param name="strPass">0-未通过;1通过;空所有</param>
|
||||
/// <param name="pageIndex">页码</param>
|
||||
/// <returns>考试记录列表</returns>
|
||||
public Model.ResponeData getTrainingTestRecordListQuery(string projectId, string unitId, string workPostId, string strPass, int pageIndex)
|
||||
public Model.ResponeData getTrainingTestRecordListQuery(string projectId, string unitId, string workPostId, string departId, string strPass, int pageIndex)
|
||||
{
|
||||
var responeData = new Model.ResponeData();
|
||||
try
|
||||
{
|
||||
var getDataLists = APITestRecordService.getTrainingTestRecordListByProjectId(projectId, unitId, workPostId, strPass, string.Empty);
|
||||
int pageCount = getDataLists.Count;
|
||||
if (pageCount > 0 && pageIndex > 0)
|
||||
if (!string.IsNullOrEmpty(departId))
|
||||
{
|
||||
getDataLists = getDataLists.OrderByDescending(x => x.TestStartTime).Skip(Funs.PageSize * (pageIndex - 1)).Take(Funs.PageSize).ToList();
|
||||
var getDataLists = APITestRecordService.getTrainingTestRecordListByDepartId(unitId,departId,strPass,string.Empty);
|
||||
int pageCount = getDataLists.Count;
|
||||
if (pageCount > 0 && pageIndex > 0)
|
||||
{
|
||||
getDataLists = getDataLists.OrderByDescending(x => x.TestStartTime).Skip(Funs.PageSize * (pageIndex - 1)).Take(Funs.PageSize).ToList();
|
||||
}
|
||||
responeData.data = new { pageCount, getDataLists };
|
||||
}
|
||||
responeData.data = new { pageCount, getDataLists };
|
||||
else
|
||||
{
|
||||
|
||||
var getDataLists = APITestRecordService.getTrainingTestRecordListByProjectId(projectId, unitId, workPostId, strPass, string.Empty);
|
||||
int pageCount = getDataLists.Count;
|
||||
if (pageCount > 0 && pageIndex > 0)
|
||||
{
|
||||
getDataLists = getDataLists.OrderByDescending(x => x.TestStartTime).Skip(Funs.PageSize * (pageIndex - 1)).Take(Funs.PageSize).ToList();
|
||||
}
|
||||
responeData.data = new { pageCount, getDataLists };
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
@@ -251,26 +267,7 @@ namespace WebAPI.Controllers
|
||||
/// <param name="strParam">参数</param>
|
||||
/// <param name="pageIndex">页码</param>
|
||||
/// <returns>考试记录列表</returns>
|
||||
public Model.ResponeData getTrainingTestRecordListQuery(string projectId, string unitId, string workPostId, string strPass,string strParam, int pageIndex)
|
||||
{
|
||||
var responeData = new Model.ResponeData();
|
||||
try
|
||||
{
|
||||
var getDataLists = APITestRecordService.getTrainingTestRecordListByProjectId(projectId, unitId, workPostId, strPass, strParam);
|
||||
int pageCount = getDataLists.Count;
|
||||
if (pageCount > 0 && pageIndex > 0)
|
||||
{
|
||||
getDataLists = getDataLists.OrderByDescending(x => x.TestStartTime).Skip(Funs.PageSize * (pageIndex - 1)).Take(Funs.PageSize).ToList();
|
||||
}
|
||||
responeData.data = new { pageCount, getDataLists };
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
responeData.code = 0;
|
||||
responeData.message = ex.Message;
|
||||
}
|
||||
return responeData;
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
#region 根据TestRecordItemId、selectedItem 考生答题
|
||||
@@ -284,25 +281,58 @@ namespace WebAPI.Controllers
|
||||
var responeData = new Model.ResponeData();
|
||||
try
|
||||
{
|
||||
var getItem = TestRecordItemService.GetTestRecordItemTestRecordItemId(testRecordItemId);
|
||||
if (getItem != null)
|
||||
if (!string.IsNullOrEmpty(testRecordItemId) && !string.IsNullOrEmpty(selectedItem))
|
||||
{
|
||||
//更新没有结束时间且超时的考试记录
|
||||
int closeCount = TestRecordService.UpdateTestEndTimeNull(getItem.TestRecordId);
|
||||
if (closeCount > 0)
|
||||
using (Model.SGGLDB db = new Model.SGGLDB(Funs.ConnString))
|
||||
{
|
||||
responeData.code = 2;
|
||||
responeData.message = "本次考试已结束,系统自动交卷!";
|
||||
}
|
||||
else
|
||||
{
|
||||
APITestRecordService.getTestRecordItemAnswerBySelectedItem(getItem, selectedItem);
|
||||
var getTItem = db.Training_TestRecordItem.FirstOrDefault(x => x.TestRecordItemId == testRecordItemId);
|
||||
if (getTItem != null)
|
||||
{
|
||||
getTItem.SubjectScore = 0;
|
||||
getTItem.SelectedItem = selectedItem;
|
||||
if (!string.IsNullOrEmpty(selectedItem))
|
||||
{
|
||||
if (getTItem.AnswerItems == selectedItem)
|
||||
{
|
||||
getTItem.SubjectScore = getTItem.Score ?? 0;
|
||||
}
|
||||
else
|
||||
{
|
||||
var listA = Funs.GetStrListByStr(getTItem.AnswerItems.ToUpper(), ',');
|
||||
var listS = Funs.GetStrListByStr(selectedItem.ToUpper(), ',');
|
||||
if (getTItem.TestType == "2" && listA.Count >= listS.Count)
|
||||
{
|
||||
int i = 0;
|
||||
foreach (var item in listS)
|
||||
{
|
||||
if (!listA.Contains(item))
|
||||
{
|
||||
i++;
|
||||
break;
|
||||
}
|
||||
}
|
||||
if (i == 0)
|
||||
{
|
||||
if (listA.Count == listS.Count)
|
||||
{
|
||||
getTItem.SubjectScore = getTItem.Score ?? 0;
|
||||
}
|
||||
else
|
||||
{
|
||||
getTItem.SubjectScore = Convert.ToDecimal((getTItem.Score ?? 0) * 1.0 / 2);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
db.SubmitChanges();
|
||||
}
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
responeData.code = 0;
|
||||
responeData.message = "试题有问题!";
|
||||
responeData.message = "答题为空选项!";
|
||||
}
|
||||
}
|
||||
catch (Exception ex)
|
||||
@@ -325,36 +355,50 @@ namespace WebAPI.Controllers
|
||||
var responeData = new Model.ResponeData();
|
||||
try
|
||||
{
|
||||
var getTestRecord = Funs.DB.Training_TestRecord.FirstOrDefault(e => e.TestRecordId == testRecordId);
|
||||
if (getTestRecord != null)
|
||||
using (Model.SGGLDB db = new Model.SGGLDB(Funs.ConnString))
|
||||
{
|
||||
string returnTestRecordId = string.Empty;
|
||||
////考试分数
|
||||
decimal getTestScores = APITestRecordService.getSubmitTestRecord(getTestRecord);
|
||||
////及格分数
|
||||
int getPassScores = SysConstSetService.getPassScore();
|
||||
if (getTestScores <= getPassScores)
|
||||
decimal getTestScores = 0;
|
||||
var getTestRecord = db.Training_TestRecord.FirstOrDefault(e => e.TestRecordId == testRecordId);
|
||||
if (getTestRecord != null)
|
||||
{
|
||||
int testCount = Funs.DB.Training_TestRecord.Where(x => x.TestPlanId == getTestRecord.TestPlanId && x.TestManId == getTestRecord.TestManId).Count();
|
||||
if (testCount < 2)
|
||||
if (getTestRecord.TestStartTime.HasValue)
|
||||
{
|
||||
////重新生成一条考试记录 以及考试试卷
|
||||
returnTestRecordId = APITestRecordService.getResitTestRecord(getTestRecord);
|
||||
responeData.message = "考试不合格!您的成绩为:【" + getTestScores.ToString() + "】,您将进入补考。";
|
||||
getTestRecord.TestEndTime = DateTime.Now;
|
||||
var getRItem = db.Training_TestRecordItem.Where(x => x.TestRecordId == testRecordId);
|
||||
if (getRItem.Count() > 0)
|
||||
{
|
||||
getTestRecord.TestScores = getRItem.Sum(x => x.SubjectScore ?? 0);
|
||||
}
|
||||
db.SubmitChanges();
|
||||
getTestScores = getTestRecord.TestScores ?? 0;
|
||||
}
|
||||
|
||||
////考试分数
|
||||
int getPassScores = SysConstSetService.getPassScore();
|
||||
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() + "】,请再次参加培训后补考。";
|
||||
// APITestRecordService.updateAll(getTestRecord.TestPlanId);
|
||||
responeData.message = "恭喜考试通过!您的成绩为:【" + getTestScores.ToString() + "】。";
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
APITestRecordService.updateAll(getTestRecord.TestPlanId);
|
||||
responeData.message = "恭喜考试通过!您的成绩为:【" + getTestScores.ToString() + "】。";
|
||||
}
|
||||
|
||||
responeData.data = new { getTestScores, getPassScores, returnTestRecordId };
|
||||
responeData.data = new { getTestScores, getPassScores, returnTestRecordId };
|
||||
}
|
||||
}
|
||||
}
|
||||
catch (Exception ex)
|
||||
|
||||
Reference in New Issue
Block a user