A sample backend plugin for the Open edX Platform
Project description
backend-plugin-sample
A Django app plugin for edx-platform that adds a small course-archiving feature: learners can mark courses as archived (hidden from their active list) and unarchive them later. It demonstrates three backend extension points working together:
- A model + REST API (
CourseArchiveStatus), consumed byfrontend-plugin-sample - An Open edX Events handler that auto-unarchives on verified upgrade
- An Open edX Filters pipeline step that rewrites the course-about URL
How to use it
See the root README for setup instructions. With Tutor, tutor-contrib-sample installs this plugin automatically (or bind-mounts your local checkout if you tutor mounts add it). Without Tutor, pip install -e . into your edx-platform environment and run migrations.
How it works
Plugin registration. apps.py declares the Django app to edx-platform via the plugin_app config (URL routing, settings, signal registration). The entry points in pyproject.toml make the platform discover the app automatically — no INSTALLED_APPS edit needed. See How to create a plugin app.
Model. models.py defines CourseArchiveStatus(user, course_id, is_archived, archive_date), indexed for the lookups the API performs. Registered in Django admin via admin.py.
REST API. views.py exposes the model as a DRF ModelViewSet at /sample-plugin/api/v1/course-archive-status/, with per-user permissions, throttling, and pagination. Serializer in serializers.py; URLs in urls.py. Business logic (e.g. setting archive_date when is_archived becomes true) lives in perform_create/perform_update rather than in the serializer.
Event handler. signals.py listens for COURSE_ENROLLMENT_CHANGED and unarchives a learner's course when they upgrade to the verified track. An event (not a filter) is the right shape here because we want a one-time nudge at the moment of upgrade — if the learner re-archives the course later, we respect that. A filter would re-impose the rule on every render.
Filter. pipeline.py implements ChangeCourseAboutPageUrl, a PipelineStep for org.openedx.learning.course.about.render.started.v1 that rewrites course-about URLs to an external host. Registered via OPEN_EDX_FILTERS_CONFIG in settings/common.py.
Settings. Per-environment settings live in settings/ (common.py, production.py, test.py). The plugin app loads these via its plugin_app config in apps.py.
Testing and quality
cd backend-plugin-sample
make requirements # install test deps
make test # pytest
make quality # lint
Tests live in tests/.
Project details
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file openedx_plugin_sample-3.6.0.tar.gz.
File metadata
- Download URL: openedx_plugin_sample-3.6.0.tar.gz
- Upload date:
- Size: 147.3 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.1.0 CPython/3.13.12
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
f5ac4beae9a67c4ed1edef3d38030ef89c4e73657e7e6940212375078bdb2be1
|
|
| MD5 |
fa39cce0e22d8c5fc42617070b539dfa
|
|
| BLAKE2b-256 |
7bd96e81d114f82c4a560c1a20be1aa13a1b20ebfbe66fba0c0e06ea74021a8b
|
File details
Details for the file openedx_plugin_sample-3.6.0-py2.py3-none-any.whl.
File metadata
- Download URL: openedx_plugin_sample-3.6.0-py2.py3-none-any.whl
- Upload date:
- Size: 24.6 kB
- Tags: Python 2, Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.1.0 CPython/3.13.12
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
b4450140295ef4699c3cfbd4c82d9015a7e7b6cc2a356cd1b672c90372b3c1dc
|
|
| MD5 |
12a80ec3581a750b8928c2c12c9ef352
|
|
| BLAKE2b-256 |
ba7d7f93c03f8654ede9985ec48e10364e4e43f303b8f791ece861bef467771f
|