Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Aufteilung der Veranstaltungen auf die Stehordner #97

Open
ckleemann opened this issue Mar 28, 2017 · 2 comments
Open

Aufteilung der Veranstaltungen auf die Stehordner #97

ckleemann opened this issue Mar 28, 2017 · 2 comments

Comments

@ckleemann
Copy link
Collaborator

Der folgende Code berechnet die Aufteilung in der Konsole. Es mangelt noch an einer GUI

from feedback.models import Veranstaltung, Semester
from django.db.models import Q, Sum

num_buckets = 9
return_factor = 0.6

s = Semester.objects.filter(semester=20160)
vl = Veranstaltung.objects.filter(semester=s,anzahl__gt=0)
# alles auser reine vorlesung
#vl = vl.filter(~Q(typ='v'))
# alle vorlesung
vl = vl.filter(Q(typ='v') | Q(typ='vu'))
vl = vl.order_by('name')

num_sheets = 0

#  ist Aggregate besser?
for v in vl:
 num_sheets += v.anzahl

expected_return = num_sheets * return_factor

average_num_per_bucket = expected_return / num_buckets

print('expected Sheets per bucket: %d' % (average_num_per_bucket))

in_c_bucket = 0

bucket = 1

print ('\n Bucket No: %d\n' % (bucket) )
for v in vl:
  if ((in_c_bucket + ((v.anzahl * return_factor) / 2)) > average_num_per_bucket):
    print ('Anzahl in Bucket: %d' %(in_c_bucket))
    bucket+=1
    in_c_bucket = 0
    print ('\n Bucket No: %d\n' % (bucket))
  in_c_bucket += v.anzahl * return_factor
  print ('%s erwartete Anzahl: %d' % (v, v.anzahl * return_factor))

print ('Anzahl in Bucket: %d' %(in_c_bucket))

Gitlab: 22

@cvoelcker
Copy link
Contributor

cvoelcker commented Jul 6, 2017

Hier macht der Code alles auf einmal

from feedback.models import Veranstaltung, Semester
from django.db.models import Q, Sum

num_buckets = 18
return_factor = 0.6

s = Semester.objects.filter(semester=20170)
vl = Veranstaltung.objects.filter(semester=s,anzahl__gt=0)
# alles auser reine vorlesung
not_vl = vl.filter(~Q(typ='v'))
# alle vorlesung
vl = vl.filter(Q(typ='v') | Q(typ='vu'))
vl = vl.order_by('name')
not_vl = not_vl.order_by('name')

num_sheets = 0

#  ist Aggregate besser?
for v in vl:
 num_sheets += v.anzahl

for v in not_vl:
 num_sheets += v.anzahl

expected_return = num_sheets * return_factor

average_num_per_bucket = expected_return / num_buckets

print('expected Sheets per bucket: %d' % (average_num_per_bucket))

in_c_bucket = 0

bucket = 1

print ('\n Bucket No: %d\n' % (bucket) )
for v in vl:
  if ((in_c_bucket + ((v.anzahl * return_factor) / 2)) > average_num_per_bucket):
    print ('Anzahl in Bucket: %d' %(in_c_bucket))
    bucket+=1
    in_c_bucket = 0
    print ('\n Bucket No: %d\n' % (bucket))
  in_c_bucket += v.anzahl * return_factor
  print ('%s erwartete Anzahl: %d' % (v, v.anzahl * return_factor))

print ('Anzahl in Bucket: %d' %(in_c_bucket))

in_c_bucket = 0
bucket += 1

print ('\n Bucket No: %d\n' % (bucket) )
for v in not_vl:
  if ((in_c_bucket + ((v.anzahl * return_factor) / 2)) > average_num_per_bucket):
    print ('Anzahl in Bucket: %d' %(in_c_bucket))
    bucket+=1
    in_c_bucket = 0
    print ('\n Bucket No: %d\n' % (bucket))
  in_c_bucket += v.anzahl * return_factor
  print ('%s erwartete Anzahl: %d' % (v, v.anzahl * return_factor))

print ('Anzahl in Bucket: %d' %(in_c_bucket))```

@miterion miterion added this to the Wintersemester 2017 milestone Jul 14, 2017
@miterion
Copy link
Member

Zudem wäre Funktionalität gut, welche die Trennblätter automatisch generiert und schaut, welche schon existieren (seit Sommersemester 2016) und diese nicht neu ausdruckt.

\documentclass[a4paper]{article}
\usepackage[left=70pt,top=80pt]{geometry}
\usepackage[utf8]{inputenc}
\newcommand{\ver}[1]{
	\thispagestyle{empty}
	\huge #1
	\newpage
}

\begin{document}
\ver{#Veranstaltungsname}
\end{document}

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

3 participants