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); }
private static SingleChoiceFieldBase[] GetSingleChoiceFields(ApplicationFormContext applicationFormContext) { return(applicationFormContext .Configuration .Experiences[0] .Navigation .Steps .SelectMany(s => s.Sections) .SelectMany(s => s.Fields) .OfType <SingleChoiceFieldBase>() .ToArray()); }
public ScoringResult CalculateOutcome(ApplicationFormContext applicationFormContext) { var scoringPoints = this.scoringPointsCalculator.CalculatePoints(applicationFormContext); var scoringResult = new ScoringResult { Points = scoringPoints.Points, PointsOutline = scoringPoints.PointsOutline }; return(CalculateOutcome(scoringResult)); }
private IScoringOutcomeMethod GetScoringOutcomeMethod(ApplicationFormContext applicationFormContext) { return(this.scoringOutcomeMethodFactory.Get(applicationFormContext.Configuration)); }
private ScoringResult CalculateApplicationScoringResult(ApplicationFormContext applicationFormContext) { return(GetScoringOutcomeMethod(applicationFormContext).CalculateOutcome(applicationFormContext)); }
public void Execute(ApplicationFormContext applicationFormContext) { applicationFormContext.Application.ScoringResult = CalculateApplicationScoringResult(applicationFormContext); applicationFormContext.Application.State = ApplicationState.Submitted; }