-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathStudent.py
More file actions
180 lines (144 loc) · 5.94 KB
/
Copy pathStudent.py
File metadata and controls
180 lines (144 loc) · 5.94 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
"""
Author(s): Brian Leeson + Jamie Zimmerman + Amie Corso
Student.py holds a class Student that serves as a way to store data in main memory. We created our own object type to hold information about each student, the most important information being their name, their meeting time freedom, and their programming language skill. Each instantiation represents a student in a CIS422 course. The information is gathered via a Google survey.
name
duckID -> specific to each student
codeExperience -> a dictionary mapping a particular language to approximate rated skill
availability -> dictionary mapping days to a list of zeros and ones, which correspond to the time slots 10:00-12:00, 12:00-2:00, 2:00-4:00, and 4:00-6:00
requests -> duckIDs of desired teammates
potential_teams -> a list of Team objects in which a student could belong on - these slowly disappear as the algorithm determines that the Team is unviable.
assignedTeam -> whichever Team the student ends up on
Notes for fellow/future developers:
Read the comments and docstrings - you don't need to know how the functions or methods work or what attribute methods serve for.
In general, this module has little to it besides attributes and getter/setter methods. It is mostly used as a container because no other data object served our purposes as well as building our own.
"""
class Student:
"""
This class will represent an individuals survey results
"""
def __init__(self, name, duckID):
self.name = name
self.duckID = duckID # Use this attribute as a unique identifier
self.codeExperience = {'Python': 0, 'Java': 0, 'Javascript': 0, 'C': 0, 'C++': 0, 'PHP': 0, 'HTML': 0, 'SQL': 0, 'Bash/Unix': 0}
self.availability = {'Monday': [], #values are list of 0s and 1s representing true availability for time slots
'Tuesday': [],
'Wednesday': [],
'Thursday': [],
'Friday': []}
self.time_list = [] #non-binary representation of available time, each entry is a string of the day and hours available
self.requests = [] # list of strings - duckIDs of desired teammates
self.potential_teams = [] # used during sorting process to keep track of which teams on which a student COULD appear
self.assignedTeam = None # keeps track during sorting process of which team a student is associated with
# final once the sorting process is complete
self.teammates = []
def sort_potential_teams(self):
self.potential_teams.sort()
self.potential_teams.reverse()
return None
def __str__(self):
return self.getName()
def __cmp__(self, other):
return self.getduckID() == other.getduckID()
def __lt__(self, other):
return len(self.potential_teams) < len(other.potential_teams)
def __le__(self, other):
return len(self.potential_teams) <= len(other.potential_teams)
def __gt__(self, other):
return len(self.potential_teams) > len(other.potential_teams)
def __ge__(self, other):
return len(self.potential_teams) >= len(other.potential_teams)
def getName(self):
return self.name
def setName(self, name):
self.name = name
return None
def getduckID(self):
return self.duckID
def setduckID(self, duckID):
self.duckID = duckID
return None
def setRequests(self, requests):
self.requests = requests
return None
def getRequests(self):
return self.requests
def getCodeExperience(self):
"""
output -> dictionary mapping languages to integer rating of skill
ex: dict = {'Python': 5 ... and so on}
"""
return self.codeExperience
def getLanguages(self):
'''
output -> list of student's proficient coding languages, i.e. self rated skill is 3 or higher
'''
languages = []
for language, skill in self.codeExperience.items():
if skill > 2:
languages.append(language)
return languages
def setCodeExperience(self, tool, capability):
"""
input -> tool - string of a coding lanugage i.e.: 'Python'
capability - string OR int that is integer rating of skill
this function sets the student's particular language skill to a rating, casting the rating to an int as a safety measure
"""
self.codeExperience[tool] = capability
return None
def getAvailability(self):
"""
output -> dictionary representation of student's availability chart
may want to add specifying parameters that narrow down for a certain day
"""
return self.availability
def setAvailability(self, graph):
"""
input -> graph is an entire dictionary representing the student's entire weeklong availability
"""
self.availability = graph
return None
def get_time_list(self):
return self.time_list
def add_to_time_list(self, daytime):
self.time_list.append(daytime)
return None
def setTeammates(self, buddies):
"""
input: buddies is a list of strings, the duck ID's of desired teammates
"""
self.teammates = buddies
return None
def addTeammate(self, buddy):
'''
input is a string, a singular duckID of one person requested
'''
self.teammates.append(buddy)
return None
def getTeammates(self):
return self.teammates
# -----------------------------------Sandbox Area -------------------------------------------------#
# This code here was used for testing purposes during initial development. It does not need to be saved.
if __name__ == '__main__':
student = Student('Brian', 'brian@brian.com')
student.setCodeExperience('Python', 5)
student.setCodeExperience('Java', 2)
student.setCodeExperience('Javascript', 4)
student.setCodeExperience('C', 3)
print(student.getLanguages())
student.add_to_time_list('Monday 12:00 - 2:00')
student.add_to_time_list('Monday 2:00 - 4:00')
print(student.get_time_list())
student.setCodeExperience('Python', 8)
print(student.getCodeExperience())
# testing availability attributes
print(student.getAvailability())
student.setAvailability('Thursday')
print(student.getAvailability())
student.setAvailability('Thursday')
print(student.getAvailability())
# testing requested teammates list
friend = Student('Jamie', 'jamie@yellow.edu')
student.setTeammates(friend)
#for s in student.getTeammates():
# print(s)
print(student)