Skip to content
This repository has been archived by the owner on Feb 12, 2022. It is now read-only.

Commit

Permalink
Merge branch 'master' into python3.5+
Browse files Browse the repository at this point in the history
  • Loading branch information
ckleemann committed Jun 2, 2019
2 parents 2b49975 + ee6708f commit 5249b20
Show file tree
Hide file tree
Showing 5 changed files with 42 additions and 27 deletions.
33 changes: 18 additions & 15 deletions exam/models.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
import math
from functools import partial
from itertools import chain, repeat

import math
from django.db import models
from django.db.models import Sum
from django.utils import formats
Expand All @@ -12,12 +13,14 @@

class ExamRoom(models.Model):
"""A room which is suitable for the exam."""

class Meta:
verbose_name = _('Klausurraum')
verbose_name_plural = _('Klausurräume')
ordering = ['available', '-capacity_1_free', '-capacity_2_free', 'room']

room = models.OneToOneField('ophasebase.Room', models.CASCADE, verbose_name=_('Raum'), limit_choices_to={"type": "HS"})
room = models.OneToOneField('ophasebase.Room', models.CASCADE, verbose_name=_('Raum'),
limit_choices_to={"type": "HS"})
available = models.BooleanField(verbose_name=_('Verfügbar'), default=True)
capacity_1_free = models.IntegerField(verbose_name=_('Plätze (1 Platz Abstand)'))
capacity_2_free = models.IntegerField(verbose_name=_('Plätze (2 Plätze Abstand)'))
Expand All @@ -28,6 +31,9 @@ def __str__(self):
def capacity(self, spacing):
return self.capacity_1_free if spacing == 1 else self.capacity_2_free

def seats(self, spacing, ratio):
return math.ceil(self.capacity(spacing) * ratio)


class Assignment(models.Model):
"""
Expand Down Expand Up @@ -64,7 +70,7 @@ def __str__(self):
# see http://stackoverflow.com/a/8288298
formatted_datetime = formats.date_format(self.created_at, 'SHORT_DATETIME_FORMAT')
return _('Zuteilung vom %(formated_datetime)s') % {
'formated_datetime' : formatted_datetime,}
'formated_datetime': formatted_datetime, }

def save(self, *args, **kwargs):
if self.ophase_id is None:
Expand All @@ -89,7 +95,8 @@ def assign(self):
Do the real assignment based on object properties
"""

capacity_string = 'capacity_{:d}_free'.format(self.spacing)
spacing = self.spacing
capacity_string = 'capacity_{:d}_free'.format(spacing)
order_by_string = "-{:s}".format(capacity_string)

exam_rooms = ExamRoom.objects.filter(available=True).order_by(order_by_string)
Expand All @@ -100,29 +107,25 @@ def assign(self):
if exam_rooms.count() == 0 or student_count == 0:
return 0

total_places = exam_rooms.aggregate(total_places=Sum(capacity_string)).get('total_places')
maximum_capacity = exam_rooms.aggregate(maximum_capacity=Sum(capacity_string)).get('maximum_capacity')

# Set ratio so that all room gets equals percentage
ratio = student_count / total_places
ratio = student_count / maximum_capacity

# on minimal room mode and if the ratio is less then 90% the ratio is set to 90%
# e.g. the first rooms get filled by 90%. The other rooms are not used
if self.mode == 1 and ratio < 0.9:
ratio = 0.9

exam_rooms_list = []

for exam_room in exam_rooms:
places = math.ceil(exam_room.capacity(self.spacing) * ratio)
# add each room as often to the list as places available in the room
exam_rooms_list.extend((exam_room, ) * places)
# returns each room as often as seats are available for the given ratio
exam_seats = chain.from_iterable(repeat(room, room.seats(spacing, ratio)) for room in exam_rooms)

assign = partial(PersonToExamRoomAssignment, assignment=self)

assignments = (assign(person = student, room = room) for student, room in zip(exam_students, exam_rooms_list))
PersonToExamRoomAssignment.objects.bulk_create(assignments)
assignments = (assign(person=student, room=seat) for student, seat in zip(exam_students, exam_seats))
result = PersonToExamRoomAssignment.objects.bulk_create(assignments)

return min(student_count, len(exam_rooms_list))
return len(result)


class PersonToExamRoomAssignment(models.Model):
Expand Down
12 changes: 6 additions & 6 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

4 changes: 2 additions & 2 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -10,8 +10,8 @@
"bootstrap": "~4.3.1",
"bootstrap-chosen": "alxlit/bootstrap-chosen",
"chosen-js": "~1.8.7",
"@fortawesome/fontawesome-free": "~5.8.1",
"jquery": "~3.3.1",
"@fortawesome/fontawesome-free": "~5.8.2",
"jquery": "~3.4.1",
"popper.js": "^1.15.0"
}
}
2 changes: 1 addition & 1 deletion requirements/base.txt
Original file line number Diff line number Diff line change
Expand Up @@ -6,4 +6,4 @@ django-formtools==2.1
odswriter==0.4.0
Pillow==6.0.0
pyTUID==1.3.4
pytz==2019.1
pytz==2019.1
18 changes: 15 additions & 3 deletions website/templates/website/description/bachelor.html
Original file line number Diff line number Diff line change
Expand Up @@ -15,9 +15,15 @@
wichtigsten Ereignisse in Deinem Studium. Darum nimm Dir die Zeit und besuche die Ophase.
</p>

<h3>Bachelor of Science</h3>
<p>
Die meisten Erstis in der Ophase studieren diesen Studiengang. Das normale Programm wie es im Stundenplan
dargestellt wird ist primät auf euch ausgelegt.
</p>

<h3>Joint-Bachelor Informatik</h3>
<p>
Ersties, die den Joint-Bachelor mit Informatik-Anteil beginnen, können an unserer Ophase teilnehmen. Es gibt keinen
Erstis, die den Joint-Bachelor mit Informatik-Anteil beginnen, können an unserer Ophase teilnehmen. Es gibt keinen
gesonderten Stundenplan. Stattdessen erhalten sie
vom FB 02 die Stundenpläne ihrer beiden Fächer und können dann selbst aussuchen, welche Veranstaltungen sie bei
welcher Ophase besuchen. Welche Veranstaltungen besonders relevant sind, lässt sich schwer sagen, weil dies auch
Expand All @@ -26,6 +32,12 @@ <h3>Joint-Bachelor Informatik</h3>
Ophase hilft unser Helpdesk gerne weiter, davor könnt ihr eine Mail an die Ophasenleitung schreiben.
</p>

<h3>Bachelor of Education</h3>
<p>
Für den Bachelor of Education wird es in einem der Workshopslots spezifische informationen zu dem Studiengang und
dessen Organisation geben.
</p>

<h3>Programmiervorkurs</h3>
<p>
Noch keine Ahnung vom Programmieren? Dann komm zum Vorkurs! Alle relevanten Infos findest du auf der
Expand All @@ -49,7 +61,7 @@ <h3>Semesterticket</h3>

<h3>Ofahrt</h3>
<p>
Ein Angebot über die Ophase hinaus ist die Ofahrt, bei der Ersties und Fachschaftler*innen zusammen
Ein Angebot über die Ophase hinaus ist die Ofahrt, bei der Erstis und Fachschaftler*innen zusammen
einige Tage in einer Jugendherberge verbringen. Mehr Informationen findet ihr auf den
<a href="https://www2.fachschaft.informatik.tu-darmstadt.de/ofahrt/">Seiten der Ofahrt</a>.
<a href="https://www.fachschaft.informatik.tu-darmstadt.de/ofahrt/">Seiten der Ofahrt</a>.
</p>

0 comments on commit 5249b20

Please sign in to comment.