培训考试
This commit is contained in:
parent
d16907d32b
commit
caa62a9aeb
|
|
@ -1,5 +1,8 @@
|
|||
using EmitMapper;
|
||||
using EmitMapper.MappingConfiguration;
|
||||
using FastReport.Data;
|
||||
using Microsoft.SqlServer.Dts.Runtime;
|
||||
using Model;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
|
|
@ -76,7 +79,16 @@ namespace BLL
|
|||
}
|
||||
#endregion
|
||||
|
||||
#region 生成考试试卷
|
||||
|
||||
/// <summary>
|
||||
/// 生成考试试卷【只取培训教材对应题库的题目】
|
||||
/// </summary>
|
||||
/// <param name="getCompanyTraining"></param>
|
||||
/// <param name="testRecordId"></param>
|
||||
/// <param name="person"></param>
|
||||
/// <param name="user"></param>
|
||||
/// <returns></returns>
|
||||
public static string CreateTestRecordItem(Model.Training_CompanyTrainingItem getCompanyTraining, string testRecordId, Model.SitePerson_Person person, Model.Sys_User user)
|
||||
{
|
||||
using (Model.CNPCDB db = new Model.CNPCDB(Funs.ConnString))
|
||||
|
|
@ -92,6 +104,75 @@ namespace BLL
|
|||
db.SubmitChanges();
|
||||
}
|
||||
|
||||
////当前人考试记录 未加入考试计划的 当考试开始扫码时 不允许再参与考试
|
||||
var item = db.Training_TestRecordItem.FirstOrDefault(x => x.TestRecordId == getTestRecord.TestRecordId);
|
||||
if (item == null)
|
||||
{
|
||||
List<Model.Training_TestTrainingItem> getTestTrainingItemList = new List<Model.Training_TestTrainingItem>();
|
||||
foreach (var itemT in testTrainings)
|
||||
{
|
||||
//// 获取类型下的题目
|
||||
var getTestTrainingItems = db.Training_TestTrainingItem.Where(x => x.TrainingId == itemT.TrainingId).ToList();
|
||||
if (getTestTrainingItems.Count() > 0)
|
||||
{
|
||||
getTestTrainingItemList.AddRange(getTestTrainingItems);
|
||||
}
|
||||
}
|
||||
double totalScore = 100;//试卷满分
|
||||
if (getTestTrainingItemList.Count() > 0)
|
||||
{
|
||||
var getItems = from x in getTestTrainingItemList
|
||||
select new Model.Training_TestRecordItem
|
||||
{
|
||||
TestRecordItemId = SQLHelper.GetNewID(),
|
||||
TestRecordId = getTestRecord.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 = (int)Math.Floor(totalScore / getTestTrainingItemList.Count()),
|
||||
};
|
||||
|
||||
db.Training_TestRecordItem.InsertAllOnSubmit(getItems);
|
||||
db.SubmitChanges();
|
||||
BLL.RedisHelper redis = new BLL.RedisHelper();
|
||||
redis.SetObjString(testRecordId, getItems);
|
||||
}
|
||||
}
|
||||
}
|
||||
return testRecordId;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 生成考试试卷【不满25题自动补充,不满足考试规则配置的题目数自动补足】
|
||||
/// </summary>
|
||||
/// <param name="getCompanyTraining"></param>
|
||||
/// <param name="testRecordId"></param>
|
||||
/// <param name="person"></param>
|
||||
/// <param name="user"></param>
|
||||
/// <returns></returns>
|
||||
public static string CreateTestRecordItemOld(Model.Training_CompanyTrainingItem getCompanyTraining, string testRecordId, Model.SitePerson_Person person, Model.Sys_User user)
|
||||
{
|
||||
using (Model.CNPCDB db = new Model.CNPCDB(Funs.ConnString))
|
||||
{
|
||||
var trainingIds = getCompanyTraining.TestTrainingIds.Split(',');
|
||||
var testTrainings = db.Training_TestTraining.Where(x => trainingIds.Contains(x.TrainingId));
|
||||
var getTestRecord = db.Training_TestRecord.FirstOrDefault(x => x.TestRecordId == testRecordId);
|
||||
if (getTestRecord != null && !getTestRecord.TestStartTime.HasValue)
|
||||
{
|
||||
////考试时长
|
||||
getTestRecord.Duration = 120;
|
||||
getTestRecord.TestStartTime = DateTime.Now;
|
||||
db.SubmitChanges();
|
||||
}
|
||||
|
||||
////当前人考试记录 未加入考试计划的 当考试开始扫码时 不允许再参与考试
|
||||
var item = db.Training_TestRecordItem.FirstOrDefault(x => x.TestRecordId == getTestRecord.TestRecordId);
|
||||
if (item == null)
|
||||
|
|
@ -227,6 +308,7 @@ namespace BLL
|
|||
return testRecordId;
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
#region 根据PersonId、TestPlanId生成试卷 扫码生成试卷
|
||||
/// <summary>
|
||||
|
|
@ -504,8 +586,12 @@ namespace BLL
|
|||
using (Model.CNPCDB db = new Model.CNPCDB(Funs.ConnString))
|
||||
{
|
||||
var getDataLists = (from x in db.Training_TestRecord
|
||||
join y in db.Training_TestPlan on x.TestPlanId equals y.TestPlanId into yGroup
|
||||
from y in yGroup.DefaultIfEmpty()
|
||||
//join y in db.Training_TestPlan on x.TestPlanId equals y.TestPlanId into yGroup
|
||||
//from y in yGroup.DefaultIfEmpty()
|
||||
join z in db.Training_CompanyTrainingItem on x.CompanyTrainingItemId equals z.CompanyTrainingItemId into zGroup
|
||||
from z in zGroup.DefaultIfEmpty()
|
||||
join w in db.Training_CompanyTraining on z.CompanyTrainingId equals w.CompanyTrainingId into wGroup
|
||||
from w in wGroup.DefaultIfEmpty()
|
||||
where x.ProjectId == projectId && x.TestManId == personId && x.TestStartTime.HasValue
|
||||
orderby x.TestStartTime descending
|
||||
select new Model.TestRecordItem
|
||||
|
|
@ -513,14 +599,16 @@ namespace BLL
|
|||
TestRecordId = x.TestRecordId,
|
||||
ProjectId = x.ProjectId,
|
||||
TestPlanId = x.TestPlanId,
|
||||
TestPlanName = y.PlanName,
|
||||
TestPlanName = $"{w.CompanyTrainingName}——{z.CompanyTrainingItemName}",
|
||||
//TestPlanName = y.PlanName,
|
||||
TestManId = x.TestManId,
|
||||
TestManName = db.SitePerson_Person.FirstOrDefault(p => p.PersonId == x.TestManId).PersonName,
|
||||
TestStartTime = string.Format("{0:yyyy-MM-dd HH:mm}", x.TestStartTime),
|
||||
TestEndTime = string.Format("{0:yyyy-MM-dd HH:mm}", x.TestEndTime),
|
||||
Duration = x.Duration,
|
||||
TestPlanEndTime = string.Format("{0:yyyy-MM-dd HH:mm}", x.TestStartTime.Value.AddMinutes(x.Duration)),
|
||||
TotalScore = y.TotalScore ?? 0,
|
||||
TotalScore = 100,
|
||||
//TotalScore = y.TotalScore ?? 0,
|
||||
TestScores = x.TestScores ?? 0,
|
||||
TestType = x.TestType,
|
||||
TemporaryUser = x.TemporaryUser,
|
||||
|
|
@ -696,7 +784,7 @@ namespace BLL
|
|||
/// </summary>
|
||||
/// <param name="testRecordItemId"></param>
|
||||
/// <param name="answerItems"></param>
|
||||
public static void getTestRecordItemAnswerBySelectedItem(Model.Training_TestRecordItem getTItemT, string selectedItem)
|
||||
public static void getTestRecordItemAnswerBySelectedItemOld(Model.Training_TestRecordItem getTItemT, string selectedItem)
|
||||
{
|
||||
using (Model.CNPCDB db = new Model.CNPCDB(Funs.ConnString))
|
||||
{
|
||||
|
|
@ -744,11 +832,69 @@ namespace BLL
|
|||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
public static void getTestRecordItemAnswerBySelectedItem(Model.Training_TestRecordItem getTItemT, string selectedItem)
|
||||
{
|
||||
using (Model.CNPCDB db = new Model.CNPCDB(Funs.ConnString))
|
||||
{
|
||||
var getTItem = db.Training_TestRecordItem.FirstOrDefault(x => x.TestRecordItemId == getTItemT.TestRecordItemId);
|
||||
if (getTItem != null)
|
||||
{
|
||||
selectedItem = selectedItem.ToUpper();
|
||||
getTItem.AnswerItems = getTItem.AnswerItems.ToUpper();
|
||||
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, ',');
|
||||
var listS = Funs.GetStrListByStr(selectedItem, ',');
|
||||
if (getTItem.TestType == "2" && listA.Count >= listS.Count)
|
||||
{
|
||||
int i = 0;
|
||||
foreach (var item in listS)
|
||||
{
|
||||
if (listA.Contains(item))
|
||||
{
|
||||
i++;
|
||||
}
|
||||
}
|
||||
if (i > 0)
|
||||
{
|
||||
if (listA.Count == listS.Count)
|
||||
{
|
||||
getTItem.SubjectScore = getTItem.Score ?? 0;
|
||||
}
|
||||
else
|
||||
{
|
||||
//getTItem.SubjectScore = Convert.ToDecimal((getTItem.Score ?? 0) * 1.0 / 2);
|
||||
|
||||
var result = (double)((double)i / (double)listA.Count) * getTItem.Score;
|
||||
getTItem.SubjectScore = Math.Round((decimal)result, 2);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
db.SubmitChanges();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
#endregion
|
||||
|
||||
#region 根据TestRecordId 提交试卷
|
||||
/// <summary>
|
||||
/// 根据TestRecordId 提交试卷
|
||||
/// 根据TestRecordId 提交试卷,获取考试分数
|
||||
/// </summary>
|
||||
/// <param name="testRecordId"></param>
|
||||
public static decimal getSubmitTestRecord(Model.Training_TestRecord testRecord)
|
||||
|
|
@ -769,7 +915,37 @@ namespace BLL
|
|||
db.SubmitChanges();
|
||||
|
||||
getCode = getTestRecord.TestScores ?? 0;
|
||||
}
|
||||
}
|
||||
return getCode;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 根据答题正确数计算考试得分
|
||||
/// </summary>
|
||||
/// <param name="testRecord"></param>
|
||||
/// <returns></returns>
|
||||
public static decimal getSubmitTestRecordByAnswer(Model.Training_TestRecord testRecord)
|
||||
{
|
||||
decimal getCode = 0;
|
||||
using (Model.CNPCDB db = new Model.CNPCDB(Funs.ConnString))
|
||||
{
|
||||
var getTestRecord = db.Training_TestRecord.FirstOrDefault(e => e.TestRecordId == testRecord.TestRecordId);
|
||||
/////试卷
|
||||
if (getTestRecord.TestStartTime.HasValue)
|
||||
{
|
||||
getTestRecord.TestEndTime = DateTime.Now;
|
||||
var getRItem = db.Training_TestRecordItem.Where(x => x.TestRecordId == getTestRecord.TestRecordId);
|
||||
var getROKItem = db.Training_TestRecordItem.Where(x => x.TestRecordId == getTestRecord.TestRecordId && x.AnswerItems == x.SelectedItem);
|
||||
if (getRItem.Count() > 0)
|
||||
{
|
||||
//getTestRecord.TestScores = getRItem.Sum(x => x.SubjectScore);
|
||||
decimal result = (decimal)(getROKItem.Count() / getRItem.Count());
|
||||
getTestRecord.TestScores = Math.Round(result, 2);
|
||||
}
|
||||
db.SubmitChanges();
|
||||
|
||||
getCode = getTestRecord.TestScores ?? 0;
|
||||
}
|
||||
}
|
||||
return getCode;
|
||||
|
|
|
|||
|
|
@ -82,7 +82,7 @@
|
|||
<asp:Label ID="labNumber" runat="server" Text=' <%# Grid1.PageIndex * Grid1.PageSize + Container.DataItemIndex + 1%>'></asp:Label>
|
||||
</ItemTemplate>
|
||||
</f:TemplateField>
|
||||
<f:RenderField Width="110px" ColumnID="PlanName" DataField="PlanName" FieldType="String"
|
||||
<f:RenderField Width="220px" ColumnID="PlanName" DataField="PlanName" FieldType="String"
|
||||
HeaderText="考试名称" HeaderTextAlign="Center" TextAlign="Left">
|
||||
</f:RenderField>
|
||||
<f:RenderField Width="230px" ColumnID="UnitName" DataField="UnitName" FieldType="String"
|
||||
|
|
@ -106,9 +106,9 @@
|
|||
<f:RenderField Width="70px" ColumnID="Duration" DataField="Duration" FieldType="String"
|
||||
HeaderText="时长" HeaderTextAlign="Center" TextAlign="Right">
|
||||
</f:RenderField>
|
||||
<f:RenderField Width="80px" ColumnID="QuestionCount" DataField="QuestionCount" FieldType="String"
|
||||
<%--<f:RenderField Width="80px" ColumnID="QuestionCount" DataField="QuestionCount" FieldType="String"
|
||||
HeaderText="题目数量" HeaderTextAlign="Center" TextAlign="Right">
|
||||
</f:RenderField>
|
||||
</f:RenderField>--%>
|
||||
<%-- <f:RenderField Width="150px" ColumnID="TestPalce" DataField="TestPalce" FieldType="String"
|
||||
HeaderText="考试地点" HeaderTextAlign="Center" TextAlign="Left">
|
||||
</f:RenderField> --%>
|
||||
|
|
|
|||
|
|
@ -115,12 +115,15 @@ namespace FineUIPro.Web.HSSE.EduTrain
|
|||
return;
|
||||
}
|
||||
string strSql = @"SELECT TestRecord.TestRecordId,TestRecord.TestPlanId, TestRecord.TestManId,TestRecord.TestStartTime,TestRecord.TestEndTime, TestRecord.TestScores,
|
||||
(CASE WHEN TestPlan.PlanName IS NULL THEN Training.TrainingName ELSE TestPlan.PlanName END) AS PlanName,
|
||||
ISNULL(TestPlan.Duration,90) AS Duration,ISNULL(TestPlan.TotalScore,100) AS TotalScore,TestPlan.TestPalce,ISNULL(TestPlan.QuestionCount,95) AS QuestionCount,TestRecord.TemporaryUser,Person.PersonName AS TestManName
|
||||
--(CASE WHEN TestPlan.PlanName IS NULL THEN Training.TrainingName ELSE TestPlan.PlanName END) AS PlanName,
|
||||
TC.CompanyTrainingName +'——'+TCItem.CompanyTrainingItemName AS PlanName,
|
||||
ISNULL(TestPlan.Duration,120) AS Duration,ISNULL(TestPlan.TotalScore,100) AS TotalScore,TestPlan.TestPalce,ISNULL(TestPlan.QuestionCount,95) AS QuestionCount,TestRecord.TemporaryUser,Person.PersonName AS TestManName
|
||||
,Unit.UnitName"
|
||||
+ @" FROM dbo.Training_TestRecord AS TestRecord"
|
||||
+ @" LEFT JOIN dbo.Training_TestPlan AS TestPlan ON TestPlan.TestPlanId=TestRecord.TestPlanId"
|
||||
+ @" LEFT JOIN dbo.Training_TestTraining AS Training ON Training.TrainingId = TestRecord.TestType"
|
||||
//+ @" LEFT JOIN dbo.Training_TestTraining AS Training ON Training.TrainingId = TestRecord.TestType"
|
||||
+ @" LEFT JOIN dbo.Training_CompanyTrainingItem AS TCItem ON TCItem.CompanyTrainingItemId = TestRecord.CompanyTrainingItemId"
|
||||
+ @" LEFT JOIN dbo.Training_CompanyTraining AS TC ON TC.CompanyTrainingId = TCItem.CompanyTrainingId"
|
||||
+ @" LEFT JOIN dbo.SitePerson_Person AS Person ON Person.PersonId = TestRecord.TestManId "
|
||||
+ @" LEFT JOIN dbo.Base_Unit AS Unit ON Person.UnitId=Unit.UnitId"
|
||||
+ @" WHERE TestRecord.TestStartTime is not null and (isFiled IS NULL OR isFiled = 0) ";
|
||||
|
|
|
|||
|
|
@ -77,7 +77,7 @@
|
|||
<f:RenderField Width="80px" ColumnID="SelectedItem" DataField="SelectedItem" FieldType="String"
|
||||
HeaderText="选择项" HeaderTextAlign="Center" TextAlign="Left">
|
||||
</f:RenderField>
|
||||
<f:RenderField Width="70px" ColumnID="SubjectScore" DataField="SubjectScore" FieldType="Int"
|
||||
<f:RenderField Width="70px" ColumnID="SubjectScore" DataField="SubjectScore" FieldType="Double"
|
||||
HeaderText="得分" HeaderTextAlign="Center" TextAlign="Left">
|
||||
</f:RenderField>
|
||||
</Columns>
|
||||
|
|
|
|||
|
|
@ -294,9 +294,9 @@ namespace WebAPI.Controllers
|
|||
#endregion
|
||||
|
||||
/// <summary>
|
||||
/// companyTrainingItemCode、personId、projectId获取考试记录id
|
||||
/// 根据companyTrainingItemCode、personId、projectId生成、获取考试记录id
|
||||
/// </summary>
|
||||
/// <param name="companyTrainingItemCode"></param>
|
||||
/// <param name="companyTrainingItemCode">培训课程教材Code</param>
|
||||
/// <param name="personId"></param>
|
||||
/// <param name="projectId"></param>
|
||||
/// <returns></returns>
|
||||
|
|
|
|||
|
|
@ -31,7 +31,7 @@ namespace WebAPI.Controllers
|
|||
int pageCount = getQualityLists.Count;
|
||||
if (pageCount > 0 && pageIndex > 0)
|
||||
{
|
||||
var getdata = from x in getQualityLists.OrderByDescending(u => u.TrainStartDate).Skip(BLL.Funs.PageSize * (pageIndex - 1)).Take(BLL.Funs.PageSize)
|
||||
var getdata = from x in getQualityLists.OrderByDescending(u => u.TrainStartDate).OrderBy(u => u.TrainingItemCode).Skip(BLL.Funs.PageSize * (pageIndex - 1)).Take(BLL.Funs.PageSize)
|
||||
select x;
|
||||
responeData.data = new { pageCount, getdata };
|
||||
}
|
||||
|
|
|
|||
Loading…
Reference in New Issue