signalsafe-learning-core 0.5.0__py3-none-any.whl
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.
- learning_core/__init__.py +1 -0
- learning_core/enums.py +70 -0
- learning_core/models/__init__.py +1 -0
- learning_core/models/base.py +18 -0
- learning_core/models/contracts.py +347 -0
- learning_core/models/defaults.py +212 -0
- learning_core/py.typed +0 -0
- learning_core/repositories/__init__.py +1 -0
- learning_core/repositories/courseattempt.py +161 -0
- learning_core/repositories/coursebatch.py +61 -0
- learning_core/repositories/coursecertificate.py +74 -0
- learning_core/repositories/courseenrollment.py +281 -0
- learning_core/repositories/coursemetrics.py +29 -0
- learning_core/repositories/courseprogress.py +73 -0
- learning_core/repositories/courserunstepprogress.py +75 -0
- learning_core/repositories/courses.py +176 -0
- learning_core/repositories/coursesteprun.py +52 -0
- learning_core/repositories/dailycoursemetrics.py +48 -0
- learning_core/repositories/lessons.py +89 -0
- learning_core/repositories/steps.py +110 -0
- learning_core/services/__init__.py +1 -0
- learning_core/services/base.py +50 -0
- learning_core/services/lessons.py +93 -0
- learning_core/services/lifecycle.py +216 -0
- learning_core/services/progress.py +187 -0
- learning_core/validation.py +23 -0
- signalsafe_learning_core-0.5.0.dist-info/METADATA +18 -0
- signalsafe_learning_core-0.5.0.dist-info/RECORD +31 -0
- signalsafe_learning_core-0.5.0.dist-info/WHEEL +5 -0
- signalsafe_learning_core-0.5.0.dist-info/licenses/LICENSE +21 -0
- signalsafe_learning_core-0.5.0.dist-info/top_level.txt +1 -0
|
@@ -0,0 +1 @@
|
|
|
1
|
+
"""Shared learning-core APIs; import from explicit defining modules."""
|
learning_core/enums.py
ADDED
|
@@ -0,0 +1,70 @@
|
|
|
1
|
+
"""Owned persisted domain values; wire values remain stable."""
|
|
2
|
+
|
|
3
|
+
from enum import Enum, StrEnum
|
|
4
|
+
|
|
5
|
+
|
|
6
|
+
class StringEnum(StrEnum):
|
|
7
|
+
"""Preserve established display formatting independently of identity packages."""
|
|
8
|
+
|
|
9
|
+
def __str__(self) -> str:
|
|
10
|
+
return Enum.__str__(self)
|
|
11
|
+
|
|
12
|
+
def __format__(self, format_spec: str) -> str:
|
|
13
|
+
return Enum.__format__(self, format_spec)
|
|
14
|
+
|
|
15
|
+
|
|
16
|
+
class CourseState(StringEnum):
|
|
17
|
+
DRAFT = "draft"
|
|
18
|
+
RUNNING = "running"
|
|
19
|
+
COMPLETED = "completed"
|
|
20
|
+
ARCHIVED = "archived"
|
|
21
|
+
|
|
22
|
+
|
|
23
|
+
class CourseStepType(StringEnum):
|
|
24
|
+
BASELINE = "baseline_sim"
|
|
25
|
+
LESSON = "lesson"
|
|
26
|
+
FINAL_TEST = "final_test"
|
|
27
|
+
POST = "post_sim"
|
|
28
|
+
|
|
29
|
+
@classmethod
|
|
30
|
+
def ordered(cls) -> tuple[str, ...]:
|
|
31
|
+
return (
|
|
32
|
+
cls.BASELINE.value,
|
|
33
|
+
cls.LESSON.value,
|
|
34
|
+
cls.FINAL_TEST.value,
|
|
35
|
+
cls.POST.value,
|
|
36
|
+
)
|
|
37
|
+
|
|
38
|
+
|
|
39
|
+
class EnrollmentStatus(StringEnum):
|
|
40
|
+
ENROLLED = "enrolled"
|
|
41
|
+
IN_PROGRESS = "in_progress"
|
|
42
|
+
COMPLETED = "completed"
|
|
43
|
+
|
|
44
|
+
|
|
45
|
+
class CourseRunStatus(StringEnum):
|
|
46
|
+
NOT_STARTED = "not_started"
|
|
47
|
+
IN_PROGRESS = "in_progress"
|
|
48
|
+
COMPLETED = "completed"
|
|
49
|
+
|
|
50
|
+
|
|
51
|
+
class StepProgressStatus(StringEnum):
|
|
52
|
+
COMPLETED = "completed"
|
|
53
|
+
|
|
54
|
+
|
|
55
|
+
class CourseAssignmentType(StringEnum):
|
|
56
|
+
COURSE = "course" # compatibility value for course-linked assignments
|
|
57
|
+
|
|
58
|
+
|
|
59
|
+
class CourseAssignmentStatus(StringEnum):
|
|
60
|
+
ASSIGNED = "assigned"
|
|
61
|
+
COMPLETED = "completed"
|
|
62
|
+
|
|
63
|
+
|
|
64
|
+
class CourseStepAvailability(StringEnum):
|
|
65
|
+
LOCKED = "locked"
|
|
66
|
+
READY = "ready"
|
|
67
|
+
COMPLETED = "completed"
|
|
68
|
+
|
|
69
|
+
|
|
70
|
+
DEFAULT_COURSE_COMPLETION_MODE = "manual"
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
"""Owned domain fields and default mapped models."""
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
"""Independent learning model contracts and default persistence registry."""
|
|
2
|
+
|
|
3
|
+
from sqlalchemy import MetaData
|
|
4
|
+
from sqlalchemy.orm import DeclarativeBase
|
|
5
|
+
|
|
6
|
+
|
|
7
|
+
class LearnerContract(DeclarativeBase):
|
|
8
|
+
"""Unmapped fields; hosts choose their own concrete registry and relationships."""
|
|
9
|
+
|
|
10
|
+
|
|
11
|
+
class LearnerBase(DeclarativeBase):
|
|
12
|
+
"""Default learning registry; no organization or identity tables are registered."""
|
|
13
|
+
|
|
14
|
+
metadata = MetaData(
|
|
15
|
+
naming_convention={
|
|
16
|
+
"fk": "fk_%(table_name)s_%(column_0_name)s_%(referred_table_name)s"
|
|
17
|
+
}
|
|
18
|
+
)
|
|
@@ -0,0 +1,347 @@
|
|
|
1
|
+
"""Package-owned scalar model definitions; hosts add integration relationships."""
|
|
2
|
+
|
|
3
|
+
from datetime import date, datetime
|
|
4
|
+
from uuid import UUID
|
|
5
|
+
|
|
6
|
+
from sqlalchemy import (
|
|
7
|
+
BigInteger,
|
|
8
|
+
Boolean,
|
|
9
|
+
Date,
|
|
10
|
+
DateTime,
|
|
11
|
+
Float,
|
|
12
|
+
ForeignKey,
|
|
13
|
+
Integer,
|
|
14
|
+
SmallInteger,
|
|
15
|
+
String,
|
|
16
|
+
Text,
|
|
17
|
+
UniqueConstraint,
|
|
18
|
+
Uuid,
|
|
19
|
+
)
|
|
20
|
+
from sqlalchemy.dialects.postgresql import JSONB
|
|
21
|
+
from sqlalchemy.orm import Mapped, declared_attr, mapped_column
|
|
22
|
+
from sqlphilosophy.audit.model import (
|
|
23
|
+
TimestampModel,
|
|
24
|
+
)
|
|
25
|
+
from sqlphilosophy.types import JSONObject
|
|
26
|
+
|
|
27
|
+
from learning_core.models.base import LearnerContract
|
|
28
|
+
|
|
29
|
+
|
|
30
|
+
class CourseModel(TimestampModel, LearnerContract):
|
|
31
|
+
__abstract__ = True
|
|
32
|
+
|
|
33
|
+
id: Mapped[int] = mapped_column(BigInteger, primary_key=True, autoincrement=True)
|
|
34
|
+
|
|
35
|
+
is_master: Mapped[bool] = mapped_column(Boolean)
|
|
36
|
+
|
|
37
|
+
name: Mapped[str] = mapped_column(String(200))
|
|
38
|
+
|
|
39
|
+
state: Mapped[str] = mapped_column(String(16))
|
|
40
|
+
|
|
41
|
+
started_at: Mapped[datetime | None] = mapped_column(
|
|
42
|
+
DateTime(timezone=True), nullable=True
|
|
43
|
+
)
|
|
44
|
+
|
|
45
|
+
completed_at: Mapped[datetime | None] = mapped_column(
|
|
46
|
+
DateTime(timezone=True), nullable=True
|
|
47
|
+
)
|
|
48
|
+
|
|
49
|
+
snapshot_hash: Mapped[str | None] = mapped_column(String(64), nullable=True)
|
|
50
|
+
|
|
51
|
+
|
|
52
|
+
class CourseAttemptModel(TimestampModel, LearnerContract):
|
|
53
|
+
__abstract__ = True
|
|
54
|
+
|
|
55
|
+
id: Mapped[int] = mapped_column(BigInteger, primary_key=True, autoincrement=True)
|
|
56
|
+
|
|
57
|
+
course_id: Mapped[int] = mapped_column(BigInteger, ForeignKey("content_course.id"))
|
|
58
|
+
|
|
59
|
+
profile_id: Mapped[int] = mapped_column(BigInteger)
|
|
60
|
+
|
|
61
|
+
status: Mapped[str] = mapped_column(String(16))
|
|
62
|
+
|
|
63
|
+
started_at: Mapped[datetime] = mapped_column(DateTime(timezone=True))
|
|
64
|
+
|
|
65
|
+
completed_at: Mapped[datetime | None] = mapped_column(
|
|
66
|
+
DateTime(timezone=True), nullable=True
|
|
67
|
+
)
|
|
68
|
+
|
|
69
|
+
|
|
70
|
+
class CourseBatchModel(TimestampModel, LearnerContract):
|
|
71
|
+
__abstract__ = True
|
|
72
|
+
|
|
73
|
+
@declared_attr.directive
|
|
74
|
+
def __table_args__(cls) -> tuple[UniqueConstraint, ...]:
|
|
75
|
+
return (UniqueConstraint("key"),)
|
|
76
|
+
|
|
77
|
+
id: Mapped[int] = mapped_column(BigInteger, primary_key=True, autoincrement=True)
|
|
78
|
+
|
|
79
|
+
course_id: Mapped[int] = mapped_column(BigInteger, ForeignKey("content_course.id"))
|
|
80
|
+
|
|
81
|
+
name: Mapped[str] = mapped_column(String(200))
|
|
82
|
+
|
|
83
|
+
key: Mapped[str] = mapped_column(String(64))
|
|
84
|
+
|
|
85
|
+
assigned_by_id: Mapped[int | None] = mapped_column(BigInteger, nullable=True)
|
|
86
|
+
|
|
87
|
+
assigned_at: Mapped[datetime] = mapped_column(DateTime(timezone=True))
|
|
88
|
+
|
|
89
|
+
starts_at: Mapped[datetime | None] = mapped_column(
|
|
90
|
+
DateTime(timezone=True), nullable=True
|
|
91
|
+
)
|
|
92
|
+
|
|
93
|
+
due_at: Mapped[datetime | None] = mapped_column(
|
|
94
|
+
DateTime(timezone=True), nullable=True
|
|
95
|
+
)
|
|
96
|
+
|
|
97
|
+
ends_at: Mapped[datetime | None] = mapped_column(
|
|
98
|
+
DateTime(timezone=True), nullable=True
|
|
99
|
+
)
|
|
100
|
+
|
|
101
|
+
state: Mapped[str] = mapped_column(String(16))
|
|
102
|
+
|
|
103
|
+
selection_type: Mapped[str | None] = mapped_column(String(24), nullable=True)
|
|
104
|
+
|
|
105
|
+
selection_definition_json: Mapped[JSONObject | None] = mapped_column(
|
|
106
|
+
JSONB, nullable=True
|
|
107
|
+
)
|
|
108
|
+
|
|
109
|
+
notes: Mapped[str] = mapped_column(Text)
|
|
110
|
+
|
|
111
|
+
|
|
112
|
+
class CourseCertificateModel(TimestampModel, LearnerContract):
|
|
113
|
+
__abstract__ = True
|
|
114
|
+
|
|
115
|
+
@declared_attr.directive
|
|
116
|
+
def __table_args__(cls) -> tuple[UniqueConstraint, ...]:
|
|
117
|
+
return (UniqueConstraint("profile_id", "course_id"),)
|
|
118
|
+
|
|
119
|
+
id: Mapped[int] = mapped_column(BigInteger, primary_key=True, autoincrement=True)
|
|
120
|
+
|
|
121
|
+
profile_id: Mapped[int] = mapped_column(BigInteger)
|
|
122
|
+
|
|
123
|
+
course_id: Mapped[int] = mapped_column(BigInteger, ForeignKey("content_course.id"))
|
|
124
|
+
|
|
125
|
+
issued_at: Mapped[datetime] = mapped_column(DateTime(timezone=True))
|
|
126
|
+
|
|
127
|
+
score: Mapped[float | None] = mapped_column(Float, nullable=True)
|
|
128
|
+
|
|
129
|
+
|
|
130
|
+
class CourseEnrollmentModel(TimestampModel, LearnerContract):
|
|
131
|
+
__abstract__ = True
|
|
132
|
+
|
|
133
|
+
@declared_attr.directive
|
|
134
|
+
def __table_args__(cls) -> tuple[UniqueConstraint, ...]:
|
|
135
|
+
return (UniqueConstraint("profile_id", "course_id"),)
|
|
136
|
+
|
|
137
|
+
id: Mapped[int] = mapped_column(BigInteger, primary_key=True, autoincrement=True)
|
|
138
|
+
|
|
139
|
+
course_id: Mapped[int] = mapped_column(BigInteger, ForeignKey("content_course.id"))
|
|
140
|
+
|
|
141
|
+
profile_id: Mapped[int] = mapped_column(BigInteger)
|
|
142
|
+
|
|
143
|
+
attempt_id: Mapped[int | None] = mapped_column(
|
|
144
|
+
BigInteger, ForeignKey("content_courseattempt.id"), nullable=True
|
|
145
|
+
)
|
|
146
|
+
|
|
147
|
+
batch_id: Mapped[int | None] = mapped_column(
|
|
148
|
+
BigInteger, ForeignKey("content_coursebatch.id"), nullable=True
|
|
149
|
+
)
|
|
150
|
+
|
|
151
|
+
enrolled_at: Mapped[datetime] = mapped_column(DateTime(timezone=True))
|
|
152
|
+
|
|
153
|
+
completed_at: Mapped[datetime | None] = mapped_column(
|
|
154
|
+
DateTime(timezone=True), nullable=True
|
|
155
|
+
)
|
|
156
|
+
|
|
157
|
+
due_at: Mapped[datetime | None] = mapped_column(
|
|
158
|
+
DateTime(timezone=True), nullable=True
|
|
159
|
+
)
|
|
160
|
+
|
|
161
|
+
assigned_by_id: Mapped[int | None] = mapped_column(BigInteger, nullable=True)
|
|
162
|
+
|
|
163
|
+
status: Mapped[str] = mapped_column(String(16))
|
|
164
|
+
|
|
165
|
+
|
|
166
|
+
class CourseMetricsModel(LearnerContract):
|
|
167
|
+
__abstract__ = True
|
|
168
|
+
|
|
169
|
+
@declared_attr.directive
|
|
170
|
+
def __table_args__(cls) -> tuple[UniqueConstraint, ...]:
|
|
171
|
+
return (UniqueConstraint("course_id"),)
|
|
172
|
+
|
|
173
|
+
id: Mapped[int] = mapped_column(BigInteger, primary_key=True, autoincrement=True)
|
|
174
|
+
|
|
175
|
+
course_id: Mapped[int] = mapped_column(BigInteger, ForeignKey("content_course.id"))
|
|
176
|
+
|
|
177
|
+
baseline_fail_rate: Mapped[float] = mapped_column(Float)
|
|
178
|
+
|
|
179
|
+
post_fail_rate: Mapped[float] = mapped_column(Float)
|
|
180
|
+
|
|
181
|
+
improvement_delta: Mapped[float] = mapped_column(Float)
|
|
182
|
+
|
|
183
|
+
last_calculated_at: Mapped[datetime | None] = mapped_column(
|
|
184
|
+
DateTime(timezone=True), nullable=True
|
|
185
|
+
)
|
|
186
|
+
|
|
187
|
+
|
|
188
|
+
class CourseProgressModel(TimestampModel, LearnerContract):
|
|
189
|
+
__abstract__ = True
|
|
190
|
+
|
|
191
|
+
@declared_attr.directive
|
|
192
|
+
def __table_args__(cls) -> tuple[UniqueConstraint, ...]:
|
|
193
|
+
return (UniqueConstraint("profile_id", "course_id"),)
|
|
194
|
+
|
|
195
|
+
id: Mapped[int] = mapped_column(BigInteger, primary_key=True, autoincrement=True)
|
|
196
|
+
|
|
197
|
+
course_id: Mapped[int] = mapped_column(BigInteger, ForeignKey("content_course.id"))
|
|
198
|
+
|
|
199
|
+
profile_id: Mapped[int] = mapped_column(BigInteger)
|
|
200
|
+
|
|
201
|
+
current_step: Mapped[int | None] = mapped_column(SmallInteger, nullable=True)
|
|
202
|
+
|
|
203
|
+
completed_steps_count: Mapped[int] = mapped_column(SmallInteger)
|
|
204
|
+
|
|
205
|
+
total_steps: Mapped[int] = mapped_column(SmallInteger)
|
|
206
|
+
|
|
207
|
+
percent_complete: Mapped[float] = mapped_column(Float)
|
|
208
|
+
|
|
209
|
+
|
|
210
|
+
class CourseStepModel(TimestampModel, LearnerContract):
|
|
211
|
+
__abstract__ = True
|
|
212
|
+
|
|
213
|
+
id: Mapped[int] = mapped_column(BigInteger, primary_key=True, autoincrement=True)
|
|
214
|
+
|
|
215
|
+
course_id: Mapped[int] = mapped_column(BigInteger, ForeignKey("content_course.id"))
|
|
216
|
+
|
|
217
|
+
order: Mapped[int] = mapped_column(SmallInteger)
|
|
218
|
+
|
|
219
|
+
step_type: Mapped[str] = mapped_column(String(24))
|
|
220
|
+
|
|
221
|
+
required: Mapped[bool] = mapped_column(Boolean)
|
|
222
|
+
|
|
223
|
+
completion_mode: Mapped[str] = mapped_column(String(16))
|
|
224
|
+
|
|
225
|
+
name: Mapped[str] = mapped_column(String(200))
|
|
226
|
+
|
|
227
|
+
description: Mapped[str] = mapped_column(Text)
|
|
228
|
+
|
|
229
|
+
simulation_run_id: Mapped[int | None] = mapped_column(BigInteger, nullable=True)
|
|
230
|
+
|
|
231
|
+
lesson_id: Mapped[UUID | None] = mapped_column(
|
|
232
|
+
Uuid(as_uuid=True), ForeignKey("content_lesson.id"), nullable=True
|
|
233
|
+
)
|
|
234
|
+
|
|
235
|
+
scenario_version_id: Mapped[UUID | None] = mapped_column(
|
|
236
|
+
Uuid(as_uuid=True), nullable=True
|
|
237
|
+
)
|
|
238
|
+
|
|
239
|
+
template_key: Mapped[str | None] = mapped_column(String(128), nullable=True)
|
|
240
|
+
|
|
241
|
+
|
|
242
|
+
class CourseStepRunModel(TimestampModel, LearnerContract):
|
|
243
|
+
__abstract__ = True
|
|
244
|
+
|
|
245
|
+
id: Mapped[int] = mapped_column(BigInteger, primary_key=True, autoincrement=True)
|
|
246
|
+
|
|
247
|
+
course_step_id: Mapped[int] = mapped_column(
|
|
248
|
+
BigInteger, ForeignKey("content_coursestep.id")
|
|
249
|
+
)
|
|
250
|
+
|
|
251
|
+
profile_id: Mapped[int] = mapped_column(BigInteger)
|
|
252
|
+
|
|
253
|
+
simulation_run_id: Mapped[int] = mapped_column(BigInteger)
|
|
254
|
+
|
|
255
|
+
status: Mapped[str] = mapped_column(String(16))
|
|
256
|
+
|
|
257
|
+
completed_at: Mapped[datetime | None] = mapped_column(
|
|
258
|
+
DateTime(timezone=True), nullable=True
|
|
259
|
+
)
|
|
260
|
+
|
|
261
|
+
clicked_link: Mapped[bool] = mapped_column(Boolean)
|
|
262
|
+
|
|
263
|
+
reported: Mapped[bool] = mapped_column(Boolean)
|
|
264
|
+
|
|
265
|
+
verified: Mapped[bool] = mapped_column(Boolean)
|
|
266
|
+
|
|
267
|
+
entered_credentials: Mapped[bool] = mapped_column(Boolean)
|
|
268
|
+
|
|
269
|
+
time_to_action: Mapped[int | None] = mapped_column(Integer, nullable=True)
|
|
270
|
+
|
|
271
|
+
|
|
272
|
+
class DailyCourseMetricsModel(LearnerContract):
|
|
273
|
+
__abstract__ = True
|
|
274
|
+
|
|
275
|
+
@declared_attr.directive
|
|
276
|
+
def __table_args__(cls) -> tuple[UniqueConstraint, ...]:
|
|
277
|
+
return (UniqueConstraint("course_id", "date"),)
|
|
278
|
+
|
|
279
|
+
id: Mapped[int] = mapped_column(BigInteger, primary_key=True, autoincrement=True)
|
|
280
|
+
|
|
281
|
+
course_id: Mapped[int] = mapped_column(BigInteger, ForeignKey("content_course.id"))
|
|
282
|
+
|
|
283
|
+
date_: Mapped[date] = mapped_column("date", Date)
|
|
284
|
+
|
|
285
|
+
enrolled_count: Mapped[int] = mapped_column(Integer)
|
|
286
|
+
|
|
287
|
+
completed_count: Mapped[int] = mapped_column(Integer)
|
|
288
|
+
|
|
289
|
+
avg_completion_time: Mapped[float | None] = mapped_column(Float, nullable=True)
|
|
290
|
+
|
|
291
|
+
|
|
292
|
+
class LessonModel(TimestampModel, LearnerContract):
|
|
293
|
+
__abstract__ = True
|
|
294
|
+
|
|
295
|
+
id: Mapped[UUID] = mapped_column(Uuid(as_uuid=True), primary_key=True)
|
|
296
|
+
|
|
297
|
+
key: Mapped[str] = mapped_column(String(50))
|
|
298
|
+
|
|
299
|
+
title: Mapped[str] = mapped_column(String(200))
|
|
300
|
+
|
|
301
|
+
short_takeaway: Mapped[str] = mapped_column(String(200))
|
|
302
|
+
|
|
303
|
+
description: Mapped[str] = mapped_column(Text)
|
|
304
|
+
|
|
305
|
+
category: Mapped[str] = mapped_column(String(64))
|
|
306
|
+
|
|
307
|
+
is_active: Mapped[bool] = mapped_column(Boolean)
|
|
308
|
+
|
|
309
|
+
is_master: Mapped[bool] = mapped_column(Boolean)
|
|
310
|
+
|
|
311
|
+
summary: Mapped[str] = mapped_column(Text)
|
|
312
|
+
|
|
313
|
+
content_markdown: Mapped[str] = mapped_column(Text)
|
|
314
|
+
|
|
315
|
+
estimated_minutes: Mapped[int | None] = mapped_column(SmallInteger, nullable=True)
|
|
316
|
+
|
|
317
|
+
content_updated_at: Mapped[datetime | None] = mapped_column(
|
|
318
|
+
DateTime(timezone=True), nullable=True
|
|
319
|
+
)
|
|
320
|
+
|
|
321
|
+
|
|
322
|
+
class CourseRunStepProgressModel(TimestampModel, LearnerContract):
|
|
323
|
+
__abstract__ = True
|
|
324
|
+
|
|
325
|
+
@declared_attr.directive
|
|
326
|
+
def __table_args__(cls) -> tuple[UniqueConstraint, ...]:
|
|
327
|
+
return (UniqueConstraint("course_run_id", "course_step_id"),)
|
|
328
|
+
|
|
329
|
+
id: Mapped[int] = mapped_column(BigInteger, primary_key=True, autoincrement=True)
|
|
330
|
+
|
|
331
|
+
course_run_id: Mapped[int] = mapped_column(
|
|
332
|
+
BigInteger, ForeignKey("content_courseattempt.id")
|
|
333
|
+
)
|
|
334
|
+
|
|
335
|
+
course_step_id: Mapped[int] = mapped_column(
|
|
336
|
+
BigInteger, ForeignKey("content_coursestep.id")
|
|
337
|
+
)
|
|
338
|
+
|
|
339
|
+
status: Mapped[str] = mapped_column(String(16))
|
|
340
|
+
|
|
341
|
+
started_at: Mapped[datetime | None] = mapped_column(
|
|
342
|
+
DateTime(timezone=True), nullable=True
|
|
343
|
+
)
|
|
344
|
+
|
|
345
|
+
completed_at: Mapped[datetime | None] = mapped_column(
|
|
346
|
+
DateTime(timezone=True), nullable=True
|
|
347
|
+
)
|
|
@@ -0,0 +1,212 @@
|
|
|
1
|
+
"""Ready-to-use domain models on the default package registry."""
|
|
2
|
+
|
|
3
|
+
from sqlalchemy.orm import Mapped, relationship
|
|
4
|
+
|
|
5
|
+
from learning_core.models.base import LearnerBase
|
|
6
|
+
from learning_core.models.contracts import (
|
|
7
|
+
CourseAttemptModel,
|
|
8
|
+
CourseBatchModel,
|
|
9
|
+
CourseCertificateModel,
|
|
10
|
+
CourseEnrollmentModel,
|
|
11
|
+
CourseMetricsModel,
|
|
12
|
+
CourseModel,
|
|
13
|
+
CourseProgressModel,
|
|
14
|
+
CourseRunStepProgressModel,
|
|
15
|
+
CourseStepModel,
|
|
16
|
+
CourseStepRunModel,
|
|
17
|
+
DailyCourseMetricsModel,
|
|
18
|
+
LessonModel,
|
|
19
|
+
)
|
|
20
|
+
|
|
21
|
+
|
|
22
|
+
class Course(LearnerBase, CourseModel):
|
|
23
|
+
__tablename__ = "content_course"
|
|
24
|
+
|
|
25
|
+
steps: Mapped[list["CourseStep"]] = relationship(
|
|
26
|
+
"CourseStep",
|
|
27
|
+
back_populates="course",
|
|
28
|
+
foreign_keys="[CourseStep.course_id]",
|
|
29
|
+
order_by="CourseStep.order",
|
|
30
|
+
)
|
|
31
|
+
|
|
32
|
+
attempts: Mapped[list["CourseAttempt"]] = relationship(
|
|
33
|
+
"CourseAttempt", back_populates="course", foreign_keys="[CourseAttempt.course_id]"
|
|
34
|
+
)
|
|
35
|
+
|
|
36
|
+
batches: Mapped[list["CourseBatch"]] = relationship(
|
|
37
|
+
"CourseBatch", back_populates="course", foreign_keys="[CourseBatch.course_id]"
|
|
38
|
+
)
|
|
39
|
+
|
|
40
|
+
certificates: Mapped[list["CourseCertificate"]] = relationship(
|
|
41
|
+
"CourseCertificate",
|
|
42
|
+
back_populates="course",
|
|
43
|
+
foreign_keys="[CourseCertificate.course_id]",
|
|
44
|
+
)
|
|
45
|
+
|
|
46
|
+
enrollments: Mapped[list["CourseEnrollment"]] = relationship(
|
|
47
|
+
"CourseEnrollment",
|
|
48
|
+
back_populates="course",
|
|
49
|
+
foreign_keys="[CourseEnrollment.course_id]",
|
|
50
|
+
)
|
|
51
|
+
|
|
52
|
+
metrics: Mapped[list["CourseMetrics"]] = relationship(
|
|
53
|
+
"CourseMetrics", back_populates="course", foreign_keys="[CourseMetrics.course_id]"
|
|
54
|
+
)
|
|
55
|
+
|
|
56
|
+
progress_records: Mapped[list["CourseProgress"]] = relationship(
|
|
57
|
+
"CourseProgress",
|
|
58
|
+
back_populates="course",
|
|
59
|
+
foreign_keys="[CourseProgress.course_id]",
|
|
60
|
+
)
|
|
61
|
+
|
|
62
|
+
daily_metrics: Mapped[list["DailyCourseMetrics"]] = relationship(
|
|
63
|
+
"DailyCourseMetrics",
|
|
64
|
+
back_populates="course",
|
|
65
|
+
foreign_keys="[DailyCourseMetrics.course_id]",
|
|
66
|
+
)
|
|
67
|
+
|
|
68
|
+
|
|
69
|
+
class CourseAttempt(LearnerBase, CourseAttemptModel):
|
|
70
|
+
__tablename__ = "content_courseattempt"
|
|
71
|
+
|
|
72
|
+
enrollments: Mapped[list["CourseEnrollment"]] = relationship(
|
|
73
|
+
"CourseEnrollment",
|
|
74
|
+
back_populates="attempt",
|
|
75
|
+
foreign_keys="[CourseEnrollment.attempt_id]",
|
|
76
|
+
)
|
|
77
|
+
|
|
78
|
+
run_step_progress: Mapped[list["CourseRunStepProgress"]] = relationship(
|
|
79
|
+
"CourseRunStepProgress",
|
|
80
|
+
back_populates="course_run",
|
|
81
|
+
foreign_keys="[CourseRunStepProgress.course_run_id]",
|
|
82
|
+
)
|
|
83
|
+
|
|
84
|
+
course: Mapped["Course"] = relationship(
|
|
85
|
+
"Course", back_populates="attempts", foreign_keys="[CourseAttempt.course_id]"
|
|
86
|
+
)
|
|
87
|
+
|
|
88
|
+
|
|
89
|
+
class CourseBatch(LearnerBase, CourseBatchModel):
|
|
90
|
+
__tablename__ = "content_coursebatch"
|
|
91
|
+
|
|
92
|
+
enrollments: Mapped[list["CourseEnrollment"]] = relationship(
|
|
93
|
+
"CourseEnrollment",
|
|
94
|
+
back_populates="batch",
|
|
95
|
+
foreign_keys="[CourseEnrollment.batch_id]",
|
|
96
|
+
)
|
|
97
|
+
|
|
98
|
+
course: Mapped["Course"] = relationship(
|
|
99
|
+
"Course", back_populates="batches", foreign_keys="[CourseBatch.course_id]"
|
|
100
|
+
)
|
|
101
|
+
|
|
102
|
+
|
|
103
|
+
class CourseCertificate(LearnerBase, CourseCertificateModel):
|
|
104
|
+
__tablename__ = "content_coursecertificate"
|
|
105
|
+
|
|
106
|
+
course: Mapped["Course"] = relationship(
|
|
107
|
+
"Course",
|
|
108
|
+
back_populates="certificates",
|
|
109
|
+
foreign_keys="[CourseCertificate.course_id]",
|
|
110
|
+
)
|
|
111
|
+
|
|
112
|
+
|
|
113
|
+
class CourseEnrollment(LearnerBase, CourseEnrollmentModel):
|
|
114
|
+
__tablename__ = "content_courseenrollment"
|
|
115
|
+
|
|
116
|
+
course: Mapped["Course"] = relationship(
|
|
117
|
+
"Course",
|
|
118
|
+
back_populates="enrollments",
|
|
119
|
+
foreign_keys="[CourseEnrollment.course_id]",
|
|
120
|
+
)
|
|
121
|
+
|
|
122
|
+
batch: Mapped["CourseBatch | None"] = relationship(
|
|
123
|
+
"CourseBatch",
|
|
124
|
+
back_populates="enrollments",
|
|
125
|
+
foreign_keys="[CourseEnrollment.batch_id]",
|
|
126
|
+
)
|
|
127
|
+
|
|
128
|
+
attempt: Mapped["CourseAttempt | None"] = relationship(
|
|
129
|
+
"CourseAttempt",
|
|
130
|
+
back_populates="enrollments",
|
|
131
|
+
foreign_keys="[CourseEnrollment.attempt_id]",
|
|
132
|
+
)
|
|
133
|
+
|
|
134
|
+
|
|
135
|
+
class CourseMetrics(LearnerBase, CourseMetricsModel):
|
|
136
|
+
__tablename__ = "content_coursemetrics"
|
|
137
|
+
|
|
138
|
+
course: Mapped["Course"] = relationship(
|
|
139
|
+
"Course", back_populates="metrics", foreign_keys="[CourseMetrics.course_id]"
|
|
140
|
+
)
|
|
141
|
+
|
|
142
|
+
|
|
143
|
+
class CourseProgress(LearnerBase, CourseProgressModel):
|
|
144
|
+
__tablename__ = "content_courseprogress"
|
|
145
|
+
|
|
146
|
+
course: Mapped["Course"] = relationship(
|
|
147
|
+
"Course",
|
|
148
|
+
back_populates="progress_records",
|
|
149
|
+
foreign_keys="[CourseProgress.course_id]",
|
|
150
|
+
)
|
|
151
|
+
|
|
152
|
+
|
|
153
|
+
class CourseStep(LearnerBase, CourseStepModel):
|
|
154
|
+
__tablename__ = "content_coursestep"
|
|
155
|
+
|
|
156
|
+
runs: Mapped[list["CourseStepRun"]] = relationship(
|
|
157
|
+
"CourseStepRun",
|
|
158
|
+
back_populates="step",
|
|
159
|
+
foreign_keys="[CourseStepRun.course_step_id]",
|
|
160
|
+
)
|
|
161
|
+
|
|
162
|
+
run_step_progress: Mapped[list["CourseRunStepProgress"]] = relationship(
|
|
163
|
+
"CourseRunStepProgress",
|
|
164
|
+
back_populates="step",
|
|
165
|
+
foreign_keys="[CourseRunStepProgress.course_step_id]",
|
|
166
|
+
)
|
|
167
|
+
|
|
168
|
+
lesson: Mapped["Lesson | None"] = relationship(
|
|
169
|
+
"Lesson", foreign_keys="[CourseStep.lesson_id]"
|
|
170
|
+
)
|
|
171
|
+
|
|
172
|
+
course: Mapped["Course"] = relationship(
|
|
173
|
+
"Course", back_populates="steps", foreign_keys="[CourseStep.course_id]"
|
|
174
|
+
)
|
|
175
|
+
|
|
176
|
+
|
|
177
|
+
class CourseStepRun(LearnerBase, CourseStepRunModel):
|
|
178
|
+
__tablename__ = "content_coursesteprun"
|
|
179
|
+
|
|
180
|
+
step: Mapped["CourseStep"] = relationship(
|
|
181
|
+
"CourseStep", back_populates="runs", foreign_keys="[CourseStepRun.course_step_id]"
|
|
182
|
+
)
|
|
183
|
+
|
|
184
|
+
|
|
185
|
+
class DailyCourseMetrics(LearnerBase, DailyCourseMetricsModel):
|
|
186
|
+
__tablename__ = "content_dailycoursemetrics"
|
|
187
|
+
|
|
188
|
+
course: Mapped["Course"] = relationship(
|
|
189
|
+
"Course",
|
|
190
|
+
back_populates="daily_metrics",
|
|
191
|
+
foreign_keys="[DailyCourseMetrics.course_id]",
|
|
192
|
+
)
|
|
193
|
+
|
|
194
|
+
|
|
195
|
+
class Lesson(LearnerBase, LessonModel):
|
|
196
|
+
__tablename__ = "content_lesson"
|
|
197
|
+
|
|
198
|
+
|
|
199
|
+
class CourseRunStepProgress(LearnerBase, CourseRunStepProgressModel):
|
|
200
|
+
__tablename__ = "content_courserunstepprogress"
|
|
201
|
+
|
|
202
|
+
course_run: Mapped["CourseAttempt"] = relationship(
|
|
203
|
+
"CourseAttempt",
|
|
204
|
+
back_populates="run_step_progress",
|
|
205
|
+
foreign_keys="[CourseRunStepProgress.course_run_id]",
|
|
206
|
+
)
|
|
207
|
+
|
|
208
|
+
step: Mapped["CourseStep"] = relationship(
|
|
209
|
+
"CourseStep",
|
|
210
|
+
back_populates="run_step_progress",
|
|
211
|
+
foreign_keys="[CourseRunStepProgress.course_step_id]",
|
|
212
|
+
)
|
learning_core/py.typed
ADDED
|
File without changes
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
"""Domain persistence; import explicit model-bound repositories."""
|