CourseKitBackend
Built-in Constraints
Overlap, capacity, and availability constraint implementations
Overview
CourseKit ships with three built-in constraints that are registered automatically (unless enableBuiltInConstraints is set to false). Each extends the ScheduleConstraint abstract class.
OverlapConstraint
Detects instructor double-bookings and room time overlaps.
| Property | Value |
|---|---|
type | 'overlap' |
severity | 'error' |
How it works:
- Groups all occurrences by instructor (via
getInstructorsForEvent) - Groups all occurrences by room
- Within each group, sorts by start time and checks for overlapping consecutive pairs
- Produces
'instructor-double-book'or'room-overlap'conflicts
// Example conflict output
{
id: 'overlap-instructor-inst1-event1-event2',
type: 'instructor-double-book',
severity: 'error',
message: 'Instructor inst1 is double-booked between events event1 and event2',
involvedEventIds: ['event1', 'event2'],
involvedEntityIds: ['inst1'],
metadata: { entityType: 'instructor', aStart: '...', aEnd: '...', bStart: '...' },
}CapacityConstraint
Checks if the total student count across all assigned groups exceeds the room's capacity.
| Property | Value |
|---|---|
type | 'capacity' |
severity | 'warning' |
How it works:
- For each occurrence with a room, fetches the group IDs
- Sums student counts across all groups
- Compares against
room.capacity - Skips rooms with
capacity === 0(unlimited)
// Example conflict output
{
id: 'capacity-room1-event1-1709308800000',
type: 'room-over-capacity',
severity: 'warning',
message: 'Room Lecture Hall A has capacity 50 but event has 75 students',
involvedEventIds: ['event1'],
involvedEntityIds: ['room1', 'group1', 'group2'],
metadata: { roomCapacity: 50, totalStudents: 75, excess: 25 },
}AvailabilityConstraint
Checks events against entity availability rules (blocked time windows).
| Property | Value |
|---|---|
type | 'availability' |
severity | 'error' for hard blocks, 'warning' for soft blocks |
How it works:
- For each occurrence, collects all entities to check (room + instructors)
- Calls
isEntityAvailable()for each entity - Hard blocks produce
severity: 'error'; soft blocks produceseverity: 'warning'
// Example conflict output
{
id: 'availability-inst1-event1-1709308800000',
type: 'availability-violation',
severity: 'error',
message: 'instructor inst1 is blocked during event event1',
involvedEventIds: ['event1'],
involvedEntityIds: ['inst1'],
metadata: { entityType: 'instructor', hardness: 'hard', blockStart: '...', blockEnd: '...' },
}Built-in Constraints Summary
| Constraint | Type | Severity | What it checks |
|---|---|---|---|
OverlapConstraint | overlap | error | Instructor and room double-bookings |
CapacityConstraint | capacity | warning | Room capacity vs. group size |
AvailabilityConstraint | availability | error / warning | Events during blocked time windows |
Custom Constraints
See the Custom Constraints guide for how to create your own.