Skip to content
Snippets Groups Projects
Commit 4b0ed65a authored by Christopher Bohn's avatar Christopher Bohn :thinking:
Browse files

Bugfixes with blacklist and graylist

- There was a bug involving students with blacklists make requests
- is_blacklist_compatible & is_graylist_compatible always returned true
parent deff2805
No related branches found
No related tags found
No related merge requests found
...@@ -97,7 +97,7 @@ class CompositeUser: ...@@ -97,7 +97,7 @@ class CompositeUser:
your_past_partners: Set[str] = set() your_past_partners: Set[str] = set()
for assignment in self.graylist: for assignment in self.graylist:
if isinstance(self.graylist[assignment], set): if isinstance(self.graylist[assignment], set):
my_past_partners.union(self.graylist[assignment]) my_past_partners.update(self.graylist[assignment])
elif isinstance(self.graylist[assignment], str): elif isinstance(self.graylist[assignment], str):
my_past_partners.add(str(self.graylist[assignment])) my_past_partners.add(str(self.graylist[assignment]))
else: else:
...@@ -105,7 +105,7 @@ class CompositeUser: ...@@ -105,7 +105,7 @@ class CompositeUser:
f'are recorded as a {self.graylist[assignment].__class__}') f'are recorded as a {self.graylist[assignment].__class__}')
for assignment in other.graylist: for assignment in other.graylist:
if isinstance(other.graylist[assignment], set): if isinstance(other.graylist[assignment], set):
your_past_partners.union(other.graylist[assignment]) your_past_partners.update(other.graylist[assignment])
elif isinstance(other.graylist[assignment], str): elif isinstance(other.graylist[assignment], str):
your_past_partners.add(str(other.graylist[assignment])) your_past_partners.add(str(other.graylist[assignment]))
else: else:
......
...@@ -140,9 +140,9 @@ def create_pairs(students: Set[CompositeUser], groupset_name: str = 'Unknown Ass ...@@ -140,9 +140,9 @@ def create_pairs(students: Set[CompositeUser], groupset_name: str = 'Unknown Ass
print('Next we shall assign partners to students with blacklists.') print('Next we shall assign partners to students with blacklists.')
else: else:
print('There are no students with blacklists.') print('There are no students with blacklists.')
for student in students_with_blacklist: # TODO: there's a bug here when students with blacklists make requests for student in students_with_blacklist:
if student in unassigned_students:
pair_number += 1 pair_number += 1
if student in unassigned_students: # TODO: can probably fix bug by putting ALL the code under this "if"
unassigned_students.remove(student) unassigned_students.remove(student)
potential_partner: CompositeUser = random.choice(tuple(unassigned_students)) potential_partner: CompositeUser = random.choice(tuple(unassigned_students))
while not (student.is_blacklist_compatible(potential_partner) and while not (student.is_blacklist_compatible(potential_partner) and
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment