Esempio n. 1
0
        public ExamResultViewModel EvaluateExam()
        {
            ExamResultViewModel examResult = new ExamResultViewModel();

            QuestionAnswers questionAnswers;
            ExamEvaluator   examEvaluator = new ExamEvaluator();
            QuestionResult  questionResult;
            List <QuestionResultViewModel> questionResultList = new List <QuestionResultViewModel>();

            foreach (UserResponse userResponse in _examResponse)
            {
                questionAnswers = _questionAnswers.First(qa => qa.Question.ID == userResponse.QuestionID);

                examEvaluator.QuestionAnswers = questionAnswers;
                examEvaluator.UserResponse    = userResponse;

                questionResult = examEvaluator.Evaluate();
                questionResultList.Add(new QuestionResultViewModel()
                {
                    Question = questionResult.Question.Text, Result = questionResult.Result
                });
            }

            examResult.Results = questionResultList;

            return(examResult);
        }
Esempio n. 2
0
        public ActionResult EvaluateExam()
        {
            ExamManager         examManager = Session["ExamManager"] as ExamManager;
            ExamResultViewModel examResult  = examManager.EvaluateExam();

            return(View(examResult));
        }
Esempio n. 3
0
        private void cboExamCode_SelectedIndexChanged(object sender, EventArgs e)
        {
            if (cboExamCode.SelectedIndex > -1)
            {
                examResultViewModel = _examResultViewModelList.Where(ex => ex.ExamCode == cboExamCode.Text).Single();

                _examineeTakeId = examResultViewModel.ExamineeTakeId;

                if (examResultViewModel.Result == "PASSED")
                {
                    lblResult.BackColor = Color.FromArgb(92, 184, 92);
                    lblResult.ForeColor = Color.White;
                }
                else
                {
                    lblResult.BackColor = Color.LightCoral;
                    lblResult.ForeColor = Color.White;
                }

                lblResult.Text      = examResultViewModel.Result;
                lblPassingRate.Text = string.Format("Passing Rate: {0} % of items", examResultViewModel.PassingRate);


                lblDateTimeIssued.Text = string.Format("Issued On: {0}", examResultViewModel.CodeDateTimeIssued.Value);
                lblIssuedBy.Text       = string.Format("Issued By: {0}", examResultViewModel.IssuedBy);
                lblExamDateTime.Text   = string.Format("Exam Taken On: {0}", examResultViewModel.ExamDateTimeTaken.Value);

                dgvSubjResult.DataSource = null;
                dgvSubjResult.DataSource = examResultViewModel.ExamSubjectResult;
            }
        }
Esempio n. 4
0
        public IActionResult AskQuestion(bool isRightAnswer = false)
        {
            ExamInProgressViewModel currentExam = this.HttpContext.Session.GetObject <ExamInProgressViewModel>("exam");

            if (currentExam.Words.Count == 0)
            {
                ExamResultViewModel resultModel = this.mapper.Map <ExamResultViewModel>(currentExam);
                return(this.RedirectToAction("Result", resultModel));
            }

            if (isRightAnswer)
            {
                currentExam.RightAnswers += 1;
            }

            currentExam.CurrentQuestion = currentExam.Words.Pop();

            currentExam.CurrentQuestionSequelNumber += 1;

            ExamAnswerViewModel model = this.mapper.Map <ExamAnswerViewModel>(currentExam);


            this.HttpContext.Session.SetObject("exam", currentExam);

            return(this.View(model));
        }
Esempio n. 5
0
        public ActionResult EvaluateExam()
        {
            ExamManagerEF       examManagerEF = examUtil.GetExamManager();
            ExamResultViewModel examResult    = examManagerEF.EvaluateExam();

            return(View(examResult));
        }
Esempio n. 6
0
        public async Task <IActionResult> Result(ExamResultViewModel model)
        {
            Exam exam = this.mapper.Map <Exam>(model);

            await this.examService.Add(exam);

            return(this.View(model));
        }
Esempio n. 7
0
        public ActionResult AddExamResult(IEnumerable <ExamQuestionResult> ExamQuestionResult, string MEID, List <ExamQuestionDetail> ExamQuestionDetail)
        {
            string QuestionCorrectAns = "";
            int    DencrptedMEID      = Convert.ToInt32(_encryptionService.DecryptString2(MEID));
            ExamResultViewModel ExamResultViewModel = new ExamResultViewModel();

            ExamResultViewModel.ExamResult             = Mapper.Map <IEnumerable <ExamResult> >(_examInternalService.GetExamAttempResulttByUser(HCRGUser.UID, Convert.ToInt32(DencrptedMEID)));
            ExamResultViewModel.FinalExamAttemptByUser = ExamResultViewModel.ExamResult.Count();
            if (ExamResultViewModel.FinalExamAttemptByUser < 3)
            {
                ExamResult ExamResult = new Domain.Models.ExamModel.ExamResult();
                ExamResult.UID    = HCRGUser.UID;
                ExamResult.MEID   = DencrptedMEID;
                ExamResult.ExamID = ExamQuestionDetail.ElementAt(0).ExamID;
                int correctAnsCount = 0;
                int ExamResultID    = _examInternalService.AddExamResult(Mapper.Map <HCRGUniversityApp.NEPService.ExamInternalService.ExamResult>(ExamResult));
                foreach (ExamQuestionResult eQuestionResult in ExamQuestionResult)
                {
                    eQuestionResult.ExamResultID = ExamResultID;
                    if (eQuestionResult.ExamAnswerType == GlobalConst.ExamAnswerType.MultipleChoice || eQuestionResult.ExamAnswerType == null)
                    {
                        eQuestionResult.ExamAnswerTrueFalse = null;
                        QuestionCorrectAns = (from ExamQuestion in ExamQuestionDetail
                                              where
                                              ExamQuestion.ExamQuestionID == eQuestionResult.ExamQuestionID
                                              select ExamQuestion.ExamAnswer).First().ToString();
                        if (eQuestionResult.ExamAnswer == QuestionCorrectAns)
                        {
                            correctAnsCount = correctAnsCount + 1;
                        }
                    }
                    else
                    {
                        eQuestionResult.ExamAnswer = null;
                        QuestionCorrectAns         = (from ExamQuestion in ExamQuestionDetail
                                                      where
                                                      ExamQuestion.ExamQuestionID == eQuestionResult.ExamQuestionID
                                                      select ExamQuestion.ExamAnswerTrueFalse).First().ToString();
                        if (eQuestionResult.ExamAnswerTrueFalse == Convert.ToBoolean(QuestionCorrectAns))
                        {
                            correctAnsCount = correctAnsCount + 1;
                        }
                    }
                    int ExamQuestionResultID = _examInternalService.AddExamQuestionResults(Mapper.Map <HCRGUniversityApp.NEPService.ExamInternalService.ExamQuestionResult>(eQuestionResult));
                }
                ExamResultViewModel.TotalPercentage          = correctAnsCount * 100 / ExamQuestionResult.Count();
                ExamResultViewModel.encryptedTotalPercentage = _encryptionService.EncryptString2(ExamResultViewModel.TotalPercentage.ToString());
                if (ExamResultViewModel.TotalPercentage >= 70)
                {
                    _examInternalService.UpdateExamResultIsPass(ExamResultID, DencrptedMEID, true);
                }
                else
                {
                    _examInternalService.UpdateExamResultIsPass(ExamResultID, DencrptedMEID, false);
                }
            }
            return(Json(ExamResultViewModel, GlobalConst.Message.text_html));
        }
        public IActionResult Add(Guid courseUID, Guid examUID)
        {
            ViewBagMethod();
            var list = _courseRegistrationService.GetAllStudentList(courseUID, "StudentU.PersonU");
            List <ExamResultViewModel> examResultViewModels = new List <ExamResultViewModel>();

            foreach (var item in list)
            {
                ExamResultViewModel model = new ExamResultViewModel();
                model.ExamUID        = examUID;
                model.PersonName     = item.StudentU.PersonU.FirstName;
                model.PersonLastName = item.StudentU.PersonU.LastName;
                model.PersonUID      = item.StudentUid ?? Guid.Empty;
                examResultViewModels.Add(model);
            }
            TempData["ExamUID"] = examUID;
            return(View(examResultViewModels));
        }
Esempio n. 9
0
        public ExamResultViewModel PostTest(List <QuestionViewModel> answerSheet)
        {
            ExamResultViewModel examResultViewModel = new ExamResultViewModel();

            List <ResultKnowledgeAreaViewModel> resultKnowledgeAreaViewModellist = new List <ResultKnowledgeAreaViewModel>();

            foreach (QuestionViewModel qvmodel in answerSheet)
            {
                var question = QuizAPI.Repository.QuestionRepository.GetQuestion(qvmodel.QuestionId);

                qvmodel.CorrectAnswer = question.CorrectAnswerIndex;


                if (qvmodel.UserAnswer.Trim() == "")
                {
                    qvmodel.isCorrect = "S";
                }
                else
                {
                    if (qvmodel.UserAnswer.Trim() == qvmodel.CorrectAnswer.Trim())
                    {
                        qvmodel.isCorrect = "Y";
                    }
                    else
                    {
                        qvmodel.isCorrect = "N";
                    }
                }
            }



            var knowledgeare = answerSheet.Select(u => u.AreaofKnowledge).Distinct();

            foreach (var knw in knowledgeare)
            {
                ResultKnowledgeAreaViewModel rsk = new ResultKnowledgeAreaViewModel();

                rsk.KnowledgeAreaName = knw;

                List <QuestionViewModel> qst = answerSheet.Where(u => u.AreaofKnowledge == knw).ToList();

                int totalqstn   = qst.Count();
                int correctqstn = qst.Where(u => u.isCorrect == "Y").Count();
                int wrongqstn   = qst.Where(u => u.isCorrect == "N").Count();
                int skippedqstn = qst.Where(u => u.isCorrect == "S").Count();


                rsk.QuestionsAsked   = totalqstn;
                rsk.QuestionsCorrect = correctqstn;
                rsk.QuestionsWrong   = wrongqstn;
                rsk.QuestionsSkipped = skippedqstn;

                resultKnowledgeAreaViewModellist.Add(rsk);
            }

            examResultViewModel.QuestionViewModels            = answerSheet;
            examResultViewModel.ResultKnowledgeAreaViewModels = resultKnowledgeAreaViewModellist;



            return(examResultViewModel);
        }