学习考试

This commit is contained in:
李鹏飞 2024-05-24 17:51:17 +08:00
parent f3e7713083
commit b675dc1cb6
5 changed files with 52 additions and 23 deletions

View File

@ -266,19 +266,19 @@ namespace BLL
public static string CreateTestRecordItem(Model.Training_CompanyTrainingItem getCompanyTraining, string testRecordId, Model.SitePerson_Person person, Model.Sys_User user) public static string CreateTestRecordItem(Model.Training_CompanyTrainingItem getCompanyTraining, string testRecordId, Model.SitePerson_Person person, Model.Sys_User user)
{ {
using (Model.SGGLDB db = new Model.SGGLDB(Funs.ConnString)) using (Model.SGGLDB db = new Model.SGGLDB(Funs.ConnString))
{ {
var trainingIds = getCompanyTraining.TestTrainingIds.Split(','); var trainingIds = getCompanyTraining.TestTrainingIds.Split(',');
var testTrainings= db.Training_TestTraining.Where(x => trainingIds.Contains(x.TrainingId)); var testTrainings = db.Training_TestTraining.Where(x => trainingIds.Contains(x.TrainingId));
var getTestRecord = db.Training_TestRecord.FirstOrDefault(x => x.TestRecordId == testRecordId); var getTestRecord = db.Training_TestRecord.FirstOrDefault(x => x.TestRecordId == testRecordId);
if (getTestRecord != null && !getTestRecord.TestStartTime.HasValue) if (getTestRecord != null && !getTestRecord.TestStartTime.HasValue)
{ {
////考试时长 ////考试时长
getTestRecord.Duration =120; getTestRecord.Duration = 120;
getTestRecord.TestStartTime = DateTime.Now; getTestRecord.TestStartTime = DateTime.Now;
db.SubmitChanges(); db.SubmitChanges();
} }
@ -293,16 +293,16 @@ namespace BLL
// select x; // select x;
//// 计划考试中单选、多选、判断题总数 //// 计划考试中单选、多选、判断题总数
var sysTestRule = Funs.DB.Sys_TestRule.FirstOrDefault(); var sysTestRule = Funs.DB.Sys_TestRule.FirstOrDefault();
int sumTestType1Count = 0;// testPlanTrainings.Sum(x => x.TestType1Count) ?? 0; int sumTestType1Count = 0;// testPlanTrainings.Sum(x => x.TestType1Count) ?? 0;
int sumTestType2Count = 0;//testPlanTrainings.Sum(x => x.TestType2Count) ?? 0; int sumTestType2Count = 0;//testPlanTrainings.Sum(x => x.TestType2Count) ?? 0;
int sumTestType3Count = 0;//testPlanTrainings.Sum(x => x.TestType3Count) ?? 0; int sumTestType3Count = 0;//testPlanTrainings.Sum(x => x.TestType3Count) ?? 0;
if (sysTestRule != null) if (sysTestRule != null)
{ {
sumTestType1Count = sysTestRule.SCount; sumTestType1Count = sysTestRule.SCount;
sumTestType2Count = sysTestRule.MCount; sumTestType2Count = sysTestRule.MCount;
sumTestType3Count = sysTestRule.JCount; sumTestType3Count = sysTestRule.JCount;
} }
////获取类型下适合岗位试题集合 ////获取类型下适合岗位试题集合
List<Model.Training_TestTrainingItem> getTestTrainingItemALLs; List<Model.Training_TestTrainingItem> getTestTrainingItemALLs;
@ -318,7 +318,7 @@ namespace BLL
} }
getTestTrainingItemALLs = (from x in db.Training_TestTrainingItem getTestTrainingItemALLs = (from x in db.Training_TestTrainingItem
where x.TrainingId != null && (x.WorkPostIds == null || string.IsNullOrEmpty(WorkPostId) || x.WorkPostIds.Contains(WorkPostId)) || (x.DepartIds == null || string.IsNullOrEmpty(DepartId) || x.DepartIds.Contains(DepartId)) where x.TrainingId != null && (x.WorkPostIds == null || string.IsNullOrEmpty(WorkPostId) || x.WorkPostIds.Contains(WorkPostId)) || (x.DepartIds == null || string.IsNullOrEmpty(DepartId) || x.DepartIds.Contains(DepartId))
select x).ToList(); select x).ToList();
foreach (var itemT in testTrainings) foreach (var itemT in testTrainings)
{ {
@ -347,9 +347,9 @@ namespace BLL
} }
} }
//// 获取得到的单选题、多选题、判断题 数量 //// 获取得到的单选题、多选题、判断题 数量
int getDiffTestType1Count = sumTestType1Count;// - getTestTrainingItemList.Where(x => x.TestType == "1").Count(); int getDiffTestType1Count = sumTestType1Count - getTestTrainingItemList.Where(x => x.TestType == "1").Count();
int getDiffTestType2Count = sumTestType2Count;// - getTestTrainingItemList.Where(x => x.TestType == "2").Count(); int getDiffTestType2Count = sumTestType2Count - getTestTrainingItemList.Where(x => x.TestType == "2").Count();
int getDiffTestType3Count = sumTestType3Count;// - getTestTrainingItemList.Where(x => x.TestType == "3").Count(); int getDiffTestType3Count = sumTestType3Count - getTestTrainingItemList.Where(x => x.TestType == "3").Count();
if (getDiffTestType1Count > 0 || getDiffTestType2Count > 0 || getDiffTestType3Count > 0) if (getDiffTestType1Count > 0 || getDiffTestType2Count > 0 || getDiffTestType3Count > 0)
{ {
var getTestTrainingItemNulls = getTestTrainingItemALLs.Where(x => x.WorkPostIds == null).ToList(); var getTestTrainingItemNulls = getTestTrainingItemALLs.Where(x => x.WorkPostIds == null).ToList();
@ -365,7 +365,7 @@ namespace BLL
{ {
getTestTrainingItemList.AddRange(getSItemD); getTestTrainingItemList.AddRange(getSItemD);
} }
} }
///多选题 ///多选题
if (getDiffTestType2Count > 0) if (getDiffTestType2Count > 0)
{ {

View File

@ -85,6 +85,8 @@ namespace BLL
GetDataService.CreateTrainingTaskItemByTaskId(taskId); GetDataService.CreateTrainingTaskItemByTaskId(taskId);
var getDataLists = (from x in db.Training_TaskItem var getDataLists = (from x in db.Training_TaskItem
join y in db.Training_CompanyTrainingItem on x.TrainingItemCode equals y.CompanyTrainingItemCode into temp
from y in temp.DefaultIfEmpty()
where x.TaskId == taskId where x.TaskId == taskId
orderby x.TrainingItemCode orderby x.TrainingItemCode
select new Model.TrainingTaskItemItem select new Model.TrainingTaskItemItem
@ -94,7 +96,8 @@ namespace BLL
PlanId = x.PlanId, PlanId = x.PlanId,
StartTime = x.StartTime, StartTime = x.StartTime,
EndTime =x.EndTime, EndTime =x.EndTime,
LearningTime=x.LearnTime, LearningTime= x.LearnTime,
AttachTime= y.LearningTime,
VideoProgress = x.VideoProgress, VideoProgress = x.VideoProgress,
PersonId = x.PersonId, PersonId = x.PersonId,
TrainingItemCode = x.TrainingItemCode, TrainingItemCode = x.TrainingItemCode,
@ -305,21 +308,23 @@ namespace BLL
{ {
item.LearnTime = 0; item.LearnTime = 0;
} }
item.LearnTime = item.LearnTime.Value + (int)span.TotalMinutes; item.LearnTime = item.LearnTime.Value + (int)span.TotalSeconds;
item.EndTime = endTime; item.EndTime = endTime;
db.SubmitChanges(); db.SubmitChanges();
var companyTrainingItem = db.Training_CompanyTrainingItem.FirstOrDefault(x => x.CompanyTrainingItemCode == item.TrainingItemCode);
int companyTrainingItemLearnTime = companyTrainingItem?.LearningTime ?? 0; //培训教材时长(秒)
//如果学习时长大于培训教材时长,则关闭状态 //如果学习时长大于培训教材时长,则关闭状态
if (item.VideoProgress > item.LearnTime) if (item.LearnTime > companyTrainingItemLearnTime)
{ {
var taskModel = db.Training_Task.FirstOrDefault(x => x.TaskId == item.TaskId); var taskModel = db.Training_Task.FirstOrDefault(x => x.TaskId == item.TaskId);
taskModel.States = "2"; taskModel.States = "2";
db.SubmitChanges(); db.SubmitChanges();
} }
return item; return item;
} }
} }

View File

@ -39,7 +39,8 @@ namespace BLL
PersonId = item.UserId, PersonId = item.UserId,
TrainingItemCode = dataItem.TrainingItemCode, TrainingItemCode = dataItem.TrainingItemCode,
TrainingItemName = dataItem.TrainingItemName, TrainingItemName = dataItem.TrainingItemName,
LearnTime = dataItem.LearningTime, // LearnTime = dataItem.LearningTime,//秒 注释原因2024-5-24存储过程LearningTime是教材时长培训任务教材明细表中的学习时间字段LearnTime不能复用
LearnTime =0,
AttachUrl = dataItem.AttachUrl, AttachUrl = dataItem.AttachUrl,
}; };

View File

@ -87,22 +87,38 @@ namespace Model
get; get;
set; set;
} }
/// <summary>
/// 开始时间
/// </summary>
public DateTime? StartTime public DateTime? StartTime
{ {
get; get;
set; set;
} }
/// <summary>
/// 学习时长(秒)
/// </summary>
public int? LearningTime public int? LearningTime
{ {
get; get;
set; set;
} }
public DateTime? EndTime /// <summary>
/// 教材时长(秒)
/// </summary>
public int? AttachTime
{
get;
set;
}
public DateTime? EndTime
{ {
get; get;
set; set;
} }
/// <summary>
/// 视频进度(秒)
/// </summary>
public int? VideoProgress public int? VideoProgress
{ {
get; get;

View File

@ -128,7 +128,14 @@ namespace WebAPI.Controllers
} }
#endregion #endregion
/// <summary>
/// 修改培训任务教材明细学习时间
/// </summary>
/// <param name="taskItemId"></param>
/// <param name="startTime"></param>
/// <param name="endTime"></param>
/// <param name="VideoProgress"></param>
/// <returns></returns>
[HttpGet] [HttpGet]
public Model.ResponeData updateTaskItemLearnTime(string taskItemId, DateTime startTime, DateTime endTime,string VideoProgress) public Model.ResponeData updateTaskItemLearnTime(string taskItemId, DateTime startTime, DateTime endTime,string VideoProgress)
{ {