Beispiel #1
0
        public ExamResultViewModel EvaluateExam()
        {
            CommitUserResponse();

            OnlineExamAppDBEntities3 dbContext = new OnlineExamAppDBEntities3();
            //UserResponseHeader userResponse = dbContext.UserResponseHeaders.Where(urh => urh.ExamID == _exam.ID).FirstOrDefault();

            ExamResultViewModel            examResult      = new ViewModel.ExamResultViewModel();
            List <QuestionResultViewModel> questionResults = new List <ViewModel.QuestionResultViewModel>();

            bool result = false;

            foreach (ExamDetail examDetail in _exam.ExamDetails)
            {
                List <QuestionAnswer>     questionAnswers     = dbContext.QuestionAnswers.Where(qa => qa.QuestionID == examDetail.QuestionID).ToList <QuestionAnswer>();
                List <UserResponseDetail> userResponseDetails = dbContext.UserResponseDetails.Where(urd => urd.UserResponseHeaderID == _userResponseHeader.ID && urd.QuestionID == examDetail.QuestionID).ToList <UserResponseDetail>();

                foreach (QuestionAnswer questionAnswer in questionAnswers)
                {
                    result = userResponseDetails.Exists(urd => urd.AnswerID == questionAnswer.AnswerID);

                    if (!result)
                    {
                        break;
                    }
                }

                questionResults.Add(new ViewModel.QuestionResultViewModel()
                {
                    Question = examDetail.Question.QuestionText, Result = result
                });
            }

            examResult.UserName = this._candidate.Name;
            examResult.Results  = questionResults;

            return(examResult);
        }
Beispiel #2
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;
        }
Beispiel #3
0
        public ExamResultViewModel EvaluateExam()
        {
            CommitUserResponse();

            OnlineExamAppDBEntities3 dbContext = new OnlineExamAppDBEntities3();
            //UserResponseHeader userResponse = dbContext.UserResponseHeaders.Where(urh => urh.ExamID == _exam.ID).FirstOrDefault();

            ExamResultViewModel examResult = new ViewModel.ExamResultViewModel();
            List<QuestionResultViewModel> questionResults = new List<ViewModel.QuestionResultViewModel>();

            bool result = false;

            foreach(ExamDetail examDetail in _exam.ExamDetails)
            {
                List<QuestionAnswer> questionAnswers = dbContext.QuestionAnswers.Where(qa => qa.QuestionID == examDetail.QuestionID).ToList<QuestionAnswer>();
                List<UserResponseDetail> userResponseDetails = dbContext.UserResponseDetails.Where(urd => urd.UserResponseHeaderID == _userResponseHeader.ID && urd.QuestionID == examDetail.QuestionID).ToList<UserResponseDetail>();

                foreach(QuestionAnswer questionAnswer in questionAnswers)
                {
                    result = userResponseDetails.Exists(urd => urd.AnswerID == questionAnswer.AnswerID);

                    if (!result)
                        break;
                }

                questionResults.Add(new ViewModel.QuestionResultViewModel() { Question = examDetail.Question.QuestionText, Result = result});
            }

            examResult.UserName = this._candidate.Name;
            examResult.Results = questionResults;
            
            return examResult;
        }