using Core.Entities; using Core.Models; using Core.Validation.Rules.BaseRules; namespace Core.Validation.Rules.StudentAssignmentRules; /// /// Validation rule that checks if a student has too few event assignments /// public class TooFewEventsRule : EventCountThresholdRuleBase { protected override int GetCount(StudentEventStatistics statistics) => statistics.EventCount; protected override int GetThreshold(ValidationConfiguration config) => config.MinRecommendedEvents; protected override bool ViolatesThreshold(int count, int threshold) => count < threshold; protected override ValidationSeverity GetBaseSeverity(ValidationConfiguration config) => config.EventCountSeverity; protected override int? GetCriticalThreshold(ValidationConfiguration config) => config.MinCriticalEvents; protected override bool ViolatesCriticalThreshold(int count, int criticalThreshold) => count < criticalThreshold; protected override string Code => "TOO_FEW_EVENTS"; protected override string GetMessage(int count, int threshold) => $"Student has {count} events (min recommended: {threshold})"; protected override Dictionary BuildAdditionalMetadata(StudentEventStatistics statistics, ValidationConfiguration config) { return new Dictionary { { "MinRecommended", config.MinRecommendedEvents }, { "MinCritical", config.MinCriticalEvents } }; } }