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 many regional events in their assignments
///
public class TooManyRegionalEventsAssignmentRule : EventCountThresholdRuleBase
{
protected override int GetCount(StudentEventStatistics statistics) =>
statistics.Events.Count(e => e.RegionalEvent);
protected override int GetThreshold(ValidationConfiguration config) => config.MaxRegionalEvents;
protected override bool ViolatesThreshold(int count, int threshold) => count > threshold;
protected override ValidationSeverity GetBaseSeverity(ValidationConfiguration config) =>
config.TooManyRegionalEventsSeverity;
protected override string Code => "TOO_MANY_REGIONAL_EVENTS";
protected override string GetMessage(int count, int threshold) =>
$"Student has {count} regional events (max recommended: {threshold})";
protected override string? IconIdentifier => "RegionalEvent";
protected override Dictionary BuildAdditionalMetadata(StudentEventStatistics statistics, ValidationConfiguration config)
{
return new Dictionary
{
{ "RegionalEventCount", GetCount(statistics) },
{ "MaxRegionalEvents", config.MaxRegionalEvents }
};
}
}