Last active
August 3, 2018 13:45
-
-
Save rubysoho07/810d7b0e4c2b94fb1a8fb1af625a6c6c to your computer and use it in GitHub Desktop.
Caliper Example 2. Describing Event
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
import datetime | |
from caliper import entities, events | |
from caliper.constants import CALIPER_ACTIONS | |
event = events.SessionEvent( | |
actor=entities.Person(id='http://example.org/person/123', name='Test'), | |
action=CALIPER_ACTIONS['LOGGED_IN'] | |
object=entities.SoftwareApplication(id='http://example.org/app/testservice', name='Learning Analytics Example'), | |
eventTime=datetime.datetime.utcnow().isoformat(timespec='milliseconds') + 'Z' | |
) | |
print(event.as_json(thin_context=True, thin_props=True)) | |
# Result | |
""" | |
{ | |
"@context":"http://purl.imsglobal.org/ctx/caliper/v1p1", | |
"action":"LoggedIn", | |
"actor":{ | |
"id":"http://example.org/person/123", | |
"name":"Test", | |
"type":"Person" | |
}, | |
"eventTime":"2018-07-09T10:22:47.856Z", | |
"id":"urn:uuid:ac188287-ea71-4fe4-a283-8919190891ad", | |
"object":{ | |
"id":"http://example.org/app/testservice", | |
"name":"Learning Analytics Example", | |
"type":"SoftwareApplication" | |
}, | |
"type":"SessionEvent" | |
} | |
""" |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment