培训通知发布时判断题库是否够
This commit is contained in:
parent
bf5fbf1ac7
commit
636c1a0721
@ -138,6 +138,101 @@ namespace APT.SC.WebApi.Controllers.Api.SE
|
||||
throw new Exception("培训时长不能为0!");
|
||||
}
|
||||
|
||||
#region 如果没有课件 只有知识点 判断 题库数量是否足够
|
||||
|
||||
if (ListCour == null || ListCour.Count() < 1)
|
||||
{
|
||||
|
||||
#region 题目数量判断
|
||||
|
||||
var config = GetEntity<T_SE_SECONFIG>(t => true);
|
||||
var SCount = 1;
|
||||
var MCount = 1;
|
||||
var CCount = 1;
|
||||
if (config != null)
|
||||
{
|
||||
if (config.M_TEST_COUNT > 0 || config.S_TEST_COUNT > 0 || config.C_TEST_COUNT > 0)
|
||||
{
|
||||
//王永文 只要有配置 就获取
|
||||
MCount = config.M_TEST_COUNT;
|
||||
SCount = config.S_TEST_COUNT;
|
||||
CCount = config.C_TEST_COUNT;
|
||||
}
|
||||
else
|
||||
{
|
||||
//保持原来的版本
|
||||
if (config.M_TEST_COUNT > 0)
|
||||
{
|
||||
MCount = config.M_TEST_COUNT;
|
||||
}
|
||||
if (config.S_TEST_COUNT > 0)
|
||||
{
|
||||
SCount = config.S_TEST_COUNT;
|
||||
}
|
||||
if (config.C_TEST_COUNT > 0)
|
||||
{
|
||||
CCount = config.C_TEST_COUNT;
|
||||
}
|
||||
}
|
||||
}
|
||||
var pointIDS = Nav_TrainContentList.Select(t => t.POINT_ID).ToList();
|
||||
var testidlist = new List<Guid>();
|
||||
var testFilter = new BaseFilter(entity.ORG_ID);
|
||||
testFilter.Include = new string[] { "Nav_Points" };
|
||||
|
||||
|
||||
var allTests = GetEntities<T_SE_TEST>(st => st.Nav_Points.Any(pt => pointIDS.Contains(pt.POINT_ID.Value)), testFilter).ToList();
|
||||
if (allTests.Count() == 0)
|
||||
{
|
||||
allTests = GetEntities<T_SE_TEST>(st => st.TRAINNAME.Contains(entity.NAME) && st.Nav_Points.Any(pt => pointIDS.Contains(pt.POINT_ID.Value)), testFilter).ToList();
|
||||
}
|
||||
|
||||
var errorMsg = "";
|
||||
foreach (var testPoint in pointIDS)
|
||||
{
|
||||
var havepoint = allTests.Where(st => st.Nav_Points.Any(pt => pt.POINT_ID == testPoint));
|
||||
if (havepoint.Count() < 1)
|
||||
{
|
||||
var noPoint = GetEntity<T_SE_TEST_ENUM_POINT>(testPoint);
|
||||
errorMsg += noPoint.NAME + ",";
|
||||
}
|
||||
}
|
||||
if (errorMsg != "")
|
||||
{
|
||||
throw new Exception("知识点 " + errorMsg + " 没有题目!");
|
||||
}
|
||||
var SCurrentCount = allTests.Count(t => t.TYPE == SETestTypeEnum.单选题);
|
||||
var MCurrentCount = allTests.Count(t => t.TYPE == SETestTypeEnum.多选题);
|
||||
var CCurrentCount = allTests.Count(t => t.TYPE == SETestTypeEnum.是非题);
|
||||
errorMsg = "";
|
||||
if (SCurrentCount < SCount)
|
||||
{
|
||||
errorMsg += "题库中题目数量不足!";
|
||||
errorMsg += "单选题还需" + (SCount - SCurrentCount) + "题\n";
|
||||
}
|
||||
if (MCurrentCount < MCount)
|
||||
{
|
||||
errorMsg += "题库中题目数量不足!";
|
||||
errorMsg += "多选题还需" + (MCount - MCurrentCount) + "题\n";
|
||||
}
|
||||
if (CCurrentCount < CCount)
|
||||
{
|
||||
errorMsg += "题库中题目数量不足!";
|
||||
errorMsg += "是非题还需" + (CCount - CCurrentCount) + "题\n";
|
||||
}
|
||||
if (errorMsg != "")
|
||||
{
|
||||
throw new Exception(errorMsg);
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
}
|
||||
|
||||
|
||||
#endregion
|
||||
|
||||
|
||||
entity.STATUS = SETrainNotifyStatus.通知中;
|
||||
//触发培训通知给所有培训人员
|
||||
var allSendUserNames = new List<string>();
|
||||
|
||||
Loading…
Reference in New Issue
Block a user