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.
This commit is contained in:
@@ -0,0 +1,34 @@
|
||||
using Core.Entities;
|
||||
|
||||
namespace Core.Models
|
||||
{
|
||||
public class AssignmentParameters(
|
||||
int effortLowerBound = 6,
|
||||
int effortUpperBound = 8,
|
||||
int eventsLowerBound = 2,
|
||||
int eventsUpperBound = 4,
|
||||
int teamSizeLimit = 4,
|
||||
bool limitTeamsToOne = true,
|
||||
bool requireRegional = true,
|
||||
bool requireOnSite = true)
|
||||
{
|
||||
public int EffortLowerBound { get; set; } = effortLowerBound;
|
||||
public int EffortUpperBound { get; set; } = effortUpperBound;
|
||||
public int EventsLowerBound { get; set; } = eventsLowerBound;
|
||||
public int EventsUpperBound { get; set; } = eventsUpperBound;
|
||||
public int TeamSizeLimit { get; set; } = teamSizeLimit;
|
||||
public bool LimitTeamsToOne { get; set; } = limitTeamsToOne;
|
||||
public bool RequireRegional { get; set; } = requireRegional;
|
||||
public bool RequireOnSite { get; set; } = requireOnSite;
|
||||
|
||||
public override string ToString()
|
||||
{
|
||||
return $"Team Size Limit: {TeamSizeLimit}" + Environment.NewLine +
|
||||
$"Require Regional: {RequireRegional}" + Environment.NewLine +
|
||||
$"Require On-site: {RequireOnSite}" + Environment.NewLine +
|
||||
$"Events Range: [{EventsLowerBound}-{EventsUpperBound}]" + Environment.NewLine +
|
||||
$"Effort Range: [{EffortLowerBound}-{EffortUpperBound}]";
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -0,0 +1,11 @@
|
||||
using Core.Entities;
|
||||
|
||||
namespace Core.Models;
|
||||
|
||||
public class AssignmentRequirement(EventDefinition eventDefinition, Student student, Requirement requirement)
|
||||
{
|
||||
public EventDefinition EventDefinition { get; } = eventDefinition;
|
||||
public Student Student { get; } = student;
|
||||
public Requirement Requirement { get; } = requirement;
|
||||
}
|
||||
|
||||
@@ -0,0 +1,16 @@
|
||||
using Core.Entities;
|
||||
|
||||
namespace Core.Models;
|
||||
|
||||
public class PartialTeam : Team
|
||||
{
|
||||
public IList<Student> OmittedStudents { get; set; } = null!;
|
||||
|
||||
public override Team CloneWithOmittedStudents(IEnumerable<Student> studentsToOmit)
|
||||
{
|
||||
var remainingStudents = Students.Where(s => !studentsToOmit.Contains(s)).ToList();
|
||||
var omittedStudents = OmittedStudents.Union(Students.Where(studentsToOmit.Contains)).Distinct().ToList();
|
||||
return new PartialTeam{Identifier = Identifier, Event = Event, Students = remainingStudents, OmittedStudents = omittedStudents };
|
||||
}
|
||||
}
|
||||
|
||||
@@ -0,0 +1,35 @@
|
||||
using Core.Entities;
|
||||
|
||||
namespace Core.Models;
|
||||
|
||||
public class StudentEventStatistics
|
||||
{
|
||||
public Student Student { get; set; } = null!;
|
||||
public List<EventDefinition> Events { get; set; } = [];
|
||||
|
||||
public int? TotalLevelOfEffort => Events.Sum(e => e.LevelOfEffort);
|
||||
|
||||
public int EventCount => Events.Count;
|
||||
|
||||
public bool HasRegionalEvent => Events.Any(e => e.RegionalEvent);
|
||||
|
||||
public bool HasOnSiteActivity => Events.Any(e => e.OnSiteActivity);
|
||||
|
||||
public static List<StudentEventStatistics> Generate(ICollection<Team> teams)
|
||||
{
|
||||
Dictionary<Student, StudentEventStatistics> statistics = [];
|
||||
|
||||
foreach (var team in teams)
|
||||
{
|
||||
foreach (var student in team.Students)
|
||||
{
|
||||
if (!statistics.ContainsKey(student))
|
||||
statistics.Add(student, new StudentEventStatistics(){Student = student});
|
||||
statistics[student].Events.Add(team.Event);
|
||||
}
|
||||
}
|
||||
|
||||
return statistics.Values.ToList();
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user