signalsafe-learning-core 0.5.0__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.
Files changed (38) hide show
  1. signalsafe_learning_core-0.5.0/LICENSE +21 -0
  2. signalsafe_learning_core-0.5.0/MANIFEST.in +2 -0
  3. signalsafe_learning_core-0.5.0/PKG-INFO +18 -0
  4. signalsafe_learning_core-0.5.0/README.md +5 -0
  5. signalsafe_learning_core-0.5.0/docs/README.md +41 -0
  6. signalsafe_learning_core-0.5.0/pyproject.toml +28 -0
  7. signalsafe_learning_core-0.5.0/setup.cfg +4 -0
  8. signalsafe_learning_core-0.5.0/src/learning_core/__init__.py +1 -0
  9. signalsafe_learning_core-0.5.0/src/learning_core/enums.py +70 -0
  10. signalsafe_learning_core-0.5.0/src/learning_core/models/__init__.py +1 -0
  11. signalsafe_learning_core-0.5.0/src/learning_core/models/base.py +18 -0
  12. signalsafe_learning_core-0.5.0/src/learning_core/models/contracts.py +347 -0
  13. signalsafe_learning_core-0.5.0/src/learning_core/models/defaults.py +212 -0
  14. signalsafe_learning_core-0.5.0/src/learning_core/py.typed +0 -0
  15. signalsafe_learning_core-0.5.0/src/learning_core/repositories/__init__.py +1 -0
  16. signalsafe_learning_core-0.5.0/src/learning_core/repositories/courseattempt.py +161 -0
  17. signalsafe_learning_core-0.5.0/src/learning_core/repositories/coursebatch.py +61 -0
  18. signalsafe_learning_core-0.5.0/src/learning_core/repositories/coursecertificate.py +74 -0
  19. signalsafe_learning_core-0.5.0/src/learning_core/repositories/courseenrollment.py +281 -0
  20. signalsafe_learning_core-0.5.0/src/learning_core/repositories/coursemetrics.py +29 -0
  21. signalsafe_learning_core-0.5.0/src/learning_core/repositories/courseprogress.py +73 -0
  22. signalsafe_learning_core-0.5.0/src/learning_core/repositories/courserunstepprogress.py +75 -0
  23. signalsafe_learning_core-0.5.0/src/learning_core/repositories/courses.py +176 -0
  24. signalsafe_learning_core-0.5.0/src/learning_core/repositories/coursesteprun.py +52 -0
  25. signalsafe_learning_core-0.5.0/src/learning_core/repositories/dailycoursemetrics.py +48 -0
  26. signalsafe_learning_core-0.5.0/src/learning_core/repositories/lessons.py +89 -0
  27. signalsafe_learning_core-0.5.0/src/learning_core/repositories/steps.py +110 -0
  28. signalsafe_learning_core-0.5.0/src/learning_core/services/__init__.py +1 -0
  29. signalsafe_learning_core-0.5.0/src/learning_core/services/base.py +50 -0
  30. signalsafe_learning_core-0.5.0/src/learning_core/services/lessons.py +93 -0
  31. signalsafe_learning_core-0.5.0/src/learning_core/services/lifecycle.py +216 -0
  32. signalsafe_learning_core-0.5.0/src/learning_core/services/progress.py +187 -0
  33. signalsafe_learning_core-0.5.0/src/learning_core/validation.py +23 -0
  34. signalsafe_learning_core-0.5.0/src/signalsafe_learning_core.egg-info/PKG-INFO +18 -0
  35. signalsafe_learning_core-0.5.0/src/signalsafe_learning_core.egg-info/SOURCES.txt +36 -0
  36. signalsafe_learning_core-0.5.0/src/signalsafe_learning_core.egg-info/dependency_links.txt +1 -0
  37. signalsafe_learning_core-0.5.0/src/signalsafe_learning_core.egg-info/requires.txt +3 -0
  38. signalsafe_learning_core-0.5.0/src/signalsafe_learning_core.egg-info/top_level.txt +1 -0
@@ -0,0 +1,21 @@
1
+ MIT License
2
+
3
+ Copyright (c) 2026 Josh Martin
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies
9
+ of the Software, and to permit persons to whom the Software is furnished to do so,
10
+ subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in all
13
+ copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21
+ SOFTWARE.
@@ -0,0 +1,2 @@
1
+ recursive-include docs *.md
2
+ prune tests
@@ -0,0 +1,18 @@
1
+ Metadata-Version: 2.4
2
+ Name: signalsafe-learning-core
3
+ Version: 0.5.0
4
+ Summary: Shared learning-core services and persistence
5
+ License-Expression: MIT
6
+ Requires-Python: <4,>=3.12
7
+ Description-Content-Type: text/markdown
8
+ License-File: LICENSE
9
+ Requires-Dist: servicephilosophy<0.2,>=0.1.2
10
+ Requires-Dist: sqlphilosophy<0.4,>=0.3.4
11
+ Requires-Dist: sqlalchemy<3,>=2
12
+ Dynamic: license-file
13
+
14
+ # learning-core Python
15
+
16
+ See [Python models and services](docs/README.md). Python 0.5.0 is the Company-free release approved on 2026-10-21; TypeScript remains 0.1.0. Existing hosts stay on their prior compatible artifacts until tenant-bound session adoption.
17
+
18
+ Coordinated candidate dependencies: servicePhilosophy >=0.1.2,<0.2 and SQLPhilosophy >=0.3.4,<0.4. Build tooling requires patched setuptools >=84.2.1,<85. These unpublished minima are tested with exact local wheels before approval; fresh registry-only frozen checks remain required after upstream publication.
@@ -0,0 +1,5 @@
1
+ # learning-core Python
2
+
3
+ See [Python models and services](docs/README.md). Python 0.5.0 is the Company-free release approved on 2026-10-21; TypeScript remains 0.1.0. Existing hosts stay on their prior compatible artifacts until tenant-bound session adoption.
4
+
5
+ Coordinated candidate dependencies: servicePhilosophy >=0.1.2,<0.2 and SQLPhilosophy >=0.3.4,<0.4. Build tooling requires patched setuptools >=84.2.1,<85. These unpublished minima are tested with exact local wheels before approval; fresh registry-only frozen checks remain required after upstream publication.
@@ -0,0 +1,41 @@
1
+ # Learning models and services
2
+
3
+ Python 0.5.0 is an unpublished breaking Company-free candidate. Twelve learning defaults,
4
+ field contracts, repositories and services have no Company columns, FKs or scoping arguments.
5
+ TypeScript remains 0.1.0. Learning still has no platform-core dependency. Hosts add genuine
6
+ local identity/simulation/scenario-version FKs when composing contracts on their own registry.
7
+
8
+ ```python
9
+ from learning_core.models.defaults import Lesson
10
+ from learning_core.repositories.lessons import LessonRepository
11
+ from learning_core.services.lessons import LessonService
12
+
13
+ service = LessonService(LessonRepository(Lesson, session))
14
+ lesson = service.create_lesson({"key": "intro", "title": "Introduction"})
15
+ ```
16
+
17
+ The host supplies a tenant-bound database session, authorization, effective grants and concrete
18
+ versioned content. This package never chooses databases, parses hostnames or verifies JWTs.
19
+ Existing shared-database hosts must remain on 0.4.0 until session/authentication isolation is
20
+ implemented. These defaults do not authorize changes to existing databases.
21
+
22
+ Course lifecycle methods use local course IDs. Publication still requires an explicit,
23
+ host-authorized recipient_profile_ids list; omitting it fails before writes. Profile predicates
24
+ remain on learner run, enrollment, certificate and progress reads. State guards, ordered steps,
25
+ snapshot hashes, run-specific activity completion and caller-owned transactions remain intact.
26
+ Multiple attempts remain historical records; enrollment/progress/certificate uniqueness is
27
+ local to (profile_id, course_id). Batch keys, metrics and run-step progress retain local keys.
28
+
29
+ Lesson creation defaults to editable local content. Administration/import orchestration may
30
+ explicitly set is_master=True; user fields cannot override provenance. Master/imported lessons
31
+ remain visible when active, but default update and delete paths reject them. Authorized central
32
+ catalog editing may explicitly use update_lesson(..., allow_master=True); never expose this flag
33
+ as a customer permission bypass. Content timestamps and writable-field filtering remain.
34
+
35
+ `CourseProgressService` activity callbacks receive (profile_id, step, run_id). Preserve the
36
+ run ID when reading assessment/simulation completion so another course run cannot satisfy it.
37
+ Hosts own published scenario-version validation, assessment launch, provider integration and
38
+ HTTP contracts. Services return domain models/results and never commit or serialize HTTP views.
39
+
40
+ Run Ruff, strict mypy and all tests against disposable PostgreSQL, build clean wheel/sdist
41
+ artifacts and run scripts/check_python_artifact.py. Verify installed bytes before adoption.
@@ -0,0 +1,28 @@
1
+ [build-system]
2
+ requires = ["setuptools>=84.2.1,<85", "wheel>=0.46,<1"]
3
+ build-backend = "setuptools.build_meta"
4
+ [project]
5
+ name = "signalsafe-learning-core"
6
+ version = "0.5.0"
7
+ description = "Shared learning-core services and persistence"
8
+ readme = "README.md"
9
+ requires-python = ">=3.12,<4"
10
+ license = "MIT"
11
+ dependencies = ["servicephilosophy>=0.1.2,<0.2", "sqlphilosophy>=0.3.4,<0.4", "sqlalchemy>=2,<3"]
12
+ [dependency-groups]
13
+ dev = ["build>=1.6.1,<2", "mypy>=1.17,<2", "pytest>=8.3,<10", "psycopg2-binary>=2.9,<3", "ruff>=0.12,<1"]
14
+ [tool.setuptools.packages.find]
15
+ where = ["src"]
16
+ [tool.setuptools.package-data]
17
+ learning_core = ["py.typed"]
18
+ [tool.mypy]
19
+ strict = true
20
+ python_version = "3.12"
21
+ files = ["src", "tests"]
22
+ [tool.ruff]
23
+ target-version = "py312"
24
+ line-length = 90
25
+ [tool.ruff.lint]
26
+ select = ["E", "F", "I", "ANN", "ARG", "B", "C4", "PIE", "RET", "RUF", "SIM", "UP"]
27
+ [tool.pytest.ini_options]
28
+ testpaths = ["tests"]
@@ -0,0 +1,4 @@
1
+ [egg_info]
2
+ tag_build =
3
+ tag_date = 0
4
+
@@ -0,0 +1 @@
1
+ """Shared learning-core APIs; import from explicit defining modules."""
@@ -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
+ )