From b2f103e656e0f4386f434f2211e6a156ad78dacd Mon Sep 17 00:00:00 2001 From: alangsto <46360176+alangsto@users.noreply.github.com> Date: Thu, 5 Oct 2023 12:47:09 -0400 Subject: [PATCH] feat: update topic names for events (#193) --- edx_exams/apps/core/signals/handlers.py | 11 +++++++---- edx_exams/settings/base.py | 3 +++ 2 files changed, 10 insertions(+), 4 deletions(-) diff --git a/edx_exams/apps/core/signals/handlers.py b/edx_exams/apps/core/signals/handlers.py index 4d74d575..962de7fc 100644 --- a/edx_exams/apps/core/signals/handlers.py +++ b/edx_exams/apps/core/signals/handlers.py @@ -1,6 +1,7 @@ """ Signal handlers for the edx-exams application. """ +from django.conf import settings from django.dispatch import receiver from openedx_events.event_bus import get_producer from openedx_events.learning.signals import ( @@ -10,6 +11,8 @@ EXAM_ATTEMPT_VERIFIED ) +topic_name = getattr(settings, 'EXAM_ATTEMPT_EVENTS_KAFKA_TOPIC_NAME', '') + @receiver(EXAM_ATTEMPT_SUBMITTED) def listen_for_exam_attempt_submitted(sender, signal, **kwargs): # pylint: disable=unused-argument @@ -18,7 +21,7 @@ def listen_for_exam_attempt_submitted(sender, signal, **kwargs): # pylint: disa """ get_producer().send( signal=EXAM_ATTEMPT_SUBMITTED, - topic='exam-attempt-submitted', + topic=topic_name, event_key_field='exam_attempt.course_key', event_data={'exam_attempt': kwargs['exam_attempt']}, event_metadata=kwargs['metadata'], @@ -32,7 +35,7 @@ def listen_for_exam_attempt_verified(sender, signal, **kwargs): # pylint: disab """ get_producer().send( signal=EXAM_ATTEMPT_VERIFIED, - topic='exam-attempt-verified', + topic=topic_name, event_key_field='exam_attempt.course_key', event_data={'exam_attempt': kwargs['exam_attempt']}, event_metadata=kwargs['metadata'], @@ -46,7 +49,7 @@ def listen_for_exam_attempt_rejected(sender, signal, **kwargs): # pylint: disab """ get_producer().send( signal=EXAM_ATTEMPT_REJECTED, - topic='exam-attempt-rejected', + topic=topic_name, event_key_field='exam_attempt.course_key', event_data={'exam_attempt': kwargs['exam_attempt']}, event_metadata=kwargs['metadata'], @@ -60,7 +63,7 @@ def listen_for_exam_attempt_errored(sender, signal, **kwargs): # pylint: disabl """ get_producer().send( signal=EXAM_ATTEMPT_ERRORED, - topic='exam-attempt-errored', + topic=topic_name, event_key_field='exam_attempt.course_key', event_data={'exam_attempt': kwargs['exam_attempt']}, event_metadata=kwargs['metadata'], diff --git a/edx_exams/settings/base.py b/edx_exams/settings/base.py index c4c86c17..2b5aae05 100644 --- a/edx_exams/settings/base.py +++ b/edx_exams/settings/base.py @@ -277,3 +277,6 @@ def root(*path_fragments): LEARNING_MICROFRONTEND_URL = None EXAMS_DASHBOARD_MFE_URL = None + +# Event Bus Settings +EXAM_ATTEMPT_EVENTS_KAFKA_TOPIC_NAME = 'learning-exam-attempt-lifecycle'