-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathmodels.py
67 lines (57 loc) · 1.64 KB
/
models.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
from typing import Any, List, Optional
class QLCRequest:
def __init__(
self,
count: int,
fill: Optional[bool] = None,
types: Optional[List[str]] = None,
unique_types: Optional[bool] = None
):
self.count = count
self.fill = fill
self.types = types
self.unique_types = unique_types
def __repr__(self) -> str:
txt = [f'count={self.count}']
if self.fill:
txt.append('filled')
if self.types:
txt.append(f'types=[{", ".join(self.types)}]')
if self.unique_types:
txt.append('unique')
return f'<{" ".join(txt)}>'
class QLCOption:
def __init__(self, type: str, answer: Any, correct: bool = False, info: str = None):
self.type = type
self.answer = answer
self.correct = correct
self.info = info
def to_dict(self):
return {
'type': self.type,
'answer': self.answer,
'correct': self.correct,
'info': self.info,
}
def __repr__(self) -> str:
return f'{"*" if self.correct else " "} {self.answer}: {self.info} [{self.type}]'
class QLC:
def __init__(self, pos: int, type: str, question: str, options: List[QLCOption]):
self.pos = pos
self.type = type
self.question = question
self.options = options
def to_dict(self):
return {
'type': self.type,
'question': self.question,
'options': list(o.to_dict() for o in self.options),
}
def __repr__(self) -> str:
return '\n'.join([f'{self.question} [{self.type}]', *[str(o) for o in self.options]])
class QLCPrepared:
def __init__(self, pos: int, type: str):
self.pos = pos
self.type = type
def make(self) -> Optional[QLC]:
return None