Commit b6a98dea authored by LammLukas's avatar LammLukas

added offset for assign_participants

parent f9b64f00
......@@ -179,12 +179,11 @@ class Exam(Exportable):
def assign_participants(self, form='matriculation', rev=False, offset=5):
""" Assign participants to rooms
todo: Add optional offset for room
"""
if not self.is_object_initialized():
raise UninitializedObject('Not able to assign participants. '
'Please first initialize the exam object properly.', self)
self.check_room_capacity()
self.check_room_capacity(offset)
if form == 'matriculation':
self.Participants.sort(key=lambda x: x.Matriculation, reverse=rev)
......@@ -194,7 +193,7 @@ class Exam(Exportable):
counter = 0
for room in self.Rooms:
room.AssignedParticipants = []
seats_available = room.NumSeats - 1
seats_available = int(room.NumSeats) - (1 + offset)
seat_count = 0
while seat_count <= seats_available:
if counter <= (len(self.Participants) - 1):
......@@ -204,14 +203,13 @@ class Exam(Exportable):
else:
break
def check_room_capacity(self):
def check_room_capacity(self, offset):
"""Check if total room capacity is sufficient
todo: Include room offset
"""
num_part = len(self.Participants)
num_seats = 0
for room in self.Rooms:
num_seats = num_seats + room.NumSeats
num_seats = num_seats + int(room.NumSeats) - offset
if not (num_seats - num_part) >= 0:
raise InsuffientCapacity('Number of participants exceeds number of '
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment