Example #1
0
        public CoreScoreAnswer GetLattestCoreScore(long userId)
        {
            QuestionnaireAnswers lattestSummaries = QuestionnaireAnswersRepository.GetAsQueryable <QuestionnaireAnswers>().LastOrDefault(q => q.UserId == userId);

            //var calculationAlgorithm = new QuestionnaireCalculationAlgorithmWeek3();
            //if (lattestSummaries != null)
            //    return calculationAlgorithm.GetLocalizedCoreScore(Constants.DEFAULT_QUESTIONNAIRE_LOCALE, lattestSummaries.CoreScore);
            return(QuestionnaireCalculationAlgorithmBase.GetNullCoreScore());
        }
Example #2
0
        public CoreScoreAnswer GetAverageCoreScoreForPeriod(int userId, int period, DateTime currentTime, string locale)
        {
            IEnumerable <QuestionnaireAnswers> lattestSummaries = GetQuestionnaireAnswers(userId, period, currentTime);

            IList <QuestionnaireAnswers> questionnaireAnswerses = lattestSummaries as IList <QuestionnaireAnswers> ??
                                                                  lattestSummaries.ToList();

            if (questionnaireAnswerses.Any())
            {
                var averageCoreScores = (int)Math.Round(((float)questionnaireAnswerses.Sum(c => c.CoreScore) / questionnaireAnswerses.Count()));
                return(QuestionnaireCalculationAlgorithmBase.GetLocalizedCoreScore(locale, (byte)averageCoreScores));
            }
            return(QuestionnaireCalculationAlgorithmBase.GetNullCoreScore());
        }