-
Notifications
You must be signed in to change notification settings - Fork 0
/
ratings.py
113 lines (87 loc) · 3.84 KB
/
ratings.py
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
# Try and get professors to get their students to submit reviews
# For Courses: For big classes, have people pick best professor for a certain class (think Orgo)
# Who's the best professor to take for ...
# Highest rated classes in each subject/department
class Course(object):
"""
Course Class that keeps track of a Course's name, ID, when it was taught, and the professor who taught it
"""
def __init__(self, Course_Name,Course_ID, semester_taught, professor):
self.Course_Name = Course_Name
self.Course_ID = Course_ID
self.semester_taught = semester_taught
self.professor = professor
self.ratings = []
self.toughness = None
def add_rating(self, rating):
self.ratings.append(rating)
class Professor(object):
""" Professor Class stores information about the professor, including name,
college, department, courses they've taught, any and all ratings, and a link to the ND.edu page
Methods: 1. add_rating(rating)
Input: Professor Rating (type == TeacherRating)
2. add_course_taught(course)
Input: Course (type == Course)
"""
def __init__(self, name, college, department, page = None):
self.name = name
self.college = college
self.department = department
self.courses_taught = []
self.ratings = []
self.page = page
self.grading_rating = None
self.workload_rating = None
self.quality_rating = None
self.overall_rating = None
def add_rating(self, rating):
"""
Adds a rating to a professor and updates ratings
"""
self.ratings.append(rating)
self.update_ratings()
def add_course_taught(self, course):
self.courses_taught.append(course)
def get_grading(self):
"""
returns the grading rating of a professor
"""
return sum([rating.grading for rating in self.ratings]) / float(len(self.ratings))
def get_workload(self):
"""
returns the workload rating of a professor
"""
return sum([rating.workload for rating in self.ratings]) / float(len(self.ratings))
def get_quality(self):
"""
returns the quality rating of a professor
"""
return sum([rating.quality for rating in self.ratings]) / float(len(self.ratings))
def update_ratings(self):
"""
Updates professor ratings. Called by add_rating whenever a rating is added
"""
self.grading_rating = self.get_grading()
self.workload_rating = self.get_workload()
self.quality_rating = self.get_quality()
self.overall_rating = (self.quality_rating + self.grading_rating + self.workload_rating) / 3
class Rating(object):
def __init__(self, author, date, course, text = None):
self.author = author
self.date = date
self.course = course
self.text = text
class TeacherRating(Rating):
def __init__(self, author, date, course, grading,workload, quality, syllabus,accessibility, text = None):
super(TeacherRating, self).__init__(author,date,course, text)
self.grading = grading
self.workload = workload
self.quality = quality
self.syllabus = syllabus # 0 == throw syllabus out; 1 == syllabus is useful; 2 == syllabus is your lifeline
self.accessibility = accessibility
class CourseRating(Rating):
def __init__(self,author, date, course, toughness_rating,interest_rating, text = None):
super(CourseRating, self).__init__(author,date, course, text)
self.toughness_rating = toughness_rating
self.interest_rating = interest_rating
# Add something about breakdown for work (essays, tests, labs, homework, etc)