Exemplo n.º 1
0
        //private int GetQuestionCount(int QuestionCount)
        //{
        //    QuestionBL topicBL = new QuestionBL();
        //    return topicBL.GetAllQuestion(QuestionCount);
        //}

        //public JsonResult GetNextQuestion(string pageindex,string pagesize, string radioValue,string quesId)
        //{
        //    ExamPaper examPaper = new ExamPaper();
        //    QuestionBL topicBL = new QuestionBL();
        //    if (radioValue != null)
        //    {
        //        if(! String.IsNullOrEmpty(quesId))
        //            if(int.Parse(quesId) > 0 && !String.IsNullOrEmpty(radioValue))
        //        topicBL.SaveUserAnswer(int.Parse(radioValue), int.Parse(quesId), int.Parse(Session["UserId"].ToString()));
        //    }

        //    int questionCount = int.Parse(ConfigurationManager.AppSettings["QuestionCount"].ToString());

        //    examPaper = topicBL.GetNextPrevQuestion(int.Parse(pageindex), int.Parse(pagesize), int.Parse(Session["UserId"].ToString()));
        //    examPaper.QuestionEntities = examPaper.QuestionEntities.OrderBy(o => o.Id).ToList();

        //    return Json(examPaper, JsonRequestBehavior.AllowGet);

        //}

        public ExamPaper GetQuestion(string pageindex, string pagesize, string radioValue, string quesId, string currentTime)
        {
            ExamPaper  examPaper = new ExamPaper();
            QuestionBL topicBL   = new QuestionBL();

            if (radioValue != null && radioValue != String.Empty)
            {
                if (!String.IsNullOrEmpty(quesId))
                {
                    if (int.Parse(quesId) > 0 && !String.IsNullOrEmpty(radioValue))
                    {
                        topicBL.SaveUserAnswer(int.Parse(radioValue), int.Parse(quesId), int.Parse(Session["UserId"].ToString()), currentTime);
                    }
                }
            }
            else
            {
                ExamBL examBL = new ExamBL();
                examBL.UpdateExamTime(int.Parse(Session["UserId"].ToString()), currentTime);
            }

            int questionCount = int.Parse(ConfigurationManager.AppSettings["QuestionCount"].ToString());

            examPaper = topicBL.GetNextPrevQuestion(int.Parse(pageindex), int.Parse(pagesize), int.Parse(Session["UserId"].ToString()));
            examPaper.QuestionEntities = examPaper.QuestionEntities.OrderBy(o => o.Id).ToList();


            return(examPaper);
        }