Documentation
¶
Overview ¶
Package rooms holds the stateful per-slot room-allocation machine that assigns concrete rooms to the exams planned in a slot. It was extracted verbatim from the plexams package (roomsPrepare.go); the logic is unchanged.
The machine is driven by a *Cfg that carries both the static configuration (room master data, pre-planned rooms, blocked rooms, the allowed rooms per slot, …) and the per-slot mutable state. The plexams package builds the Cfg (populating the exported fields) and drives the outer slot loop, calling PrepareForSlot once per slot; the roomsNotUsableInSlot carryover between slots therefore lives in the outer loop / the Cfg, not here.
It depends only on a small DB interface (ExamsInSlot + RoomByName, satisfied by *db.DB), a minimal Reporter (Step/Println/Warnf, satisfied structurally by the plexams reporter), and the pure roomcalc math.
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func PrepareForSlot ¶
func PrepareForSlot(ctx context.Context, db DB, cfg *Cfg, reporter Reporter) ([]*model.PlannedRoom, []*model.UnplacedExam, error)
PrepareForSlot assigns rooms to all exams planned in cfg.Slot and returns the planned rooms plus any students that could not be placed. It mutates cfg's runtime state (exams/availableRooms/plannedRoomsWithFreeSeats/RoomsNotUsableInSlot).
Types ¶
type Cfg ¶
type Cfg struct {
RoomInfo map[string]*model.Room
PrePlannedRooms map[int][]*model.PrePlannedRoom
AdditionalSeats map[int]int
Slot *model.Slot
RoomsNotUsableInSlot set.Set[string]
BlockedRooms map[SlotKey]set.Set[string] // slot -> blocked room names
ExactSeatRooms map[int]map[string]bool // ancode -> room names with an exact seat count (do not refill with this exam)
RoomsForSlots map[SlotKey][]string // slot -> allowed room names (computed once)
// SlotBlockMinutes is the spacing between consecutive slot start times (e.g. 120);
// RoomTurnaroundMinutes is the ordinary Vorlauf/Nachlauf (15). Together they decide
// whether an exam with an extended Nachlauf keeps its room past the following slot's
// start (see roomOccupancyOverrunsSlot). 0 disables the check (default room turnaround
// stays governed by the NTA-overrun rule only).
SlotBlockMinutes int
RoomTurnaroundMinutes int
// contains filtered or unexported fields
}
Cfg carries the static configuration and the per-slot mutable state of the room-allocation machine. The exported fields are populated by the plexams builder (and the characterization test); the unexported fields are the runtime state set during PrepareForSlot.
type DB ¶
type DB interface {
ExamsInSlot(ctx context.Context, day int, time int) ([]*model.PlannedExam, error)
RoomByName(ctx context.Context, roomName string) (*model.Room, error)
}
DB is the persistence the room machine needs; *db.DB satisfies it.
type SlotKey ¶
type SlotKey struct {
Day, Slot int
}
SlotKey identifies a slot by day and slot number. It is the rooms-package-local counterpart of plexams.SlotNumber (which stays in plexams because it is used package-wide); the plexams Cfg builder converts its SlotNumber-keyed maps to SlotKey at the boundary.