예제 #1
0
 public ScoreUserItemStatistic(Tag tag, UserInTest inTest, decimal? totalScore)
 {
     Name = tag.TagName;
     var details = inTest.UserInTestDetails.Where(i =>
     {
         var tagIds = i.Question.TagInQuestions.Select(k => k.Tag.TagID);
         return tagIds.Contains(tag.TagID);
     });
     var score = details.Sum(i => i.RealScore() ?? 0 + i.RealNonChoiceScore() ?? 0);
     decimal percent = 0;
     if (totalScore.HasValue)
     {
         percent = score / totalScore.Value;
     }
     Percent = percent;
 }
예제 #2
0
 public JsonResult SubmitTest(UserInTest userInTest)
 {
     var common = new CommonService();
     common.SubmitTest(userInTest);
     return Json(new { common.success, common.message });
 }
예제 #3
0
        public ScoreUserItem(List<Tag> tags, UserInTest inTest, decimal? totalScoreOfTest)
        {
            UserLabel = !string.IsNullOrEmpty(inTest.User.Name) ? inTest.User.Name : inTest.User.UserMail;
            decimal? percent = 0;
            if (totalScoreOfTest!=0&&totalScoreOfTest.HasValue) {
               percent= (decimal)inTest.Score / totalScoreOfTest;
            }

            if (inTest.Score == 0)
            {
                UserDecimalPercent = null;
            }
            else {
                UserDecimalPercent = percent;
            }

            UserPercent = (percent).ToPercent();
            UserID = inTest.User.UserID;
            User = inTest.User;
            Overall = new ScoreUserItemStatistic() { Name = "Overall Score", Percent = percent.RoundTwo() ?? 0 };
            Statistics = new List<ScoreUserItemStatistic>();
            tags.ForEach(i =>
            {
                var item = new ScoreUserItemStatistic(i, inTest, totalScoreOfTest);
                Statistics.Add(item);
            });
            Test = inTest.Test;
        }