Support emitting analytical events from xblocks running in the LMS

XBlocks can and should use the "publish" method provided by the runtime to emit analytical events. In theory we could now start replacing calls to track_function with calls to publish, however, that migration is not handled by this change.

Fixes: AN-789
This commit is contained in:
Gabe Mulley
2014-03-27 12:48:53 -04:00
parent 30f7f1cfa1
commit d6052675da
6 changed files with 30 additions and 21 deletions

View File

@@ -21,8 +21,13 @@ These are properties and methods available on ``self.runtime`` when a view or ha
that the block is being executed in. The same student in two different courses
will have two different ids.
* publish(event): Emit events to the surrounding system. Events are dictionaries with
at least the key 'event_type', which identifies the other fields.
* publish(event): Emit events to the surrounding system. Events are dictionaries that can contain arbitrary data.
XBlocks can publish events by calling ``self.runtime.publish(self, event_type, event)``. The ``event_type`` parameter
enables downstream processing of the event since it uniquely identifies the schema. This call will cause the runtime
to save the event data in the application event stream. XBlocks should publish events whenever a significant state
change occurs. Post-hoc analysis of the event stream can yield insight about how the XBlock is used in the context of
the application. Ideally interesting state of the XBlock could be reconstructed at any point in history through
careful analysis of the event stream.
TODO: Link to the authoritive list of event types.
@@ -51,12 +56,14 @@ should ``publish`` a ``grade`` event whenever the grade changes. The ``grade`` e
dictionary of the following form::
{
'event_type': 'grade',
'value': <number>,
'max_value': <number>,
'user_id': <number>,
}
The grade event represents a grade of ``value/max_value`` for the current user.
The grade event represents a grade of ``value/max_value`` for the current user. The
``user_id`` field is optional, the currently logged in user's ID will be used if it is
omitted.
Restrictions
~~~~~~~~~~~~