Enhance team overlap calculation by excluding absent students
This commit updates the GetTeamsWithoutExcludedStudents method to filter out both excluded and absent students during overlap calculations. A new HashSet is introduced to store absent student IDs, improving the accuracy of team compositions. This change ensures that the team formation logic accounts for student availability, enhancing the overall functionality of the meeting schedule feature.
This commit is contained in:
@@ -426,23 +426,26 @@
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Creates teams with excluded students filtered out for overlap calculation.
|
||||
/// Creates teams with excluded students and absent students filtered out for overlap calculation.
|
||||
/// </summary>
|
||||
private Team[] GetTeamsWithoutExcludedStudents(Team[] teams, int timeSlotIndex)
|
||||
{
|
||||
var absentStudentIds = _absentStudents.Select(s => s.Id).ToHashSet();
|
||||
|
||||
return teams.Select(team =>
|
||||
{
|
||||
// Find excluded students for this team in this time slot
|
||||
// Also exclude absent students from overlap calculations
|
||||
// More efficient: iterate through team students and check exclusions
|
||||
var includedStudents = team.Students
|
||||
.Where(s => !IsStudentExcluded(team.Id, timeSlotIndex, s.Id))
|
||||
.Where(s => !IsStudentExcluded(team.Id, timeSlotIndex, s.Id) && !absentStudentIds.Contains(s.Id))
|
||||
.ToList();
|
||||
|
||||
// If no students are excluded, return original team
|
||||
if (includedStudents.Count == team.Students.Count)
|
||||
return team;
|
||||
|
||||
// Create a temporary team with excluded students removed
|
||||
// Create a temporary team with excluded and absent students removed
|
||||
return new Team
|
||||
{
|
||||
Id = team.Id,
|
||||
|
||||
Reference in New Issue
Block a user