예제 #1
0
        public ActionResult ExamResult(int id)
        {
            Exam ex = db.Exams.Where(x => x.Exam_Id == id).SingleOrDefault();

            if (ex != null)
            {
                int               exid    = ex.Exam_Id;
                List <Paper>      lipaper = db.Papers.Where(x => x.exam.Exam_Id == exid).ToList();
                List <PaperScore> lips    = new List <PaperScore>();
                int               usid    = (int)Session["UserId"];
                foreach (Paper p in lipaper)
                {
                    PaperScore ps = db.PaperScores.Where(x => x.Paper_Id == p.Id && x.Student_Id == usid).SingleOrDefault();
                    if (ps != null)
                    {
                        lips.Add(ps);
                    }
                }

                ViewBag.Exam       = ex;
                ViewBag.Papers     = lipaper;
                ViewBag.PaperScore = lips;
            }
            else
            {
            }
            return(View());
        }
예제 #2
0
        public ActionResult GivePaper(FormCollection collection)
        {
            int             id = (int)Session["PaperId"];
            List <Question> qq = new List <Question>();

            foreach (PaperQuestion pq in db.PaperQuestions.Where(x => x.PaperId == id).ToList())
            {
                Question q = db.Questions.Where(x => x.QuestionId == pq.QuestionId).SingleOrDefault();
                if (q != null)
                {
                    qq.Add(q);
                }
            }
            ViewBag.Questions = qq;

            string Submition = "";

            foreach (Question ans in ViewBag.Questions)
            {
                Submition += ans.Description + "$";

                string anss = collection[ans.QuestionId.ToString()];
                Submition += anss + "$";
            }
            PaperScore ps = new PaperScore();

            ps.Student_Id = (int)Session["UserId"];
            ps.Paper_Id   = (int)Session["PaperId"];
            ps.Submition  = Encoding.ASCII.GetBytes(Submition);
            db.PaperScores.Add(ps);
            db.SaveChanges();
            Response.Redirect("/Test/CloseWindow");
            return(View());
        }
예제 #3
0
        public ActionResult ViewResult(int id)
        {
            int        stuid = (int)Session["UserId"];
            PaperScore ps    = db.PaperScores.Where(x => x.Paper_Id == id && x.Student_Id == stuid).SingleOrDefault();
            Paper      p     = db.Papers.Where(x => x.Id == id).SingleOrDefault();

            if (ps != null)
            {
                ViewBag.PaperScore = ps;
                ViewBag.Paper      = p;
            }
            else
            {
                ViewBag.error = "You Have Not Attended This Paper";
            }

            return(View());
        }