edX CCX Keys
raw JSON → 2.0.2 verified Mon Apr 27 auth: no python
Opaque key support for Custom Courses on edX (CCX). Provides key classes to identify CCX objects within the edX platform. Current version 2.0.2, release cadence is sporadic.
pip install edx-ccx-keys Common errors
error InvalidKeyError: Invalid key string: 'ccx-v1:...' ↓
cause The key string format is incorrect or malformed.
fix
Use the correct format: 'ccx-v1:org+course+ccx@ccx_id'.
error ModuleNotFoundError: No module named 'ccx_keys' ↓
cause The package is not installed.
fix
Run 'pip install edx-ccx-keys'.
Warnings
breaking Version 2.0.0 dropped support for Python 3.8. Python 3.9+ is required. ↓
fix Upgrade Python to 3.9+.
gotcha CcxLocator.from_string() expects a string in the format 'ccx-v1:org+course+ccx@ccx_id'. Incorrect formats will raise InvalidKeyError. ↓
fix Ensure the string matches exactly 'ccx-v1:...' or use the constructor directly.
Imports
- CcxLocator wrong
from opaque_keys.edx.locator import CcxLocatorcorrectfrom ccx_keys.locator import CcxLocator - CcxBlockUsageLocator wrong
from opaque_keys.edx.locator import CcxBlockUsageLocatorcorrectfrom ccx_keys.locator import CcxBlockUsageLocator
Quickstart
from ccx_keys.locator import CcxLocator
# Parse a CCX key string
key = CcxLocator.from_string('ccx-v1:org+course+ccx@ccx_id')
print(key)
# Create a new CCX key
course_key = CcxLocator('org', 'course', 'run', 'ccx_id')
print(course_key)