edx-tincan-py35

raw JSON →
2.0.0 verified Fri May 01 auth: no python maintenance

A Python 3 library for implementing the Tin Can API (Experience API). Version 2.0.0 is released with basic support for creating and sending statements. Low activity; last release in 2016. Use with caution as it appears to be in maintenance mode.

pip install edx-tincan-py35
error ModuleNotFoundError: No module named 'edx_tincan_py35'
cause Package name in pip is 'edx-tincan-py35', but the import namespace is 'tincan'.
fix
Use import tincan or from tincan import ...
error ImportError: No module named 'tincan'
cause Package not installed or installed in wrong environment.
fix
Run 'pip install edx-tincan-py35' and ensure the environment is Python 3.5 or compatible.
error TypeError: __init__() got an unexpected keyword argument 'definition'
cause In older versions of the library, Activity's definition may be passed differently. In v2.0.0, definition is a dict, not a separate object.
fix
Use correct constructor: Activity(id='...', definition={'name': {'en-US': '...'}})
gotcha Library name: edx-tincan-py35 but the Python package import is `tincan`. Many users mistakenly try to import `edx_tincan_py35` which does not work.
fix Use `import tincan` (or `from tincan import ...`)
deprecated The library is not actively maintained; last release in 2016. It may not work with Python 3.6+ without patches.
fix Consider using modern alternatives like `xapi-python` or `tincanpython` if you need active support.
gotcha The library does not support Python 2.x but the name suggests py35. It only supports Python 3.4 and 3.5. In Python 3.6+ some features like `OrderedDict` usage may break.
fix Use Python 3.4 or 3.5 explicitly, or upgrade to a maintained fork.

Create and send a simple Tin Can statement to a remote LRS.

from tincan import RemoteLRS, Statement, Agent, Activity

lrs = RemoteLRS(
    endpoint='https://example.com/xapi/',
    username='user',
    password='pass'
)
agent = Agent(name='Test User', mbox='mailto:test@example.com')
activity = Activity(id='http://example.com/activity', definition={'name': {'en-US': 'Test Activity'}})
statement = Statement(
    actor=agent,
    verb={'id': 'http://adlnet.gov/expapi/verbs/experienced', 'display': {'en-US': 'experienced'}},
    object=activity
)
response = lrs.save_statement(statement)
print(response.data)