stapel-courses 0.1.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.
- stapel_courses-0.1.0/CONFIG.MD +43 -0
- stapel_courses-0.1.0/LICENSE +21 -0
- stapel_courses-0.1.0/PKG-INFO +155 -0
- stapel_courses-0.1.0/README.md +120 -0
- stapel_courses-0.1.0/__init__.py +31 -0
- stapel_courses-0.1.0/_capabilities.py +39 -0
- stapel_courses-0.1.0/_codegen.py +123 -0
- stapel_courses-0.1.0/_codegen_settings.py +119 -0
- stapel_courses-0.1.0/access.py +152 -0
- stapel_courses-0.1.0/actions.py +78 -0
- stapel_courses-0.1.0/admin.py +135 -0
- stapel_courses-0.1.0/apps.py +23 -0
- stapel_courses-0.1.0/beat.py +48 -0
- stapel_courses-0.1.0/blocks.py +168 -0
- stapel_courses-0.1.0/checks.py +154 -0
- stapel_courses-0.1.0/codegen_urls.py +6 -0
- stapel_courses-0.1.0/conf.py +100 -0
- stapel_courses-0.1.0/conftest.py +163 -0
- stapel_courses-0.1.0/docs/capabilities.json +299 -0
- stapel_courses-0.1.0/docs/errors.json +644 -0
- stapel_courses-0.1.0/docs/flows.json +639 -0
- stapel_courses-0.1.0/docs/llms.txt +214 -0
- stapel_courses-0.1.0/dto.py +353 -0
- stapel_courses-0.1.0/errors.py +81 -0
- stapel_courses-0.1.0/flows.py +68 -0
- stapel_courses-0.1.0/fsm.py +54 -0
- stapel_courses-0.1.0/functions.py +66 -0
- stapel_courses-0.1.0/gdpr.py +128 -0
- stapel_courses-0.1.0/management/__init__.py +0 -0
- stapel_courses-0.1.0/management/commands/__init__.py +0 -0
- stapel_courses-0.1.0/management/commands/courses_housekeeping.py +10 -0
- stapel_courses-0.1.0/management/commands/courses_seed_demo.py +16 -0
- stapel_courses-0.1.0/migrations/0001_initial.py +228 -0
- stapel_courses-0.1.0/migrations/__init__.py +0 -0
- stapel_courses-0.1.0/models.py +502 -0
- stapel_courses-0.1.0/pagination.py +47 -0
- stapel_courses-0.1.0/presenters.py +416 -0
- stapel_courses-0.1.0/preset.py +27 -0
- stapel_courses-0.1.0/py.typed +0 -0
- stapel_courses-0.1.0/pyproject.toml +89 -0
- stapel_courses-0.1.0/schemas/consumes/orders.order.paid.json +11 -0
- stapel_courses-0.1.0/schemas/consumes/orders.order.placed.json +23 -0
- stapel_courses-0.1.0/schemas/consumes/orders.order.refunded.json +11 -0
- stapel_courses-0.1.0/schemas/consumes/orders.order.status_changed.json +12 -0
- stapel_courses-0.1.0/schemas/consumes/user.merged.json +19 -0
- stapel_courses-0.1.0/schemas/emits/courses.certificate.issued.json +15 -0
- stapel_courses-0.1.0/schemas/emits/courses.course.completed.json +15 -0
- stapel_courses-0.1.0/schemas/emits/courses.enrollment.activated.json +17 -0
- stapel_courses-0.1.0/schemas/emits/courses.enrollment.status_changed.json +17 -0
- stapel_courses-0.1.0/schemas/functions/courses.certificate.verify.json +11 -0
- stapel_courses-0.1.0/schemas/functions/courses.enrollment.status.json +12 -0
- stapel_courses-0.1.0/schemas/functions/courses.purchasables.json +37 -0
- stapel_courses-0.1.0/seed.py +82 -0
- stapel_courses-0.1.0/serializers.py +725 -0
- stapel_courses-0.1.0/services/__init__.py +46 -0
- stapel_courses-0.1.0/services/authoring.py +351 -0
- stapel_courses-0.1.0/services/catalog.py +57 -0
- stapel_courses-0.1.0/services/certificates.py +112 -0
- stapel_courses-0.1.0/services/enrollments.py +300 -0
- stapel_courses-0.1.0/services/entitlements.py +67 -0
- stapel_courses-0.1.0/services/events.py +155 -0
- stapel_courses-0.1.0/services/gate.py +216 -0
- stapel_courses-0.1.0/services/learners.py +48 -0
- stapel_courses-0.1.0/services/progress.py +179 -0
- stapel_courses-0.1.0/services/purchases.py +177 -0
- stapel_courses-0.1.0/services/quizzes.py +307 -0
- stapel_courses-0.1.0/setup.cfg +4 -0
- stapel_courses-0.1.0/stapel_courses.egg-info/PKG-INFO +155 -0
- stapel_courses-0.1.0/stapel_courses.egg-info/SOURCES.txt +169 -0
- stapel_courses-0.1.0/stapel_courses.egg-info/dependency_links.txt +1 -0
- stapel_courses-0.1.0/stapel_courses.egg-info/requires.txt +10 -0
- stapel_courses-0.1.0/stapel_courses.egg-info/top_level.txt +1 -0
- stapel_courses-0.1.0/tests/test_access.py +167 -0
- stapel_courses-0.1.0/tests/test_access_strategies.py +47 -0
- stapel_courses-0.1.0/tests/test_architecture.py +57 -0
- stapel_courses-0.1.0/tests/test_author_certificates.py +60 -0
- stapel_courses-0.1.0/tests/test_authoring.py +255 -0
- stapel_courses-0.1.0/tests/test_catalog.py +121 -0
- stapel_courses-0.1.0/tests/test_certificates.py +103 -0
- stapel_courses-0.1.0/tests/test_checks.py +96 -0
- stapel_courses-0.1.0/tests/test_concurrency.py +169 -0
- stapel_courses-0.1.0/tests/test_contract.py +205 -0
- stapel_courses-0.1.0/tests/test_contract_profile2.py +84 -0
- stapel_courses-0.1.0/tests/test_contract_wire.py +436 -0
- stapel_courses-0.1.0/tests/test_embed_hosts.py +81 -0
- stapel_courses-0.1.0/tests/test_error_i18n.py +230 -0
- stapel_courses-0.1.0/tests/test_error_params.py +106 -0
- stapel_courses-0.1.0/tests/test_fsm.py +53 -0
- stapel_courses-0.1.0/tests/test_functions.py +38 -0
- stapel_courses-0.1.0/tests/test_gdpr.py +72 -0
- stapel_courses-0.1.0/tests/test_housekeeping.py +68 -0
- stapel_courses-0.1.0/tests/test_learners.py +76 -0
- stapel_courses-0.1.0/tests/test_merge.py +80 -0
- stapel_courses-0.1.0/tests/test_pacing.py +128 -0
- stapel_courses-0.1.0/tests/test_progress.py +190 -0
- stapel_courses-0.1.0/tests/test_public_api.py +46 -0
- stapel_courses-0.1.0/tests/test_purchases.py +179 -0
- stapel_courses-0.1.0/tests/test_quizzes.py +282 -0
- stapel_courses-0.1.0/tests/test_reviews.py +66 -0
- stapel_courses-0.1.0/translations/errors.es.json +31 -0
- stapel_courses-0.1.0/translations/errors.ru.json +31 -0
- stapel_courses-0.1.0/urls.py +14 -0
- stapel_courses-0.1.0/urls_v1.py +71 -0
- stapel_courses-0.1.0/views.py +777 -0
|
@@ -0,0 +1,43 @@
|
|
|
1
|
+
# CONFIG.MD — stapel-courses
|
|
2
|
+
|
|
3
|
+
Config registry for **stapel-courses**. One row per configuration key the
|
|
4
|
+
module reads, its **source** (`env` = the process environment / the
|
|
5
|
+
`STAPEL_COURSES` settings dict; `settings` = the settings module only), what
|
|
6
|
+
it is for, whether it is required, and its default.
|
|
7
|
+
|
|
8
|
+
Every key is read through `courses_settings` (`stapel_courses.conf`,
|
|
9
|
+
namespace `STAPEL_COURSES`). Resolution order per key:
|
|
10
|
+
`settings.STAPEL_COURSES` dict → a flat Django setting of the same name →
|
|
11
|
+
environment variable → the default below. `DEFAULT_ACCESS`,
|
|
12
|
+
`ENROLLMENT_REQUIRES_ACCOUNT`, `PURCHASE_ACTIVATION`, `DEFAULT_DRIP`,
|
|
13
|
+
`DEFAULT_SEQUENTIAL`, `AUTHORING` and `CERTIFICATES` are CTO-facing config
|
|
14
|
+
axes.
|
|
15
|
+
|
|
16
|
+
## stapel-courses
|
|
17
|
+
|
|
18
|
+
| Key | Source | Purpose | Required | Default |
|
|
19
|
+
|-----|--------|---------|----------|---------|
|
|
20
|
+
| ACCESS_STRATEGIES | settings | access strategies `{name: dotted path or None}` merged over free / enrolled / purchased / entitlement; a dotted path under a built-in name replaces it. Checked by E001. | no | {} |
|
|
21
|
+
| DEFAULT_ACCESS | env | axis: the access strategy a new course starts with. Unknown name is E002. | no | enrolled |
|
|
22
|
+
| DEFAULT_DRIP | env | axis: the drip mode a new course starts with (none, days, date). E005. | no | none |
|
|
23
|
+
| DEFAULT_SEQUENTIAL | env | axis: a new course unlocks lessons strictly in order. | no | false |
|
|
24
|
+
| AUTHORING | env | axis: who creates courses (staff, members). E005. | no | staff |
|
|
25
|
+
| ENROLLMENT_REQUIRES_ACCOUNT | env | axis: a guest gets `error.403.enrollment_requires_account` on enroll / progress / attempts. | no | true |
|
|
26
|
+
| PURCHASABLE_TYPE | env | the orders purchasable type a course line carries. | no | course |
|
|
27
|
+
| PURCHASE_ACTIVATION | env | axis: which order fact activates a bought course (paid, confirmed, placed). E005. | no | paid |
|
|
28
|
+
| ENTITLEMENT_FUNCTION | env | the comm Function asked `{user_id, key}` for the entitlement strategy. | no | billing.check_entitlement |
|
|
29
|
+
| ENTITLEMENT_KEY_TEMPLATE | env | `{slug}` / `{course_id}` template of the entitlement key when a course names none. | no | course:{slug} |
|
|
30
|
+
| ENTITLEMENT_CACHE_SECONDS | env | how long an entitlement answer is cached; 0 = ask every time. | no | 300 |
|
|
31
|
+
| BLOCK_TYPES | settings | lesson block validators `{type: dotted path or None}` merged over text / video / attachment / embed. E004. | no | {} |
|
|
32
|
+
| CARDS_FUNCTION | env | the comm Function asked `{user_ids}` for learner display cards on the author/staff views (profiles.public_cards contract); empty = `user_id` only. | no | profiles.public_cards |
|
|
33
|
+
| EMBED_HOSTS | settings | exact hosts an embed block may use (https only); bare host names (E007); empty = no embed block is accepted. | no | youtube, youtube-nocookie, vimeo, google maps hosts |
|
|
34
|
+
| DEFAULT_PASS_MARK | env | pass mark (percent) of a new quiz. | no | 70 |
|
|
35
|
+
| DEFAULT_MAX_ATTEMPTS | env | attempt limit of a new quiz; 0 = unlimited. | no | 3 |
|
|
36
|
+
| COMPLETION_RULE | settings | dotted path `(enrollment) -> bool` deciding completion. E006. | no | stapel_courses.services.progress.default_completion_rule |
|
|
37
|
+
| CERTIFICATES | env | axis: issue a certificate on completion. | no | true |
|
|
38
|
+
| PUBLIC_VERIFY_FIELDS | settings | fields the public verification shows besides number and validity (holder_name, course_title, course_slug, issued_at). E003. | no | ["course_title", "issued_at"] |
|
|
39
|
+
| CERTIFICATE_NUMBER_PREFIX | env | prefix of certificate numbers. | no | CERT |
|
|
40
|
+
| HOLDER_NAME_RESOLVER | settings | dotted path `(user_id) -> str`, the name printed on a certificate. E006. | no | stapel_courses.services.certificates.default_holder_name |
|
|
41
|
+
| NOTIFY | env | best-effort notifications courses.enrollment_activated / .completed / .certificate_issued. | no | true |
|
|
42
|
+
| COURSE_URL_TEMPLATE | env | `{slug}` / `{course_id}` link for notifications and the purchasable `url`; empty = no link. | no | "" |
|
|
43
|
+
| CERTIFICATE_URL_TEMPLATE | env | `{number}` / `{slug}` / `{course_id}` link for the certificate notification; empty = no link. | no | "" |
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
MIT License
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2026 Stapel contributors
|
|
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
|
|
9
|
+
copies of the Software, and to permit persons to whom the Software is
|
|
10
|
+
furnished to do so, 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,155 @@
|
|
|
1
|
+
Metadata-Version: 2.4
|
|
2
|
+
Name: stapel-courses
|
|
3
|
+
Version: 0.1.0
|
|
4
|
+
Summary: Courses, lessons, enrollment, progress, quizzes and certificates for the Stapel framework
|
|
5
|
+
License: MIT
|
|
6
|
+
Project-URL: Homepage, https://github.com/usestapel/stapel-courses
|
|
7
|
+
Project-URL: Repository, https://github.com/usestapel/stapel-courses
|
|
8
|
+
Project-URL: Documentation, https://github.com/usestapel/stapel-courses#readme
|
|
9
|
+
Project-URL: Changelog, https://github.com/usestapel/stapel-courses/blob/main/CHANGELOG.md
|
|
10
|
+
Project-URL: Issues, https://github.com/usestapel/stapel-courses/issues
|
|
11
|
+
Keywords: django,stapel,courses,lms,e-learning,quizzes,certificates
|
|
12
|
+
Classifier: Development Status :: 3 - Alpha
|
|
13
|
+
Classifier: Framework :: Django
|
|
14
|
+
Classifier: Intended Audience :: Developers
|
|
15
|
+
Classifier: License :: OSI Approved :: MIT License
|
|
16
|
+
Classifier: Operating System :: OS Independent
|
|
17
|
+
Classifier: Programming Language :: Python :: 3 :: Only
|
|
18
|
+
Classifier: Programming Language :: Python :: 3.11
|
|
19
|
+
Classifier: Programming Language :: Python :: 3.12
|
|
20
|
+
Classifier: Programming Language :: Python :: 3.13
|
|
21
|
+
Classifier: Programming Language :: Python :: 3.14
|
|
22
|
+
Classifier: Typing :: Typed
|
|
23
|
+
Requires-Python: >=3.11
|
|
24
|
+
Description-Content-Type: text/markdown
|
|
25
|
+
License-File: LICENSE
|
|
26
|
+
Requires-Dist: stapel-core<1.0,>=0.99.3
|
|
27
|
+
Provides-Extra: all
|
|
28
|
+
Provides-Extra: test
|
|
29
|
+
Requires-Dist: pytest; extra == "test"
|
|
30
|
+
Requires-Dist: pytest-django; extra == "test"
|
|
31
|
+
Requires-Dist: pytest-cov; extra == "test"
|
|
32
|
+
Requires-Dist: stapel-tools<1,>=0.84.0; extra == "test"
|
|
33
|
+
Requires-Dist: jsonschema>=4; extra == "test"
|
|
34
|
+
Dynamic: license-file
|
|
35
|
+
|
|
36
|
+
<!-- Generated by stapel-readme from docs/readme.md + docs/*.json. Do not edit this file; edit docs/readme.md and re-run `make readme`. -->
|
|
37
|
+
|
|
38
|
+
# stapel-courses
|
|
39
|
+
|
|
40
|
+
[](https://github.com/usestapel/stapel-courses/actions/workflows/ci.yml?query=branch%3Amain)
|
|
41
|
+
[](https://app.codecov.io/gh/usestapel/stapel-courses)
|
|
42
|
+
[](https://pypi.org/project/stapel-courses/)
|
|
43
|
+
[](https://pepy.tech/project/stapel-courses)
|
|
44
|
+
[](https://pypi.org/project/stapel-courses/)
|
|
45
|
+
[](https://github.com/usestapel/stapel-courses/blob/main/LICENSE)
|
|
46
|
+
[](https://github.com/usestapel/stapel-courses/blob/main/docs/llms.txt)
|
|
47
|
+
|
|
48
|
+
> Courses for a Stapel education product: Course -> Module -> Lesson (ordered, typed content blocks: text, video and attachments by opaque media id, embeds), enrollment with a lifecycle (pending, active, completed, expired, cancelled), a source (free, purchase, entitlement, staff grant) and an optional expiry, and an access gate per course chosen from a strategy registry (free, enrolled, purchased through stapel-orders, entitlement through stapel-billing). The outline names a lock reason for every lesson (sign in, enroll, buy, plan, drip date, previous lesson). Lesson progress is an idempotent upsert with a per-enrollment progress cache; drip by days since enrollment or by fixed date and a sequential-unlock switch pace a course. Quizzes on a lesson or module (single and multiple choice, true/false, short text) are graded on the server with attempt limits, a pass mark and a stored shuffle seed; answers never leave before submission. Completing every required lesson and quiz completes the course and issues a certificate with a public verification endpoint. A course is sold as orders purchasable type 'course' (resolver Function courses.purchasables); the order facts activate and cancel the enrollment. Courses never imports orders or billing.
|
|
49
|
+
|
|
50
|
+
Part of the [Stapel framework](https://github.com/usestapel) — composable Django apps that deploy as a monolith or as microservices without changing module code.
|
|
51
|
+
|
|
52
|
+
## Install
|
|
53
|
+
|
|
54
|
+
```bash
|
|
55
|
+
pip install stapel-courses
|
|
56
|
+
```
|
|
57
|
+
|
|
58
|
+
## At a glance
|
|
59
|
+
|
|
60
|
+
| Fact | Value |
|
|
61
|
+
|---|---|
|
|
62
|
+
| Version | `0.1.0` |
|
|
63
|
+
| Python | `>=3.11` (3.11, 3.12, 3.13, 3.14) |
|
|
64
|
+
| HTTP operations | 41 |
|
|
65
|
+
| Config axes | 8 |
|
|
66
|
+
| Usage surface | 12 |
|
|
67
|
+
| Extension points | 10 |
|
|
68
|
+
| Error codes | 72 |
|
|
69
|
+
| Documented flows | 5 |
|
|
70
|
+
| Fleet dependencies | [`stapel-auth`](https://github.com/usestapel/stapel-auth) (optional) · [`stapel-billing`](https://github.com/usestapel/stapel-billing) (optional) · [`stapel-cdn`](https://github.com/usestapel/stapel-cdn) (optional) · [`stapel-core`](https://github.com/usestapel/stapel-core) · [`stapel-notifications`](https://github.com/usestapel/stapel-notifications) (optional) · [`stapel-orders`](https://github.com/usestapel/stapel-orders) (optional) · [`stapel-profiles`](https://github.com/usestapel/stapel-profiles) (optional) |
|
|
71
|
+
|
|
72
|
+
## Documentation
|
|
73
|
+
|
|
74
|
+
**Errors:** [English](https://github.com/usestapel/stapel-courses/blob/main/docs/errors.en.md) · [Español](https://github.com/usestapel/stapel-courses/blob/main/docs/errors.es.md) · [Русский](https://github.com/usestapel/stapel-courses/blob/main/docs/errors.ru.md) · [OpenAPI](https://github.com/usestapel/stapel-courses/blob/main/docs/schema.json) · [capabilities.json](https://github.com/usestapel/stapel-courses/blob/main/docs/capabilities.json) · [llms.txt (for agents)](https://github.com/usestapel/stapel-courses/blob/main/docs/llms.txt)
|
|
75
|
+
|
|
76
|
+
## What this is
|
|
77
|
+
|
|
78
|
+
Courses for a Stapel education product: courses made of modules and
|
|
79
|
+
lessons, enrollment with a lifecycle and an access gate per course, lesson
|
|
80
|
+
progress, quizzes graded on the server, and certificates with a public
|
|
81
|
+
verification page. The module never imports a sibling: a course is **sold**
|
|
82
|
+
through stapel-orders as purchasable type `course` (its resolver is the
|
|
83
|
+
`courses.purchasables` Function and the order facts open and close the
|
|
84
|
+
enrollment), and a **plan** includes a course through stapel-billing's
|
|
85
|
+
`billing.check_entitlement` Function, asked by name.
|
|
86
|
+
|
|
87
|
+
## Quick start
|
|
88
|
+
|
|
89
|
+
```python
|
|
90
|
+
INSTALLED_APPS = [
|
|
91
|
+
# ...
|
|
92
|
+
"stapel_courses",
|
|
93
|
+
]
|
|
94
|
+
|
|
95
|
+
STAPEL_COURSES = {
|
|
96
|
+
"DEFAULT_ACCESS": "enrolled", # free | enrolled | purchased | entitlement
|
|
97
|
+
}
|
|
98
|
+
|
|
99
|
+
# urls.py
|
|
100
|
+
path("courses/api/", include("stapel_courses.urls")) # -> /courses/api/v1/...
|
|
101
|
+
|
|
102
|
+
# settings.py — enrollment expiry (Celery optional; or manage.py courses_housekeeping)
|
|
103
|
+
from stapel_courses.beat import get_courses_beat_schedule
|
|
104
|
+
CELERY_BEAT_SCHEDULE = {**get_courses_beat_schedule()}
|
|
105
|
+
```
|
|
106
|
+
|
|
107
|
+
Sell courses next to stapel-orders (no import either way):
|
|
108
|
+
|
|
109
|
+
```python
|
|
110
|
+
from stapel_courses.preset import SETTINGS_DEFAULTS as COURSES
|
|
111
|
+
|
|
112
|
+
STAPEL_ORDERS = {
|
|
113
|
+
"PURCHASABLE_TYPES": {**COURSES["STAPEL_ORDERS"]["PURCHASABLE_TYPES"]}, # "course"
|
|
114
|
+
}
|
|
115
|
+
STAPEL_COURSES = {"PURCHASE_ACTIVATION": "paid"} # paid | confirmed | placed
|
|
116
|
+
```
|
|
117
|
+
|
|
118
|
+
A demo course: `python manage.py courses_seed_demo`.
|
|
119
|
+
|
|
120
|
+
## Concepts
|
|
121
|
+
|
|
122
|
+
- **Course → Module → Lesson** — ordered; a lesson is a list of typed
|
|
123
|
+
content blocks (`text`, `video` and `attachment` by opaque media id,
|
|
124
|
+
`embed` by https URL; a host registers more in `BLOCK_TYPES`). A lesson
|
|
125
|
+
may be a free preview, optional, or need a reviewer's "passed".
|
|
126
|
+
- **Access** — each course names a strategy: `free` (everyone reads),
|
|
127
|
+
`enrolled` (enroll for free, then read), `purchased` (buy it through
|
|
128
|
+
orders), `entitlement` (a billing plan includes it). The outline names a
|
|
129
|
+
lock reason for every lesson; staff and the author always see everything.
|
|
130
|
+
- **Enrollment** — `pending → active → completed`, `expired` (by the beat
|
|
131
|
+
after `access_days`), `cancelled`; source `free`, `purchase`,
|
|
132
|
+
`entitlement` or `staff`. One row per course and learner.
|
|
133
|
+
- **Pacing** — drip by days since enrollment or by fixed dates, and a
|
|
134
|
+
sequential switch (a lesson opens after the earlier required lessons and
|
|
135
|
+
quizzes are done).
|
|
136
|
+
- **Progress** — an idempotent upsert per lesson (forward-only status, last
|
|
137
|
+
video position) and a progress cache on the enrollment.
|
|
138
|
+
- **Quizzes** — single/multiple choice, true/false, short text (exact or
|
|
139
|
+
normalised match); attempt limits, pass mark, a stored shuffle seed;
|
|
140
|
+
graded on the server; right answers are never sent before submission and
|
|
141
|
+
afterwards only as the quiz's reveal mode allows.
|
|
142
|
+
- **Completion and certificates** — every required lesson completed and
|
|
143
|
+
every required quiz passed completes the course; a certificate with a
|
|
144
|
+
unique number is issued once; `GET certificates/{number}/` verifies it and
|
|
145
|
+
shows only the fields `PUBLIC_VERIFY_FIELDS` names.
|
|
146
|
+
- **GDPR** — export of enrollments, progress, attempts and certificates;
|
|
147
|
+
erasure deletes the learning data and anonymises and revokes certificates.
|
|
148
|
+
|
|
149
|
+
## License
|
|
150
|
+
|
|
151
|
+
MIT — see [LICENSE](https://github.com/usestapel/stapel-courses/blob/main/LICENSE).
|
|
152
|
+
|
|
153
|
+
---
|
|
154
|
+
|
|
155
|
+
<sub>This page is assembled by `stapel-readme` from `docs/readme.md` plus the contract artifacts in `docs/`. Edit the prose in `docs/readme.md`; the badges, facts and links above and below it are generated — do not hand-edit `README.md`.</sub>
|
|
@@ -0,0 +1,120 @@
|
|
|
1
|
+
<!-- Generated by stapel-readme from docs/readme.md + docs/*.json. Do not edit this file; edit docs/readme.md and re-run `make readme`. -->
|
|
2
|
+
|
|
3
|
+
# stapel-courses
|
|
4
|
+
|
|
5
|
+
[](https://github.com/usestapel/stapel-courses/actions/workflows/ci.yml?query=branch%3Amain)
|
|
6
|
+
[](https://app.codecov.io/gh/usestapel/stapel-courses)
|
|
7
|
+
[](https://pypi.org/project/stapel-courses/)
|
|
8
|
+
[](https://pepy.tech/project/stapel-courses)
|
|
9
|
+
[](https://pypi.org/project/stapel-courses/)
|
|
10
|
+
[](https://github.com/usestapel/stapel-courses/blob/main/LICENSE)
|
|
11
|
+
[](https://github.com/usestapel/stapel-courses/blob/main/docs/llms.txt)
|
|
12
|
+
|
|
13
|
+
> Courses for a Stapel education product: Course -> Module -> Lesson (ordered, typed content blocks: text, video and attachments by opaque media id, embeds), enrollment with a lifecycle (pending, active, completed, expired, cancelled), a source (free, purchase, entitlement, staff grant) and an optional expiry, and an access gate per course chosen from a strategy registry (free, enrolled, purchased through stapel-orders, entitlement through stapel-billing). The outline names a lock reason for every lesson (sign in, enroll, buy, plan, drip date, previous lesson). Lesson progress is an idempotent upsert with a per-enrollment progress cache; drip by days since enrollment or by fixed date and a sequential-unlock switch pace a course. Quizzes on a lesson or module (single and multiple choice, true/false, short text) are graded on the server with attempt limits, a pass mark and a stored shuffle seed; answers never leave before submission. Completing every required lesson and quiz completes the course and issues a certificate with a public verification endpoint. A course is sold as orders purchasable type 'course' (resolver Function courses.purchasables); the order facts activate and cancel the enrollment. Courses never imports orders or billing.
|
|
14
|
+
|
|
15
|
+
Part of the [Stapel framework](https://github.com/usestapel) — composable Django apps that deploy as a monolith or as microservices without changing module code.
|
|
16
|
+
|
|
17
|
+
## Install
|
|
18
|
+
|
|
19
|
+
```bash
|
|
20
|
+
pip install stapel-courses
|
|
21
|
+
```
|
|
22
|
+
|
|
23
|
+
## At a glance
|
|
24
|
+
|
|
25
|
+
| Fact | Value |
|
|
26
|
+
|---|---|
|
|
27
|
+
| Version | `0.1.0` |
|
|
28
|
+
| Python | `>=3.11` (3.11, 3.12, 3.13, 3.14) |
|
|
29
|
+
| HTTP operations | 41 |
|
|
30
|
+
| Config axes | 8 |
|
|
31
|
+
| Usage surface | 12 |
|
|
32
|
+
| Extension points | 10 |
|
|
33
|
+
| Error codes | 72 |
|
|
34
|
+
| Documented flows | 5 |
|
|
35
|
+
| Fleet dependencies | [`stapel-auth`](https://github.com/usestapel/stapel-auth) (optional) · [`stapel-billing`](https://github.com/usestapel/stapel-billing) (optional) · [`stapel-cdn`](https://github.com/usestapel/stapel-cdn) (optional) · [`stapel-core`](https://github.com/usestapel/stapel-core) · [`stapel-notifications`](https://github.com/usestapel/stapel-notifications) (optional) · [`stapel-orders`](https://github.com/usestapel/stapel-orders) (optional) · [`stapel-profiles`](https://github.com/usestapel/stapel-profiles) (optional) |
|
|
36
|
+
|
|
37
|
+
## Documentation
|
|
38
|
+
|
|
39
|
+
**Errors:** [English](https://github.com/usestapel/stapel-courses/blob/main/docs/errors.en.md) · [Español](https://github.com/usestapel/stapel-courses/blob/main/docs/errors.es.md) · [Русский](https://github.com/usestapel/stapel-courses/blob/main/docs/errors.ru.md) · [OpenAPI](https://github.com/usestapel/stapel-courses/blob/main/docs/schema.json) · [capabilities.json](https://github.com/usestapel/stapel-courses/blob/main/docs/capabilities.json) · [llms.txt (for agents)](https://github.com/usestapel/stapel-courses/blob/main/docs/llms.txt)
|
|
40
|
+
|
|
41
|
+
## What this is
|
|
42
|
+
|
|
43
|
+
Courses for a Stapel education product: courses made of modules and
|
|
44
|
+
lessons, enrollment with a lifecycle and an access gate per course, lesson
|
|
45
|
+
progress, quizzes graded on the server, and certificates with a public
|
|
46
|
+
verification page. The module never imports a sibling: a course is **sold**
|
|
47
|
+
through stapel-orders as purchasable type `course` (its resolver is the
|
|
48
|
+
`courses.purchasables` Function and the order facts open and close the
|
|
49
|
+
enrollment), and a **plan** includes a course through stapel-billing's
|
|
50
|
+
`billing.check_entitlement` Function, asked by name.
|
|
51
|
+
|
|
52
|
+
## Quick start
|
|
53
|
+
|
|
54
|
+
```python
|
|
55
|
+
INSTALLED_APPS = [
|
|
56
|
+
# ...
|
|
57
|
+
"stapel_courses",
|
|
58
|
+
]
|
|
59
|
+
|
|
60
|
+
STAPEL_COURSES = {
|
|
61
|
+
"DEFAULT_ACCESS": "enrolled", # free | enrolled | purchased | entitlement
|
|
62
|
+
}
|
|
63
|
+
|
|
64
|
+
# urls.py
|
|
65
|
+
path("courses/api/", include("stapel_courses.urls")) # -> /courses/api/v1/...
|
|
66
|
+
|
|
67
|
+
# settings.py — enrollment expiry (Celery optional; or manage.py courses_housekeeping)
|
|
68
|
+
from stapel_courses.beat import get_courses_beat_schedule
|
|
69
|
+
CELERY_BEAT_SCHEDULE = {**get_courses_beat_schedule()}
|
|
70
|
+
```
|
|
71
|
+
|
|
72
|
+
Sell courses next to stapel-orders (no import either way):
|
|
73
|
+
|
|
74
|
+
```python
|
|
75
|
+
from stapel_courses.preset import SETTINGS_DEFAULTS as COURSES
|
|
76
|
+
|
|
77
|
+
STAPEL_ORDERS = {
|
|
78
|
+
"PURCHASABLE_TYPES": {**COURSES["STAPEL_ORDERS"]["PURCHASABLE_TYPES"]}, # "course"
|
|
79
|
+
}
|
|
80
|
+
STAPEL_COURSES = {"PURCHASE_ACTIVATION": "paid"} # paid | confirmed | placed
|
|
81
|
+
```
|
|
82
|
+
|
|
83
|
+
A demo course: `python manage.py courses_seed_demo`.
|
|
84
|
+
|
|
85
|
+
## Concepts
|
|
86
|
+
|
|
87
|
+
- **Course → Module → Lesson** — ordered; a lesson is a list of typed
|
|
88
|
+
content blocks (`text`, `video` and `attachment` by opaque media id,
|
|
89
|
+
`embed` by https URL; a host registers more in `BLOCK_TYPES`). A lesson
|
|
90
|
+
may be a free preview, optional, or need a reviewer's "passed".
|
|
91
|
+
- **Access** — each course names a strategy: `free` (everyone reads),
|
|
92
|
+
`enrolled` (enroll for free, then read), `purchased` (buy it through
|
|
93
|
+
orders), `entitlement` (a billing plan includes it). The outline names a
|
|
94
|
+
lock reason for every lesson; staff and the author always see everything.
|
|
95
|
+
- **Enrollment** — `pending → active → completed`, `expired` (by the beat
|
|
96
|
+
after `access_days`), `cancelled`; source `free`, `purchase`,
|
|
97
|
+
`entitlement` or `staff`. One row per course and learner.
|
|
98
|
+
- **Pacing** — drip by days since enrollment or by fixed dates, and a
|
|
99
|
+
sequential switch (a lesson opens after the earlier required lessons and
|
|
100
|
+
quizzes are done).
|
|
101
|
+
- **Progress** — an idempotent upsert per lesson (forward-only status, last
|
|
102
|
+
video position) and a progress cache on the enrollment.
|
|
103
|
+
- **Quizzes** — single/multiple choice, true/false, short text (exact or
|
|
104
|
+
normalised match); attempt limits, pass mark, a stored shuffle seed;
|
|
105
|
+
graded on the server; right answers are never sent before submission and
|
|
106
|
+
afterwards only as the quiz's reveal mode allows.
|
|
107
|
+
- **Completion and certificates** — every required lesson completed and
|
|
108
|
+
every required quiz passed completes the course; a certificate with a
|
|
109
|
+
unique number is issued once; `GET certificates/{number}/` verifies it and
|
|
110
|
+
shows only the fields `PUBLIC_VERIFY_FIELDS` names.
|
|
111
|
+
- **GDPR** — export of enrollments, progress, attempts and certificates;
|
|
112
|
+
erasure deletes the learning data and anonymises and revokes certificates.
|
|
113
|
+
|
|
114
|
+
## License
|
|
115
|
+
|
|
116
|
+
MIT — see [LICENSE](https://github.com/usestapel/stapel-courses/blob/main/LICENSE).
|
|
117
|
+
|
|
118
|
+
---
|
|
119
|
+
|
|
120
|
+
<sub>This page is assembled by `stapel-readme` from `docs/readme.md` plus the contract artifacts in `docs/`. Edit the prose in `docs/readme.md`; the badges, facts and links above and below it are generated — do not hand-edit `README.md`.</sub>
|
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
"""stapel-courses — Courses and learning for the Stapel framework.
|
|
2
|
+
|
|
3
|
+
Public API (lazily exported, PEP 562 — importing this package never pulls
|
|
4
|
+
in Django or requires configured settings):
|
|
5
|
+
|
|
6
|
+
- ``courses_settings`` — resolved app settings (``stapel_courses.conf``).
|
|
7
|
+
"""
|
|
8
|
+
|
|
9
|
+
__all__ = [
|
|
10
|
+
"courses_settings",
|
|
11
|
+
]
|
|
12
|
+
|
|
13
|
+
# name -> submodule that defines it. Resolution is deferred until first
|
|
14
|
+
# attribute access so that `import stapel_courses` stays Django-free.
|
|
15
|
+
_LAZY_EXPORTS = {
|
|
16
|
+
"courses_settings": ".conf",
|
|
17
|
+
}
|
|
18
|
+
|
|
19
|
+
|
|
20
|
+
def __getattr__(name):
|
|
21
|
+
if name in _LAZY_EXPORTS:
|
|
22
|
+
from importlib import import_module
|
|
23
|
+
|
|
24
|
+
value = getattr(import_module(_LAZY_EXPORTS[name], __name__), name)
|
|
25
|
+
globals()[name] = value # cache for subsequent lookups
|
|
26
|
+
return value
|
|
27
|
+
raise AttributeError(f"module {__name__!r} has no attribute {name!r}")
|
|
28
|
+
|
|
29
|
+
|
|
30
|
+
def __dir__():
|
|
31
|
+
return sorted(set(globals()) | set(__all__))
|
|
@@ -0,0 +1,39 @@
|
|
|
1
|
+
"""stapel-courses capabilities.json emitter — thin shim over stapel_tools.capabilities."""
|
|
2
|
+
from pathlib import Path
|
|
3
|
+
|
|
4
|
+
from stapel_tools.capabilities import axis_group_rules, run_capabilities_cli
|
|
5
|
+
|
|
6
|
+
#: CTO-facing axes, all behavioural (no endpoint is unmounted).
|
|
7
|
+
AXES = {
|
|
8
|
+
"DEFAULT_ACCESS": "courses.access",
|
|
9
|
+
"ENROLLMENT_REQUIRES_ACCOUNT": "courses.access",
|
|
10
|
+
"PURCHASE_ACTIVATION": "courses.purchase",
|
|
11
|
+
"DEFAULT_DRIP": "courses.pacing",
|
|
12
|
+
"DEFAULT_SEQUENTIAL": "courses.pacing",
|
|
13
|
+
"AUTHORING": "courses.authoring",
|
|
14
|
+
"CERTIFICATES": "courses.certificates",
|
|
15
|
+
"EMBED_HOSTS": "courses.content",
|
|
16
|
+
}
|
|
17
|
+
|
|
18
|
+
|
|
19
|
+
def main(argv=None):
|
|
20
|
+
from stapel_courses._codegen import _configure
|
|
21
|
+
|
|
22
|
+
_configure()
|
|
23
|
+
from stapel_courses.conf import DEFAULTS
|
|
24
|
+
from stapel_courses.urls import GATE_REGISTRY
|
|
25
|
+
|
|
26
|
+
return run_capabilities_cli(
|
|
27
|
+
argv,
|
|
28
|
+
repo=Path(__file__).resolve().parent,
|
|
29
|
+
canonical_prefix="/courses/api/v1",
|
|
30
|
+
defaults=DEFAULTS,
|
|
31
|
+
registry=GATE_REGISTRY,
|
|
32
|
+
is_axis=lambda k: k in AXES,
|
|
33
|
+
axis_group=axis_group_rules(exact=AXES),
|
|
34
|
+
prog="stapel-courses-capabilities",
|
|
35
|
+
)
|
|
36
|
+
|
|
37
|
+
|
|
38
|
+
if __name__ == "__main__":
|
|
39
|
+
raise SystemExit(main())
|
|
@@ -0,0 +1,123 @@
|
|
|
1
|
+
"""stapel-courses contract-emission harness (contract-pipeline.md §2-3).
|
|
2
|
+
|
|
3
|
+
Emits the module's own contract triad into ``docs/`` from a single-module
|
|
4
|
+
``{courses + core}`` Django instance mounted at the canonical
|
|
5
|
+
``courses/api/v1/`` prefix:
|
|
6
|
+
|
|
7
|
+
docs/schema.json drf-spectacular OpenAPI, this module only, canonical prefix
|
|
8
|
+
docs/flows.json generate_flow_docs machine artifact ([] — no @flow_step here)
|
|
9
|
+
docs/errors.json generate_error_keys registry
|
|
10
|
+
|
|
11
|
+
The *mechanism* is stapel_tools.codegen (shared, unchanged); this file is the
|
|
12
|
+
thin per-module *config* that wires the module's settings + canonical mount.
|
|
13
|
+
|
|
14
|
+
Usage:
|
|
15
|
+
python -m stapel_courses._codegen --out docs # `make contract`
|
|
16
|
+
"""
|
|
17
|
+
from __future__ import annotations
|
|
18
|
+
|
|
19
|
+
import argparse
|
|
20
|
+
import os
|
|
21
|
+
import sys
|
|
22
|
+
from pathlib import Path
|
|
23
|
+
|
|
24
|
+
|
|
25
|
+
def _configure() -> None:
|
|
26
|
+
"""Configure + boot the single-module Django instance for emission."""
|
|
27
|
+
repo_root = os.path.dirname(os.path.abspath(__file__))
|
|
28
|
+
sys.path[:] = [p for p in sys.path if os.path.abspath(p or os.getcwd()) != repo_root]
|
|
29
|
+
|
|
30
|
+
from django.conf import settings
|
|
31
|
+
|
|
32
|
+
if not settings.configured:
|
|
33
|
+
from stapel_courses._codegen_settings import settings_kwargs
|
|
34
|
+
|
|
35
|
+
settings.configure(
|
|
36
|
+
**settings_kwargs(root_urlconf="stapel_courses.codegen_urls", contract=True)
|
|
37
|
+
)
|
|
38
|
+
|
|
39
|
+
import django
|
|
40
|
+
|
|
41
|
+
django.setup()
|
|
42
|
+
|
|
43
|
+
from drf_spectacular.settings import spectacular_settings
|
|
44
|
+
|
|
45
|
+
from stapel_courses._codegen_settings import CODEGEN_SCHEMA_PATH_PREFIX
|
|
46
|
+
|
|
47
|
+
spectacular_settings.SCHEMA_PATH_PREFIX = CODEGEN_SCHEMA_PATH_PREFIX
|
|
48
|
+
|
|
49
|
+
# Stable enum component names (stapel-schema-lint SCH004).
|
|
50
|
+
from drf_spectacular.plumbing import _load_enum_name_overrides
|
|
51
|
+
|
|
52
|
+
from stapel_courses._codegen_settings import enum_name_overrides
|
|
53
|
+
|
|
54
|
+
spectacular_settings.ENUM_NAME_OVERRIDES = enum_name_overrides()
|
|
55
|
+
_load_enum_name_overrides.cache_clear()
|
|
56
|
+
|
|
57
|
+
# Register drf-spectacular's JWT cookie-auth extension explicitly (a real
|
|
58
|
+
# host triggers this as a side effect of wiring its Swagger URLs). Without
|
|
59
|
+
# it, the protected endpoints
|
|
60
|
+
# would emit without their `security: [{"JWTCookieAuth": []}]` entry — a
|
|
61
|
+
# real contract gap. Applied per stapel-calendar's precedent.
|
|
62
|
+
from stapel_core.django.openapi.swagger import _register_jwt_auth_extension
|
|
63
|
+
|
|
64
|
+
_register_jwt_auth_extension()
|
|
65
|
+
|
|
66
|
+
|
|
67
|
+
def _require_python_312() -> None:
|
|
68
|
+
"""Abort emission if not running the pinned 3.12 interpreter.
|
|
69
|
+
|
|
70
|
+
drf-spectacular's rendering of component descriptions (``Optional[X]`` vs
|
|
71
|
+
``X | None``) depends on the Python minor version — contracts emitted on
|
|
72
|
+
anything other than 3.12 (the CI/monolith pin) produce false diffs.
|
|
73
|
+
"""
|
|
74
|
+
if sys.version_info[:2] != (3, 12):
|
|
75
|
+
got = f"{sys.version_info.major}.{sys.version_info.minor}"
|
|
76
|
+
raise SystemExit(
|
|
77
|
+
f"stapel-courses contract emission ABORTED: running Python {got}, "
|
|
78
|
+
"but contracts must be emitted on Python 3.12 (the CI/monolith "
|
|
79
|
+
"pin). drf-spectacular renders component descriptions (Optional[X] "
|
|
80
|
+
"vs X | None) differently across Python minor versions, so emitting "
|
|
81
|
+
"on any other minor produces false diffs against the committed "
|
|
82
|
+
"docs/*.json. Re-run under a 3.12 interpreter."
|
|
83
|
+
)
|
|
84
|
+
|
|
85
|
+
|
|
86
|
+
def main(argv: list[str] | None = None) -> int:
|
|
87
|
+
_require_python_312()
|
|
88
|
+
|
|
89
|
+
parser = argparse.ArgumentParser(
|
|
90
|
+
prog="stapel-courses-contract",
|
|
91
|
+
description="Emit this module's contract triad (schema.json + flows.json "
|
|
92
|
+
"+ errors.json) into --out, canonical /courses/api/v1/ prefix.",
|
|
93
|
+
)
|
|
94
|
+
parser.add_argument(
|
|
95
|
+
"--out",
|
|
96
|
+
default="docs",
|
|
97
|
+
help="Output directory for the triad (default: docs).",
|
|
98
|
+
)
|
|
99
|
+
args = parser.parse_args(argv)
|
|
100
|
+
|
|
101
|
+
_configure()
|
|
102
|
+
|
|
103
|
+
from stapel_tools.codegen import emit_errors, emit_flows, emit_schema
|
|
104
|
+
|
|
105
|
+
out = Path(args.out)
|
|
106
|
+
out.mkdir(parents=True, exist_ok=True)
|
|
107
|
+
paths = emit_schema(out / "schema.json")
|
|
108
|
+
# Profile 2 goes to its own file: docs/schema.json is what stapel-react's
|
|
109
|
+
# generators read, and stays profile 1.
|
|
110
|
+
emit_schema(out / "schema.v2.json", contract_profile=2)
|
|
111
|
+
flows = emit_flows(out / "flows.json")
|
|
112
|
+
errors = emit_errors(out / "errors.json")
|
|
113
|
+
|
|
114
|
+
print(
|
|
115
|
+
f"stapel-courses contract: {paths} paths, {flows} flows, {errors} error keys "
|
|
116
|
+
f"→ {out}/",
|
|
117
|
+
file=sys.stderr,
|
|
118
|
+
)
|
|
119
|
+
return 0
|
|
120
|
+
|
|
121
|
+
|
|
122
|
+
if __name__ == "__main__":
|
|
123
|
+
raise SystemExit(main())
|
|
@@ -0,0 +1,119 @@
|
|
|
1
|
+
"""Single-module Django settings shared by the test suite and contract emission.
|
|
2
|
+
|
|
3
|
+
One copy, so the harness that emits ``docs/schema.json`` and the tests that
|
|
4
|
+
prove it can never drift in INSTALLED_APPS or comm config. The production
|
|
5
|
+
``REST_FRAMEWORK`` (exception handler, schema class) is used by both: the
|
|
6
|
+
error envelope the tests assert is the one a host serves.
|
|
7
|
+
"""
|
|
8
|
+
from __future__ import annotations
|
|
9
|
+
|
|
10
|
+
|
|
11
|
+
def settings_kwargs(
|
|
12
|
+
*,
|
|
13
|
+
root_urlconf: str = "stapel_courses.tests.urls",
|
|
14
|
+
contract: bool = False,
|
|
15
|
+
) -> dict:
|
|
16
|
+
rest_framework = {
|
|
17
|
+
"DEFAULT_RENDERER_CLASSES": ["rest_framework.renderers.JSONRenderer"],
|
|
18
|
+
"DEFAULT_SCHEMA_CLASS": "stapel_core.django.openapi.schemas.PermissionAwareAutoSchema",
|
|
19
|
+
"EXCEPTION_HANDLER": "stapel_core.django.api.errors.stapel_exception_handler",
|
|
20
|
+
}
|
|
21
|
+
if contract:
|
|
22
|
+
rest_framework.update({
|
|
23
|
+
"DEFAULT_AUTHENTICATION_CLASSES": [
|
|
24
|
+
"stapel_core.django.jwt.authentication.JWTCookieAuthentication",
|
|
25
|
+
],
|
|
26
|
+
"DEFAULT_PERMISSION_CLASSES": [
|
|
27
|
+
"stapel_core.django.api.permissions.IsServiceRequest",
|
|
28
|
+
"stapel_core.django.api.permissions.IsSuperUser",
|
|
29
|
+
],
|
|
30
|
+
"DEFAULT_RENDERER_CLASSES": [
|
|
31
|
+
"rest_framework.renderers.JSONRenderer",
|
|
32
|
+
"rest_framework.renderers.BrowsableAPIRenderer",
|
|
33
|
+
],
|
|
34
|
+
})
|
|
35
|
+
return dict(
|
|
36
|
+
SECRET_KEY="test-secret-key-not-for-production",
|
|
37
|
+
INSTALLED_APPS=[
|
|
38
|
+
"django.contrib.contenttypes",
|
|
39
|
+
"django.contrib.auth",
|
|
40
|
+
"django.contrib.sessions",
|
|
41
|
+
"django.contrib.admin",
|
|
42
|
+
"django.contrib.messages",
|
|
43
|
+
"stapel_core.django.apps.CommonDjangoConfig",
|
|
44
|
+
"stapel_core.django.users",
|
|
45
|
+
"rest_framework",
|
|
46
|
+
"drf_spectacular",
|
|
47
|
+
"stapel_courses",
|
|
48
|
+
],
|
|
49
|
+
AUTH_USER_MODEL="users.User",
|
|
50
|
+
DATABASES={"default": {"ENGINE": "django.db.backends.sqlite3", "NAME": ":memory:"}},
|
|
51
|
+
DEFAULT_AUTO_FIELD="django.db.models.BigAutoField",
|
|
52
|
+
USE_TZ=True,
|
|
53
|
+
ROOT_URLCONF=root_urlconf,
|
|
54
|
+
CACHES={"default": {"BACKEND": "django.core.cache.backends.locmem.LocMemCache"}},
|
|
55
|
+
STAPEL_BUS_BACKEND="stapel_core.bus.backends.memory.MemoryBus",
|
|
56
|
+
STAPEL_COMM={
|
|
57
|
+
"OUTBOX_ENABLED": False,
|
|
58
|
+
"ACTION_TRANSPORT": "inprocess",
|
|
59
|
+
"VALIDATE_SCHEMAS": True,
|
|
60
|
+
},
|
|
61
|
+
TEMPLATES=[{
|
|
62
|
+
"BACKEND": "django.template.backends.django.DjangoTemplates",
|
|
63
|
+
"APP_DIRS": True,
|
|
64
|
+
"OPTIONS": {"context_processors": [
|
|
65
|
+
"django.template.context_processors.request",
|
|
66
|
+
"django.contrib.auth.context_processors.auth",
|
|
67
|
+
"django.contrib.messages.context_processors.messages",
|
|
68
|
+
]},
|
|
69
|
+
}],
|
|
70
|
+
MIDDLEWARE=[
|
|
71
|
+
"django.contrib.sessions.middleware.SessionMiddleware",
|
|
72
|
+
"django.contrib.auth.middleware.AuthenticationMiddleware",
|
|
73
|
+
"django.contrib.messages.middleware.MessageMiddleware",
|
|
74
|
+
],
|
|
75
|
+
MIGRATION_MODULES={"users": None},
|
|
76
|
+
REST_FRAMEWORK=rest_framework,
|
|
77
|
+
)
|
|
78
|
+
|
|
79
|
+
|
|
80
|
+
#: Forced on drf-spectacular's singleton so a single-module instance derives
|
|
81
|
+
#: the same operation ids as a multi-module aggregate.
|
|
82
|
+
CODEGEN_SCHEMA_PATH_PREFIX = "/"
|
|
83
|
+
|
|
84
|
+
|
|
85
|
+
def enum_name_overrides() -> dict:
|
|
86
|
+
"""Stable enum component names (stapel-schema-lint SCH004). Called after setup."""
|
|
87
|
+
from stapel_courses.access import LOCK_REASONS
|
|
88
|
+
from stapel_courses.models import (
|
|
89
|
+
AttemptStatus,
|
|
90
|
+
CourseLevel,
|
|
91
|
+
CourseStatus,
|
|
92
|
+
DripMode,
|
|
93
|
+
EnrollmentSource,
|
|
94
|
+
EnrollmentStatus,
|
|
95
|
+
ProgressStatus,
|
|
96
|
+
QuestionKind,
|
|
97
|
+
RevealMode,
|
|
98
|
+
TextMatch,
|
|
99
|
+
)
|
|
100
|
+
|
|
101
|
+
return {
|
|
102
|
+
"CourseStatusEnum": CourseStatus,
|
|
103
|
+
"CourseLevelEnum": CourseLevel,
|
|
104
|
+
"DripModeEnum": DripMode,
|
|
105
|
+
"EnrollmentStatusEnum": EnrollmentStatus,
|
|
106
|
+
"EnrollmentSourceEnum": EnrollmentSource,
|
|
107
|
+
"ProgressStatusEnum": ProgressStatus,
|
|
108
|
+
"QuestionKindEnum": QuestionKind,
|
|
109
|
+
"RevealModeEnum": RevealMode,
|
|
110
|
+
"TextMatchEnum": TextMatch,
|
|
111
|
+
"AttemptStatusEnum": AttemptStatus,
|
|
112
|
+
"LockReasonEnum": [(r, r) for r in LOCK_REASONS],
|
|
113
|
+
"EnrollmentTransitionTargetEnum": [(s, s) for s in ("active", "expired", "cancelled")],
|
|
114
|
+
"TextBlockTypeEnum": [("text", "text")],
|
|
115
|
+
"VideoBlockTypeEnum": [("video", "video")],
|
|
116
|
+
"AttachmentBlockTypeEnum": [("attachment", "attachment")],
|
|
117
|
+
"EmbedBlockTypeEnum": [("embed", "embed")],
|
|
118
|
+
"TextFormatEnum": [("markdown", "markdown"), ("plain", "plain")],
|
|
119
|
+
}
|