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:
2026-01-19 22:42:44 -05:00
parent 6bc4c2e7f2
commit 649a0061cf
@@ -426,23 +426,26 @@
} }
/// <summary> /// <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> /// </summary>
private Team[] GetTeamsWithoutExcludedStudents(Team[] teams, int timeSlotIndex) private Team[] GetTeamsWithoutExcludedStudents(Team[] teams, int timeSlotIndex)
{ {
var absentStudentIds = _absentStudents.Select(s => s.Id).ToHashSet();
return teams.Select(team => return teams.Select(team =>
{ {
// Find excluded students for this team in this time slot // 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 // More efficient: iterate through team students and check exclusions
var includedStudents = team.Students 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(); .ToList();
// If no students are excluded, return original team // If no students are excluded, return original team
if (includedStudents.Count == team.Students.Count) if (includedStudents.Count == team.Students.Count)
return team; return team;
// Create a temporary team with excluded students removed // Create a temporary team with excluded and absent students removed
return new Team return new Team
{ {
Id = team.Id, Id = team.Id,