Last active
July 29, 2018 03:24
-
-
Save rubysoho07/062df1cf32a72a0bbc3ebd77c5111312 to your computer and use it in GitHub Desktop.
xAPI Example 1. Actor, Verb, Object
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
from tincan import Agent, Verb, Activity, ActivityDefinition, LanguageMap | |
# Agent (Check: https://github.com/adlnet/xAPI-Spec/blob/master/xAPI-Data.md#242-actor) | |
actor = Agent( | |
name="Test User", | |
mbox="mailto:test@example.org" | |
) | |
print actor.to_json() | |
# Result: {"mbox": "mailto:test@example.org", "name": "Test User", "objectType": "Agent"} | |
# Verb: (Check: https://registry.tincanapi.com/#home/verbs, | |
# https://github.com/adlnet/xAPI-Spec/blob/master/xAPI-Data.md#243-verb) | |
verb = Verb( | |
id="https://brindlewaye.com/xAPITerms/verbs/loggedin/", | |
display=LanguageMap({'en-us': 'Log In'}) | |
) | |
print verb.to_json() | |
# Result: {"id": "https://brindlewaye.com/xAPITerms/verbs/loggedin/", "display": {"en-us": "Log In"}} | |
# Object(Activity) | |
# Check: https://github.com/adlnet/xAPI-Spec/blob/master/xAPI-Data.md#244-object | |
obj = Activity( | |
id="http://example.org/activity/1", | |
definition=ActivityDefinition( | |
name=LanguageMap({'en-us': 'Test Activity'}) | |
) | |
) | |
print obj.to_json() | |
# Result: | |
# {"definition": {"name": {"en-us": "Test Activity"}}, "id": "http://example.org/activity/1", "objectType": "Activity"} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment