Skip to content

Instantly share code, notes, and snippets.

@rubysoho07
Last active July 29, 2018 03:24
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save rubysoho07/393057852a1457fb7d826ae3d21cf2c5 to your computer and use it in GitHub Desktop.
Save rubysoho07/393057852a1457fb7d826ae3d21cf2c5 to your computer and use it in GitHub Desktop.
Caliper Example 1. Actor, Action, Object
from caliper import entities
# actor: 'Subject' part of an Event
actor = entities.Person(
id='http://example.org/person/123',
name='Test'
)
print(actor.as_json(thin_context=True, thin_props=True))
# Result: {"@context": "http://purl.imsglobal.org/ctx/caliper/v1p1", "id": "http://example.org/person/123", "name": "Test", "type": "Person"}
# action: 'Verb' part of an Event
from caliper.constants import CALIPER_ACTIONS
action = CALIPER_ACTIONS['LOGGED_IN']
print(action)
# Result: LoggedIn
# object: 'Object' part of an Event
obj = entities.SoftwareApplication(
id='http://example.org/app/testservice',
name='Learning Analytics Example'
)
print(obj.as_json(thin_context=True, thin_props=True))
# Result:
"""
{
"@context":"http://purl.imsglobal.org/ctx/caliper/v1p1",
"id":"http://example.org/app/testservice",
"name":"Learning Analytics Example",
"type":"SoftwareApplication"
}
"""
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment