Пример #1
0
        public ActionResult Attend(int id = 0)
        {
            if (id == 0 || !Permission.LoginedNeed(Request, Response, Session))
            {
                return(null);
            }

            Exam exam = ExamView.GetExamById(id);

            if (exam == null || DateTime.Now < exam.start_date || DateTime.Now > exam.end_date)
            {
                Permission.BackToPrevPageOrIndex(Request, Response);
                return(null);
            }

            User             user       = (User)Session["user"];
            List <int>       userGroups = GroupView.GetGroupMemberByUID(user.uid).Select(gm => (int)gm.gid).ToList();
            IQueryable <int> examGroups = ExamView.GetAllGroupsByExam(exam.eid).Select(e => e.gid);
            List <int>       gids       = userGroups.Intersect(examGroups).ToList();

            if ((exam._public == false && gids.Count() == 0) || ResultView.GetResult(id, user.uid) != null)
            {
                Permission.BackToPrevPageOrIndex(Request, Response);
                return(null);
            }

            ViewBag.exam      = exam;
            ViewBag.questions = FileOperation.ReadFile(exam.exam_path);

            return(View());
        }