-
Notifications
You must be signed in to change notification settings - Fork 0
/
utils.py
178 lines (140 loc) · 5.74 KB
/
utils.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
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
import random
import string
from captcha.image import ImageCaptcha
class Student:
def __init__(self, student):
self.fname = student[0]
self.minit = student[1]
self.lname = student[2]
self.AM = student[3]
self.username = student[4]
self.phone = student[5]
self.email = student[6]
self.admission_date = student[7]
self.kwd_kat = student[8]
def __str__(self):
return f'First name: {self.fname}\n' \
f'Middle initial: {self.minit}\n' \
f'Last name: {self.lname}\n' \
f'AM: {self.AM}\n' \
f'Username: {self.username}\n' \
f'Phone number: {self.phone}\n' \
f'Email address: {self.email}\n' \
f'Admission date: {self.admission_date}\n' \
f'Kwdikos kateuthinshs: {self.kwd_kat}\n'
def to_list(self):
return [self.fname, self.minit, self.lname, self.AM, self.username, self.phone, self.email,
self.admission_date, self.kwd_kat]
class Professor:
def __init__(self, professor):
self.fname = professor[0]
self.minit = professor[1]
self.lname = professor[2]
self.ID = professor[3]
self.username = professor[4]
self.phone = professor[5]
self.email = professor[6]
self.bathmida = professor[7]
def __str__(self):
return f'First name: {self.fname}\n' \
f'Middle initial: {self.minit}\n' \
f'Last name: {self.lname}\n' \
f'ID number: {self.ID}\n' \
f'Username: {self.username}\n' \
f'Phone number: {self.phone}\n' \
f'Email address: {self.email}\n' \
f'Academic rank: {self.bathmida}\n'
def to_list(self):
return [self.fname, self.minit, self.lname, self.ID, self.username, self.phone, self.email, self.bathmida]
class Course:
def __init__(self, mathima):
self.code = mathima[0]
self.title = mathima[1]
self.group = mathima[2]
self.ECTS = mathima[3]
self.credits = mathima[4]
self.weight = mathima[5]
self.semester = mathima[6]
def __str__(self):
return f'Course code: {self.code}\n' \
f'Title: {self.title}\n' \
f'Course group: {self.group}\n' \
f'ECTS: {self.ECTS}\n' \
f'Credits: {self.credits}\n' \
f'Weight: {self.weight}\n' \
f'Semester: {self.semester}\n'
def to_list(self):
return [self.code, self.title, self.group, self.ECTS, self.credits, self.weight, self.semester]
class StudentCourse:
def __init__(self, student, course, status):
self.student = student
self.course = course
self.status = status
def __str__(self):
return f'Student AM: {self.student.AM}\n' \
f'Course code: {self.course.code}\n' \
f'Course title: {self.course.title}\n' \
f'Status: {self.status}\n'
class ProfessorCourse:
def __init__(self, professor, course, activities):
self.professor = professor
self.course = course
self.activities = activities
def __str__(self):
string = f'Professor ID: {self.professor.ID}\n' \
f'Course code: {self.course.code}\n' \
f'Course title: {self.course.title}\n' \
for i, activity in enumerate(self.activities):
string += f'Activity {i+1}: {activity.title}\n'
return string
class Grade:
def __init__(self, mark, status):
self.mark = mark
self.status = status
def __str__(self):
return f'Grade mark: {self.mark}\n' \
f'Grade status: {self.status}\n'
class Activity:
def __init__(self, activity):
self.activity_code = activity[0]
self.course_code = activity[1]
self.professorID = activity[2]
self.title = activity[3]
self.weight = activity[4]
self.room = activity[5]
def __str__(self):
return f'Activity code: {self.activity_code}\n' \
f'Course code: {self.course_code}\n' \
f'Professor ID: {self.professorID}\n' \
f'Title: {self.title}\n' \
f'Weight: {self.weight}\n' \
f'Room: {self.room}\n'
def to_list(self):
return [self.activity_code, self.course_code, self.professorID, self.title, self.weight, self.room]
class FieldOfStudy:
def __init__(self, fos):
self.code = fos[0]
self.title = fos[1]
def __str__(self):
return f'Κωδικός Κατεύθυνσης: {self.code}\n' \
f'Τίτλος Κατεύθυνσης: {self.title}\n'
class Captcha:
def __init__(self, length):
self.length = length
self.string = Captcha.generate_captcha_string(self.length)
self.image = Captcha.generate_captcha_image(self.string)
@staticmethod
def generate_captcha_string(length: int):
return ''.join(random.choice(string.ascii_letters) for _ in range(length))
@staticmethod
def generate_captcha_image(string: str):
return ImageCaptcha().generate_image(string)
class Thesis:
def __init__(self, thesis):
self.code = thesis[0]
self.title = thesis[1]
self.professorID = thesis[2]
def __str__(self):
return f'Κωδικός Διπλωματικής: {self.code}\n' \
f'Τίτλος Διπλωματικης: {self.title}\n' \
f"ΑΤ Επιβλέπων Καθηγητή: {self.professorID}\n"