Beispiel #1
0
        public ActionResult AttemptReport(int activityId, int attempt)
        {
            try
            {
                TblUser        sessionUser = (TblUser)Session["UserSession"];
                List <TblQuiz> lstAllQuiz  = new List <TblQuiz>();
                lstAllQuiz = quizRepository.GetQuizForLaunch(activityId, sessionUser.UserId);
                //var attempt = quizRepository.GetQuizAttemptByUserID(activityId, sessionUser.UserId);
                List <TblRespons> quizResponses = new List <TblRespons>();
                quizResponses = quizRepository.GetQuizResponsesByUserID(activityId, sessionUser.UserId, attempt);
                lstAllQuiz[0].TblResponses = quizResponses;

                var noOfQuestions = lstAllQuiz[0].TblQuestions.Where(x => x.QuestionTypeId == 1 || x.QuestionTypeId == 2).Count();
                var score         = quizRepository.GetQuizScoreByUserID(activityId, sessionUser.UserId, attempt);
                //lstAllQuiz[0].Score = Convert.ToInt32(score.Score);
                if (score.Score == 0)
                {
                    lstAllQuiz[0].Score = "0%";
                }
                else
                {
                    lstAllQuiz[0].Score = Convert.ToString(Math.Round(Convert.ToDecimal(score.Score * 100 / noOfQuestions), 2));
                }
                lstAllQuiz[0].completeTime = score.completedTime;

                JavaScriptSerializer json_serializer = new JavaScriptSerializer();
                json_serializer.MaxJsonLength = int.MaxValue;
                lstAllQuiz[0].hdnReviewData   = json_serializer.Serialize(lstAllQuiz[0]);
                //var attemptList = rpt.GetDetailReportForLearner(sessionUser.UserId, sessionUser.TenantId, activityId);
                return(View("AttemptReport", lstAllQuiz[0]));
            }
            catch (Exception ex)
            {
                newException.AddException(ex);
                return(View("AttemptReport"));
            }
        }
Beispiel #2
0
        public ActionResult ReviewQuiz(int QuizId)
        {
            bool isPlek = false;

            try
            {
                //newException.AddDummyException("In - 1 ");

                TblUser sessionUser = (TblUser)Session["UserSession"];
                if (sessionUser == null)
                {
                    //newException.AddDummyException("In - 444 ");
                    CommonFunctions common   = new CommonFunctions();
                    var             password = common.GetEncodePassword("123456");
                    sessionUser            = ur.IsValidUser("*****@*****.**", password, Request.Url.Host);
                    Session["UserSession"] = sessionUser;
                    isPlek = true;
                }
                if (sessionUser.TenantId == 9)
                {
                    CommonFunctions common   = new CommonFunctions();
                    var             password = common.GetEncodePassword("123456");
                    sessionUser            = ur.IsValidUser("*****@*****.**", password, Request.Url.Host);
                    Session["UserSession"] = sessionUser;
                    isPlek = true;
                }
                if (sessionUser.TenantId == 6)
                {
                    isPlek = true;
                }
                List <TblQuiz> lstAllQuiz = new List <TblQuiz>();
                lstAllQuiz = quizRepository.GetQuizForLaunch(QuizId, sessionUser.UserId);
                var attempt = quizRepository.GetQuizAttemptByUserID(QuizId, sessionUser.UserId);
                List <TblRespons> quizResponses = new List <TblRespons>();
                quizResponses = quizRepository.GetQuizResponsesByUserID(QuizId, sessionUser.UserId, attempt);
                lstAllQuiz[0].TblResponses = quizResponses;

                var noOfQuestions = lstAllQuiz[0].TblQuestions.Where(x => x.QuestionTypeId == 1 || x.QuestionTypeId == 2).Count();
                //newException.AddDummyException("In - noOfQuestions " + noOfQuestions);
                var score = quizRepository.GetQuizScoreByUserID(QuizId, sessionUser.UserId, attempt);

                //newException.AddDummyException("In - Score " + score.Score);
                if (score.Score == 0)
                {
                    lstAllQuiz[0].Score = "0";
                }
                else
                {
                    lstAllQuiz[0].Score = Convert.ToString(Math.Round(Convert.ToDecimal(score.Score * 100 / noOfQuestions), 2));
                }
                //newException.AddDummyException("In - 6 ");
                JavaScriptSerializer json_serializer = new JavaScriptSerializer();
                json_serializer.MaxJsonLength = int.MaxValue;
                lstAllQuiz[0].hdnReviewData   = json_serializer.Serialize(lstAllQuiz[0]);
                //newException.AddDummyException("In - 7 ");
                if (isPlek)
                {
                    //newException.AddDummyException("In - PLEK ");
                    return(View("ReviewQuizLearnerForPlek", lstAllQuiz[0]));
                }
                else
                {
                    //newException.AddDummyException("Out - PLEK ");
                    return(View("ReviewQuizLearner", lstAllQuiz[0]));
                }
            }
            catch (Exception ex)
            {
                newException.AddDummyException(ex.ToString());
                if (isPlek)
                {
                    return(View("ReviewQuizLearnerForPlek", null));
                }
                else
                {
                    return(View("ReviewQuizLearner", null));
                }
            }
        }