Skip to content

Commit

Permalink
Merge pull request #19 from Bostonhacks/jasonli
Browse files Browse the repository at this point in the history
set up our track and sponsor track CSVs
  • Loading branch information
sarah256 committed Apr 4, 2019
2 parents df2b440 + 2552928 commit d781cf1
Show file tree
Hide file tree
Showing 2 changed files with 40 additions and 5 deletions.
31 changes: 26 additions & 5 deletions giudice/projects.py
Original file line number Diff line number Diff line change
Expand Up @@ -90,8 +90,8 @@ def assign_tables_to_judges():
for track in track_judges.keys():
judge_assignments[track] = assign_judges_to_track(track, track_judges[track])

print(num_track_judges)
print(judge_assignments)
#print(num_track_judges)
#print(judge_assignments)

return judge_assignments

Expand Down Expand Up @@ -129,7 +129,8 @@ def assign_judges_to_track(track, judges):
#print(assignments[judges[judge_idx]])
#print(project)
assignments[judges[judge_idx]].append(project)

projects[project]["num_judges"][track] += 1

judge_idx = (judge_idx + 1) % len(judges) # updates the judge index; reset once the last judge is reached

return assignments
Expand All @@ -149,13 +150,15 @@ def assign_judges_to_track(track, judges):

# we now have a new project and can add it to this judge's assignments
assignments[judges[judge_idx]].append(random_proj)
projects[random_proj]["num_judges"][track] += 1
project_views.remove(random_proj)
count = 0

judge_idx = (judge_idx + 1) % len(judges) # updates the judge index; reset once the last judge is reached


# we can assume that all the projects left to be assigned have already been assigned to this last judge
# we can assume that all the projects left to be assigned have already been assigned to this last judge,
# so start from the beginning and start assign a proj from judge 1 to the last judge, then judge 2 to second last
if edge:
count = 0 # used to sequentially step through the array of judges from index 0
jLen = len(assignments[judges[count]]) # goal length of assignments
Expand All @@ -171,12 +174,13 @@ def assign_judges_to_track(track, judges):
edge_idx -= 1


# if there are still unassigned projects left
# if there are still unassigned projects left assign them to the first x judges
if len(project_views) > 0:
edge_idx = 0 # sequentially step through the first judges to add the unassigned ones to them

for project in project_views:
assignments[judges[edge_idx]].append(project)
projects[project]["num_judges"][track] += 1
edge_idx = (edge_idx + 1) % len(judges)

return assignments
Expand Down Expand Up @@ -236,6 +240,23 @@ def get_judge_assignments(judge_name):
return result


def judging_csv():
# needs project name, table number, and number of judges
with open('judging.csv', 'w') as judgingCSV:
filewriter = csv.writer(judgingCSV, delimiter=',', quotechar='"', quoting=csv.QUOTE_MINIMAL)
for proj in projects:
filewriter.writerow([projects[proj]["project"], proj, projects[proj]["num_judges"]])


def sponsorship_csv():
#Each sponsor should be listed along with the table numbers assigned to them
with open('sponsorship.csv', 'w') as sponsorshipCSV:
filewriter = csv.writer(sponsorshipCSV, delimiter=',', quotechar='"', quoting=csv.QUOTE_MINIMAL)
keys = sponsor_tracks.keys()
for track in keys:
filewriter.writerow([track, sponsor_tracks.get(track)])


# def get_judge_categories(judge_name):
# """
# Get the categories that a given judge is judging projects for
Expand Down
14 changes: 14 additions & 0 deletions tests/projects_tests.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,7 @@
from giudice.projects import assign_tables_to_judges
from giudice.projects import judging_csv
from giudice.projects import sponsorship_csv


################
# PUT ALL TESTS FOR projects.py FILE HERE
Expand All @@ -12,6 +15,8 @@ def run_tests():
"""
test_assign_judges()
test_repeat_assignments()
test_judging_csv()
test_sponsorship_csv()


def test_assign_judges():
Expand Down Expand Up @@ -39,3 +44,12 @@ def test_repeat_assignments():
proj = jAssignments.pop(0)
if proj in jAssignments:
raise Exception('Duplicates found!!!!')


def test_judging_csv():
judging_csv()


def test_sponsorship_csv():
sponsorship_csv()

0 comments on commit d781cf1

Please sign in to comment.