예제 #1
0
        public ActionResult Questions(string SubjectName)
        {
            string UserName = Session["user"].ToString();

            blayer_ob.SetStatusToZero(UserName);
            int crt   = 0;
            int tques = Convert.ToInt32(Request["tques"]);

            string[]         a               = new string[tques];
            string[]         b               = new string[tques];
            List <Questions> correctanswer   = new List <Questions>();
            List <Questions> questiondispaly = new List <Questions>();

            for (int j = 1; j <= tques - 1; j++)
            {
                a[j - 1] = Request["arr" + j];
                b[j - 1] = Request["crt" + j];

                Questions q = new Questions()
                {
                    option1 = a[j - 1],
                    option2 = b[j - 1]
                };
                correctanswer.Add(q);

                Questions quesdis = new Questions()
                {
                    question = Request["que" + j],
                    option1  = Request["que1" + j],
                    option2  = Request["que2" + j],
                    option3  = Request["que3" + j],
                    option4  = Request["que4" + j]
                };
                questiondispaly.Add(quesdis);
            }
            ViewBag.correctanswers  = correctanswer;
            ViewBag.questiondisplay = questiondispaly;
            for (int k = 1; k <= tques - 1; k++)
            {
                if (a[k - 1] == b[k - 1])
                {
                    crt++;
                }
            }
            ViewBag.correct    = crt;
            ViewBag.wrong      = tques - crt - 1;
            ViewBag.percentage = ((100 / (tques - 1)) * crt);
            float  Percentage = ViewBag.percentage;
            string Status;

            if (Percentage > 40)
            {
                Status = "Pass";
            }
            else
            {
                Status = "Fail";
            }
            blayer_ob.UpdateReportsTable(UserName, DateTime.Now, SubjectName, crt, Percentage, Status);
            return(View());
        }