Add a TimeSlot object, refactor
This commit is contained in:
@@ -5,13 +5,17 @@ namespace Core.Calculation;
|
||||
public class UnassignedStudentScheduler
|
||||
{
|
||||
private readonly Student[] _students;
|
||||
private readonly Team[] _teams;
|
||||
private readonly Team[] _allTeams;
|
||||
private readonly IList<Team>[] _timeSlots;
|
||||
|
||||
public UnassignedStudentScheduler(Team[] teams, Team[][] timeslots)
|
||||
public UnassignedStudentScheduler(Team[] allTeams, TeamScheduleTimeSlot[] timeslots)
|
||||
: this(allTeams, timeslots.Select(e => e.Teams).ToArray())
|
||||
{ }
|
||||
|
||||
public UnassignedStudentScheduler(Team[] allTeams, Team[][] timeslots)
|
||||
{
|
||||
_teams = teams;
|
||||
_students = teams.SelectMany(t => t.Students).Distinct().ToArray();
|
||||
_allTeams = allTeams;
|
||||
_students = allTeams.SelectMany(t => t.Students).Distinct().ToArray();
|
||||
_timeSlots = timeslots.Select(ts => ts.Select(t => t.Clone()).ToList()).ToArray<IList<Team>>();
|
||||
}
|
||||
public static IEnumerable<Student> UnassignedStudents(IList<Student> students, IList<Team> timeSlot)
|
||||
@@ -68,7 +72,7 @@ public class UnassignedStudentScheduler
|
||||
// find teams where several unassigned students can work together
|
||||
private IEnumerable<Team> GetAvailableTeams_BiggestGroup(
|
||||
IEnumerable<Team> scheduledTeams, IEnumerable<Student> assignedStudents) =>
|
||||
_teams
|
||||
_allTeams
|
||||
.Where(t => scheduledTeams.All(st => st.Id != t.Id))
|
||||
.Select(t => t.CloneWithOmittedStudents(assignedStudents))
|
||||
.Where(t => t.Students.Count > 1) //|| t.Event.EventFormat is EventFormat.Individual
|
||||
@@ -79,7 +83,7 @@ public class UnassignedStudentScheduler
|
||||
// find individual events unassigned students can work on
|
||||
private IEnumerable<Team> GetAvailableTeams_Individual(
|
||||
IEnumerable<Team> scheduledTeams, IEnumerable<Student> assignedStudents) =>
|
||||
_teams
|
||||
_allTeams
|
||||
.Where(t => scheduledTeams.All(st => st.Id != t.Id))
|
||||
.Where(t => t.Event.EventFormat == EventFormat.Individual || t.Students.Count == 1)
|
||||
.Select(t => t.CloneWithOmittedStudents(assignedStudents))
|
||||
@@ -88,14 +92,14 @@ public class UnassignedStudentScheduler
|
||||
// find any unassigned eventDefinition students can work on
|
||||
private IEnumerable<Team> GetAvailableTeams_AnyNotMeetingAlready(
|
||||
IEnumerable<Team> scheduledTeams, IEnumerable<Student> assignedStudents) =>
|
||||
_teams
|
||||
_allTeams
|
||||
.Where(t => scheduledTeams.All(st => st.Id != t.Id))
|
||||
.Select(t => t.CloneWithOmittedStudents(assignedStudents))
|
||||
.Where(t => t.Students.Count > 0);
|
||||
|
||||
private IEnumerable<Team> GetAvailableTeams_Any(
|
||||
IEnumerable<Team> scheduledTeams, IEnumerable<Student> assignedStudents) =>
|
||||
_teams
|
||||
_allTeams
|
||||
.Select(t => t.CloneWithOmittedStudents(assignedStudents))
|
||||
.Where(t => t.Students.Count > 0);
|
||||
|
||||
@@ -103,7 +107,7 @@ public class UnassignedStudentScheduler
|
||||
// find teams where several unassigned students can work together
|
||||
private IEnumerable<Team> GetAvailableTeams_LevelOfEffort(
|
||||
IEnumerable<Team> scheduledTeams, IEnumerable<Student> assignedStudents) =>
|
||||
_teams
|
||||
_allTeams
|
||||
.Where(t => scheduledTeams.All(st => st.Id != t.Id))
|
||||
.Select(t => t.CloneWithOmittedStudents(assignedStudents))
|
||||
.Where(t => t.Students.Count > 1) //|| t.Event.EventFormat is EventFormat.Individual
|
||||
|
||||
Reference in New Issue
Block a user