Documentation
¶
Overview ¶
Package roomcalc holds the pure room-seat math of the room preparation: whether a room satisfies an exam's room constraints (EXaHM/SEB/Lab/socket/allowed-rooms feature matching), the required free-seat buffer for an exam, and the free seats an exam currently has across its rooms. All functions are I/O-free over graph/model types; the stateful room allocation and DB access stay in the plexams package.
Index ¶
- Constants
- func ExamFreeSeats(roomInfo map[string]*model.Room, examRooms []*model.PlannedRoom, ancode int) (free, normalStudents int)
- func ExamRegsAndNTAs(exam *model.PlannedExam) (normalRegs []string, ntasInNormalRooms, ntasInAloneRooms []*model.NTA)
- func FreeSeatsBuffer(normalStudents int) int
- func SatisfiesConstraints(room *model.Room, constraints *model.Constraints) bool
- func SortPrePlannedRooms(rooms []*model.PrePlannedRoom, roomInfo map[string]*model.Room)
Constants ¶
const ( FreeSeatsMin = 2 FreeSeatsPercent = 5 )
FreeSeatsMin / FreeSeatsPercent define the minimum free-seat buffer an exam must keep: at least FreeSeatsMin seats and at least FreeSeatsPercent percent of the normal students, so no exam is packed exactly full.
Variables ¶
This section is empty.
Functions ¶
func ExamFreeSeats ¶
func ExamFreeSeats(roomInfo map[string]*model.Room, examRooms []*model.PlannedRoom, ancode int) (free, normalStudents int)
ExamFreeSeats returns, for one exam, the free seats across its normal rooms (NTA-alone rooms excluded, reserve rooms count as free) and the number of students placed in normal rooms.
func ExamRegsAndNTAs ¶
func ExamRegsAndNTAs(exam *model.PlannedExam) (normalRegs []string, ntasInNormalRooms, ntasInAloneRooms []*model.NTA)
ExamRegsAndNTAs partitions an exam's registrations for the room allocation: the NTAs are split into those needing a room alone and those going into normal rooms; normalRegs holds the Mtknrs of all non-NTA student registrations across the exam's Primuss sections, in section then registration order.
func FreeSeatsBuffer ¶
FreeSeatsBuffer returns the required free-seat buffer for an exam with the given number of normal (non-NTA) students: max(FreeSeatsMin, ceil(FreeSeatsPercent%)).
func SatisfiesConstraints ¶
func SatisfiesConstraints(room *model.Room, constraints *model.Constraints) bool
SatisfiesConstraints reports whether a room may host an exam with the given room constraints. A room with a special feature (EXaHM / Lab / SEB) is only used for an exam that requires at least one feature the room actually has; never for one that requires none of them. EXaHM and SEB are compatible: an EXaHM room may also host SEB exams (the T-building EXaHM rooms run SEB too). A Lab room only serves Lab exams (or SEB/EXaHM if it has those). An all-false RoomConstraints object (present but nothing required) must not let such a room slip through.
func SortPrePlannedRooms ¶
func SortPrePlannedRooms(rooms []*model.PrePlannedRoom, roomInfo map[string]*model.Room)
SortPrePlannedRooms orders an exam's pre-planned rooms into fill order, in place: NTA rooms (Mtknr != nil) first (keeping their relative input order), then the non-reserve rooms by descending seat count, then the reserve rooms last (keeping their relative input order). roomInfo provides the seat counts for the non-reserve ordering.
Types ¶
This section is empty.