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

Catch students with invalid grades in phase zero #3141

Merged
merged 1 commit into from
Dec 17, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
28 changes: 24 additions & 4 deletions esp/esp/program/modules/handlers/studentregphasezeromanage.py
Original file line number Diff line number Diff line change
Expand Up @@ -147,13 +147,23 @@ def phasezero(self, request, tl, one, two, module, extra, prog):

grades = range(prog.grade_min, prog.grade_max + 1)
stats = {}
invalid_grades = set()

#Calculate grade counts
for grade in grades:
stats[grade] = {}
stats[grade]['in_lottery'] = 0
for entrant in entrants:
stats[entrant.getGrade(prog)]['in_lottery'] += 1
grade = entrant.getGrade(prog)
if grade in grades:
stats[grade]['in_lottery'] += 1
else:
# Catch students that somehow don't have a valid grade
invalid_grades.add(entrant)
if 'Invalid Grade' not in stats:
stats['Invalid Grade'] = {}
stats['Invalid Grade']['in_lottery'] = 0
stats['Invalid Grade']['in_lottery'] += 1

#Run lottery if requested
if request.POST:
Expand All @@ -169,17 +179,27 @@ def phasezero(self, request, tl, one, two, module, extra, prog):

#If lottery has been run, calculate acceptance stats
if Tag.getBooleanTag('student_lottery_run', prog):
for grade in grades:
for grade in stats:
stats[grade]['num_accepted'] = stats[grade]['per_accepted'] = 0
winners = ESPUser.objects.filter(groups__name=role).distinct()
for winner in winners:
stats[winner.getGrade(prog)]['num_accepted'] += 1
for grade in grades:
grade = winner.getGrade(prog)
if grade in grades:
stats[grade]['num_accepted'] += 1
else:
# Catch students that somehow don't have a valid grade
invalid_grades.add(winner)
if 'Invalid Grade' not in stats:
stats['Invalid Grade'] = {}
stats['Invalid Grade']['num_accepted'] = 0
stats['Invalid Grade']['num_accepted'] += 1
for grade in stats:
if stats[grade]['in_lottery'] == 0:
stats[grade]['per_accepted'] = "NA"
else:
stats[grade]['per_accepted'] = round(stats[grade]['num_accepted'],1)/stats[grade]['in_lottery']*100
context['stats'] = stats
context['invalid_grades'] = invalid_grades
return render_to_response('program/modules/studentregphasezero/status.html', request, context)

class Meta:
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -75,6 +75,7 @@ <h1>Manage Phase Zero (Student Lottery) for {{program.niceName}}</h1>
<center>
<hr>
{% if error %}<p><font color="red">{{ error }}</font></p>{% endif %}
{% if invalid_grades %}<p><font color="red">The following students have invalid grades:</br>{% for student in invalid_grades %}{{ student }}</br>{% endfor %}</font></p>{% endif %}
{% autoescape off %}
{% if lottery_messages %}<p><font color="blue">{{ lottery_messages|join:"<br/>" }}</font></p>{% endif %}
{% endautoescape %}
Expand Down