예제 #1
0
 protected AbsResponseQuestion(Question question, List<int> checkIds)
 {
     if (checkIds.Count == 1)
     {
         isOneIdChecked = true;
     }
     QuestionID = question.QuestionID;
     ImageUrl = question.ImageUrl;
     Type = question.QuestionType.Type;
     LabelOrder = question.LabelOrder;
     QuestionTitle = question.QuestionTitle;
     NonChoiceScore = question.RealNoneChoiceScore().RoundTwo();
     var score = question.Answers.Sum(k => {
                 var point = k.RealScore();
                 if (!point.HasValue || point < 0) {
                     point = 0;
                 }
                 return point;
             });
     var calculateScore = (!score.HasValue || score < 0) ? 0 : score;
     ChoiceScore = calculateScore.RoundTwo();
     CheckedUserIds = checkIds;
     InTests = question.Test.UserInTests.FilterInTestsOnAttempSetting();
     InTestDetails = InTests.SelectMany(i => i.UserInTestDetails).Where(i => i.QuestionID == question.QuestionID);
 }
예제 #2
0
        public ResponseQuestionShort(Question question, List<int> checkIds)
            : base(question, checkIds)
        {
            var count = InTestDetails.Count();
            var point = InTestDetails.Sum(i => i.RealNonChoiceScore());
            decimal? averagePoint = decimal.Zero;
            if (count != 0) { averagePoint = point / count; }
            if (checkIds.Count == 0)
            {
                var id = checkIds.FirstOrDefault();
                if (id != 0)
                {
                    var detail = InTestDetails.FirstOrDefault(k => k.UserInTest.UserID == id);
                    if (detail != null)
                    {
                        averagePoint = detail.RealNonChoiceScore() ?? 0;
                    }
                }
            }
            var maxPoint = question.RealNoneChoiceScore().RoundTwo();
            _correctPraction = String.Format("{0:0.00} pt (of {1} pt)", averagePoint, maxPoint);

            if (checkIds.Count == 1)
            {
                var id = checkIds.FirstOrDefault();
                var detail = InTestDetails.FirstOrDefault(i => i.UserInTest.UserID == id);
                if (detail != null)
                {
                    _nonChoiceText = detail.AnswerContent;
                    _userNonScore = detail.RealNonChoiceScore();
                    _userNonScore = _userNonScore.RoundTwo();
                }
            }
        }