Exemplo n.º 1
0
        private void CalculateGrade(EvaluationEntity evaluationToGrade)
        {
            var wizard      = new EvaluationWizard();
            var scoreWizard = new ScoreWizard();

            var evalSpell = new EvaluationResult
            {
                TotalScoreCount    = evaluationToGrade.NumberOfScores,
                DropLowest         = evaluationToGrade.DropLowest,
                DropLowestCount    = evaluationToGrade.NumberToDrop,
                PointValuePerScore = evaluationToGrade.PointsPerScore
            };

            var scores = ScoreInteractor.GetScoresByEvaluationId(evaluationToGrade.Id);

            var scoreSpells = new List <ScoreResult>();

            if (scores.Count > 0)
            {
                foreach (var scoreEntity in scores)
                {
                    scoreSpells.Add(scoreWizard.GetSingleScoreResult(scoreEntity.PointsEarned, scoreEntity.PointsPossible));
                }

                evalSpell.Scores = scoreSpells;

                wizard.Evaluation = evalSpell;

                wizard.UpdateAllGrades();

                evaluationToGrade.PointsEarned          = wizard.Evaluation.PointsEarned;
                evaluationToGrade.CurrentPointsPossible = wizard.Evaluation.PointsPossibleToDate;
                evaluationToGrade.TotalPointsPossible   = wizard.Evaluation.PointsPossibleOverall;
                evaluationToGrade.CurrentPointsGrade    = wizard.Evaluation.GradeToDateRaw;
                evaluationToGrade.FinalPointsGrade      = wizard.Evaluation.GradeOverallRaw;
            }
            else
            {
                var pointsTotal = (evaluationToGrade.NumberOfScores -
                                   evaluationToGrade.NumberToDrop) * evaluationToGrade.PointsPerScore;

                evaluationToGrade.CurrentPointsGrade    = 1;
                evaluationToGrade.FinalPointsGrade      = 0;
                evaluationToGrade.PointsEarned          = 0;
                evaluationToGrade.CurrentPointsPossible = pointsTotal;
                evaluationToGrade.TotalPointsPossible   = pointsTotal;
            }
        }
Exemplo n.º 2
0
        public CourseWhatIfDomainModel CalcWhatIfGrade(IEnumerable <EvaluationDomainModel> whatIfModels)
        {
            var evalSpells = whatIfModels.Select(w => new EvaluationConjureGradeResultModel
            {
                EvaluationId          = w.Id,
                EvaluationName        = w.Name,
                PointsEarned          = w.PointsEarned,
                PointsPossibleOverall = w.TotalPointsPossible,
                WeightAmount          = w.Weight
            }).ToList();

            var evalWizard = new EvaluationWizard();

            foreach (var spell in evalSpells)
            {
                evalWizard.Evaluation = spell;
                evalWizard.UpdateGradeOverAll();
                spell.GradeOverallFriendly = evalWizard.Evaluation.GradeOverallFriendly;
            }

            var courseWizard = new CourseWizard();

            ICourseResult courseSpell = null;

            if (evalSpells.Any(es => es.WeightAmount != 1))
            {
                evalSpells = evalSpells.Select(e => new EvaluationConjureGradeResultModel
                {
                    WeightAmount          = e.WeightAmount,
                    Weighted              = true, PointsEarned = e.PointsEarned,
                    PointsPossibleOverall = e.PointsPossibleOverall,
                    EvaluationId          = e.EvaluationId,
                    EvaluationName        = e.EvaluationName,
                    GradeOverallFriendly  = e.GradeOverallFriendly
                }).ToList();

                courseSpell = new WeightedCourseResult
                {
                    Evaluations = evalSpells.ToList()
                };

                courseWizard.Course = courseSpell;

                courseWizard.UpdateGradeOverall();
                courseWizard.UpdateAllGrades();

                return(new CourseWhatIfDomainModel
                {
                    WhatIfGrade = courseWizard.OverallGradeFriendly,
                    WhatIfEvaluations = evalSpells.Select(e => new EvaluationWhatIfDomainModel
                    {
                        EvaluationId = (Guid)e.EvaluationId,
                        EvaluationName = e.EvaluationName,
                        WhatIfGrade = e.GradeOverallFriendly
                    }).ToList()
                });
            }
            else
            {
                courseSpell = new CourseResult
                {
                    Evaluations = evalSpells.ToList()
                };

                courseWizard.Course = courseSpell;

                courseWizard.UpdateGradeOverall();

                return(new CourseWhatIfDomainModel
                {
                    WhatIfGrade = courseWizard.OverallGradeFriendly,
                    WhatIfEvaluations = evalSpells.Select(e => new EvaluationWhatIfDomainModel
                    {
                        EvaluationId = (Guid)e.EvaluationId,
                        EvaluationName = e.EvaluationName,
                        WhatIfGrade = e.GradeOverallFriendly
                    }).ToList()
                });
            }
        }