Accordion XBlock
An Open edX XBlock to present content in a foldable accordion.
Installation
You can install the XBlock from PyPi using:
pip install xblock-accordion
Or install it directly from source:
pip install xblock-accordion@git+https://github.com/open-craft/xblock-accordion.git
In Tutor, you can the package to OPENEDX_EXTRA_PIP_REQUIREMENTS in config.yml.
OPENEDX_EXTRA_PIP_REQUIREMENTS:
- xblock-accordion
# Or
- xblock-accordion@git+https://github.com/open-craft/xblock-accordion.git
Versions
XBlock Version |
Open edX Release |
|---|---|
1.2.0 |
Teak or lower |
> 2.0.0 |
Ulmo and higher |
Development
uv is used for managing requirements for the project.
Setup the project env using make requirements.
Run tests using make test.
Before commit changes run make quality.
Add new libraries using uv add <package-name>
See the Makefile for other helper functions.
Testing with Docker
This XBlock comes with a Docker test environment ready to build, based on the xblock-sdk workbench. To build and run it:
$ make dev.run
The XBlock SDK Workbench, including this XBlock, will be available on the list of XBlocks at http://localhost:8000
Testing frontend
The frontend code in the XBlock can be tested without the backend running for quicker iteration on the UI. To do this, just run npm run dev in the frontend folder. This will start a dev server with just the frontend component. You can open the URL in the terminal and browse to the student or studio components.
Usage
To use the XBlock in a course, you need to ensure that you have "accordion" in the Advanced Modules List in the Advanced settings page of the course.
Once added there you will be able to add an Accordion block from the Advanced Modules section of blocks.
Configuration
The XBlock reads its settings from the XBLOCK_SETTINGS Django setting, under the AccordionXBlock key.
JSON editing
Course authors can export an Accordion block’s data as JSON, and replace it by uploading a JSON file. This is turned off by default. To turn it on, set enable_json_editing to True:
XBLOCK_SETTINGS = {
"AccordionXBlock": {
"enable_json_editing": True,
},
}
The Studio editor reads this setting, so add it to the CMS settings. In Tutor, you can do this with a plugin that patches openedx-cms-common-settings:
from tutor import hooks
hooks.Filters.ENV_PATCHES.add_item(
(
"openedx-cms-common-settings",
"""
XBLOCK_SETTINGS.setdefault("AccordionXBlock", {})
XBLOCK_SETTINGS["AccordionXBlock"]["enable_json_editing"] = True
""",
)
)
When the setting is on, the Studio editor shows a JSON tab where authors can:
Download component data: save the block’s current data (display name, description, panels and styling) as a JSON file. This includes edits that are not saved yet.
Download Schema: save the JSON Schema of the block’s data. Use it to check JSON files with other tools before uploading them.
Upload a JSON file: replace the block’s data with the contents of the file. The file is checked against the schema when it is saved. If it does not match, the editor lists the errors and the fields they apply to, and nothing is saved. The description is cleaned of unsupported HTML, the same way as when it is edited in the editor.
Metadata
Release files for xblock-accordion 2.1.0
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | Provenance | Actions |
|---|---|---|---|---|
| xblock_accordion-2.1.0.tar.gz | 869.5 kB | Without provenance | Details for xblock_accordion-2.1.0.tar.gz |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Actions Reset |
|---|---|---|---|---|
| xblock_accordion-2.1.0-py3-none-any.whl | Python 3 | none | any | Details for xblock_accordion-2.1.0-py3-none-any.whl |
Total release size: 1.8 MB
Release files / xblock_accordion-2.1.0.tar.gz
| Download URL | xblock_accordion-2.1.0.tar.gz |
|---|---|
| Size | 869.5 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
f1271d5a5ed5b0dc3c5e3baa3120e529d8ea60e26a651ad7e46defbd7804daf6
|
|
BLAKE2b-256 checksum How to use checksums |
f88f853207d2384e62feba68b81206b7f879a550f4ac441e93ebde2e2cff3bf8
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/7.0.0 CPython/3.13.16
|
Release files / xblock_accordion-2.1.0-py3-none-any.whl
| Download URL | xblock_accordion-2.1.0-py3-none-any.whl |
|---|---|
| Size | 883.0 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
a82399ac702377aa44cb6d9fcf9c101972c675d38b6aaccda106cfadf1e9157e
|
|
BLAKE2b-256 checksum How to use checksums |
08bf02290870227bd59e26d73b9dc90adfa7840fab737d61bfd48084c273e8c6
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/7.0.0 CPython/3.13.16
|
Security for xblock-accordion 2.1.0
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
No provenance found
None of the files in this release were uploaded with provenance metadata.
A note on package security
PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.
To learn more about protecting yourself from malicious actors, visit our package security documentation.