usos-api 0.4.0__tar.gz → 0.4.1__tar.gz
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- {usos_api-0.4.0 → usos_api-0.4.1}/PKG-INFO +1 -1
- {usos_api-0.4.0 → usos_api-0.4.1}/pyproject.toml +1 -1
- {usos_api-0.4.0 → usos_api-0.4.1}/usos_api/helper.py +1 -2
- {usos_api-0.4.0 → usos_api-0.4.1}/usos_api/models/__init__.py +48 -0
- usos_api-0.4.1/usos_api/models/exam_report.py +265 -0
- {usos_api-0.4.0 → usos_api-0.4.1}/usos_api/models/grade.py +18 -4
- usos_api-0.4.1/usos_api/models/usos_bool.py +18 -0
- {usos_api-0.4.0 → usos_api-0.4.1}/usos_api/services/exam_reports.py +145 -244
- {usos_api-0.4.0 → usos_api-0.4.1}/uv.lock +1 -1
- {usos_api-0.4.0 → usos_api-0.4.1}/.github/workflows/publish.yml +0 -0
- {usos_api-0.4.0 → usos_api-0.4.1}/.gitignore +0 -0
- {usos_api-0.4.0 → usos_api-0.4.1}/.readthedocs.yaml +0 -0
- {usos_api-0.4.0 → usos_api-0.4.1}/README.md +0 -0
- {usos_api-0.4.0 → usos_api-0.4.1}/docs/Makefile +0 -0
- {usos_api-0.4.0 → usos_api-0.4.1}/docs/conf.py +0 -0
- {usos_api-0.4.0 → usos_api-0.4.1}/docs/full-docs.rst +0 -0
- {usos_api-0.4.0 → usos_api-0.4.1}/docs/index.rst +0 -0
- {usos_api-0.4.0 → usos_api-0.4.1}/docs/make.bat +0 -0
- {usos_api-0.4.0 → usos_api-0.4.1}/docs/quickstart.rst +0 -0
- {usos_api-0.4.0 → usos_api-0.4.1}/run.py +0 -0
- {usos_api-0.4.0 → usos_api-0.4.1}/usos_api/__init__.py +0 -0
- {usos_api-0.4.0 → usos_api-0.4.1}/usos_api/auth.py +0 -0
- {usos_api-0.4.0 → usos_api-0.4.1}/usos_api/client.py +0 -0
- {usos_api-0.4.0 → usos_api-0.4.1}/usos_api/connection.py +0 -0
- {usos_api-0.4.0 → usos_api-0.4.1}/usos_api/exceptions.py +0 -0
- {usos_api-0.4.0 → usos_api-0.4.1}/usos_api/logger.py +0 -0
- {usos_api-0.4.0 → usos_api-0.4.1}/usos_api/models/api_documentation.py +0 -0
- {usos_api-0.4.0 → usos_api-0.4.1}/usos_api/models/consumer.py +0 -0
- {usos_api-0.4.0 → usos_api-0.4.1}/usos_api/models/course.py +0 -0
- {usos_api-0.4.0 → usos_api-0.4.1}/usos_api/models/group.py +0 -0
- {usos_api-0.4.0 → usos_api-0.4.1}/usos_api/models/lang_dict.py +0 -0
- {usos_api-0.4.0 → usos_api-0.4.1}/usos_api/models/programme.py +0 -0
- {usos_api-0.4.0 → usos_api-0.4.1}/usos_api/models/registration.py +0 -0
- {usos_api-0.4.0 → usos_api-0.4.1}/usos_api/models/term.py +0 -0
- {usos_api-0.4.0 → usos_api-0.4.1}/usos_api/models/user.py +0 -0
- {usos_api-0.4.0 → usos_api-0.4.1}/usos_api/services/__init__.py +0 -0
- {usos_api-0.4.0 → usos_api-0.4.1}/usos_api/services/api_documentation.py +0 -0
- {usos_api-0.4.0 → usos_api-0.4.1}/usos_api/services/api_server.py +0 -0
- {usos_api-0.4.0 → usos_api-0.4.1}/usos_api/services/courses.py +0 -0
- {usos_api-0.4.0 → usos_api-0.4.1}/usos_api/services/grades.py +0 -0
- {usos_api-0.4.0 → usos_api-0.4.1}/usos_api/services/groups.py +0 -0
- {usos_api-0.4.0 → usos_api-0.4.1}/usos_api/services/registrations.py +0 -0
- {usos_api-0.4.0 → usos_api-0.4.1}/usos_api/services/terms.py +0 -0
- {usos_api-0.4.0 → usos_api-0.4.1}/usos_api/services/users.py +0 -0
- {usos_api-0.4.0 → usos_api-0.4.1}/usos_api/utils/__init__.py +0 -0
|
@@ -1,8 +1,7 @@
|
|
|
1
1
|
from typing import TYPE_CHECKING, List
|
|
2
2
|
|
|
3
|
-
from usos_api.models import CourseEdition, Grade
|
|
3
|
+
from usos_api.models import CourseEdition, Grade, UserExamReportsByTerm
|
|
4
4
|
from usos_api.services.courses import CourseEctsByTerm
|
|
5
|
-
from usos_api.services.exam_reports import UserExamReportsByTerm
|
|
6
5
|
|
|
7
6
|
if TYPE_CHECKING:
|
|
8
7
|
from usos_api import USOSClient
|
|
@@ -16,6 +16,31 @@ from .course import (
|
|
|
16
16
|
CourseEditionConducted,
|
|
17
17
|
CourseUnit,
|
|
18
18
|
)
|
|
19
|
+
from .exam_report import (
|
|
20
|
+
ExamReport,
|
|
21
|
+
ExamReport2,
|
|
22
|
+
ExamReport2ClassGroup,
|
|
23
|
+
ExamReport2Session,
|
|
24
|
+
ExamReport2StudentGrade,
|
|
25
|
+
ExamReport2UserGrade,
|
|
26
|
+
ExamReportCourse,
|
|
27
|
+
ExamReportCourseUnit,
|
|
28
|
+
ExamReportGradeDistributionItem,
|
|
29
|
+
ExamReportIssuerGrade,
|
|
30
|
+
ExamReportSessionAccess,
|
|
31
|
+
ExamReportType,
|
|
32
|
+
ExternalObject,
|
|
33
|
+
ExamReportSession,
|
|
34
|
+
GradeType,
|
|
35
|
+
GradeValue,
|
|
36
|
+
LegacyCourseEditionExamReport,
|
|
37
|
+
LegacyUserExamReportsByTerm,
|
|
38
|
+
RawUserExamReportsByTerm,
|
|
39
|
+
UserExamReportsByTerm,
|
|
40
|
+
parse_legacy_course_edition_exam_report,
|
|
41
|
+
parse_legacy_user_exam_reports,
|
|
42
|
+
parse_user_exam_reports,
|
|
43
|
+
)
|
|
19
44
|
from .grade import Grade
|
|
20
45
|
from .group import Group
|
|
21
46
|
from .lang_dict import LangDict
|
|
@@ -72,9 +97,32 @@ __all__ = [
|
|
|
72
97
|
"Grade",
|
|
73
98
|
"Course",
|
|
74
99
|
"CourseEditionConducted",
|
|
100
|
+
"ExternalObject",
|
|
101
|
+
"ExamReport2",
|
|
102
|
+
"ExamReport2ClassGroup",
|
|
103
|
+
"ExamReport2Session",
|
|
104
|
+
"ExamReport2StudentGrade",
|
|
105
|
+
"ExamReport2UserGrade",
|
|
106
|
+
"ExamReport",
|
|
107
|
+
"ExamReportCourse",
|
|
108
|
+
"ExamReportCourseUnit",
|
|
109
|
+
"ExamReportGradeDistributionItem",
|
|
110
|
+
"ExamReportIssuerGrade",
|
|
111
|
+
"ExamReportSession",
|
|
112
|
+
"ExamReportSessionAccess",
|
|
113
|
+
"ExamReportType",
|
|
114
|
+
"GradeType",
|
|
115
|
+
"GradeValue",
|
|
75
116
|
"Term",
|
|
76
117
|
"Consumer",
|
|
77
118
|
"CourseUnit",
|
|
119
|
+
"UserExamReportsByTerm",
|
|
120
|
+
"RawUserExamReportsByTerm",
|
|
121
|
+
"LegacyUserExamReportsByTerm",
|
|
122
|
+
"LegacyCourseEditionExamReport",
|
|
123
|
+
"parse_user_exam_reports",
|
|
124
|
+
"parse_legacy_user_exam_reports",
|
|
125
|
+
"parse_legacy_course_edition_exam_report",
|
|
78
126
|
"AuthOptions",
|
|
79
127
|
"Argument",
|
|
80
128
|
"ResultField",
|
|
@@ -0,0 +1,265 @@
|
|
|
1
|
+
from datetime import datetime
|
|
2
|
+
from typing import Any, Mapping, TypeAlias
|
|
3
|
+
|
|
4
|
+
from pydantic import BaseModel, ConfigDict, field_validator
|
|
5
|
+
|
|
6
|
+
from .lang_dict import LangDict
|
|
7
|
+
from .usos_bool import USOSBool
|
|
8
|
+
from .user import User
|
|
9
|
+
|
|
10
|
+
|
|
11
|
+
class ExternalObject(BaseModel):
|
|
12
|
+
model_config = ConfigDict(extra="allow")
|
|
13
|
+
|
|
14
|
+
id: str | int | None = None
|
|
15
|
+
name: LangDict | str | None = None
|
|
16
|
+
|
|
17
|
+
|
|
18
|
+
class GradeValue(BaseModel):
|
|
19
|
+
grade_type: ExternalObject | None = None
|
|
20
|
+
order_key: str | int | None = None
|
|
21
|
+
symbol: str | None = None
|
|
22
|
+
passes: USOSBool | None = None
|
|
23
|
+
decimal_value: float | None = None
|
|
24
|
+
name: LangDict | None = None
|
|
25
|
+
|
|
26
|
+
|
|
27
|
+
class GradeType(BaseModel):
|
|
28
|
+
id: str | None = None
|
|
29
|
+
name: LangDict | None = None
|
|
30
|
+
values: list[GradeValue] | None = None
|
|
31
|
+
|
|
32
|
+
|
|
33
|
+
class ExamReportType(BaseModel):
|
|
34
|
+
id: str | None = None
|
|
35
|
+
name: LangDict | None = None
|
|
36
|
+
grade_type: GradeType | None = None
|
|
37
|
+
|
|
38
|
+
|
|
39
|
+
class ExamReport2StudentGrade(BaseModel):
|
|
40
|
+
grade_value: GradeValue | None = None
|
|
41
|
+
comment: str | None = None
|
|
42
|
+
private_comment: str | None = None
|
|
43
|
+
user: ExternalObject | None = None
|
|
44
|
+
grader: ExternalObject | None = None
|
|
45
|
+
last_updated: datetime | None = None
|
|
46
|
+
is_editable: USOSBool | None = None
|
|
47
|
+
resignation: USOSBool | None = None
|
|
48
|
+
inactive_links: USOSBool | None = None
|
|
49
|
+
why_cannot_edit: str | None = None
|
|
50
|
+
date_acquisition: datetime | None = None
|
|
51
|
+
examrep_session: ExternalObject | None = None
|
|
52
|
+
|
|
53
|
+
|
|
54
|
+
class ExamReport2UserGrade(BaseModel):
|
|
55
|
+
grade_value: GradeValue | None = None
|
|
56
|
+
comment: str | None = None
|
|
57
|
+
user: ExternalObject | None = None
|
|
58
|
+
grader: ExternalObject | None = None
|
|
59
|
+
last_updated: datetime | None = None
|
|
60
|
+
|
|
61
|
+
|
|
62
|
+
def grades_by_user(value: Any) -> dict[str, ExamReport2StudentGrade] | None:
|
|
63
|
+
if value is None or isinstance(value, dict):
|
|
64
|
+
return value
|
|
65
|
+
if isinstance(value, list):
|
|
66
|
+
parsed_grades: dict[str, ExamReport2StudentGrade] = {}
|
|
67
|
+
for index, raw_grade in enumerate(value):
|
|
68
|
+
grade = ExamReport2StudentGrade.model_validate(raw_grade)
|
|
69
|
+
user_id = grade.user.id if grade.user is not None else None
|
|
70
|
+
parsed_grades[str(user_id if user_id is not None else index)] = grade
|
|
71
|
+
return parsed_grades
|
|
72
|
+
raise ValueError("Expected grade dictionary, grade list or None.")
|
|
73
|
+
|
|
74
|
+
|
|
75
|
+
class ExamReport2Session(BaseModel):
|
|
76
|
+
examrep_id: str | int | None = None
|
|
77
|
+
number: int | None = None
|
|
78
|
+
status: str | None = None
|
|
79
|
+
description: LangDict | None = None
|
|
80
|
+
deadline: datetime | None = None
|
|
81
|
+
is_open: USOSBool | None = None
|
|
82
|
+
is_acquisition_date_required: USOSBool | None = None
|
|
83
|
+
all_grades: dict[str, ExamReport2StudentGrade] | None = None
|
|
84
|
+
issuer_grade: ExamReport2UserGrade | None = None
|
|
85
|
+
read_access: list[ExternalObject] | None = None
|
|
86
|
+
write_access: list[ExternalObject] | None = None
|
|
87
|
+
|
|
88
|
+
@field_validator("all_grades", mode="before")
|
|
89
|
+
@classmethod
|
|
90
|
+
def _parse_all_grades(
|
|
91
|
+
cls, value: Any
|
|
92
|
+
) -> dict[str, ExamReport2StudentGrade] | None:
|
|
93
|
+
return grades_by_user(value)
|
|
94
|
+
|
|
95
|
+
|
|
96
|
+
class ExamReport2(BaseModel):
|
|
97
|
+
id: str | int | None = None
|
|
98
|
+
description: LangDict | None = None
|
|
99
|
+
counts_into_average: USOSBool | None = None
|
|
100
|
+
grade_type: GradeType | None = None
|
|
101
|
+
is_general_report: USOSBool | None = None
|
|
102
|
+
sessions: list[ExamReport2Session] | None = None
|
|
103
|
+
edit_access: list[ExternalObject] | None = None
|
|
104
|
+
course_edition: ExternalObject | None = None
|
|
105
|
+
course_unit: ExternalObject | None = None
|
|
106
|
+
active_sessions: list[ExamReport2Session] | None = None
|
|
107
|
+
|
|
108
|
+
|
|
109
|
+
class ExamReportSessionAccess(BaseModel):
|
|
110
|
+
cause: str | None = None
|
|
111
|
+
groups: list[ExternalObject] | None = None
|
|
112
|
+
exam_groups: list[ExternalObject] | None = None
|
|
113
|
+
unassigned: USOSBool | None = None
|
|
114
|
+
|
|
115
|
+
|
|
116
|
+
class ExamReport2ClassGroup(BaseModel):
|
|
117
|
+
class_group: ExternalObject | None = None
|
|
118
|
+
grades: dict[str, ExamReport2StudentGrade] | None = None
|
|
119
|
+
|
|
120
|
+
@field_validator("grades", mode="before")
|
|
121
|
+
@classmethod
|
|
122
|
+
def _parse_grades(cls, value: Any) -> dict[str, ExamReport2StudentGrade] | None:
|
|
123
|
+
return grades_by_user(value)
|
|
124
|
+
|
|
125
|
+
|
|
126
|
+
class ExamReportCourse(BaseModel):
|
|
127
|
+
id: str | None = None
|
|
128
|
+
name: LangDict | None = None
|
|
129
|
+
|
|
130
|
+
|
|
131
|
+
class ExamReportCourseUnit(BaseModel):
|
|
132
|
+
id: str | None = None
|
|
133
|
+
course_id: str | None = None
|
|
134
|
+
course_name: LangDict | None = None
|
|
135
|
+
classtype_id: str | None = None
|
|
136
|
+
term_id: str | None = None
|
|
137
|
+
|
|
138
|
+
|
|
139
|
+
class ExamReportGradeDistributionItem(BaseModel):
|
|
140
|
+
grade_symbol: str | None = None
|
|
141
|
+
percentage: float | None = None
|
|
142
|
+
|
|
143
|
+
|
|
144
|
+
class ExamReportIssuerGrade(BaseModel):
|
|
145
|
+
value_symbol: str | None = None
|
|
146
|
+
passes: USOSBool | None = None
|
|
147
|
+
value_description: LangDict | None = None
|
|
148
|
+
exam_id: str | int | None = None
|
|
149
|
+
exam_session_number: int | None = None
|
|
150
|
+
counts_into_average: USOSBool | None = None
|
|
151
|
+
comment: str | None = None
|
|
152
|
+
private_comment: str | None = None
|
|
153
|
+
grade_type_id: str | None = None
|
|
154
|
+
date_modified: datetime | None = None
|
|
155
|
+
date_acquisition: datetime | None = None
|
|
156
|
+
modification_author: User | None = None
|
|
157
|
+
|
|
158
|
+
@field_validator("modification_author", mode="before")
|
|
159
|
+
@classmethod
|
|
160
|
+
def _parse_modification_author(cls, value: Any) -> User | None:
|
|
161
|
+
if value is None or isinstance(value, User):
|
|
162
|
+
return value
|
|
163
|
+
if isinstance(value, dict):
|
|
164
|
+
return User.model_validate(value)
|
|
165
|
+
if isinstance(value, str | int):
|
|
166
|
+
return User(id=value)
|
|
167
|
+
raise ValueError("Expected user object, user id or None.")
|
|
168
|
+
|
|
169
|
+
|
|
170
|
+
class ExamReportSession(BaseModel):
|
|
171
|
+
number: int | None = None
|
|
172
|
+
examrep_id: str | int | None = None
|
|
173
|
+
status: str | None = None
|
|
174
|
+
description: LangDict | None = None
|
|
175
|
+
deadline: datetime | None = None
|
|
176
|
+
is_editable: USOSBool | None = None
|
|
177
|
+
issuer_grades: list[ExamReportIssuerGrade] | None = None
|
|
178
|
+
|
|
179
|
+
@field_validator("issuer_grades", mode="before")
|
|
180
|
+
@classmethod
|
|
181
|
+
def _parse_issuer_grades(cls, value: Any) -> list[Any] | None:
|
|
182
|
+
if value is None or isinstance(value, list):
|
|
183
|
+
return value
|
|
184
|
+
if isinstance(value, dict):
|
|
185
|
+
return [value]
|
|
186
|
+
raise ValueError("Expected issuer grade object, issuer grade list or None.")
|
|
187
|
+
|
|
188
|
+
|
|
189
|
+
class ExamReport(BaseModel):
|
|
190
|
+
id: str | int | None = None
|
|
191
|
+
description: LangDict | None = None
|
|
192
|
+
type_id: str | None = None
|
|
193
|
+
type_description: LangDict | None = None
|
|
194
|
+
counts_into_average: USOSBool | None = None
|
|
195
|
+
term_id: str | None = None
|
|
196
|
+
is_editable: USOSBool | None = None
|
|
197
|
+
course_unit: ExamReportCourseUnit | None = None
|
|
198
|
+
course: ExamReportCourse | None = None
|
|
199
|
+
sessions: list[ExamReportSession] | None = None
|
|
200
|
+
grades_distribution: list[ExamReportGradeDistributionItem] | None = None
|
|
201
|
+
|
|
202
|
+
|
|
203
|
+
UserExamReportsByTerm: TypeAlias = dict[str, dict[str, list[ExamReport]]]
|
|
204
|
+
RawUserExamReportsByTerm: TypeAlias = dict[str, dict[str, list[dict[str, Any]]]]
|
|
205
|
+
LegacyUserExamReportsByTerm: TypeAlias = dict[
|
|
206
|
+
str, dict[str, dict[str, list[ExamReport]]]
|
|
207
|
+
]
|
|
208
|
+
LegacyCourseEditionExamReport: TypeAlias = dict[
|
|
209
|
+
str, ExamReport | list[ExamReport] | dict[str, list[ExamReport]] | None
|
|
210
|
+
]
|
|
211
|
+
|
|
212
|
+
|
|
213
|
+
def parse_user_exam_reports(
|
|
214
|
+
reports_by_term: Mapping[str, Mapping[str, list[Mapping[str, Any]]]],
|
|
215
|
+
) -> UserExamReportsByTerm:
|
|
216
|
+
return {
|
|
217
|
+
term_id: {
|
|
218
|
+
course_id: [ExamReport.model_validate(report) for report in reports]
|
|
219
|
+
for course_id, reports in courses.items()
|
|
220
|
+
}
|
|
221
|
+
for term_id, courses in reports_by_term.items()
|
|
222
|
+
}
|
|
223
|
+
|
|
224
|
+
|
|
225
|
+
def parse_legacy_user_exam_reports(
|
|
226
|
+
reports_by_term: Mapping[
|
|
227
|
+
str, Mapping[str, Mapping[str, list[Mapping[str, Any]]]]
|
|
228
|
+
],
|
|
229
|
+
) -> LegacyUserExamReportsByTerm:
|
|
230
|
+
return {
|
|
231
|
+
term_id: {
|
|
232
|
+
course_id: {
|
|
233
|
+
group_id: [ExamReport.model_validate(report) for report in reports]
|
|
234
|
+
for group_id, reports in groups.items()
|
|
235
|
+
}
|
|
236
|
+
for course_id, groups in courses.items()
|
|
237
|
+
}
|
|
238
|
+
for term_id, courses in reports_by_term.items()
|
|
239
|
+
}
|
|
240
|
+
|
|
241
|
+
|
|
242
|
+
def parse_legacy_course_edition_exam_report(
|
|
243
|
+
exam_report_data: Mapping[str, Any],
|
|
244
|
+
) -> LegacyCourseEditionExamReport:
|
|
245
|
+
return {
|
|
246
|
+
key: _parse_legacy_course_edition_value(value)
|
|
247
|
+
for key, value in exam_report_data.items()
|
|
248
|
+
}
|
|
249
|
+
|
|
250
|
+
|
|
251
|
+
def _parse_legacy_course_edition_value(
|
|
252
|
+
value: Any,
|
|
253
|
+
) -> ExamReport | list[ExamReport] | dict[str, list[ExamReport]] | None:
|
|
254
|
+
if value is None:
|
|
255
|
+
return None
|
|
256
|
+
if isinstance(value, list):
|
|
257
|
+
return [ExamReport.model_validate(report) for report in value]
|
|
258
|
+
if isinstance(value, dict):
|
|
259
|
+
if all(isinstance(reports, list) for reports in value.values()):
|
|
260
|
+
return {
|
|
261
|
+
group_id: [ExamReport.model_validate(report) for report in reports]
|
|
262
|
+
for group_id, reports in value.items()
|
|
263
|
+
}
|
|
264
|
+
return ExamReport.model_validate(value)
|
|
265
|
+
raise ValueError("Expected exam report object, exam report list, mapping or None.")
|
|
@@ -1,10 +1,11 @@
|
|
|
1
1
|
from datetime import datetime
|
|
2
2
|
from typing import TYPE_CHECKING, Any, Optional
|
|
3
3
|
|
|
4
|
-
from pydantic import BaseModel
|
|
4
|
+
from pydantic import BaseModel, field_validator
|
|
5
5
|
|
|
6
6
|
from . import CourseEdition
|
|
7
7
|
from .course import CourseUnit
|
|
8
|
+
from .usos_bool import USOSBool
|
|
8
9
|
|
|
9
10
|
if TYPE_CHECKING:
|
|
10
11
|
from .user import User
|
|
@@ -15,17 +16,17 @@ from .lang_dict import LangDict
|
|
|
15
16
|
class Grade(BaseModel):
|
|
16
17
|
value: float | None = None
|
|
17
18
|
value_symbol: str | None = None
|
|
18
|
-
passes:
|
|
19
|
+
passes: USOSBool | None = None
|
|
19
20
|
value_description: LangDict | None = None
|
|
20
21
|
exam_id: int | None = None
|
|
21
22
|
exam_session_number: int | None = None
|
|
22
|
-
counts_into_average:
|
|
23
|
+
counts_into_average: USOSBool | None = None
|
|
23
24
|
comment: str | None = None
|
|
24
25
|
private_comment: str | None = None
|
|
25
26
|
grade_type_id: str | None = None
|
|
26
27
|
date_modified: datetime | None = None
|
|
27
28
|
date_acquisition: datetime | None = None
|
|
28
|
-
modification_author:
|
|
29
|
+
modification_author: Optional["User"] = None
|
|
29
30
|
course_edition: CourseEdition | None = None
|
|
30
31
|
unit: CourseUnit | None = None
|
|
31
32
|
exam_report: dict[str, Any] | None = None
|
|
@@ -41,3 +42,16 @@ class Grade(BaseModel):
|
|
|
41
42
|
self.value = float(self.value_symbol.replace(",", "."))
|
|
42
43
|
except ValueError:
|
|
43
44
|
pass # Invalid value, ignore it
|
|
45
|
+
|
|
46
|
+
@field_validator("modification_author", mode="before")
|
|
47
|
+
@classmethod
|
|
48
|
+
def _parse_modification_author(cls, value: Any) -> Optional["User"]:
|
|
49
|
+
from .user import User
|
|
50
|
+
|
|
51
|
+
if value is None or isinstance(value, User):
|
|
52
|
+
return value
|
|
53
|
+
if isinstance(value, dict):
|
|
54
|
+
return User.model_validate(value)
|
|
55
|
+
if isinstance(value, str | int):
|
|
56
|
+
return User(id=value)
|
|
57
|
+
raise ValueError("Expected user object, user id or None.")
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
from typing import Annotated, Any
|
|
2
|
+
|
|
3
|
+
from pydantic import BeforeValidator
|
|
4
|
+
|
|
5
|
+
|
|
6
|
+
def usos_bool(value: Any) -> Any:
|
|
7
|
+
if value is None or isinstance(value, bool):
|
|
8
|
+
return value
|
|
9
|
+
if isinstance(value, str):
|
|
10
|
+
normalized = value.strip().upper()
|
|
11
|
+
if normalized == "T":
|
|
12
|
+
return True
|
|
13
|
+
if normalized == "N":
|
|
14
|
+
return False
|
|
15
|
+
return value
|
|
16
|
+
|
|
17
|
+
|
|
18
|
+
USOSBool = Annotated[bool, BeforeValidator(usos_bool)]
|
|
@@ -1,166 +1,31 @@
|
|
|
1
1
|
from datetime import date, datetime
|
|
2
|
-
from typing import TypeAlias
|
|
2
|
+
from typing import TypeAlias
|
|
3
3
|
|
|
4
4
|
from ..connection import USOSAPIConnection
|
|
5
|
+
from ..models.exam_report import (
|
|
6
|
+
ExamReport,
|
|
7
|
+
ExamReport2,
|
|
8
|
+
ExamReport2ClassGroup,
|
|
9
|
+
ExamReport2Session,
|
|
10
|
+
ExamReport2StudentGrade,
|
|
11
|
+
ExamReport2UserGrade,
|
|
12
|
+
ExamReportSession,
|
|
13
|
+
ExamReportSessionAccess,
|
|
14
|
+
ExamReportType,
|
|
15
|
+
GradeType,
|
|
16
|
+
GradeValue,
|
|
17
|
+
LegacyCourseEditionExamReport,
|
|
18
|
+
LegacyUserExamReportsByTerm,
|
|
19
|
+
RawUserExamReportsByTerm,
|
|
20
|
+
UserExamReportsByTerm,
|
|
21
|
+
parse_legacy_course_edition_exam_report,
|
|
22
|
+
parse_legacy_user_exam_reports,
|
|
23
|
+
parse_user_exam_reports,
|
|
24
|
+
)
|
|
5
25
|
|
|
6
|
-
ExternalObject: TypeAlias = dict[str, object]
|
|
7
26
|
EmptyResponse: TypeAlias = dict[str, object]
|
|
8
27
|
|
|
9
28
|
|
|
10
|
-
class LangDictData(TypedDict, total=False):
|
|
11
|
-
pl: str | None
|
|
12
|
-
en: str | None
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
class GradeValue(TypedDict, total=False):
|
|
16
|
-
grade_type: ExternalObject
|
|
17
|
-
order_key: str | int
|
|
18
|
-
symbol: str
|
|
19
|
-
passes: bool
|
|
20
|
-
decimal_value: float | None
|
|
21
|
-
name: LangDictData
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
class GradeType(TypedDict, total=False):
|
|
25
|
-
id: str
|
|
26
|
-
name: LangDictData
|
|
27
|
-
values: list[GradeValue]
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
class ExamReportType(TypedDict, total=False):
|
|
31
|
-
id: str
|
|
32
|
-
name: LangDictData
|
|
33
|
-
grade_type: GradeType
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
class ExamReport2StudentGrade(TypedDict, total=False):
|
|
37
|
-
grade_value: GradeValue | None
|
|
38
|
-
comment: str | None
|
|
39
|
-
private_comment: str | None
|
|
40
|
-
user: ExternalObject
|
|
41
|
-
grader: ExternalObject
|
|
42
|
-
last_updated: str | None
|
|
43
|
-
is_editable: bool
|
|
44
|
-
resignation: bool
|
|
45
|
-
inactive_links: bool
|
|
46
|
-
why_cannot_edit: str | None
|
|
47
|
-
date_acquisition: str | None
|
|
48
|
-
examrep_session: ExternalObject
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
class ExamReport2UserGrade(TypedDict, total=False):
|
|
52
|
-
grade_value: GradeValue | None
|
|
53
|
-
comment: str | None
|
|
54
|
-
user: ExternalObject
|
|
55
|
-
grader: ExternalObject
|
|
56
|
-
last_updated: str | None
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
class ExamReport2Session(TypedDict, total=False):
|
|
60
|
-
examrep_id: str | int
|
|
61
|
-
number: int
|
|
62
|
-
status: str
|
|
63
|
-
description: LangDictData
|
|
64
|
-
deadline: str | None
|
|
65
|
-
is_open: bool
|
|
66
|
-
is_acquisition_date_required: bool
|
|
67
|
-
all_grades: dict[str, ExamReport2StudentGrade]
|
|
68
|
-
issuer_grade: ExamReport2UserGrade
|
|
69
|
-
read_access: list[ExternalObject]
|
|
70
|
-
write_access: list[ExternalObject]
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
class ExamReport2(TypedDict, total=False):
|
|
74
|
-
id: str | int
|
|
75
|
-
description: LangDictData
|
|
76
|
-
counts_into_average: bool
|
|
77
|
-
grade_type: GradeType
|
|
78
|
-
is_general_report: bool
|
|
79
|
-
sessions: list[ExamReport2Session]
|
|
80
|
-
edit_access: list[ExternalObject]
|
|
81
|
-
course_edition: ExternalObject
|
|
82
|
-
course_unit: ExternalObject
|
|
83
|
-
active_sessions: list[ExamReport2Session]
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
class ExamReportSessionAccess(TypedDict, total=False):
|
|
87
|
-
cause: str | None
|
|
88
|
-
groups: list[ExternalObject]
|
|
89
|
-
exam_groups: list[ExternalObject]
|
|
90
|
-
unassigned: list[ExternalObject]
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
class ExamReport2ClassGroup(TypedDict, total=False):
|
|
94
|
-
class_group: ExternalObject
|
|
95
|
-
grades: dict[str, ExamReport2StudentGrade]
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
class ExamReportCourse(TypedDict, total=False):
|
|
99
|
-
id: str
|
|
100
|
-
name: LangDictData
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
class ExamReportCourseUnit(TypedDict, total=False):
|
|
104
|
-
id: str
|
|
105
|
-
course_id: str
|
|
106
|
-
course_name: LangDictData
|
|
107
|
-
classtype_id: str | None
|
|
108
|
-
term_id: str
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
class ExamReportGradeDistributionItem(TypedDict, total=False):
|
|
112
|
-
grade_symbol: str
|
|
113
|
-
percentage: float
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
class ExamReportIssuerGrade(TypedDict, total=False):
|
|
117
|
-
value_symbol: str | None
|
|
118
|
-
passes: bool
|
|
119
|
-
value_description: LangDictData
|
|
120
|
-
exam_id: str | int
|
|
121
|
-
exam_session_number: int
|
|
122
|
-
counts_into_average: bool
|
|
123
|
-
comment: str | None
|
|
124
|
-
private_comment: str | None
|
|
125
|
-
grade_type_id: str
|
|
126
|
-
date_modified: str | None
|
|
127
|
-
date_acquisition: str | None
|
|
128
|
-
modification_author: str | int | None
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
class ExamReportSession(TypedDict, total=False):
|
|
132
|
-
number: int
|
|
133
|
-
examrep_id: str | int
|
|
134
|
-
status: str
|
|
135
|
-
description: LangDictData
|
|
136
|
-
deadline: str | None
|
|
137
|
-
is_editable: bool
|
|
138
|
-
issuer_grades: ExamReportIssuerGrade | list[ExamReportIssuerGrade]
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
class ExamReport(TypedDict, total=False):
|
|
142
|
-
id: str | int
|
|
143
|
-
description: LangDictData
|
|
144
|
-
type_id: str
|
|
145
|
-
type_description: LangDictData
|
|
146
|
-
counts_into_average: bool
|
|
147
|
-
term_id: str
|
|
148
|
-
is_editable: bool
|
|
149
|
-
course_unit: ExamReportCourseUnit | None
|
|
150
|
-
course: ExamReportCourse
|
|
151
|
-
sessions: list[ExamReportSession]
|
|
152
|
-
grades_distribution: list[ExamReportGradeDistributionItem]
|
|
153
|
-
|
|
154
|
-
|
|
155
|
-
UserExamReportsByTerm: TypeAlias = dict[str, dict[str, list[ExamReport]]]
|
|
156
|
-
LegacyUserExamReportsByTerm: TypeAlias = dict[
|
|
157
|
-
str, dict[str, dict[str, list[ExamReport]]]
|
|
158
|
-
]
|
|
159
|
-
LegacyCourseEditionExamReport: TypeAlias = dict[
|
|
160
|
-
str, ExamReport | list[ExamReport] | dict[str, list[ExamReport]] | None
|
|
161
|
-
]
|
|
162
|
-
|
|
163
|
-
|
|
164
29
|
def _join_fields(fields: list[str] | str | None) -> str | None:
|
|
165
30
|
if isinstance(fields, list):
|
|
166
31
|
return "|".join(fields)
|
|
@@ -185,11 +50,11 @@ class ExamReportService:
|
|
|
185
50
|
self.connection = connection
|
|
186
51
|
|
|
187
52
|
async def get_class_group(
|
|
188
|
-
|
|
189
|
-
|
|
190
|
-
|
|
191
|
-
|
|
192
|
-
|
|
53
|
+
self,
|
|
54
|
+
examrep_id: str | int,
|
|
55
|
+
course_unit_id: str,
|
|
56
|
+
group_number: str | int,
|
|
57
|
+
fields: list[str] | str,
|
|
193
58
|
) -> ExamReport2ClassGroup:
|
|
194
59
|
"""
|
|
195
60
|
Get class group and grades in given group for given exam report.
|
|
@@ -200,18 +65,19 @@ class ExamReportService:
|
|
|
200
65
|
:param fields: Selector of result fields you are interested in.
|
|
201
66
|
:return: A dictionary of selected fields and their values.
|
|
202
67
|
"""
|
|
203
|
-
|
|
68
|
+
response = await self.connection.post(
|
|
204
69
|
"services/examrep2/class_group",
|
|
205
70
|
examrep_id=examrep_id,
|
|
206
71
|
course_unit_id=course_unit_id,
|
|
207
72
|
group_number=group_number,
|
|
208
73
|
fields=_join_fields(fields),
|
|
209
74
|
)
|
|
75
|
+
return ExamReport2ClassGroup.model_validate(response)
|
|
210
76
|
|
|
211
77
|
async def get_examinee_exam_reports(
|
|
212
|
-
|
|
213
|
-
|
|
214
|
-
|
|
78
|
+
self,
|
|
79
|
+
user_id: str | int,
|
|
80
|
+
fields: list[str] | str | None = None,
|
|
215
81
|
) -> list[ExamReport2]:
|
|
216
82
|
"""
|
|
217
83
|
Get exam reports that allow the access token issuer to update a student's grades.
|
|
@@ -220,16 +86,17 @@ class ExamReportService:
|
|
|
220
86
|
:param fields: Selector of result fields you are interested in.
|
|
221
87
|
:return: List of exam report objects.
|
|
222
88
|
"""
|
|
223
|
-
|
|
89
|
+
response = await self.connection.post(
|
|
224
90
|
"services/examrep2/examinee",
|
|
225
91
|
user_id=user_id,
|
|
226
92
|
fields=_join_fields(fields),
|
|
227
93
|
)
|
|
94
|
+
return [ExamReport2.model_validate(report) for report in response]
|
|
228
95
|
|
|
229
96
|
async def get_exam_report(
|
|
230
|
-
|
|
231
|
-
|
|
232
|
-
|
|
97
|
+
self,
|
|
98
|
+
examrep_id: str | int,
|
|
99
|
+
fields: list[str] | str | None = None,
|
|
233
100
|
) -> ExamReport2:
|
|
234
101
|
"""
|
|
235
102
|
Get information about an exam report.
|
|
@@ -238,17 +105,18 @@ class ExamReportService:
|
|
|
238
105
|
:param fields: Selector of result fields you are interested in.
|
|
239
106
|
:return: A dictionary of selected fields and their values.
|
|
240
107
|
"""
|
|
241
|
-
|
|
108
|
+
response = await self.connection.post(
|
|
242
109
|
"services/examrep2/examrep",
|
|
243
110
|
examrep_id=examrep_id,
|
|
244
111
|
fields=_join_fields(fields),
|
|
245
112
|
)
|
|
113
|
+
return ExamReport2.model_validate(response)
|
|
246
114
|
|
|
247
115
|
async def get_exam_report_session(
|
|
248
|
-
|
|
249
|
-
|
|
250
|
-
|
|
251
|
-
|
|
116
|
+
self,
|
|
117
|
+
examrep_id: str | int,
|
|
118
|
+
examrep_session_number: str | int,
|
|
119
|
+
fields: list[str] | str | None = None,
|
|
252
120
|
) -> ExamReport2Session:
|
|
253
121
|
"""
|
|
254
122
|
Get information about an exam report session.
|
|
@@ -258,19 +126,20 @@ class ExamReportService:
|
|
|
258
126
|
:param fields: Selector of result fields you are interested in.
|
|
259
127
|
:return: A dictionary of selected fields and their values.
|
|
260
128
|
"""
|
|
261
|
-
|
|
129
|
+
response = await self.connection.post(
|
|
262
130
|
"services/examrep2/examrep_session",
|
|
263
131
|
examrep_id=examrep_id,
|
|
264
132
|
examrep_session_number=examrep_session_number,
|
|
265
133
|
fields=_join_fields(fields),
|
|
266
134
|
)
|
|
135
|
+
return ExamReport2Session.model_validate(response)
|
|
267
136
|
|
|
268
137
|
async def get_exam_report_session_access(
|
|
269
|
-
|
|
270
|
-
|
|
271
|
-
|
|
272
|
-
|
|
273
|
-
|
|
138
|
+
self,
|
|
139
|
+
examrep_id: str | int,
|
|
140
|
+
examrep_session_number: str | int,
|
|
141
|
+
access_type: str,
|
|
142
|
+
fields: list[str] | str | None = None,
|
|
274
143
|
) -> list[ExamReportSessionAccess]:
|
|
275
144
|
"""
|
|
276
145
|
Get access information for an exam report session.
|
|
@@ -281,18 +150,19 @@ class ExamReportService:
|
|
|
281
150
|
:param fields: Selector of result fields you are interested in.
|
|
282
151
|
:return: A dictionary of selected fields and their values.
|
|
283
152
|
"""
|
|
284
|
-
|
|
153
|
+
response = await self.connection.post(
|
|
285
154
|
"services/examrep2/examrep_session_access",
|
|
286
155
|
examrep_id=examrep_id,
|
|
287
156
|
examrep_session_number=examrep_session_number,
|
|
288
157
|
type=access_type,
|
|
289
158
|
fields=_join_fields(fields),
|
|
290
159
|
)
|
|
160
|
+
return [ExamReportSessionAccess.model_validate(access) for access in response]
|
|
291
161
|
|
|
292
162
|
async def get_exam_report_type(
|
|
293
|
-
|
|
294
|
-
|
|
295
|
-
|
|
163
|
+
self,
|
|
164
|
+
examrep_type_id: str | int,
|
|
165
|
+
fields: list[str] | str | None = None,
|
|
296
166
|
) -> ExamReportType:
|
|
297
167
|
"""
|
|
298
168
|
Get information about an exam report type.
|
|
@@ -301,16 +171,17 @@ class ExamReportService:
|
|
|
301
171
|
:param fields: Selector of result fields you are interested in.
|
|
302
172
|
:return: A dictionary of selected fields and their values.
|
|
303
173
|
"""
|
|
304
|
-
|
|
174
|
+
response = await self.connection.post(
|
|
305
175
|
"services/examrep2/examrep_type",
|
|
306
176
|
examrep_type_id=examrep_type_id,
|
|
307
177
|
fields=_join_fields(fields),
|
|
308
178
|
)
|
|
179
|
+
return ExamReportType.model_validate(response)
|
|
309
180
|
|
|
310
181
|
async def get_grade_type(
|
|
311
|
-
|
|
312
|
-
|
|
313
|
-
|
|
182
|
+
self,
|
|
183
|
+
grade_type_id: str | int,
|
|
184
|
+
fields: list[str] | str | None = None,
|
|
314
185
|
) -> GradeType:
|
|
315
186
|
"""
|
|
316
187
|
Get information about a grade type.
|
|
@@ -319,17 +190,18 @@ class ExamReportService:
|
|
|
319
190
|
:param fields: Selector of result fields you are interested in.
|
|
320
191
|
:return: A dictionary of selected fields and their values.
|
|
321
192
|
"""
|
|
322
|
-
|
|
193
|
+
response = await self.connection.post(
|
|
323
194
|
"services/examrep2/grade_type",
|
|
324
195
|
grade_type_id=grade_type_id,
|
|
325
196
|
fields=_join_fields(fields),
|
|
326
197
|
)
|
|
198
|
+
return GradeType.model_validate(response)
|
|
327
199
|
|
|
328
200
|
async def get_grade_value(
|
|
329
|
-
|
|
330
|
-
|
|
331
|
-
|
|
332
|
-
|
|
201
|
+
self,
|
|
202
|
+
grade_type_id: str | int,
|
|
203
|
+
order_key: str | int,
|
|
204
|
+
fields: list[str] | str | None = None,
|
|
333
205
|
) -> GradeValue:
|
|
334
206
|
"""
|
|
335
207
|
Get information about a grade value.
|
|
@@ -339,18 +211,19 @@ class ExamReportService:
|
|
|
339
211
|
:param fields: Selector of result fields you are interested in.
|
|
340
212
|
:return: A dictionary of selected fields and their values.
|
|
341
213
|
"""
|
|
342
|
-
|
|
214
|
+
response = await self.connection.post(
|
|
343
215
|
"services/examrep2/grade_value",
|
|
344
216
|
grade_type_id=grade_type_id,
|
|
345
217
|
order_key=order_key,
|
|
346
218
|
fields=_join_fields(fields),
|
|
347
219
|
)
|
|
220
|
+
return GradeValue.model_validate(response)
|
|
348
221
|
|
|
349
222
|
async def get_grader_exam_reports(
|
|
350
|
-
|
|
351
|
-
|
|
352
|
-
|
|
353
|
-
|
|
223
|
+
self,
|
|
224
|
+
only_writable: bool = False,
|
|
225
|
+
active_terms_only: bool = True,
|
|
226
|
+
fields: list[str] | str | None = None,
|
|
354
227
|
) -> list[ExamReport2]:
|
|
355
228
|
"""
|
|
356
229
|
Get exam reports that the access token issuer can access.
|
|
@@ -360,19 +233,20 @@ class ExamReportService:
|
|
|
360
233
|
:param fields: Selector of result fields you are interested in.
|
|
361
234
|
:return: List of exam report objects.
|
|
362
235
|
"""
|
|
363
|
-
|
|
236
|
+
response = await self.connection.post(
|
|
364
237
|
"services/examrep2/grader",
|
|
365
238
|
only_writable=_bool_param(only_writable),
|
|
366
239
|
active_terms_only=_bool_param(active_terms_only),
|
|
367
240
|
fields=_join_fields(fields),
|
|
368
241
|
)
|
|
242
|
+
return [ExamReport2.model_validate(report) for report in response]
|
|
369
243
|
|
|
370
244
|
async def get_student_grade(
|
|
371
|
-
|
|
372
|
-
|
|
373
|
-
|
|
374
|
-
|
|
375
|
-
|
|
245
|
+
self,
|
|
246
|
+
examrep_id: str | int,
|
|
247
|
+
examrep_session_number: str | int,
|
|
248
|
+
student_id: str | int,
|
|
249
|
+
fields: list[str] | str | None = None,
|
|
376
250
|
) -> ExamReport2StudentGrade:
|
|
377
251
|
"""
|
|
378
252
|
Get information about a student's grade in an exam report session.
|
|
@@ -383,19 +257,20 @@ class ExamReportService:
|
|
|
383
257
|
:param fields: Selector of result fields you are interested in.
|
|
384
258
|
:return: A dictionary of selected fields and their values.
|
|
385
259
|
"""
|
|
386
|
-
|
|
260
|
+
response = await self.connection.post(
|
|
387
261
|
"services/examrep2/student_grade",
|
|
388
262
|
examrep_id=examrep_id,
|
|
389
263
|
examrep_session_number=examrep_session_number,
|
|
390
264
|
student_id=student_id,
|
|
391
265
|
fields=_join_fields(fields),
|
|
392
266
|
)
|
|
267
|
+
return ExamReport2StudentGrade.model_validate(response)
|
|
393
268
|
|
|
394
269
|
async def get_student_grades(
|
|
395
|
-
|
|
396
|
-
|
|
397
|
-
|
|
398
|
-
|
|
270
|
+
self,
|
|
271
|
+
examrep_id: str | int,
|
|
272
|
+
student_id: str | int,
|
|
273
|
+
fields: list[str] | str | None = None,
|
|
399
274
|
) -> list[ExamReport2StudentGrade]:
|
|
400
275
|
"""
|
|
401
276
|
Get information about all of a student's grades from a single exam report.
|
|
@@ -405,23 +280,24 @@ class ExamReportService:
|
|
|
405
280
|
:param fields: Selector of result fields you are interested in.
|
|
406
281
|
:return: List of student grade objects.
|
|
407
282
|
"""
|
|
408
|
-
|
|
283
|
+
response = await self.connection.post(
|
|
409
284
|
"services/examrep2/student_grades",
|
|
410
285
|
examrep_id=examrep_id,
|
|
411
286
|
student_id=student_id,
|
|
412
287
|
fields=_join_fields(fields),
|
|
413
288
|
)
|
|
289
|
+
return [ExamReport2StudentGrade.model_validate(grade) for grade in response]
|
|
414
290
|
|
|
415
291
|
async def update_student_grade(
|
|
416
|
-
|
|
417
|
-
|
|
418
|
-
|
|
419
|
-
|
|
420
|
-
|
|
421
|
-
|
|
422
|
-
|
|
423
|
-
|
|
424
|
-
|
|
292
|
+
self,
|
|
293
|
+
student_id: str | int,
|
|
294
|
+
examrep_id: str | int,
|
|
295
|
+
examrep_session_number: str | int,
|
|
296
|
+
value_symbol: str | None = None,
|
|
297
|
+
comment: str | None = None,
|
|
298
|
+
private_comment: str | None = None,
|
|
299
|
+
date_modified: date | datetime | str | None = None,
|
|
300
|
+
date_acquisition: date | datetime | str | None = None,
|
|
425
301
|
) -> EmptyResponse:
|
|
426
302
|
"""
|
|
427
303
|
Update a student's grade in an exam report session.
|
|
@@ -449,10 +325,10 @@ class ExamReportService:
|
|
|
449
325
|
)
|
|
450
326
|
|
|
451
327
|
async def get_user_grade(
|
|
452
|
-
|
|
453
|
-
|
|
454
|
-
|
|
455
|
-
|
|
328
|
+
self,
|
|
329
|
+
examrep_id: str | int,
|
|
330
|
+
examrep_session_number: str | int,
|
|
331
|
+
fields: list[str] | str | None = None,
|
|
456
332
|
) -> ExamReport2UserGrade:
|
|
457
333
|
"""
|
|
458
334
|
Get the access token issuer's grade in an exam report session.
|
|
@@ -462,18 +338,19 @@ class ExamReportService:
|
|
|
462
338
|
:param fields: Selector of result fields you are interested in.
|
|
463
339
|
:return: A dictionary of selected fields and their values.
|
|
464
340
|
"""
|
|
465
|
-
|
|
341
|
+
response = await self.connection.post(
|
|
466
342
|
"services/examrep2/user_grade",
|
|
467
343
|
examrep_id=examrep_id,
|
|
468
344
|
examrep_session_number=examrep_session_number,
|
|
469
345
|
fields=_join_fields(fields),
|
|
470
346
|
)
|
|
347
|
+
return ExamReport2UserGrade.model_validate(response)
|
|
471
348
|
|
|
472
349
|
async def get_course_edition_exam_report(
|
|
473
|
-
|
|
474
|
-
|
|
475
|
-
|
|
476
|
-
|
|
350
|
+
self,
|
|
351
|
+
course_id: str,
|
|
352
|
+
term_id: str,
|
|
353
|
+
fields: list[str] | str | None = None,
|
|
477
354
|
) -> LegacyCourseEditionExamReport:
|
|
478
355
|
"""
|
|
479
356
|
Get legacy exam report information related to a course edition.
|
|
@@ -485,18 +362,19 @@ class ExamReportService:
|
|
|
485
362
|
:param fields: Selector of result fields you are interested in.
|
|
486
363
|
:return: A dictionary of selected fields and their values.
|
|
487
364
|
"""
|
|
488
|
-
|
|
365
|
+
response = await self.connection.post(
|
|
489
366
|
"services/examrep/course_edition",
|
|
490
367
|
course_id=course_id,
|
|
491
368
|
term_id=term_id,
|
|
492
369
|
fields=_join_fields(fields),
|
|
493
370
|
)
|
|
371
|
+
return parse_legacy_course_edition_exam_report(response)
|
|
494
372
|
|
|
495
373
|
async def get_course_edition_exam_reports(
|
|
496
|
-
|
|
497
|
-
|
|
498
|
-
|
|
499
|
-
|
|
374
|
+
self,
|
|
375
|
+
course_id: str,
|
|
376
|
+
term_id: str,
|
|
377
|
+
fields: list[str] | str | None = None,
|
|
500
378
|
) -> LegacyCourseEditionExamReport:
|
|
501
379
|
"""
|
|
502
380
|
Get legacy exam reports related to a course edition.
|
|
@@ -508,17 +386,18 @@ class ExamReportService:
|
|
|
508
386
|
:param fields: Selector of result fields you are interested in.
|
|
509
387
|
:return: A dictionary of selected fields and their values.
|
|
510
388
|
"""
|
|
511
|
-
|
|
389
|
+
response = await self.connection.post(
|
|
512
390
|
"services/examrep/course_edition2",
|
|
513
391
|
course_id=course_id,
|
|
514
392
|
term_id=term_id,
|
|
515
393
|
fields=_join_fields(fields),
|
|
516
394
|
)
|
|
395
|
+
return parse_legacy_course_edition_exam_report(response)
|
|
517
396
|
|
|
518
397
|
async def get_legacy_exam_report(
|
|
519
|
-
|
|
520
|
-
|
|
521
|
-
|
|
398
|
+
self,
|
|
399
|
+
exam_id: str | int,
|
|
400
|
+
fields: list[str] | str | None = None,
|
|
522
401
|
) -> ExamReport:
|
|
523
402
|
"""
|
|
524
403
|
Get legacy exam report information.
|
|
@@ -529,11 +408,12 @@ class ExamReportService:
|
|
|
529
408
|
:param fields: Selector of result fields you are interested in.
|
|
530
409
|
:return: A dictionary of selected fields and their values.
|
|
531
410
|
"""
|
|
532
|
-
|
|
411
|
+
response = await self.connection.post(
|
|
533
412
|
"services/examrep/exam",
|
|
534
413
|
id=exam_id,
|
|
535
414
|
fields=_join_fields(fields),
|
|
536
415
|
)
|
|
416
|
+
return ExamReport.model_validate(response)
|
|
537
417
|
|
|
538
418
|
async def get_legacy_exam_session(
|
|
539
419
|
self,
|
|
@@ -551,12 +431,13 @@ class ExamReportService:
|
|
|
551
431
|
:param fields: Selector of result fields you are interested in.
|
|
552
432
|
:return: A dictionary of selected fields and their values.
|
|
553
433
|
"""
|
|
554
|
-
|
|
434
|
+
response = await self.connection.post(
|
|
555
435
|
"services/examrep/exam_session",
|
|
556
436
|
exam_id=exam_id,
|
|
557
437
|
number=number,
|
|
558
438
|
fields=_join_fields(fields),
|
|
559
439
|
)
|
|
440
|
+
return ExamReportSession.model_validate(response)
|
|
560
441
|
|
|
561
442
|
async def get_legacy_user_exam_reports(
|
|
562
443
|
self,
|
|
@@ -572,28 +453,48 @@ class ExamReportService:
|
|
|
572
453
|
:param fields: Selector of result fields you are interested in.
|
|
573
454
|
:return: A dictionary mapping term IDs to course IDs to exam report groups.
|
|
574
455
|
"""
|
|
575
|
-
|
|
456
|
+
response = await self.connection.post(
|
|
576
457
|
"services/examrep/user",
|
|
577
458
|
term_ids=_join_fields(term_ids),
|
|
578
459
|
fields=_join_fields(fields),
|
|
579
460
|
)
|
|
461
|
+
return parse_legacy_user_exam_reports(response)
|
|
580
462
|
|
|
581
|
-
async def
|
|
463
|
+
async def get_raw_user_exam_reports(
|
|
582
464
|
self,
|
|
583
465
|
term_ids: list[str] | str | None = None,
|
|
584
466
|
fields: list[str] | str | None = None,
|
|
585
|
-
) ->
|
|
467
|
+
) -> RawUserExamReportsByTerm:
|
|
586
468
|
"""
|
|
587
|
-
Get the current user's legacy exam reports
|
|
469
|
+
Get the current user's legacy exam reports as raw API dictionaries.
|
|
588
470
|
|
|
589
471
|
This wraps ``services/examrep/user2``.
|
|
590
472
|
|
|
591
473
|
:param term_ids: Academic term IDs. If omitted, the API default is used.
|
|
592
474
|
:param fields: Selector of result fields you are interested in.
|
|
593
|
-
:return:
|
|
475
|
+
:return: Raw dictionary mapping term IDs to course IDs to exam report lists.
|
|
594
476
|
"""
|
|
595
477
|
return await self.connection.post(
|
|
596
478
|
"services/examrep/user2",
|
|
597
479
|
term_ids=_join_fields(term_ids),
|
|
598
480
|
fields=_join_fields(fields),
|
|
599
481
|
)
|
|
482
|
+
|
|
483
|
+
async def get_user_exam_reports(
|
|
484
|
+
self,
|
|
485
|
+
term_ids: list[str] | str | None = None,
|
|
486
|
+
fields: list[str] | str | None = None,
|
|
487
|
+
) -> UserExamReportsByTerm:
|
|
488
|
+
"""
|
|
489
|
+
Get the current user's legacy exam reports for selected terms.
|
|
490
|
+
|
|
491
|
+
This wraps ``services/examrep/user2`` and parses the response into
|
|
492
|
+
Pydantic models.
|
|
493
|
+
|
|
494
|
+
:param term_ids: Academic term IDs. If omitted, the API default is used.
|
|
495
|
+
:param fields: Selector of exam report fields you are interested in.
|
|
496
|
+
:return: A dictionary mapping term IDs to course IDs to exam report models.
|
|
497
|
+
"""
|
|
498
|
+
return parse_user_exam_reports(
|
|
499
|
+
await self.get_raw_user_exam_reports(term_ids=term_ids, fields=fields)
|
|
500
|
+
)
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|