45edcf5e5f
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.
38 lines
1.5 KiB
C#
38 lines
1.5 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 event assignments
|
|
/// </summary>
|
|
public class TooManyEventsRule : EventCountThresholdRuleBase
|
|
{
|
|
protected override int GetCount(StudentEventStatistics statistics) => statistics.EventCount;
|
|
|
|
protected override int GetThreshold(ValidationConfiguration config) => config.MaxRecommendedEvents;
|
|
|
|
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.MaxCriticalEvents;
|
|
|
|
protected override bool ViolatesCriticalThreshold(int count, int criticalThreshold) => count > criticalThreshold;
|
|
|
|
protected override string Code => "TOO_MANY_EVENTS";
|
|
|
|
protected override string GetMessage(int count, int threshold) =>
|
|
$"Student has {count} events (max recommended: {threshold})";
|
|
|
|
protected override Dictionary<string, object> BuildAdditionalMetadata(StudentEventStatistics statistics, ValidationConfiguration config)
|
|
{
|
|
return new Dictionary<string, object>
|
|
{
|
|
{ "MaxRecommended", config.MaxRecommendedEvents },
|
|
{ "MaxCritical", config.MaxCriticalEvents }
|
|
};
|
|
}
|
|
}
|