ActivEarth.Server.Service.Competition.ChallengeManager.GetFormattedProgress C# (CSharp) Method

GetFormattedProgress() public static method

Returns the formatted text progress report for the Challenge (e.g., "34.5 / 40.0").
public static GetFormattedProgress ( int challengeId, int userId ) : string
challengeId int Challenge to report progress for.
userId int User to evaluate.
return string
        public static string GetFormattedProgress(int challengeId, int userId)
        {
            Challenge challenge = ChallengeDAO.GetChallengeFromChallengeId(challengeId);

            float initial = ChallengeDAO.GetInitializationValue(challengeId, userId);
            UserStatistic statistic = UserStatisticDAO.GetStatisticFromUserIdAndStatType(userId, challenge.StatisticBinding);

            string numerator = (statistic != null ? Math.Min(challenge.Requirement, statistic.Value - initial) : 0).ToString(challenge.FormatString);
            string denominator = challenge.Requirement.ToString(challenge.FormatString);

            return String.Format("{0} / {1}", numerator, denominator);
        }