自动排课
This commit is contained in:
1 parent
a63c943815
commit
533ff6b9f6
5 files changed
+102
-10
No files matched your search
@@ -91,6 +91,8 @@ public sealed class ScheduleSettingsController(AppDbContext db) : ControllerBase
|
|||||||
.OrderByDescending(item => item.IsPrimary)
|
.OrderByDescending(item => item.IsPrimary)
|
||||||
.Select(item => item.Teacher!.Name),
|
.Select(item => item.Teacher!.Name),
|
||||||
x.Capacity,
|
x.Capacity,
|
||||||
|
x.StartWeek,
|
||||||
|
x.EndWeek,
|
||||||
x.WeeklyHours,
|
x.WeeklyHours,
|
||||||
x.SchedulingMode
|
x.SchedulingMode
|
||||||
})
|
})
|
||||||
@@ -114,6 +116,8 @@ public sealed class ScheduleSettingsController(AppDbContext db) : ControllerBase
|
|||||||
task.CollegeName,
|
task.CollegeName,
|
||||||
task.TeacherNames,
|
task.TeacherNames,
|
||||||
task.Capacity,
|
task.Capacity,
|
||||||
|
task.StartWeek,
|
||||||
|
task.EndWeek,
|
||||||
task.WeeklyHours,
|
task.WeeklyHours,
|
||||||
task.SchedulingMode,
|
task.SchedulingMode,
|
||||||
HasCustomConstraint = constraint is not null,
|
HasCustomConstraint = constraint is not null,
|
||||||
|
|||||||
@@ -233,10 +233,10 @@ public sealed class AutomaticScheduleGenerator(AppDbContext db)
|
|||||||
student.Status == StudentStatus.Active) ?? 0));
|
student.Status == StudentStatus.Active) ?? 0));
|
||||||
return classrooms.Where(room =>
|
return classrooms.Where(room =>
|
||||||
room.Capacity >= minimumCapacity &&
|
room.Capacity >= minimumCapacity &&
|
||||||
(!constraint?.RequiredCampusId.HasValue ?? true ||
|
(constraint?.RequiredCampusId is not Guid requiredCampusId ||
|
||||||
room.Building!.CampusId == constraint.RequiredCampusId) &&
|
room.Building!.CampusId == requiredCampusId) &&
|
||||||
(!constraint?.RequiredBuildingId.HasValue ?? true ||
|
(constraint?.RequiredBuildingId is not Guid requiredBuildingId ||
|
||||||
room.BuildingId == constraint.RequiredBuildingId) &&
|
room.BuildingId == requiredBuildingId) &&
|
||||||
(allowedRoomIds.Count == 0 || allowedRoomIds.Contains(room.Id)))
|
(allowedRoomIds.Count == 0 || allowedRoomIds.Contains(room.Id)))
|
||||||
.ToList();
|
.ToList();
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -224,7 +224,7 @@ public sealed class AutomaticScheduleGeneratorTests
|
|||||||
}
|
}
|
||||||
|
|
||||||
[Fact]
|
[Fact]
|
||||||
public async Task Generator_does_not_attach_duplicate_buildings_from_untracked_classrooms()
|
public async Task Generator_uses_scoped_rooms_without_attaching_duplicate_buildings()
|
||||||
{
|
{
|
||||||
await using var connection = new SqliteConnection("Data Source=:memory:");
|
await using var connection = new SqliteConnection("Data Source=:memory:");
|
||||||
await connection.OpenAsync();
|
await connection.OpenAsync();
|
||||||
@@ -333,6 +333,34 @@ public sealed class AutomaticScheduleGeneratorTests
|
|||||||
EndsAt = new TimeOnly(9, 40)
|
EndsAt = new TimeOnly(9, 40)
|
||||||
});
|
});
|
||||||
await db.SaveChangesAsync();
|
await db.SaveChangesAsync();
|
||||||
|
db.TeachingTaskScheduleConstraints.AddRange(
|
||||||
|
new TeachingTaskScheduleConstraint
|
||||||
|
{
|
||||||
|
TeachingTaskId = smallTask.Id,
|
||||||
|
RequiredCampusId = campus.Id,
|
||||||
|
RequiredBuildingId = building.Id,
|
||||||
|
AllowedClassrooms =
|
||||||
|
[
|
||||||
|
new TeachingTaskAllowedClassroom
|
||||||
|
{
|
||||||
|
ClassroomId = smallRoom.Id
|
||||||
|
}
|
||||||
|
]
|
||||||
|
},
|
||||||
|
new TeachingTaskScheduleConstraint
|
||||||
|
{
|
||||||
|
TeachingTaskId = largeTask.Id,
|
||||||
|
RequiredCampusId = campus.Id,
|
||||||
|
RequiredBuildingId = building.Id,
|
||||||
|
AllowedClassrooms =
|
||||||
|
[
|
||||||
|
new TeachingTaskAllowedClassroom
|
||||||
|
{
|
||||||
|
ClassroomId = largeRoom.Id
|
||||||
|
}
|
||||||
|
]
|
||||||
|
});
|
||||||
|
await db.SaveChangesAsync();
|
||||||
|
|
||||||
db.ChangeTracker.Clear();
|
db.ChangeTracker.Clear();
|
||||||
plan = await db.SchedulePlans.SingleAsync();
|
plan = await db.SchedulePlans.SingleAsync();
|
||||||
|
|||||||
Loaded 3 of 5 files, more files were not shown because too many files have changed in this diff.
Show more
Reference in new issue
Block a user