Skip to content

Commit

Permalink
feat: add listener for tracking event emitted signal
Browse files Browse the repository at this point in the history
chore: install openedx-events

refactor: only send to event bus

refactor: only listen to event bus

feat: show more information of tracking log

feat: send xAPI statements via event bus

feat: process all backends based on their class

fix: allow multiple engines and backends

feat: enable event bus engine by default

fix: do not validate metadata source

fix: make sure errors are raised to event bus

test: correct tests

chore: quality fixes

test: add test for handlers

fix: remove return statement

test: add test for event emission exit

chore: inject supported logs in EVENT_BUS_TRACKING_LOGS

fix: only process signal if it is emitted from the event bus

chore: change tracking log handler logging to debug

test: update test with from_event_bus

chore: install openedx-events v9.5.1

feat: migrate handler to eventtracking
  • Loading branch information
Ian2012 committed Feb 16, 2024
1 parent 278b145 commit 3a21781
Show file tree
Hide file tree
Showing 12 changed files with 392 additions and 279 deletions.
4 changes: 2 additions & 2 deletions event_routing_backends/backends/events_router.py
Original file line number Diff line number Diff line change
Expand Up @@ -163,14 +163,14 @@ def send(self, event):
event_name,
updated_event,
host['router_type'],
host['host_configurations']
host['host_configurations'],
)
else:
self.dispatch_event(
event_name,
updated_event,
host['router_type'],
host['host_configurations']
host['host_configurations'],
)

def process_event(self, event):
Expand Down
2 changes: 1 addition & 1 deletion event_routing_backends/helpers.py
Original file line number Diff line number Diff line change
Expand Up @@ -107,7 +107,7 @@ def get_user(username_or_id):
if username and not user:
try:
user = get_potentially_retired_user_by_username(username)
except Exception as ex: # pylint: disable=broad-except
except Exception as ex:
logger.info('User with username "%s" does not exist.%s', username, ex)

return user
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@ def _get_chunks(source, file, start_byte, end_byte):
break
# Catching all exceptions here because there's no telling what all
# the possible errors from different libcloud providers are.
except Exception as e: # pylint: disable=broad-exception-caught
except Exception as e:
print(e)
if try_number == num_retries:
print(f"Try {try_number}: Error occurred downloading, giving up.")
Expand Down
190 changes: 97 additions & 93 deletions event_routing_backends/settings/common.py
Original file line number Diff line number Diff line change
Expand Up @@ -58,6 +58,101 @@ def plugin_settings(settings):
'edx.course.enrollment.deactivated',
'edx.course.grade.passed.first_time'
]
allowed_xapi_events = [
'edx.course.enrollment.activated',
'edx.course.enrollment.deactivated',
'edx.course.enrollment.mode_changed',
'edx.grades.subsection.grade_calculated',
'edx.grades.course.grade_calculated',
'edx.special_exam.timed.attempt.created',
'edx.special_exam.timed.attempt.submitted',
'edx.special_exam.practice.attempt.created',
'edx.special_exam.practice.attempt.submitted',
'edx.special_exam.proctored.attempt.created',
'edx.special_exam.proctored.attempt.submitted',
'edx.completion.block_completion.changed',
'edx.forum.thread.created',
'edx.forum.thread.deleted',
'edx.forum.thread.edited',
'edx.forum.thread.viewed',
'edx.forum.thread.reported',
'edx.forum.thread.unreported',
'edx.forum.thread.voted',
'edx.forum.response.created',
'edx.forum.response.deleted',
'edx.forum.response.edited',
'edx.forum.response.reported',
'edx.forum.response.unreported',
'edx.forum.response.voted',
'edx.forum.comment.created',
'edx.forum.comment.deleted',
'edx.forum.comment.edited',
'edx.forum.comment.reported',
'edx.forum.comment.unreported',
'edx.ui.lms.link_clicked',
'edx.ui.lms.sequence.outline.selected',
'edx.ui.lms.outline.selected',
'edx.ui.lms.sequence.next_selected',
'edx.ui.lms.sequence.previous_selected',
'edx.ui.lms.sequence.tab_selected',
'showanswer',
'edx.problem.hint.demandhint_displayed',
'problem_check',
'load_video',
'edx.video.loaded',
'play_video',
'edx.video.played',
'complete_video',
'edx.video.completed',
'stop_video',
'edx.video.stopped',
'pause_video',
'edx.video.paused',
'seek_video',
'edx.video.position.changed',
'hide_transcript',
'edx.video.transcript.hidden',
'show_transcript',
'edx.video.transcript.shown',
'speed_change_video',
'video_hide_cc_menu',
'edx.video.closed_captions.shown',
'edx.video.closed_captions.hidden',
'edx.video.language_menu.hidden',
'video_show_cc_menu',
'edx.video.language_menu.shown',
'edx.course.grade.passed.first_time'
]
allowed_caliper_events = [
'edx.course.enrollment.activated',
'edx.course.enrollment.deactivated',
'edx.ui.lms.link_clicked',
'edx.ui.lms.sequence.outline.selected',
'edx.ui.lms.outline.selected',
'edx.ui.lms.sequence.next_selected',
'edx.ui.lms.sequence.previous_selected',
'edx.ui.lms.sequence.tab_selected',
'showanswer',
'edx.problem.hint.demandhint_displayed',
'problem_check',
'load_video',
'edx.video.loaded',
'play_video',
'edx.video.played',
'complete_video',
'edx.video.completed',
'stop_video',
'edx.video.stopped',
'pause_video',
'edx.video.paused',
'seek_video',
'edx.video.position.changed',
'edx.course.grade.passed.first_time',
'edx.course.grade.now_passed',
'edx.course.grade.now_failed'
]

settings.EVENT_BUS_TRACKING_LOGS = set(allowed_xapi_events + allowed_caliper_events)

settings.EVENT_TRACKING_BACKENDS.update({
'xapi': {
Expand All @@ -68,71 +163,7 @@ def plugin_settings(settings):
{
'ENGINE': 'eventtracking.processors.whitelist.NameWhitelistProcessor',
'OPTIONS': {
'whitelist': [
'edx.course.enrollment.activated',
'edx.course.enrollment.deactivated',
'edx.course.enrollment.mode_changed',
'edx.grades.subsection.grade_calculated',
'edx.grades.course.grade_calculated',
'edx.special_exam.timed.attempt.created',
'edx.special_exam.timed.attempt.submitted',
'edx.special_exam.practice.attempt.created',
'edx.special_exam.practice.attempt.submitted',
'edx.special_exam.proctored.attempt.created',
'edx.special_exam.proctored.attempt.submitted',
'edx.completion.block_completion.changed',
'edx.forum.thread.created',
'edx.forum.thread.deleted',
'edx.forum.thread.edited',
'edx.forum.thread.viewed',
'edx.forum.thread.reported',
'edx.forum.thread.unreported',
'edx.forum.thread.voted',
'edx.forum.response.created',
'edx.forum.response.deleted',
'edx.forum.response.edited',
'edx.forum.response.reported',
'edx.forum.response.unreported',
'edx.forum.response.voted',
'edx.forum.comment.created',
'edx.forum.comment.deleted',
'edx.forum.comment.edited',
'edx.forum.comment.reported',
'edx.forum.comment.unreported',
'edx.ui.lms.link_clicked',
'edx.ui.lms.sequence.outline.selected',
'edx.ui.lms.outline.selected',
'edx.ui.lms.sequence.next_selected',
'edx.ui.lms.sequence.previous_selected',
'edx.ui.lms.sequence.tab_selected',
'showanswer',
'edx.problem.hint.demandhint_displayed',
'problem_check',
'load_video',
'edx.video.loaded',
'play_video',
'edx.video.played',
'complete_video',
'edx.video.completed',
'stop_video',
'edx.video.stopped',
'pause_video',
'edx.video.paused',
'seek_video',
'edx.video.position.changed',
'hide_transcript',
'edx.video.transcript.hidden',
'show_transcript',
'edx.video.transcript.shown',
'speed_change_video',
'video_hide_cc_menu',
'edx.video.closed_captions.shown',
'edx.video.closed_captions.hidden',
'edx.video.language_menu.hidden',
'video_show_cc_menu',
'edx.video.language_menu.shown',
'edx.course.grade.passed.first_time'
]
'whitelist': allowed_xapi_events
}
},
],
Expand Down Expand Up @@ -161,34 +192,7 @@ def plugin_settings(settings):
{
"ENGINE": "eventtracking.processors.whitelist.NameWhitelistProcessor",
"OPTIONS": {
"whitelist": [
'edx.course.enrollment.activated',
'edx.course.enrollment.deactivated',
'edx.ui.lms.link_clicked',
'edx.ui.lms.sequence.outline.selected',
'edx.ui.lms.outline.selected',
'edx.ui.lms.sequence.next_selected',
'edx.ui.lms.sequence.previous_selected',
'edx.ui.lms.sequence.tab_selected',
'showanswer',
'edx.problem.hint.demandhint_displayed',
'problem_check',
'load_video',
'edx.video.loaded',
'play_video',
'edx.video.played',
'complete_video',
'edx.video.completed',
'stop_video',
'edx.video.stopped',
'pause_video',
'edx.video.paused',
'seek_video',
'edx.video.position.changed',
'edx.course.grade.passed.first_time',
'edx.course.grade.now_passed',
'edx.course.grade.now_failed'
]
"whitelist": allowed_caliper_events
}
}
],
Expand Down
Loading

0 comments on commit 3a21781

Please sign in to comment.