Exemple #1
0
        public ScoringPoints CalculatePoints(ApplicationFormContext applicationFormContext)
        {
            var dropDownListFields = GetSingleChoiceFields(applicationFormContext);

            fieldMappingOrchestrator.MapToFields(applicationFormContext.Application, dropDownListFields);

            var scoringPoints = new ScoringPoints();

            foreach (var field in dropDownListFields)
            {
                var availableValue = field.AvailableValues.SingleOrDefault(v => v.Value == field.Value);

                if (availableValue == null)
                {
                    Logger.Current.LogDebug <DefaultScoringOutcomeMethod>($"The field '{field.Alias}' does not have a selected value.");
                    continue;
                }

                scoringPoints.PointsOutline.Add(new ScoringPointsOutlineItem
                {
                    FieldAlias = field.Alias,
                    FieldLabel = field.Label,
                    FieldText  = availableValue.Text,
                    Score      = availableValue.Score
                });
            }

            scoringPoints.Points = scoringPoints.PointsOutline.Sum(i => i.Score);

            return(scoringPoints);
        }
Exemple #2
0
 private static SingleChoiceFieldBase[] GetSingleChoiceFields(ApplicationFormContext applicationFormContext)
 {
     return(applicationFormContext
            .Configuration
            .Experiences[0]
            .Navigation
            .Steps
            .SelectMany(s => s.Sections)
            .SelectMany(s => s.Fields)
            .OfType <SingleChoiceFieldBase>()
            .ToArray());
 }
Exemple #3
0
        public ScoringResult CalculateOutcome(ApplicationFormContext applicationFormContext)
        {
            var scoringPoints = this.scoringPointsCalculator.CalculatePoints(applicationFormContext);

            var scoringResult = new ScoringResult
            {
                Points        = scoringPoints.Points,
                PointsOutline = scoringPoints.PointsOutline
            };

            return(CalculateOutcome(scoringResult));
        }
Exemple #4
0
 private IScoringOutcomeMethod GetScoringOutcomeMethod(ApplicationFormContext applicationFormContext)
 {
     return(this.scoringOutcomeMethodFactory.Get(applicationFormContext.Configuration));
 }
Exemple #5
0
 private ScoringResult CalculateApplicationScoringResult(ApplicationFormContext applicationFormContext)
 {
     return(GetScoringOutcomeMethod(applicationFormContext).CalculateOutcome(applicationFormContext));
 }
Exemple #6
0
 public void Execute(ApplicationFormContext applicationFormContext)
 {
     applicationFormContext.Application.ScoringResult = CalculateApplicationScoringResult(applicationFormContext);
     applicationFormContext.Application.State         = ApplicationState.Submitted;
 }