20220725 优化答题交卷接口
This commit is contained in:
parent
bec6bc5fc0
commit
0f7638febc
|
@ -502,11 +502,11 @@ namespace BLL
|
||||||
/// </summary>
|
/// </summary>
|
||||||
/// <param name="testRecordItemId"></param>
|
/// <param name="testRecordItemId"></param>
|
||||||
/// <param name="answerItems"></param>
|
/// <param name="answerItems"></param>
|
||||||
public static void getTestRecordItemAnswerBySelectedItem(Model.Training_TestRecordItem getTItemT, string selectedItem)
|
public static void getTestRecordItemAnswerBySelectedItem(string testRecordItemId, string selectedItem)
|
||||||
{
|
{
|
||||||
using (Model.SGGLDB db = new Model.SGGLDB(Funs.ConnString))
|
using (Model.SGGLDB db = new Model.SGGLDB(Funs.ConnString))
|
||||||
{
|
{
|
||||||
var getTItem = db.Training_TestRecordItem.FirstOrDefault(x => x.TestRecordItemId == getTItemT.TestRecordItemId);
|
var getTItem = db.Training_TestRecordItem.FirstOrDefault(x => x.TestRecordItemId == testRecordItemId);
|
||||||
if (getTItem != null)
|
if (getTItem != null)
|
||||||
{
|
{
|
||||||
getTItem.SubjectScore = 0;
|
getTItem.SubjectScore = 0;
|
||||||
|
@ -587,6 +587,8 @@ namespace BLL
|
||||||
/// </summary>
|
/// </summary>
|
||||||
/// <param name="testRecord"></param>
|
/// <param name="testRecord"></param>
|
||||||
public static string getResitTestRecord(Model.Training_TestRecord getTestRecord)
|
public static string getResitTestRecord(Model.Training_TestRecord getTestRecord)
|
||||||
|
{
|
||||||
|
using (Model.SGGLDB db = new Model.SGGLDB(Funs.ConnString))
|
||||||
{
|
{
|
||||||
Model.Training_TestRecord newTestRecord = new Model.Training_TestRecord
|
Model.Training_TestRecord newTestRecord = new Model.Training_TestRecord
|
||||||
{
|
{
|
||||||
|
@ -600,10 +602,10 @@ namespace BLL
|
||||||
// TestStartTime = DateTime.Now,
|
// TestStartTime = DateTime.Now,
|
||||||
};
|
};
|
||||||
|
|
||||||
Funs.DB.Training_TestRecord.InsertOnSubmit(newTestRecord);
|
db.Training_TestRecord.InsertOnSubmit(newTestRecord);
|
||||||
Funs.DB.SubmitChanges();
|
db.SubmitChanges();
|
||||||
|
|
||||||
var getTestPlan = Funs.DB.Training_TestPlan.FirstOrDefault(x => x.TestPlanId == newTestRecord.TestPlanId);
|
var getTestPlan = db.Training_TestPlan.FirstOrDefault(x => x.TestPlanId == newTestRecord.TestPlanId);
|
||||||
var person = PersonService.GetPersonByUserId(newTestRecord.TestManId, getTestPlan.ProjectId);
|
var person = PersonService.GetPersonByUserId(newTestRecord.TestManId, getTestPlan.ProjectId);
|
||||||
if (getTestPlan != null && person != null)
|
if (getTestPlan != null && person != null)
|
||||||
{
|
{
|
||||||
|
@ -611,6 +613,7 @@ namespace BLL
|
||||||
}
|
}
|
||||||
return newTestRecord.TestRecordId;
|
return newTestRecord.TestRecordId;
|
||||||
}
|
}
|
||||||
|
}
|
||||||
#endregion
|
#endregion
|
||||||
}
|
}
|
||||||
}
|
}
|
|
@ -12,15 +12,19 @@
|
||||||
/// </summary>
|
/// </summary>
|
||||||
/// <returns></returns>
|
/// <returns></returns>
|
||||||
public static int getPassScore()
|
public static int getPassScore()
|
||||||
|
{
|
||||||
|
using (Model.SGGLDB db = new Model.SGGLDB(Funs.ConnString))
|
||||||
{
|
{
|
||||||
int passScore = 80;
|
int passScore = 80;
|
||||||
var testRule = Funs.DB.Sys_TestRule.FirstOrDefault();
|
var testRule =db.Sys_TestRule.FirstOrDefault();
|
||||||
if (testRule != null)
|
if (testRule != null)
|
||||||
{
|
{
|
||||||
passScore = testRule.PassingScore;
|
passScore = testRule.PassingScore;
|
||||||
}
|
}
|
||||||
|
|
||||||
return passScore;
|
return passScore;
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
#region 菜单编码模板
|
#region 菜单编码模板
|
||||||
/// <summary>
|
/// <summary>
|
||||||
|
|
|
@ -38,8 +38,8 @@
|
||||||
<SpecificVersion>False</SpecificVersion>
|
<SpecificVersion>False</SpecificVersion>
|
||||||
<HintPath>bin\Debug\AOP.Common.dll</HintPath>
|
<HintPath>bin\Debug\AOP.Common.dll</HintPath>
|
||||||
</Reference>
|
</Reference>
|
||||||
<Reference Include="Newtonsoft.Json, Version=10.0.0.0, Culture=neutral, PublicKeyToken=30ad4fe6b2a6aeed, processorArchitecture=MSIL">
|
<Reference Include="Newtonsoft.Json, Version=12.0.0.0, Culture=neutral, PublicKeyToken=30ad4fe6b2a6aeed, processorArchitecture=MSIL">
|
||||||
<HintPath>..\packages\Newtonsoft.Json.10.0.3\lib\net45\Newtonsoft.Json.dll</HintPath>
|
<HintPath>..\packages\Newtonsoft.Json.12.0.1\lib\net45\Newtonsoft.Json.dll</HintPath>
|
||||||
</Reference>
|
</Reference>
|
||||||
<Reference Include="System" />
|
<Reference Include="System" />
|
||||||
<Reference Include="System.configuration" />
|
<Reference Include="System.configuration" />
|
||||||
|
@ -76,6 +76,7 @@
|
||||||
<WCFMetadata Include="Connected Services\" />
|
<WCFMetadata Include="Connected Services\" />
|
||||||
</ItemGroup>
|
</ItemGroup>
|
||||||
<ItemGroup>
|
<ItemGroup>
|
||||||
|
<None Include="app.config" />
|
||||||
<None Include="packages.config" />
|
<None Include="packages.config" />
|
||||||
</ItemGroup>
|
</ItemGroup>
|
||||||
<Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" />
|
<Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" />
|
||||||
|
|
|
@ -321,7 +321,7 @@ namespace WebAPI.Controllers
|
||||||
var getItem = TestRecordItemService.GetTestRecordItemTestRecordItemId(testRecordItemId);
|
var getItem = TestRecordItemService.GetTestRecordItemTestRecordItemId(testRecordItemId);
|
||||||
if (getItem != null)
|
if (getItem != null)
|
||||||
{
|
{
|
||||||
APITestRecordService.getTestRecordItemAnswerBySelectedItem(getItem, selectedItem);
|
APITestRecordService.getTestRecordItemAnswerBySelectedItem(testRecordItemId, selectedItem);
|
||||||
var testRecord = Funs.DB.Training_TestRecord.FirstOrDefault(x => x.TestRecordId == getItem.TestRecordId && x.TestStartTime.Value.AddMinutes(x.Duration) < DateTime.Now);
|
var testRecord = Funs.DB.Training_TestRecord.FirstOrDefault(x => x.TestRecordId == getItem.TestRecordId && x.TestStartTime.Value.AddMinutes(x.Duration) < DateTime.Now);
|
||||||
if (testRecord != null)
|
if (testRecord != null)
|
||||||
{
|
{
|
||||||
|
|
|
@ -298,27 +298,7 @@ namespace WebAPI.Controllers
|
||||||
var responeData = new Model.ResponeData();
|
var responeData = new Model.ResponeData();
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
var getItem = TestRecordItemService.GetTestRecordItemTestRecordItemId(testRecordItemId);
|
APITestRecordService.getTestRecordItemAnswerBySelectedItem(testRecordItemId, selectedItem);
|
||||||
if (getItem != null)
|
|
||||||
{
|
|
||||||
APITestRecordService.getTestRecordItemAnswerBySelectedItem(getItem, selectedItem);
|
|
||||||
var testRecord = Funs.DB.Training_TestRecord.FirstOrDefault(x => x.TestRecordId == getItem.TestRecordId && x.TestStartTime.Value.AddMinutes(x.Duration) < DateTime.Now);
|
|
||||||
if (testRecord != null)
|
|
||||||
{
|
|
||||||
//更新没有结束时间且超时的考试记录
|
|
||||||
int closeCount = TestRecordService.UpdateTestEndTimeNull(getItem.TestRecordId);
|
|
||||||
if (closeCount > 0)
|
|
||||||
{
|
|
||||||
responeData.code = 2;
|
|
||||||
responeData.message = "本次考试已结束,系统自动交卷!";
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
responeData.code = 0;
|
|
||||||
responeData.message = "试题有问题!";
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
catch (Exception ex)
|
catch (Exception ex)
|
||||||
{
|
{
|
||||||
|
@ -340,17 +320,30 @@ namespace WebAPI.Controllers
|
||||||
var responeData = new Model.ResponeData();
|
var responeData = new Model.ResponeData();
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
var getTestRecord = Funs.DB.Training_TestRecord.FirstOrDefault(e => e.TestRecordId == testRecordId);
|
using (Model.SGGLDB db = new Model.SGGLDB(Funs.ConnString))
|
||||||
if (getTestRecord != null)
|
|
||||||
{
|
{
|
||||||
string returnTestRecordId = string.Empty;
|
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.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;
|
||||||
|
}
|
||||||
|
|
||||||
////考试分数
|
////考试分数
|
||||||
decimal getTestScores = APITestRecordService.getSubmitTestRecord(getTestRecord);
|
|
||||||
////及格分数
|
|
||||||
int getPassScores = SysConstSetService.getPassScore();
|
int getPassScores = SysConstSetService.getPassScore();
|
||||||
if (getTestScores <= getPassScores)
|
if (getTestScores <= getPassScores)
|
||||||
{
|
{
|
||||||
int testCount = Funs.DB.Training_TestRecord.Where(x => x.TestPlanId == getTestRecord.TestPlanId && x.TestManId == getTestRecord.TestManId).Count();
|
int testCount = db.Training_TestRecord.Where(x => x.TestPlanId == getTestRecord.TestPlanId && x.TestManId == getTestRecord.TestManId).Count();
|
||||||
if (testCount < 2)
|
if (testCount < 2)
|
||||||
{
|
{
|
||||||
////重新生成一条考试记录 以及考试试卷
|
////重新生成一条考试记录 以及考试试卷
|
||||||
|
@ -372,6 +365,7 @@ namespace WebAPI.Controllers
|
||||||
responeData.data = new { getTestScores, getPassScores, returnTestRecordId };
|
responeData.data = new { getTestScores, getPassScores, returnTestRecordId };
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
}
|
||||||
catch (Exception ex)
|
catch (Exception ex)
|
||||||
{
|
{
|
||||||
responeData.code = 0;
|
responeData.code = 0;
|
||||||
|
|
|
@ -10,13 +10,13 @@
|
||||||
<LastUsedBuildConfiguration>Release</LastUsedBuildConfiguration>
|
<LastUsedBuildConfiguration>Release</LastUsedBuildConfiguration>
|
||||||
<LastUsedPlatform>Any CPU</LastUsedPlatform>
|
<LastUsedPlatform>Any CPU</LastUsedPlatform>
|
||||||
<SiteUrlToLaunchAfterPublish />
|
<SiteUrlToLaunchAfterPublish />
|
||||||
<LaunchSiteAfterPublish>True</LaunchSiteAfterPublish>
|
<LaunchSiteAfterPublish>true</LaunchSiteAfterPublish>
|
||||||
<ExcludeApp_Data>False</ExcludeApp_Data>
|
<ExcludeApp_Data>false</ExcludeApp_Data>
|
||||||
<publishUrl>F:\Package\中化五环\SGGLAPI</publishUrl>
|
<publishUrl>E:\Package\中国五环工程有限公司\SGGLAPI</publishUrl>
|
||||||
<DeleteExistingFiles>True</DeleteExistingFiles>
|
<DeleteExistingFiles>true</DeleteExistingFiles>
|
||||||
<PrecompileBeforePublish>True</PrecompileBeforePublish>
|
<PrecompileBeforePublish>true</PrecompileBeforePublish>
|
||||||
<EnableUpdateable>True</EnableUpdateable>
|
<EnableUpdateable>true</EnableUpdateable>
|
||||||
<DebugSymbols>False</DebugSymbols>
|
<DebugSymbols>false</DebugSymbols>
|
||||||
<WDPMergeOption>DonotMerge</WDPMergeOption>
|
<WDPMergeOption>DonotMerge</WDPMergeOption>
|
||||||
</PropertyGroup>
|
</PropertyGroup>
|
||||||
</Project>
|
</Project>
|
Loading…
Reference in New Issue