/// <summary> /// 检测是否能报名 /// </summary> /// <param name="ClassId"></param> /// <returns></returns> public static bool CheckCanEnroll(int ClassId) { Class_Detail class_Detail = new Class_Detail(); Member_ClassRegisterBLL member_ClassRegisterBLL = new Member_ClassRegisterBLL(); Member_ClassRegister member_ClassRegister = new Member_ClassRegister(); member_ClassRegister.ClassId = ClassId; member_ClassRegister.PlanId = Code.SiteCache.Instance.PlanId; Class_DetailBLL class_DetailBLL = new Class_DetailBLL(); member_ClassRegister.TrainingId = class_DetailBLL.GetModel(ClassId).TraningId; member_ClassRegister.AccountId = Code.SiteCache.Instance.LoginInfo.UserId; member_ClassRegister.Status = 1; member_ClassRegister.ManagerId = Code.SiteCache.Instance.LoginInfo.UserId; member_ClassRegister.Delflag = false; member_ClassRegister.CreateDate = DateTime.Now; Course_UnitDetailBLL course_UnitDetailBLL = new Course_UnitDetailBLL(); member_ClassRegister.TotalSchedule = course_UnitDetailBLL.GetList(" TrainingId='" + class_DetailBLL.GetModel(ClassId).TraningId + "' and ParentId=0 and Display=1 and Delflag='false'", "").Count; List<Member_ClassRegister> listno = member_ClassRegisterBLL.GetList(" ClassId='" + ClassId + "' and AccountId='" + Code.SiteCache.Instance.LoginInfo.UserId + "' and delflag='false' and Status in (1,2,4)", ""); if (listno.Count > 0) { return false; } //List<Member_ClassRegister> listpass = member_ClassRegisterBLL.GetList(" TrainingId='" + member_ClassRegister.TrainingId + "' and AccountId='" + Code.SiteCache.Instance.LoginInfo.UserId + "' and delflag='false' and (Result=1 or (Result is NULL and Status=4))", ""); //if (listpass.Count > 0) //{ // return false; //} return true; }
public ActionResult BatchAuditGraduate(int classId, string Ids, string Remark) { try { var bll = new Member_ClassRegisterBLL(); var ids = Ids.Split(','); var classDetail = new Dianda.AP.BLL.Class_DetailBLL().GetModel(classId); var tranFieldModel = new Traning_DetailBLL().GetModel(classDetail.TraningId, ""); foreach (var id in ids) { if (!string.IsNullOrEmpty(id)) { var Val = id.Split('|')[1].ToInt(); if (Val == 0) continue;//不操作 var model = bll.GetList("Delflag=0 and ClassId=" + classId + " and AccountId=" + id.Split('|')[0].ToInt(), "").First(); model.Result = Val; var totalScore = (model.ReadingScore.HasValue ? model.ReadingScore.Value : 0) + (model.DiscussScore.HasValue ? model.DiscussScore.Value : 0) + (model.HomeWorkScore.HasValue ? model.HomeWorkScore.Value : 0) + (model.TestingScore.HasValue ? model.TestingScore.Value : 0) + (model.ExaminationScore.HasValue ? model.ExaminationScore.Value : 0) + (model.CommentScore.HasValue ? model.CommentScore.Value : 0); if (Math.Ceiling(totalScore) < 60 && Val == 1 && tranFieldModel.OutSideType == -1)//分数小于60,不操作 continue; model.ApplyRemark = Remark; model.ResultCreater = SiteCache.Instance.LoginInfo.UserId; model.TotalScore = totalScore; bll.Update(model); var comment = new Dianda.AP.BLL.Class_TraningCommentResultBLL().GetListModel(" ClassId=" + classId + " and AccountId=" + id.Split('|')[0].ToInt() + " and Delflag=0"); if (Val == 1 && comment != null && comment.Count>0)//如果结论是合格,,并且评论过课程,则要更新用户学分 { var tranEditModel = new Member_TrainingReditBLL().GetList("Delflag=0 and TrainingField=" + tranFieldModel.TraingField + " and PlanId=" + model.PlanId + " and AccountId=" + model.AccountId, ""); Member_TrainingRedit tranEdit = null; if (tranEditModel == null || tranEditModel.Count == 0)//创建 { tranEdit = new Member_TrainingRedit(); tranEdit.AccountId = model.AccountId; tranEdit.CreateDate = DateTime.Now; tranEdit.Credits = tranFieldModel.TotalTime.Value; tranEdit.Delflag = false; tranEdit.PlanId = model.PlanId; tranEdit.TrainingField = tranFieldModel.TraingField; new Member_TrainingReditBLL().Add(tranEdit); } else//更新 { tranEdit = tranEditModel.First(); tranEdit.Credits += tranFieldModel.TotalTime.Value; new Member_TrainingReditBLL().Update(tranEdit); } var traningCredit = DataTableToListHelper<Training_Credits>.ConvertToModel( new Training_CreditsBLL().GetList(" and PlanId=" + model.PlanId + " and OrganId=" + classDetail.OrganId, "") );//查找学时学分 if (traningCredit != null && traningCredit.Count > 0) //轮循所有大类 { bool graduateFlag = true; var member_traningBll = new Member_TrainingReditBLL(); foreach (var item in traningCredit) { var traning_credit = member_traningBll.GetList (" Delflag=0 and PlanId=" + model.PlanId + " and AccountId=" + model.AccountId + " and TrainingField=" + item.TraningField , ""); if (traningCredit != null && traningCredit.Count > 0) { if (traningCredit.First().MinValue > tranEdit.Credits) { graduateFlag = false; break; } } } if (graduateFlag)//所有大类学分均合格,更新Member_PlanOverall表的用户合格状态。 { var Member_PlanOverallBll = new Member_PlanOverallBLL(); var Member_PlanOverall = Member_PlanOverallBll.GetListModel(" Delflag=0 and PlanId=" + model.PlanId + " and AccountId=" + model.AccountId); if (Member_PlanOverall != null && Member_PlanOverall.Count > 0) { var item = Member_PlanOverall.First(); item.Result = 1; Member_PlanOverallBll.Update(item); } else { var item = new Member_PlanOverall(); item.Result = 1; item.PlanId = model.PlanId; item.AccountId = model.AccountId; item.CreateDate = DateTime.Now; item.Delflag = false; Member_PlanOverallBll.Add(item); } } } } } } return Json(new { Code = 0, Msg = "提交成功" }, JsonRequestBehavior.AllowGet); } catch (Exception ex) { return Json(new { Code = -1, Msg = ex.Message + ex.StackTrace }, JsonRequestBehavior.AllowGet); } }
/* * 进度汇总逻辑: * * 1.用户每次学习课程时需要往 Member_ClassUnitContentSchedule 中插入数据,作为当前的章节小进度. * 2.当当前章节所有的课程学习结束,需要判断当前在章节是否学习结束; * 3.在修改章节进度和总进度时,需要重新验证所有的章节进度是否已完成(可能存在章节追加的情况). * 4.若当前章节全部学习结束,需要在总进度表中 Member_ClassRegister 更改CurrentSchedule(当前章节进度),TotalSchedule(总课程进度). * * 所用表: select * from Member_ClassRegister select * from Course_UnitContent --1文本,2影音教材,3讨论,4作业 5测试,6结业考试 select * from Member_ClassUnitContentSchedule select * from Course_Detail select * from Course_UnitDetail * * [课程]下 分 [章]下 分 [节]下 分 [活动] * 同时也可以在[章]下面没有节,只有[活动],所以需要获取章下面所有的活动 */ /// <summary> /// 更新总体进度 /// </summary> /// <param name="iUnitId">当前[活动]所在[节]的ID</param> /// <param name="iClassId"></param> /// <param name="iTrainingId"></param> /// <param name="iAccountId"></param> /// <param name="iUnitContent"></param> private void UpdateOverallProgress(int iUnitId, int iClassId, int iTrainingId, int iAccountId, int iUnitContent) { var unitBll = new Course_UnitContentBLL(); var detailBll = new Class_DetailBLL(); var UnitDetailBll = new Course_UnitDetailBLL(); var ClassRegisterBll = new Member_ClassRegisterBLL(); var Member_ClassUnitContentSchedulebll = new Member_ClassUnitContentScheduleBLL(); int iOverChapterCount = 0, iChapterTotalCount = 0;//完成的[章]的数量,当前课程需要学习的[章]总数,该[章]已完成的[节]的数量(该章的进度) //用户的在线学习模块都要插入一条数据到Member_ClassUnitContentSchedule,作为当前小章节的学习进度 if (this.InsertMember_ClassUnitContentSchedule(iClassId, iTrainingId, iAccountId, iUnitContent)) { var List_Course_UnitDetail = UnitDetailBll.GetList(" ParentId = 0 AND Display = 1 AND Delflag = 0 AND TrainingId = " + iTrainingId, string.Empty); iChapterTotalCount = List_Course_UnitDetail.Count;//当前课程学员需要完成学习的总章数 foreach (var ChapterItem in List_Course_UnitDetail) { bool bolResult = this.GetChapterProgress(ChapterItem.Id, iClassId, ChapterItem.TrainingId.Value, iAccountId); if (bolResult)//当前[章]的进度 { iOverChapterCount++; } } //[Status] 1等待学校审核 2学校审核通过 3学校审核不通过 4开班机构审核通过 5开班机构审核不通过 int iPlanId = Code.SiteCache.Instance.PlanId; string strWhere = string.Format(@" AccountId = {0} AND ClassId = {1} AND PlanId = {2} and TrainingId = {3} and Delflag = 0 AND Status = 4", iAccountId, iClassId, iPlanId, iTrainingId); var List_Member_ClassRegister = ClassRegisterBll.GetList(strWhere, "CreateDate"); if (List_Member_ClassRegister != null && List_Member_ClassRegister.Count == 1) { var Model_Member_ClassRegister = List_Member_ClassRegister[0]; Model_Member_ClassRegister.CurrentSchedule = iOverChapterCount;//[章,节]完成数 Model_Member_ClassRegister.TotalSchedule = iChapterTotalCount;//课程总章,节数 Model_Member_ClassRegister.CreateDate = DateTime.Now; bool bolResult = ClassRegisterBll.Update(Model_Member_ClassRegister); } } }
/// <summary> /// 课程是否已结束 /// </summary> /// <param name="iClassId"></param> /// <param name="iTrainingId"></param> /// <param name="iAccountId"></param> /// <returns></returns> private bool GetCourseIsOver(int iClassId, int iTrainingId, int iAccountId) { var classBll = new Class_DetailBLL(); var registerBll = new Member_ClassRegisterBLL(); var Model_Member_ClassRegister = new Member_ClassRegister(); int iPlanId = Code.SiteCache.Instance.PlanId; var iResult = 0; ///***************************************************************1. 判断当前班级的课程有没有结束 开始***************************************************************/ //var Model_Class_Detail = classBll.GetModel(iClassId); //if (Model_Class_Detail.Status == 6 || Model_Class_Detail.OpenClassTo > DateTime.Now)//班级的课程已结束 //{ // return true; //} ///***************************************************************判断当前班级的课程有没有结束 结束***************************************************************/ /***************************************************************2. 判断当前用户的课程有没有结束 开始***************************************************************/ string strWhere = string.Format(@" AccountId = {0} AND ClassId = {1} AND PlanId = {2} and TrainingId = {3} and Delflag = 0 AND Status = 4", iAccountId, iClassId, iPlanId, iTrainingId); var List_Member_ClassRegister = registerBll.GetList(strWhere, "CreateDate"); if (List_Member_ClassRegister != null && List_Member_ClassRegister.Count == 1) { Model_Member_ClassRegister = List_Member_ClassRegister[0]; iResult = Model_Member_ClassRegister.Result == null ? 0 : Convert.ToInt32(Model_Member_ClassRegister.Result.Value); } /***************************************************************判断当前用户的课程有没有结束 结束***************************************************************/ return iResult == 1; }
public ActionResult CourseLearn(int TrainingId,int ClassId) { //ViewBag.Title = "课程预览"; Course_DetailBLL bll = new Course_DetailBLL(); Code.SiteCache cache = Code.SiteCache.Instance; //指定课程的课程ID ViewBag.TrainingId = TrainingId; //获取指定课程ID对应的课程单元信息 ViewBag.TrainingInfo = bll.GetTrainingInfoById(TrainingId); //获取班级ID ViewBag.ClassId = ClassId; Member_ClassRegisterBLL member_ClassRegisterBLL = new Member_ClassRegisterBLL(); ViewBag.Score = member_ClassRegisterBLL.GetList("ClassId='" + ClassId + "' and Status=4 and Delflag='false' and PlanId='" + Code.SiteCache.Instance.PlanId + "' and AccountId='" + Code.SiteCache.Instance.LoginInfo.UserId + "'", "")[0].ExaminationScore; cache.TrainingId = TrainingId; cache.UnitId = TrainingId; cache.ClassId = ClassId; ViewBag.ExamQuesCnt = cache.ExamQuesInfo.Count; ViewBag.ExamInfo = cache.ActivityLearn; this.MyProgress(TrainingId); return View(); }
/// <summary> /// 当前[我的进度] /// </summary> /// <param name="TrainingId"></param> public void MyProgress(int TrainingId) { int iAccountId = 0, iClassId = 0,iPlanId=0; iAccountId = Code.SiteCache.Instance.LoginInfo.UserId; int.TryParse(Convert.ToString(Request["ClassId"]) == "" ? "0" : QueryString.Decrypt(Request["ClassId"]), out iClassId);//获取 ClassId iPlanId = Code.SiteCache.Instance.PlanId; Member_ClassRegister Model_Member_ClassRegister = new Member_ClassRegister(); var bll = new Member_ClassRegisterBLL(); string strWhere = string.Format(@"AccountId = {0} AND ClassId = {1} AND PlanId = {2} and TrainingId = {3} and Delflag = 0 AND Status = 4 ", iAccountId, iClassId, iPlanId, TrainingId); var List_Member_ClassRegister = bll.GetList(strWhere, "CreateDate"); if (List_Member_ClassRegister != null && List_Member_ClassRegister.Count == 1) { Model_Member_ClassRegister = List_Member_ClassRegister[0]; } ViewBag.Model_Member_ClassRegister = Model_Member_ClassRegister; }
/// <summary> /// 重新打分 /// </summary> /// <param name="classId"></param> /// <param name="planId"></param> /// <param name="accountId"></param> public static void resetScore(int classId, int planId) { var member_classBll = new Member_ClassRegisterBLL(); var classDetail = new Class_DetailBLL().GetModel(classId); var traningBll = new Traning_DetailBLL(); var traning_detail = traningBll.GetModel(classDetail.TraningId, ""); if (traning_detail == null) return; var courseBll = new Course_DetailBLL(); var cousre_detail = courseBll.GetList(" TrainingId=" + traning_detail.Id, ""); if (cousre_detail == null || cousre_detail.Count == 0) return; var unitContentBll = new Course_UnitContentBLL(); var memberList = member_classBll.GetList("Delflag=0 and ClassId=" + classId + " and PlanId=" + planId, ""); foreach (var memberModel in memberList) { var accountId = memberModel.AccountId; int total = 1; IList<Course_UnitContent> contentList = new List<Course_UnitContent>(); #region //重新计算阅读分数 total = unitContentBll.GetUnitCountByClassAndUnitType(classId, "1,2"); contentList = DataTableToListHelper<Course_UnitContent>.ConvertToModel(unitContentBll.GetUnitByClassAndUnitType(classId, "1,2")); if (contentList != null) { var scheduleBll = new Member_ClassUnitContentScheduleBLL(); int scoreCount = 0; foreach (var item in contentList) { var scheduleModel = scheduleBll.GetList("Delflag=0 and ClassId=" + classId + " and AccountId=" + accountId + " and UnitContent=" + item.Id, ""); if (scheduleModel != null && scheduleModel.Count > 0) { if (scheduleModel.First().score.HasValue)//如果有值说明打过分 { scoreCount++; } } } if (scoreCount == total)//全部阅读过,给满分 { memberModel.ReadingScore = cousre_detail[0].ReadingRate; } else { memberModel.ReadingScore = cousre_detail[0].ReadingRate * scoreCount / total;//阅读数与总数折算 } } //重新计算讨论分数 total = unitContentBll.GetUnitCountByClassAndUnitType(classId, "3"); contentList = DataTableToListHelper<Course_UnitContent>.ConvertToModel(unitContentBll.GetUnitByClassAndUnitType(classId, "3")); if (contentList != null) { var scheduleBll = new Member_ClassUnitContentScheduleBLL(); int scoreCount = 0; foreach (var item in contentList) { var scheduleModel = scheduleBll.GetList("Delflag=0 and ClassId=" + classId + " and AccountId=" + accountId + " and UnitContent=" + item.Id, ""); if (scheduleModel != null && scheduleModel.Count > 0) { if (scheduleModel.First().score.HasValue)//如果有值说明打过分 { scoreCount++; } } } if (scoreCount == total)//全部讨论过,给满分 { memberModel.DiscussScore = cousre_detail[0].DisscusRate; } else { memberModel.DiscussScore = cousre_detail[0].DisscusRate * scoreCount / total;//讨论数与总数折算 } } //如有分值,重新计算作业分数 total = unitContentBll.GetUnitCountByClassAndUnitType(classId, "4"); contentList = DataTableToListHelper<Course_UnitContent>.ConvertToModel(unitContentBll.GetUnitByClassAndUnitType(classId, "4")); if (contentList != null) { var homeworkBll = new Course_UnitHomeWorkBLL(); double homeworkscore = 0; foreach (var item in contentList) { var scheduleModel = homeworkBll.GetList("Delflag=0 and ClassId=" + classId + " and AccountId=" + accountId + " and UnitContent=" + item.Id, ""); if (scheduleModel != null && scheduleModel.Count > 0) { if (scheduleModel.First().Score.HasValue)//如果有值说明打过分 { homeworkscore += (scheduleModel.First().Score.Value * (cousre_detail[0].HomeWorkRate) / (total * 100)).ToDouble();//已打分数与总数折算 } } } memberModel.HomeWorkScore = homeworkscore; } //重新计算测试分数 total = unitContentBll.GetUnitCountByClassAndUnitType(classId, "5"); contentList = DataTableToListHelper<Course_UnitContent>.ConvertToModel(unitContentBll.GetUnitByClassAndUnitType(classId, "5")); if (contentList != null) { var scheduleBll = new Member_ClassUnitContentScheduleBLL(); double testscore = 0; foreach (var item in contentList) { var scheduleModel = scheduleBll.GetList("Delflag=0 and ClassId=" + classId + " and AccountId=" + accountId + " and UnitContent=" + item.Id, ""); if (scheduleModel != null && scheduleModel.Count > 0) { if (scheduleModel.First().score.HasValue) { testscore += (scheduleModel.First().score.Value * (cousre_detail[0].QuestionRate) / (total * 100)).ToDouble(); } } } memberModel.TestingScore = testscore; } //重新计算考试分数 total = unitContentBll.GetUnitCountByClassAndUnitType(classId, "6"); contentList = DataTableToListHelper<Course_UnitContent>.ConvertToModel(unitContentBll.GetUnitByClassAndUnitType(classId, "6")); if (contentList != null) { var scheduleBll = new Member_ClassUnitContentScheduleBLL(); double examcore = 0; foreach (var item in contentList) { var scheduleModel = scheduleBll.GetList("Delflag=0 and ClassId=" + classId + " and AccountId=" + accountId + " and UnitContent=" + item.Id, ""); if (scheduleModel != null && scheduleModel.Count > 0) { if (scheduleModel.First().score.HasValue) { examcore += (scheduleModel.First().score.Value * (cousre_detail[0].TestingRate) / (total * 100)).ToDouble(); } } } memberModel.ExaminationScore = examcore; } #endregion member_classBll.Update(memberModel); } }
/// <summary> /// /// </summary> /// <param name="objectId">单元ID</param> /// <param name="objectType">单元类型</param> /// <param name="classId">班级ID</param> /// <param name="planId">计划ID</param> /// <param name="accountId">成员ID</param> /// <param name="score">分值</param> public static void ScoreSet(int? objectId, int objectType, int classId, int planId, int accountId, double score, bool add = true) { dynamic objectBll; dynamic model; Member_ClassRegister memberModel; int total = 1; var member_classBll = new Member_ClassRegisterBLL(); var member_class = member_classBll.GetList(" Delflag=0 and ClassId=" + classId + " and PlanId=" + planId + " and AccountId=" + accountId, ""); if (member_class == null || member_class.Count == 0) return; memberModel = member_class.FirstOrDefault(); var traningBll = new Traning_DetailBLL(); var traning_detail = traningBll.GetModel(memberModel.TrainingId.Value, ""); if (traning_detail == null) return; var courseBll = new Course_DetailBLL(); var cousre_detail = courseBll.GetList(" Delflag=0 and TrainingId=" + traning_detail.Id, ""); if (cousre_detail == null || cousre_detail.Count == 0) return; var unitContentBll = new Course_UnitContentBLL(); var oldScore = 0.0; switch (objectType) { case 1://read objectBll = new Member_ClassUnitContentScheduleBLL(); model = objectBll.GetList("Delflag=0 and ClassId=" + classId + " and AccountId=" + accountId + " and UnitContent=" + objectId, ""); if (model.Count > 0) { if (add) model[0].score = 1; else model[0].score = 0; objectBll.Update(model[0]);// } total = unitContentBll.GetUnitCountByClassAndUnitType(classId, "1,2");//阅读视频类的单元活动数 if (total > 1) { if (add) memberModel.ReadingScore = (memberModel.ReadingScore.HasValue ? memberModel.ReadingScore.Value : 0) + (cousre_detail[0].ReadingRate / (total)).ToDouble(); else { if (memberModel.ReadingScore.HasValue && memberModel.ReadingScore.Value.ToInt() > 0) memberModel.ReadingScore = memberModel.ReadingScore.Value - (cousre_detail[0].ReadingRate / (total)).ToDouble(); } } else { if (add) memberModel.ReadingScore = cousre_detail[0].ReadingRate; else memberModel.ReadingScore = 0.0; } if (memberModel.ReadingScore > cousre_detail[0].ReadingRate) { memberModel.ReadingScore = cousre_detail[0].ReadingRate; } if (memberModel.ReadingScore < 0) { memberModel.ReadingScore = 0; } member_classBll.Update(memberModel);//更新班级成员考试分数总值 break; case 2://discuss objectBll = new Member_ClassUnitContentScheduleBLL(); model = objectBll.GetList("Delflag=0 and ClassId=" + classId + " and AccountId=" + accountId + " and UnitContent=" + objectId, ""); if (model.Count > 0) { if (add) model[0].score = 1; else model[0].score = 0; objectBll.Update(model[0]);// } total = unitContentBll.GetUnitCountByClassAndUnitType(classId, "3");//讨论类的单元活动数 if (total > 1) { if (add) memberModel.DiscussScore = (memberModel.DiscussScore.HasValue ? memberModel.DiscussScore.Value : 0) + (cousre_detail[0].DisscusRate / (total)).ToDouble(); else { if (memberModel.ReadingScore.HasValue && memberModel.ReadingScore.Value.ToInt() > 0) memberModel.DiscussScore = memberModel.DiscussScore.Value - (cousre_detail[0].DisscusRate / (total)).ToDouble(); } } else { if (add) memberModel.DiscussScore = cousre_detail[0].DisscusRate; else memberModel.DiscussScore = 0.0; } if (memberModel.DiscussScore > cousre_detail[0].DisscusRate) { memberModel.DiscussScore = cousre_detail[0].DisscusRate; } if (memberModel.DiscussScore < 0) { memberModel.DiscussScore = 0; } member_classBll.Update(memberModel);//更新班级成员考试分数总值 break; case 3://homework #region objectBll = new Course_UnitHomeWorkBLL(); model = objectBll.GetModel(objectId.Value, ""); model.Score = score; model.ScoreCreater = SiteCache.Instance.ManagerId; objectBll.Update(model);//更新结果表 total = unitContentBll.GetUnitCountByClassAndUnitType(classId, "4");//作业类的单元活动数 if (total > 1) { memberModel.HomeWorkScore = (memberModel.HomeWorkScore.HasValue ? memberModel.HomeWorkScore.Value : 0) + (score * (cousre_detail[0].HomeWorkRate) / (total * 100)).ToDouble(); } else { memberModel.HomeWorkScore = (score * (cousre_detail[0].HomeWorkRate) / (100)).ToDouble(); } if (memberModel.HomeWorkScore > cousre_detail[0].HomeWorkRate) { memberModel.HomeWorkScore = cousre_detail[0].HomeWorkRate; } member_classBll.Update(memberModel);//更新班级成员作业分数总值 #endregion break; case 4://question #region objectBll = new Member_ClassUnitContentScheduleBLL(); model = objectBll.GetModel(objectId.Value, ""); oldScore = model.score == null ? 0 : model.score; model.score = score; objectBll.Update(model);//更新班级成员测试分数总值 total = unitContentBll.GetUnitCountByClassAndUnitType(classId, "5");//测试类的单元活动数 if (add)//第一次打分 { if (total > 1) { memberModel.TestingScore = (memberModel.TestingScore.HasValue ? memberModel.TestingScore.Value : 0) + (score * (cousre_detail[0].QuestionRate) / (total * 100)).ToDouble(); } else { memberModel.TestingScore = (score * (cousre_detail[0].QuestionRate) / (100)).ToDouble(); } } else//多次打分,重新计算 { var contentList = DataTableToListHelper<Course_UnitContent>.ConvertToModel(unitContentBll.GetUnitByClassAndUnitType(classId, "5")); if (contentList != null) { var scheduleBll = new Member_ClassUnitContentScheduleBLL(); double testscore = 0; foreach (var item in contentList) { var scheduleModel = scheduleBll.GetList("Delflag=0 and ClassId=" + classId + " and AccountId=" + accountId + " AND UnitContent=" + item.Id, ""); if (scheduleModel != null && scheduleModel.Count > 0) { if (scheduleModel.First().score.HasValue) { testscore += (scheduleModel.First().score.Value * (cousre_detail[0].QuestionRate) / (total * 100)).ToDouble(); } } } memberModel.TestingScore = testscore; } } if (memberModel.TestingScore > cousre_detail[0].QuestionRate) { memberModel.TestingScore = cousre_detail[0].QuestionRate; } member_classBll.Update(memberModel);//更新班级成员测试分数总值 #endregion break; case 5://examnation #region objectBll = new Member_ClassUnitContentScheduleBLL(); model = objectBll.GetModel(objectId.Value, ""); oldScore = model.score == null ? 0 : model.score; model.score = score; if (score >= 60)//考试大于等于60分算通过 memberModel.IsPass = true; objectBll.Update(model);//更新班级成员考试分数总值 total = unitContentBll.GetUnitCountByClassAndUnitType(classId, "6");//考试类的单元活动数 if (total > 1) { memberModel.ExaminationScore = (memberModel.ExaminationScore.HasValue ? memberModel.ExaminationScore.Value : 0) + (score * (cousre_detail[0].TestingRate) / (total * 100)).ToDouble(); } else { memberModel.ExaminationScore = (score * (cousre_detail[0].TestingRate) / (100)).ToDouble(); } if (memberModel.ExaminationScore > cousre_detail[0].TestingRate) { memberModel.ExaminationScore = cousre_detail[0].TestingRate; } member_classBll.Update(memberModel);//更新班级成员考试分数总值 #endregion break; case 6://comment #region objectBll = new Member_ClassRegisterBLL(); model = objectBll.GetList(" Delflag=0 and ClassId=" + classId + " and PlanId=" + planId + " and AccountId=" + accountId, "")[0]; model.CommentScore = (score * (cousre_detail[0].CommentRate) / (total * 100)).ToDouble(); objectBll.Update(model);//更新班级成员评价分数总值 #endregion break; default: break; } }
public JsonResult EditClass(string id, string Title, string TraningId, string PlanId, string SignUpStartTime, string SignUpEndTime , string OpenClassFrom, string OpenClassTo, string ClassForm, string LimitPeopleCnt, string Address , string Content, string Subject, string StudyLevel, string TeachGrade, string TeachRank, string OrganRange , string Status) { try { var bll = new Class_DetailBLL(); var model = bll.GetModel(id.ToInt()); model.Title = Title; model.TraningId = TraningId.ToInt(); model.PlanId = PlanId.ToInt(); model.SignUpStartTime = SignUpStartTime.ToDateTime(); model.SignUpEndTime = SignUpEndTime.ToDateTime(); model.OpenClassFrom = OpenClassFrom.ToDateTime(); model.OpenClassTo = OpenClassTo.ToDateTime(); model.ClassForm = ClassForm.ToInt(); model.People = 0; model.LimitPeopleCnt = LimitPeopleCnt.ToInt(); model.Address = Address; model.Content = Content; model.Subject = Subject.Contains("all") ? true : false; model.StudyLevel = StudyLevel.Contains("all") ? true : false; ; model.TeachGrade = TeachGrade.Contains("all") ? true : false; ; model.TeachRank = TeachRank.Contains("all") ? true : false; model.OrganRange = OrganRange.Contains("all") ? "0" : OrganRange; ; model.ManagerId = SiteCache.Instance.ManagerId; model.Status = Status.ToInt(); model.CreateDate = DateTime.Now; bll.Update(model); Member_ClassRegisterBLL member_ClassRegisterBLL = new Member_ClassRegisterBLL(); List<Member_ClassRegister> member_ClassRegisterList = member_ClassRegisterBLL.GetList("ClassId='" + id + "'", ""); if (member_ClassRegisterList != null && member_ClassRegisterList.Count > 0) { foreach (Member_ClassRegister m in member_ClassRegisterList) { m.Delflag = true; member_ClassRegisterBLL.Update(m); } } if (!model.StudyLevel)//不是全部则建立关联数据 { var arr = StudyLevel.Split(','); var section = new Class_StudySectionBLL(); var oldSection = section.GetList(" Delflag=0 and ClassId=" + model.Id, ""); foreach (var old in oldSection) { var oldId = old.StudySection.ToString(); var exists = arr.Where(s => s == oldId); if (exists == null || exists.Count() == 0)//旧的在新的里面不存,则删除 { old.Delflag = true; section.Update(old); } } foreach (var item in arr)//新的在旧的里面不存在,则新加 { var newid = item.ToInt(); var exists = oldSection.Where(s => s.StudySection == newid && s.Delflag == false); if (exists == null || exists.Count() == 0)// { var classSection = new Dianda.AP.Model.Class_StudySection(); classSection.ClassId = model.Id; classSection.CreateDate = DateTime.Now; classSection.Delflag = false; classSection.StudySection = item.ToInt(); section.Add(classSection); } } } if (!model.Subject)//不是全部则建立关联数据 { var arr = Subject.Split(','); var section = new Class_TeachSubjectBLL(); var oldSection = section.GetList(" Delflag=0 and ClassId=" + model.Id, ""); foreach (var old in oldSection) { var oldId = old.TeachSubject.ToString(); var exists = arr.Where(s => s == oldId); if (exists == null || exists.Count() == 0)//旧的在新的里面不存,则删除 { old.Delflag = true; section.Update(old); } } foreach (var item in arr) { var newid = item.ToInt(); var exists = oldSection.Where(s => s.TeachSubject == newid && s.Delflag == false); if (exists == null || exists.Count() == 0)// { var teachSubject = new Dianda.AP.Model.Class_TeachSubject(); teachSubject.ClassId = model.Id; teachSubject.CreateDate = DateTime.Now; teachSubject.Delflag = false; teachSubject.TeachSubject = item.ToInt(); section.Add(teachSubject); } } } if (!model.TeachGrade)//不是全部则建立关联数据 { var arr = TeachGrade.Split(','); var section = new Class_TeachGradeBLL(); var oldSection = section.GetList(" Delflag=0 and ClassId=" + model.Id, ""); foreach (var old in oldSection) { var oldId = old.TeachGrade.ToString(); var exists = arr.Where(s => s == oldId); if (exists == null || exists.Count() == 0)//旧的在新的里面不存,则删除 { old.Delflag = true; section.Update(old); } } foreach (var item in arr) { var newid = item.ToInt(); var exists = oldSection.Where(s => s.TeachGrade == newid && s.Delflag == false); if (exists == null || exists.Count() == 0)// { var classSection = new Dianda.AP.Model.Class_TeachGrade(); classSection.ClassId = model.Id; classSection.CreateDate = DateTime.Now; classSection.Delflag = false; classSection.TeachGrade = item.ToInt(); section.Add(classSection); } } } if (!model.TeachRank)//不是全部则建立关联数据 { var arr = TeachRank.Split(','); var section = new Class_TeachRankBLL(); var oldSection = section.GetList(" Delflag=0 and ClassId=" + model.Id, ""); foreach (var old in oldSection) { var oldId = old.TeachRank.ToString(); var exists = arr.Where(s => s == oldId); if (exists == null || exists.Count() == 0)//旧的在新的里面不存,则删除 { old.Delflag = true; section.Update(old); } } foreach (var item in arr) { var newid = item.ToInt(); var exists = oldSection.Where(s => s.TeachRank == newid && s.Delflag == false); if (exists == null || exists.Count() == 0)// { var classSection = new Dianda.AP.Model.Class_TeachRank(); classSection.ClassId = model.Id; classSection.CreateDate = DateTime.Now; classSection.Delflag = false; classSection.TeachRank = item.ToInt(); section.Add(classSection); } } } if (Status == "2")//为提交状态时,新建审核记录 { var apply = new Dianda.AP.Model.Class_ApplyApplication(); apply.ClassId = id.ToInt(); apply.AccountId = SiteCache.Instance.LoginInfo.UserId; apply.Remark = "提交审核"; apply.CreateDate = DateTime.Now; var applyBll = new Class_ApplyApplicationBLL(); applyBll.Add(apply); } return Json(new { Code = 0, Msg = "提交成功" }, JsonRequestBehavior.AllowGet); } catch (Exception ex) { return Json(new { Code = -1, Msg = ex.Message }, JsonRequestBehavior.AllowGet); } }
public JsonResult ClassRegisterAll(int ClassId, string Members, string MembersNames) { Class_DetailBLL class_DetailBLL = new Class_DetailBLL(); string[] members = Members.Trim().Substring(1, Members.Length - 2).Split(','); string[] membersNames = MembersNames.Trim().Substring(1, MembersNames.Length - 2).Split(','); string names = ""; string namespass = ""; string namescannotmessage = ""; string message = ""; for (int i = 0; i < members.Length; i++) { Member_ClassRegisterBLL member_ClassRegisterBLL = new Member_ClassRegisterBLL(); Member_ClassRegister member_ClassRegister = new Member_ClassRegister(); List<Member_ClassRegister> listno = member_ClassRegisterBLL.GetList(" ClassId='" + ClassId + "' and AccountId='" + members[i] + "' and delflag='false' and Status in (1,2,4)", ""); if (listno.Count > 0) { names += membersNames[i] + ","; } List<Member_ClassRegister> listpass = member_ClassRegisterBLL.GetList(" TrainingId='" + member_ClassRegister.TrainingId + "' and AccountId='" + members[i] + "' and delflag='false' and (Result=1 or (Result is NULL and Status in(1,2,4)))", ""); if (listpass.Count > 0) { namespass += membersNames[i] + ","; } string checkmessage = IsCanRegisterAll(ClassId, false, Convert.ToInt32(members[i])); if (checkmessage != "") { namescannotmessage += membersNames[i] + checkmessage; } } if (names != "") { message += names.Trim(',') + "已报名该课程;"; } if (namespass != "") { message += namespass.Trim(',') + "已学过该课程;"; } if (namescannotmessage != "") { message += namescannotmessage; } if (message != "") { return Json(new { Code = -1, Msg = message }, JsonRequestBehavior.AllowGet); } else { Class_Detail class_Detail = new Class_Detail(); class_Detail = class_DetailBLL.GetModel(ClassId); class_Detail.People += members.Length; class_DetailBLL.Update(class_Detail); for (int i = 0; i < members.Length; i++) { Member_ClassRegisterBLL member_ClassRegisterBLL = new Member_ClassRegisterBLL(); Member_ClassRegister member_ClassRegister = new Member_ClassRegister(); member_ClassRegister.ClassId = ClassId; member_ClassRegister.PlanId = Code.SiteCache.Instance.PlanId; member_ClassRegister.TrainingId = class_DetailBLL.GetModel(ClassId).TraningId; member_ClassRegister.AccountId = Convert.ToInt32(members[i]); member_ClassRegister.Status = 2; member_ClassRegister.BatchCode = Guid.NewGuid(); member_ClassRegister.ManagerId = Code.SiteCache.Instance.LoginInfo.UserId; member_ClassRegister.Delflag = false; member_ClassRegister.CreateDate = DateTime.Now; Course_UnitDetailBLL course_UnitDetailBLL = new Course_UnitDetailBLL(); member_ClassRegister.TotalSchedule = course_UnitDetailBLL.GetList(" TrainingId='" + class_DetailBLL.GetModel(ClassId).TraningId + "' and ParentId=0 and Display=1 and Delflag='false'", "").Count; List<Member_ClassRegister> listup = member_ClassRegisterBLL.GetList(" ClassId='" + ClassId + "' and AccountId='" + members[i] + "' and delflag='false' and Status in (3,5)", ""); if (listup.Count > 0) { member_ClassRegister.Id = listup[0].Id; member_ClassRegister.Status = 2; member_ClassRegisterBLL.Update(member_ClassRegister); if (member_ClassRegister.Id > 0) { Member_ClassRegisterApplicationBLL member_ClassRegisterApplicationBLL = new Member_ClassRegisterApplicationBLL(); Member_ClassRegisterApplication member_ClassRegisterApplication = new Member_ClassRegisterApplication(); member_ClassRegisterApplication.ClassRegisterId = member_ClassRegister.Id; member_ClassRegisterApplication.Status = 2; member_ClassRegisterApplication.Creater = Code.SiteCache.Instance.LoginInfo.UserId; member_ClassRegisterApplication.CreateDate = DateTime.Now; member_ClassRegisterApplication.Delflag = false; member_ClassRegisterApplicationBLL.Add(member_ClassRegisterApplication); } else { return Json(new { Code = -1, Msg = "提交失败" }, JsonRequestBehavior.AllowGet); } } else { int RegisterId = member_ClassRegisterBLL.Add(member_ClassRegister); if (RegisterId > 0) { Member_ClassRegisterApplicationBLL member_ClassRegisterApplicationBLL = new Member_ClassRegisterApplicationBLL(); Member_ClassRegisterApplication member_ClassRegisterApplication = new Member_ClassRegisterApplication(); member_ClassRegisterApplication.ClassRegisterId = RegisterId; member_ClassRegisterApplication.Status = 2; member_ClassRegisterApplication.Creater = Code.SiteCache.Instance.LoginInfo.UserId; member_ClassRegisterApplication.CreateDate = DateTime.Now; member_ClassRegisterApplication.Delflag = false; member_ClassRegisterApplicationBLL.Add(member_ClassRegisterApplication); } else { return Json(new { Code = -1, Msg = "提交失败" }, JsonRequestBehavior.AllowGet); } } } } return Json(new { Code = 0, Msg = "提交成功" }, JsonRequestBehavior.AllowGet); }
public JsonResult ClassRegister(int ClassId) { Class_Detail class_Detail = new Class_Detail(); Member_ClassRegisterBLL member_ClassRegisterBLL = new Member_ClassRegisterBLL(); Member_ClassRegister member_ClassRegister = new Member_ClassRegister(); member_ClassRegister.ClassId = ClassId; member_ClassRegister.PlanId = Code.SiteCache.Instance.PlanId; Class_DetailBLL class_DetailBLL = new Class_DetailBLL(); member_ClassRegister.TrainingId = class_DetailBLL.GetModel(ClassId).TraningId; member_ClassRegister.AccountId = Code.SiteCache.Instance.LoginInfo.UserId; member_ClassRegister.Status = 1; member_ClassRegister.ManagerId = Code.SiteCache.Instance.LoginInfo.UserId; member_ClassRegister.Delflag = false; member_ClassRegister.CreateDate = DateTime.Now; Course_UnitDetailBLL course_UnitDetailBLL = new Course_UnitDetailBLL(); member_ClassRegister.TotalSchedule = course_UnitDetailBLL.GetList(" TrainingId='" + class_DetailBLL.GetModel(ClassId).TraningId + "' and ParentId=0 and Display=1 and Delflag='false'", "").Count; //if (!IsCanRegister(ClassId, true, Code.SiteCache.Instance.LoginInfo.UserId)) string checkmessage = IsCanRegisterAll(ClassId, true, Code.SiteCache.Instance.LoginInfo.UserId); if (checkmessage != "") { return Json(new { Code = -1, Msg = checkmessage }, JsonRequestBehavior.AllowGet); } List<Member_ClassRegister> listno = member_ClassRegisterBLL.GetList(" ClassId='" + ClassId + "' and AccountId='" + Code.SiteCache.Instance.LoginInfo.UserId + "' and delflag='false' and Status in (1,2,4)", ""); if (listno.Count > 0) { return Json(new { Code = -1, Msg = "您已经提交了报名申请" }, JsonRequestBehavior.AllowGet); } List<Member_ClassRegister> listpass = member_ClassRegisterBLL.GetList(" TrainingId='" + member_ClassRegister.TrainingId + "' and AccountId='" + Code.SiteCache.Instance.LoginInfo.UserId + "' and delflag='false' and (Result=1 or (Result is NULL and Status in(1,2,4)))", ""); if (listpass.Count > 0) { return Json(new { Code = -1, Msg = "您已经学过该课程或已报名该课程下的其他班级" }, JsonRequestBehavior.AllowGet); } List<Member_ClassRegister> listup = member_ClassRegisterBLL.GetList(" ClassId='" + ClassId + "' and AccountId='" + Code.SiteCache.Instance.LoginInfo.UserId + "' and delflag='false' and Status in (3,5)", ""); if (listup.Count > 0) { member_ClassRegister.Id = listup[0].Id; member_ClassRegister.Status = 1; member_ClassRegisterBLL.Update(member_ClassRegister); if (member_ClassRegister.Id > 0) { class_Detail = class_DetailBLL.GetModel(member_ClassRegister.ClassId); class_Detail.People += 1; class_DetailBLL.Update(class_Detail); Member_ClassRegisterApplicationBLL member_ClassRegisterApplicationBLL = new Member_ClassRegisterApplicationBLL(); Member_ClassRegisterApplication member_ClassRegisterApplication = new Member_ClassRegisterApplication(); member_ClassRegisterApplication.ClassRegisterId = member_ClassRegister.Id; member_ClassRegisterApplication.Status = 1; member_ClassRegisterApplication.Creater = Code.SiteCache.Instance.LoginInfo.UserId; member_ClassRegisterApplication.CreateDate = DateTime.Now; member_ClassRegisterApplication.Delflag = false; member_ClassRegisterApplicationBLL.Add(member_ClassRegisterApplication); return Json(new { Code = 0, Msg = "提交成功" }, JsonRequestBehavior.AllowGet); } else { return Json(new { Code = -1, Msg = "提交失败" }, JsonRequestBehavior.AllowGet); } } else { int RegisterId = member_ClassRegisterBLL.Add(member_ClassRegister); class_Detail = class_DetailBLL.GetModel(member_ClassRegister.ClassId); class_Detail.People += 1; class_DetailBLL.Update(class_Detail); if (RegisterId > 0) { Member_ClassRegisterApplicationBLL member_ClassRegisterApplicationBLL = new Member_ClassRegisterApplicationBLL(); Member_ClassRegisterApplication member_ClassRegisterApplication = new Member_ClassRegisterApplication(); member_ClassRegisterApplication.ClassRegisterId = RegisterId; member_ClassRegisterApplication.Status = 1; member_ClassRegisterApplication.Creater = Code.SiteCache.Instance.LoginInfo.UserId; member_ClassRegisterApplication.CreateDate = DateTime.Now; member_ClassRegisterApplication.Delflag = false; member_ClassRegisterApplicationBLL.Add(member_ClassRegisterApplication); return Json(new { Code = 0, Msg = "提交成功" }, JsonRequestBehavior.AllowGet); } else { return Json(new { Code = -1, Msg = "提交失败" }, JsonRequestBehavior.AllowGet); } } }