-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathenums.py
86 lines (62 loc) · 2.52 KB
/
enums.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
"""
Copyright (C) 2021 Borgo Daniele
This program is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program. If not, see <https://www.gnu.org/licenses/>.
"""
from enum import Enum
class Modifier(Enum):
"""
This enum is used to describes the different needs of students,
defining several types, according to the school decided.
"""
# This is the modifier for who needs more time
MORE_TIME = 1
# This is the modifier for who needs the permission to use notes
ALLOW_NOTES = 2
# This is the modifier for who needs optional questions
OPTIONAL_QUESTIONS = 3
# This is the modifier for increasing font size
BIGGER_FONT = 4
@staticmethod
def translate(string):
"""
This method translates a string representing the type in
an enum value.
"""
if 'more_time'.__eq__(string):
return Modifier.MORE_TIME
if 'allow_notes'.__eq__(string):
return Modifier.ALLOW_NOTES
if 'optional_questions'.__eq__(string):
return Modifier.OPTIONAL_QUESTIONS
if 'bigger_font'.__eq__(string):
return Modifier.BIGGER_FONT
raise Exception("Type " + string + " unknown.")
class QuestionType(Enum):
"""
This class is used to define different types of questions in term of
visualization in the final document.
"""
# This type describes a question represented by only a question, without adding extra space
NO_SPACED_QUESTION = 0
# This type defines a question with a space for the answer
SPACED_QUESTION = 1
@staticmethod
def translate_type(string):
"""
This method translates a string representing the type in
an enum value.
"""
if 'no_space_question'.__eq__(string):
return QuestionType.NO_SPACED_QUESTION
if 'spaced_question'.__eq__(string):
return QuestionType.SPACED_QUESTION
raise Exception("Type " + string + " unknown.")