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

Added multiton for CompositeUsers; added string representation code.

parent da38c3cf
Branches
No related tags found
No related merge requests found
......@@ -120,6 +120,9 @@ class GroupSet: # aka, group_category
groups.append(Group(canvas_group))
return groups
def __repr__(self):
return self.get_name()
"""
{
......@@ -187,6 +190,9 @@ class Group:
def add_student(self, user):
self.canvas_group.create_membership(user.get_canvas_id())
def __repr__(self):
return self.get_name()
"""
{
......@@ -289,6 +295,9 @@ class Course:
group_category = self.canvas_course.create_group_category(groupset_name)
return GroupSet(group_category)
def __repr__(self):
return f'{self.canvas_course.course_code}: {self.canvas_course.name}'
"""
{
......
......@@ -6,6 +6,8 @@ NO_PARTNERING_LIST_MAXIMUM = 10
class CompositeUser:
instances = {}
def __init__(self, student_dictionary, graylist, blacklist):
self.canvas_user = None
self.gitlab_user = None
......@@ -19,6 +21,10 @@ class CompositeUser:
self.graylist = set(graylist)
self.blacklist = set(blacklist)
self.candidate_teammates = None
CompositeUser.instances[self.canvas_email] = self
CompositeUser.instances[self.gitlab_email] = self
CompositeUser.instances[self.canvas_username] = self
CompositeUser.instances[self.gitlab_username] = self
def get_canvas_user(self):
if self.canvas_user is None:
......@@ -42,6 +48,16 @@ class CompositeUser:
def discard_team(self):
self.candidate_teammates = None
def __repr__(self):
if self.canvas_email == self.gitlab_email:
return f'{self.readable_name} <{self.canvas_email}>'
else:
return f'{self.readable_name} <{self.canvas_email}> <{self.gitlab_email}>'
@staticmethod
def get_user(username_or_email):
return CompositeUser.instances[username_or_email]
@staticmethod
def read_student_csv(filename):
students = set()
......@@ -83,16 +99,16 @@ class CompositeUser:
'GitlabEmail': student.gitlab_email}
count = 0
for former_partner in student.graylist:
student_dictionary.update({f'Graylist{count}': former_partner})
count += 1
while count < NO_PARTNERING_LIST_MAXIMUM:
student_dictionary.update({f'Graylist{count}': ''})
student_dictionary[f'Graylist{count}'] = former_partner
count += 1
# while count < NO_PARTNERING_LIST_MAXIMUM:
# student_dictionary.update({f'Graylist{count}': ''})
# count += 1
count = 0
for undesired_partner in student.blacklist:
student_dictionary.update({f'Blacklist{count}': undesired_partner})
count += 1
while count < NO_PARTNERING_LIST_MAXIMUM:
student_dictionary.update({f'Blacklist{count}': ''})
student_dictionary[f'Blacklist{count}'] = undesired_partner
count += 1
# while count < NO_PARTNERING_LIST_MAXIMUM:
# student_dictionary.update({f'Blacklist{count}': ''})
# count += 1
writer.writerow(student_dictionary)
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment