Ejemplo n.º 1
0
        public static decimal GetOwnRatingForCategory(
            this IEnumerable<ReviewFeedback> reviewFeedbacks, int userId, ReviewCategory category)
        {
            if (reviewFeedbacks == null) throw new ArgumentNullException("reviewFeedbacks");

            var assessment = reviewFeedbacks.SelectMany(fb => fb.Assessments)
                .Where(a => a.ReviewCategory.Id == category.Id)
                .SingleOrDefault(a => a.ReviewedPeer.Id == userId && a.Reviewer.Id == userId);

            return assessment != null ? assessment.Rating : 0;
        }
Ejemplo n.º 2
0
        public static decimal GetPeerRatingForPeerForCategory(
            this IEnumerable<ReviewFeedback> reviewFeedbacks, int peerId, ReviewCategory category)
        {
            if (reviewFeedbacks == null) throw new ArgumentNullException("reviewFeedbacks");

            var otherReviewersCount = reviewFeedbacks.Count(fb => fb.Reviewer.Id != peerId);
            return otherReviewersCount > 0
                       ? reviewFeedbacks.SelectMany(fb => fb.Assessments)
                             .Where(a => a.ReviewCategory.Id == category.Id)
                             .Where(a => a.ReviewedPeer.Id == peerId && a.Reviewer.Id != peerId)
                             .Sum(a => a.Rating)/(decimal) otherReviewersCount
                       : 0;
        }
Ejemplo n.º 3
0
        public static decimal GetOwnRatingForCategory(
            this IEnumerable <ReviewFeedback> reviewFeedbacks, int userId, ReviewCategory category)
        {
            if (reviewFeedbacks == null)
            {
                throw new ArgumentNullException("reviewFeedbacks");
            }

            var assessment = reviewFeedbacks.SelectMany(fb => fb.Assessments)
                             .Where(a => a.ReviewCategory.Id == category.Id)
                             .SingleOrDefault(a => a.ReviewedPeer.Id == userId && a.Reviewer.Id == userId);

            return(assessment != null ? assessment.Rating : 0);
        }
Ejemplo n.º 4
0
        public static decimal GetPeerRatingForPeerForCategory(
            this IEnumerable <ReviewFeedback> reviewFeedbacks, int peerId, ReviewCategory category)
        {
            if (reviewFeedbacks == null)
            {
                throw new ArgumentNullException("reviewFeedbacks");
            }

            var otherReviewersCount = reviewFeedbacks.Count(fb => fb.Reviewer.Id != peerId);

            return(otherReviewersCount > 0
                                       ? reviewFeedbacks.SelectMany(fb => fb.Assessments)
                   .Where(a => a.ReviewCategory.Id == category.Id)
                   .Where(a => a.ReviewedPeer.Id == peerId && a.Reviewer.Id != peerId)
                   .Sum(a => a.Rating) / (decimal)otherReviewersCount
                                       : 0);
        }
Ejemplo n.º 5
0
 private static ReportDataRow TeamRatingsOverTime(IEnumerable<ReviewRound> reviewRounds, UserProfile ratedUser,
     ReviewCategory category)
 {
     var title = ratedUser != null ? ratedUser.UserName + " (by team)" : "team (by team)";
     return CreateReportDataRow(reviewRounds, ratedUser, category, title, false);
 }
Ejemplo n.º 6
0
 private static ReportDataRow OwnRatingsOverTime(IEnumerable<ReviewRound> reviewRounds, UserProfile ratedUser,
     ReviewCategory category)
 {
     var title = string.Format("{0} (by {0})", ratedUser.UserName);
     return CreateReportDataRow(reviewRounds, ratedUser, category, title, true);
 }
Ejemplo n.º 7
0
        private static ReportDataRow CreateReportDataRow(IEnumerable<ReviewRound> reviewRounds, UserProfile ratedUser, 
            ReviewCategory category, string title, bool onlyOwnRatings)
        {
            return new ReportDataRow
                       {
                           Title = title,
                           Values = reviewRounds
                               .Select(round => {
                                   var assessments = round.Feedback.SelectMany(feedback => feedback.Assessments)
                                       .Where(ass => ass.ReviewCategory == category)
                                       .Where(ass => onlyOwnRatings ? ass.ReviewedPeer == ratedUser : (ratedUser == null || ass.ReviewedPeer == ratedUser))
                                       .Where(ass => !onlyOwnRatings || ass.Reviewer == ratedUser)
                                       .ToList();

                                   return Convert.ToDecimal(assessments.Any()
                                                                ? assessments.Average(ass => ass.Rating)
                                                                : 0);
                               }).ToList()
                       };
        }
Ejemplo n.º 8
0
 private static Report CreateReport(string title, ReviewConfiguration review, ReviewCategory category)
 {
     return new Report {
         CategoryCount = 1,
         Title = title,
         ReviewName = review.Name,
         Description = category.Description,
         XAxisLabels = review.ReviewRoundsInOrder.Select(round => round.StartDate.ToShortDateString()).ToList()
     };
 }