public string GetUserStageUnfinishedExamName(int applyId) { var apply = _dataAccess.Get <PromotionApply>(applyId); var stage = _dataAccess.Get <PromotionStage>(apply.CurrentStageId); if (stage.ExamId == 0) { return(""); } var recordId = _dataAccess.FetchListBySql <int>(string.Format(@"select RecordId from Ab_PromotionStageLenRecord where ApplyId = {3} and PromotionId = {0} and Stageid = {1} and UserId = {2}", stage.PromotionId, stage.StageId, apply.UserId, applyId)).FirstOrDefault(); if (recordId > 0) { var examuser = new RetechWing.BusinessCommon.Examination.ExaminationCommonMethod().GetExamSendStudentWithByRelationIdAndUserId(recordId, 2, apply.UserId).FirstOrDefault(); if (examuser != null && examuser.ExamPaperID == stage.ExamId && examuser.IsPass == 1) { return(""); } } var paper = new RetechWing.BusinessCommon.Examination.ExaminationCommonMethod().GetSingleById <RetechWing.Models.Exam.DBModels.tbExampaperRedundancy>(stage.ExamId); if (paper == null) { return(""); } return(paper.ExampaperTitle); }
public int GetUserStageLearnPercent(int userId, int applyId) { var apply = _dataAccess.Get <PromotionApply>(applyId); var stage = _dataAccess.Get <PromotionStage>(apply.CurrentStageId); int completeCount = (int)_dataAccess.ExecuteScalar(string.Format(@"select count(0) from Len_LearningRecord where LearnProcess = 2 and LearnPath = 3 and SourceId in (select RecordId from Ab_LearningRecord where StageId = {0} and ApplyId = {2}) and UserId = {1}", apply.CurrentStageId, userId, applyId)); int allCount = (int)_dataAccess.ExecuteScalar(string.Format(@"select count(0) from Ab_AbilityResource where Ab_AbilityResource.IsDelete = 0 and Ab_AbilityResource.ResourceType = 0 and Ab_AbilityResource.AbilityId in ( select AbilityId from Ab_PostAbility where IsDelete = 0 and PostId = {0} )", stage.PostId)); if (stage.ExamId > 0) { allCount++; var record = _dataAccess.GetListBySql <AbPromotionStageLenRecord>(string.Format(@"select * from Ab_PromotionStageLenRecord where PromotionId = {0} and ApplyId = {1} and StageId = {2} and UserId = {3}", apply.PromotionId, applyId, apply.CurrentStageId, userId)).FirstOrDefault(); if (record != null) { var examuserlist = new RetechWing.BusinessCommon.Examination.ExaminationCommonMethod().GetExamSendStudentWithByRelationIdAndUserId(record.RecordId, 2, userId); if (examuserlist.Any(p => p.IsPass == 1)) { completeCount++; } } } return(allCount == 0 ? 0 : completeCount * 100 / allCount); }
/// <summary> /// /// </summary> /// <param name="courseId"></param> /// <returns></returns> public List <ResCourseToExam> LoadCourseExaminations(int courseId) { var sqlwhere = "Res_CourseToExam.CourseId=" + courseId; var list = _dataAccess.GetList <ResCourseToExam>(sqlwhere); if (list.Count > 0) { var manager = new RetechWing.BusinessCommon.Examination.ExaminationCommonMethod();// ExampaperDb(); var exampaperRedundancys = manager.GetAllExampaperRedundancy(list.Select(p => p.ExampaperId)); var sortlist = manager.GetAllListByTenantId <RetechWing.Models.Exam.DBModels.tbExampaperSort>(false, exampaperRedundancys.First().TenantId); foreach (var exam in list) { var tmp = exampaperRedundancys.FirstOrDefault(p => p._id == exam.ExampaperId); if (tmp == null) { list.Remove(exam); continue; } exam.Exampaper = tmp; exam.ExampaperId = tmp.ExampaperId; exam.ExampaperRedundancyId = tmp._id; exam.SortName = sortlist.Any(p => p._id == tmp.ExamSortID) ? sortlist.Find(p => p._id == tmp.ExamSortID).Title : ""; } } return(list); }
public List <PromotionStage> GetPromotionWayPostList(int promotionId) { string where = string.Format(" Ab_PromotionStage.IsDelete = 0 and Ab_PromotionStage.PromotionId = {0} ", promotionId); var list = _dataAccess.GetList <PromotionStage>(where); if (list.Count > 0) { var _exampaperDB = new RetechWing.BusinessCommon.Examination.ExaminationCommonMethod(); var exampaperList = _exampaperDB.GetExampaperRedundancyList(list.Select(p => p.ExamId)); foreach (var item in list) { var tmp = exampaperList.Find(p => p._id == item.ExamId); if (tmp == null) { continue; } item.PaperName = tmp.ExampaperTitle; item.ExamId = tmp.ExampaperId; } } return(list); }
public PromotionStage GetPromotionStage(int stageid, int applyId) { var apply = new PromotionApply { ApplyId = 0, PromotionId = 0, UserId = 0 }; if (applyId > 0) { apply = _dataAccess.Get <PromotionApply>(applyId); } var stage = _dataAccess.Get <PromotionStage>(stageid); //加载阶段下的技能 var sql = @"SELECT ar.AbilityId , ResourceId, co.CourseName, ai.CategoryId , ac.CategoryName, pa.PostId, AbilityName , AbilityLevel , pec.RecordId as IsElective FROM Ab_AbilityResource ar LEFT JOIN Ab_AbilityInfo ai ON ai.AbilityId = ar.AbilityId LEFT JOIN Ab_PostAbility pa ON pa.AbilityId = ai.AbilityId LEFT JOIN Ab_PromotionStage ps ON ps.PostId = pa.PostId LEFT JOIN Ab_AbilityCategory ac ON ac.CategoryId = ai.CategoryId LEFT JOIN Res_Course co ON ar.ResourceId=co.CourseId LEFT JOIN Ab_PostElectiveCourse pec ON pec.PostId=ps.PostId and pec.AbilityId = ai.AbilityId and pec.CourseId = co.CourseId WHERE ar.IsDelete=0 AND ar.ResourceType=0 AND pa.IsDelete = 0 and ai.isdelete = 0 AND ps.StageId=" + stage.StageId; var datalist = _dataAccess.FetchListBySql <Models.Views.PromotionStageCourse>(sql); //查询学习进度 var learnProcess = _dataAccess.GetListBySql <Models.LenLearningRecord>( @"SELECT lr.CourseId,LearnProcess,StartTime,lr.EndTime,alr.AbilityId FROM Len_LearningRecord lr LEFT JOIN Ab_LearningRecord alr ON alr.RecordId=lr.SourceId WHERE lr.LearnPath=3 AND alr.ApplyId=@applyId AND alr.StageId=@stageId --AND alr.AbilityId=@abilityId", new { applyId, stageid }); foreach (var course in datalist) { var lp = learnProcess.FirstOrDefault(p => p.AbilityId == course.AbilityId && p.CourseId == course.ResourceId); if (lp == null) { course.LearnProcess = 0; continue; } course.LearnProcess = lp.LearnProcess; } var klsql = @"SELECT ar.ResourceId,/*kl.ResourceName,*/ai.AbilityId,ai.AbilityName,ai.AbilityLevel,ai.CategoryId, ac.CategoryName FROM Ab_AbilityResource ar --LEFT JOIN KL_Resource kl ON kl.ResourceId = ar.ResourceId LEFT JOIN Ab_PostAbility pa ON pa.AbilityId = ar.AbilityId LEFT JOIN Ab_AbilityInfo ai ON ai.AbilityId = ar.AbilityId LEFT JOIN Ab_AbilityCategory ac ON ac.CategoryId = ai.CategoryId WHERE ar.IsDelete=0 AND ar.ResourceType=1 AND pa.IsDelete = 0 and ai.isdelete = 0 AND pa.PostId=" + stage.PostId; var kls = _dataAccess.FetchListBySql <Models.Views.PromotionStageKL>(klsql); stage.StageCourses.AddRange(datalist); stage.StageKLs.AddRange(kls); if (stage.ExamId > 0) { var _exampaperDB = new RetechWing.BusinessCommon.Examination.ExaminationCommonMethod(); var exampaper = _exampaperDB.GetSingleById <tbExampaperRedundancy>(stage.ExamId); stage.PaperName = exampaper == null ? stage.PaperName : exampaper.ExampaperTitle; stage.UserExamPass = -1; var record = _dataAccess.GetListBySql <AbPromotionStageLenRecord>(string.Format("select * from Ab_PromotionStageLenRecord where PromotionId = {0} and ApplyId = {1} and StageId = {2} and UserId = {3}", apply.PromotionId, applyId, stageid, apply.UserId)).FirstOrDefault(); if (record != null) { var _examtestDB = new RetechWing.BusinessCommon.Examination.ExaminationCommonMethod(); var examuser = _examtestDB.GetExamUser(new int[] { record.RecordId }, new int[] { apply.UserId }, 2).FirstOrDefault(p => p.ExamPaperID == stage.ExamId); if (examuser != null) { stage.UserExamPass = examuser.IsPass; } } } return(stage); }
public void SavePromotionWayPostList(out List <int> deleteIds, int promotionId, List <PromotionStage> list) { deleteIds = new List <int>(); var _exampaperDB = new RetechWing.BusinessCommon.Examination.ExaminationCommonMethod(); string where = string.Format(" Ab_PromotionStage.IsDelete = 0 and Ab_PromotionStage.PromotionId = {0} ", promotionId); var postList = _dataAccess.GetList <PromotionStage>(where); if (postList.Count > 0) { foreach (var item in postList) { var tmp = list.Find(p => p.PostId == item.PostId); if (tmp == null) { deleteIds.Add(item.StageId); UpdatePostPromotion(item.PostId, 0); } else { item.Description = tmp.Description; item.Period = tmp.Period; item.ObligatoryLessScore = tmp.ObligatoryLessScore; item.ElectiveLessScore = tmp.ElectiveLessScore; item.PassScore = tmp.PassScore; item.OrderNum = tmp.OrderNum; if (tmp.ExamId > 0) { tbExampaper exampaper = _exampaperDB.GetSingleById <tbExampaper>(tmp.ExamId); tbExampaperRedundancy model = new tbExampaperRedundancy { ExampaperId = exampaper._id, Description = exampaper.Description, Distribution = exampaper.Distribution, ExamSortID = exampaper.ExamSortID, TrainDetailId = exampaper.TrainDetailId, UserID = exampaper.UserID, CreateTime = exampaper.CreateTime, ExampaperAvailable = exampaper.ExampaperAvailable, ExampaperOpen = exampaper.ExampaperOpen, ExampaperScore = exampaper.ExampaperScore, ExampaperTitle = exampaper.ExampaperTitle, ExamType = exampaper.ExamType, LastUpdateTime = exampaper.LastUpdateTime, QuestionList = exampaper.QuestionList, QuestionRule = exampaper.QuestionRule, QuestionTypeOrder = exampaper.QuestionTypeOrder, Realname = exampaper.Realname, Status = exampaper.Status, TenantId = exampaper.TenantId }; item.ExamId = _exampaperDB.Insert <tbExampaperRedundancy>(model); } _dataAccess.UpdateEntity(item); list.Remove(tmp); } } } if (deleteIds.Count > 0) { _dataAccess.UpdateField("Ab_PromotionStage", "IsDelete", "1", "where StageId in (" + deleteIds.GetString() + ")"); } if (list.Count > 0) { foreach (var item in list) { if (item.ExamId > 0) { tbExampaper exampaper = _exampaperDB.GetSingleById <tbExampaper>(item.ExamId); tbExampaperRedundancy model = new tbExampaperRedundancy { ExampaperId = exampaper._id, Description = exampaper.Description, Distribution = exampaper.Distribution, ExamSortID = exampaper.ExamSortID, TrainDetailId = exampaper.TrainDetailId, UserID = exampaper.UserID, CreateTime = exampaper.CreateTime, ExampaperAvailable = exampaper.ExampaperAvailable, ExampaperOpen = exampaper.ExampaperOpen, ExampaperScore = exampaper.ExampaperScore, ExampaperTitle = exampaper.ExampaperTitle, ExamType = exampaper.ExamType, LastUpdateTime = exampaper.LastUpdateTime, QuestionList = exampaper.QuestionList, QuestionRule = exampaper.QuestionRule, QuestionTypeOrder = exampaper.QuestionTypeOrder, Realname = exampaper.Realname, Status = exampaper.Status, TenantId = exampaper.TenantId }; item.ExamId = _exampaperDB.Insert <tbExampaperRedundancy>(model); } } _dataAccess.AddEntities(list); } }
public void StageStudyed(int userId, int promotionId, int stageId) { var apply = _dataAccess.GetListBySql <PromotionApply>(string.Format("select * from Ab_PromotionApply where IsDelete = 0 and ApproveStatus = 2 and PromotionStatus = 0 and UserId = {0} and PromotionId = {1}", userId, promotionId)).FirstOrDefault(); if (apply == null || apply.PromotionStatus == 1 || apply.CurrentStageId != stageId) { return; } var stageList = _dataAccess.GetList <RetechWing.Models.Ab.PromotionStage>(" IsDelete = 0 and PromotionId = " + promotionId).OrderBy(p => p.OrderNum); var stage = stageList.FirstOrDefault(p => p.StageId == apply.CurrentStageId); if (stage.Period > 0 && apply.StageStartTime.HasValue && apply.StageStartTime.Value.AddDays(stage.Period) < DateTime.Now) { return; } var recordIdList = _dataAccess.FetchListBySql <int>(string.Format("select RecordId from Ab_LearningRecord where StageId = {0} and ApplyId = {1}", stageId, apply.ApplyId)); //if (recordIdList.Count() == 0) // return; if (recordIdList.Count() == 0) { if (stage.ObligatoryLessScore > 0) { return; } if (stage.ElectiveLessScore > 0) { return; } } else { var courseElective = _dataAccess.FetchListBySql <dynamic>(string.Format(@"select ResourceId as CourseId ,( SELECT COUNT(0) FROM Ab_PostElectiveCourse WHERE PostId = {0} AND AbilityId = Ab_AbilityResource.AbilityId AND COURSEID = Ab_AbilityResource.ResourceId ) AS Elective from Ab_AbilityResource where Ab_AbilityResource.IsDelete = 0 and Ab_AbilityResource.ResourceType = 0 and Ab_AbilityResource.AbilityId in ( select AbilityId from Ab_PostAbility where IsDelete = 0 and PostId = {0} )", stage.PostId)); var courseLearnScore = _dataAccess.GetListBySql <RetechWing.Models.ResCourse>(string.Format(@"select CourseId,LearnScore from Res_Course where Res_Course.CourseId in ( select CourseId from Len_LearningRecord where LearnProcess = 2 and LearnPath = 3 and SourceId in ({0}) and UserID = {1} )", recordIdList.GetString(), userId)); if (stage.ObligatoryLessScore > courseLearnScore.Where(p => courseElective.Any(ce => ce.Elective == 0 && ce.CourseId == p.CourseId)).Sum(p => p.LearnScore)) { return; } if (stage.ElectiveLessScore > courseLearnScore.Where(p => courseElective.Any(ce => ce.Elective == 1 && ce.CourseId == p.CourseId)).Sum(p => p.LearnScore)) { return; } } var psRecordList = _dataAccess.GetListBySql <RetechWing.Models.Ab.AbPromotionStageLenRecord>(string.Format(@"select * from Ab_PromotionStageLenRecord where ApplyId = {0} and UserId = {1}", apply.ApplyId, userId)); var psRecord = psRecordList.FirstOrDefault(p => p.StageId == stageId); if (psRecord == null) { return; } if (stage.ExamId > 0) { var examuserlist = new RetechWing.BusinessCommon.Examination.ExaminationCommonMethod().GetExamSendStudentWithByRelationIdAndUserId(psRecord.RecordId, 2, userId); if (examuserlist.Count == 0) { return; } if (!examuserlist.Any(p => p.IsPass == 1)) { return; } } psRecord.EndTime = DateTime.Now; _dataAccess.UpdateEntity(psRecord); var nextStage = stageList.FirstOrDefault(p => p.OrderNum == stage.OrderNum + 1); while (true) { if (nextStage == null) { break; } var tmpPsRecord = psRecordList.FirstOrDefault(p => p.StageId == nextStage.StageId); if (tmpPsRecord != null && tmpPsRecord.EndTime.HasValue) { nextStage = stageList.FirstOrDefault(p => p.OrderNum == nextStage.OrderNum + 1); } else { break; } } apply.StageStartTime = null; if (nextStage == null) { apply.PromotionStatus = 1; apply.PromotionSucceedTime = DateTime.Now; } else { apply.CurrentStageId = nextStage.StageId; } _dataAccess.UpdateEntity(apply); }