Exemple #1
0
        /// <summary>
        /// 檢查權限
        /// </summary>
        /// <param name="application"></param>
        /// <param name="uri"></param>
        /// <param name="rawUrl"></param>
        private void CheckAuth(HttpApplication application, Uri uri, string rawUrl)
        {
            SessionHelper sHelper = new SessionHelper();

            LoginUser loginUser = sHelper.AdminUser;

            string applicationPath = application.Request.ApplicationPath;
            string mamagePath = String.IsNullOrEmpty(applicationPath) ? "/admin" : applicationPath + "/admin";
            mamagePath = mamagePath.Replace("//", "/");
            //後台
            if (rawUrl.StartsWith(mamagePath) == true)
            {
                LoginUser adminVo = sHelper.AdminUser;
                if (adminVo == null)
                {
                    toLoginPage(application.Response);
                    return;
                }

                string userId = loginUser.UserId;

                //判斷路徑是否有權限
                if (!PathHasRight(UserMenuFuncContainer.GetInstance().GetUser(userId), uri, UserMenuFuncContainer.GetInstance().PathFunc))
                {
                    toLoginNoAuthPage(application.Response);
                }

                return;
            }

            ////前台
            //string frontPath = String.IsNullOrEmpty(applicationPath) ? "/content" : applicationPath + "/content";
            //frontPath = frontPath.Replace("//", "/");

            //if (rawUrl.StartsWith(frontPath) == true)
            //{
            //    MemberVO m = sHelper.Member;

            //    if (m == null)
            //    {
            //        log.Debug("front not login");
            //        application.Response.Redirect("~/content/login.aspx");
            //        return;
            //    }
            //}
        }
 /// <summary>
 /// 在线学习-结业考试提交
 /// </summary>
 /// <returns></returns>
 public ActionResult LearnOnLineRefashSession()
 {
     SessionHelper sess = new SessionHelper();
     if (sess.GetSession("LearnOnLineExam") == null)
     {
         sess.SetSession("LearnOnLineExam", DateTime.Now);
         return Json(new { Result = false, Msg = "缓存不存在!" }, JsonRequestBehavior.AllowGet);
     }
     else
     {
         sess.SetSession("LearnOnLineExam", sess.GetSession("LearnOnLineExam"));
         return Json(new { Result = true, Msg = "继续!" }, JsonRequestBehavior.AllowGet);
     }
 }
        public ActionResult LearnOnLineExamView(int TrainingId, int UnitContent, int ClassId)
        {
            var iAccountId = Code.SiteCache.Instance.LoginInfo.UserId;

            #region [结业考试]标题,答题规则
            var Model_Course_UnitContent = this.GetCourseUnitContentActivity(TrainingId, UnitContent, ClassId, false);

            SessionHelper sess = new SessionHelper();
            if (sess.GetSession("LearnOnLineExam") == null)
            {
                sess.SetSession("LearnOnLineExam", (DateTime.Now).AddMinutes(Model_Course_UnitContent.TimeLimit.Value));
            }

            #endregion

            #region [结业考试]题目信息

            int iTrainingId = 0;
            int.TryParse(Convert.ToString(Request["TrainingId"]) == "" ? "0" : QueryString.Decrypt(Request["TrainingId"]), out iTrainingId);

            this.GetExamCourseUnitTest(iTrainingId);
            #endregion

            //#region 查询该学员是否完成过[结业考试]
            //var TestResultBll = new Member_CourseContentTestAnswerResultBLL();
            //string strWhere = string.Format(" Delflag = 0 AND UnitContent = {1} AND ClassId = {2} AND AccountId = {3}", UnitContent, ClassId, iAccountId);
            //var bolIsFinished = TestResultBll.GetList(strWhere, "CreateDate").Count > 0;//若数据条数大于0,则完成过[结业考试]
            //#endregion

            //ViewBag.IsFinished = bolIsFinished;
            ViewBag.ExamTimeLimit = Model_Course_UnitContent.TimeLimit == null ? 0 : Model_Course_UnitContent.TimeLimit.Value;

            return View();
        }
        /// <summary>
        /// 在线学习-结业考试提交
        /// </summary>
        /// <returns></returns>
        public ActionResult LearnOnLineExamEdit(List<Member_CourseContentTestAnswerOther> listOther)
        {
            var TestAnswerResultBll = new Member_CourseContentTestAnswerResultBLL();
            var unitBll = new Course_UnitContentBLL();
            var stbSqlWhere = new StringBuilder();
            var strOrderBy = "CreateDate";

            int iTrainingId = 0, iId = 0;

            var Model_ExamAnswerResult = this.GetLearnOnLineExamResult(listOther, out iTrainingId);
            if (Model_ExamAnswerResult == null)
            {
                return Json(new { Result = true, Msg = "试题提交异常!" }, JsonRequestBehavior.AllowGet);
            }

            //若课程已结束禁止操作
            if (this.GetCourseIsOver(Model_ExamAnswerResult.ClassId, iTrainingId, Model_ExamAnswerResult.AccountId))
                return Json(new { Result = true, Msg = "提交失败.当前课程已结束,不能执行该操作!" }, JsonRequestBehavior.AllowGet);
            //查看当前活动是否已打分,若已打分则禁止操作
            if (this.GetActivityScore(Model_ExamAnswerResult.ClassId, iTrainingId, Model_ExamAnswerResult.AccountId, Model_ExamAnswerResult.UnitContent))
                return Json(new { Result = false, Msg = "提交失败.当前活动已打分,不能执行该操作!" }, JsonRequestBehavior.AllowGet);

            //提交时,判断其剩余考试次数
            var model = unitBll.GetModel(Model_ExamAnswerResult.UnitContent, string.Empty);

            stbSqlWhere.AppendFormat(@" UnitContent = {0} and AccountId = {1} and Delflag = 0", Model_ExamAnswerResult.UnitContent, Model_ExamAnswerResult.AccountId);
            var List_Result = TestAnswerResultBll.GetList(stbSqlWhere.ToString(), strOrderBy);
            if (List_Result.Count >= model.TestCnt && model.TestCnt != -1)
            {
                return Json(new { Result = true, Msg = "试题提交失败。你的结业考试 - [ " + model.Title + " ] 剩余答题次数不足!" }, JsonRequestBehavior.AllowGet);
            }

            //提交总分到表 Member_CourseContentTestAnswerResult
            bool bolResult = TestAnswerResultBll.Add(Model_ExamAnswerResult) > 0;
            iId = Model_ExamAnswerResult.Id;

            //提交数据到用户答案表 Member_CourseContentTestAnswer
            if (bolResult)
            {
                bolResult = this.SaveMember_CourseContentTestAnswer(listOther, iId);
            }

            if (bolResult)
            {
                SessionHelper sess = new SessionHelper();
                sess.Remove("LearnOnLineExam");

                int iUnitContent = Model_ExamAnswerResult.UnitContent;
                //更新总进度
                this.UpdateOverallProgress(model.UnitId.Value, Model_ExamAnswerResult.ClassId, iTrainingId, Model_ExamAnswerResult.AccountId, iUnitContent);

                return Json(new { Result = true, Msg = "试题提交成功!" }, JsonRequestBehavior.AllowGet);
            }
            else
            {
                return Json(new { Result = true, Msg = "试题提交失败!" }, JsonRequestBehavior.AllowGet);
            }
        }
        public ActionResult LearnOnLineExamView(int TrainingId, int UnitContent, int ClassId)
        {
            #region [结业考试]标题,答题规则
            var Model_Course_UnitContent = this.GetCourseUnitContentActivity(TrainingId, UnitContent, ClassId, false);

            SessionHelper sess = new SessionHelper();
            if (sess.GetSession("LearnOnLineExam") == null)
            {
                sess.SetSession("LearnOnLineExam", (DateTime.Now).AddMinutes(Model_Course_UnitContent.TimeLimit.Value));
            }

            #endregion

            #region [结业考试]题目信息

            int iTrainingId = 0;
            int.TryParse(Convert.ToString(Request["TrainingId"]) == "" ? "0" : QueryString.Decrypt(Request["TrainingId"]), out iTrainingId);

            this.GetExamCourseUnitTest(iTrainingId);
            #endregion

            ViewBag.ExamTimeLimit = Model_Course_UnitContent.TimeLimit == null ? 0 : Model_Course_UnitContent.TimeLimit.Value;

            return View();
        }