Files
chapter-organizer/Core/Validation/Rules/StudentAssignmentRules/TooManyRegionalEventsAssignmentRule.cs
T
poprhythm 45edcf5e5f Refactor event assignment structure and introduce new models for assignment parameters and requirements
This commit removes the obsolete EventAssignment class from Core.Entities and introduces new models in Core.Models, including AssignmentParameters, AssignmentRequirement, PartialTeam, and StudentEventStatistics. The changes enhance the organization of assignment-related data and improve the overall structure of the codebase. Additionally, several files have been updated to include references to the new Core.Models namespace, ensuring consistency across the application.
2026-01-10 18:36:52 -05:00

38 lines
1.4 KiB
C#

using Core.Entities;
using Core.Models;
using Core.Validation.Rules.BaseRules;
namespace Core.Validation.Rules.StudentAssignmentRules;
/// <summary>
/// Validation rule that checks if a student has too many regional events in their assignments
/// </summary>
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<string, object> BuildAdditionalMetadata(StudentEventStatistics statistics, ValidationConfiguration config)
{
return new Dictionary<string, object>
{
{ "RegionalEventCount", GetCount(statistics) },
{ "MaxRegionalEvents", config.MaxRegionalEvents }
};
}
}