-
Notifications
You must be signed in to change notification settings - Fork 3
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat: incorporate changes in 8.7.0 and add signal hander
- Loading branch information
1 parent
2c8cd5a
commit 1403167
Showing
6 changed files
with
76 additions
and
23 deletions.
There are no files selected for viewing
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
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,18 @@ | ||
""" | ||
Core Application Configuration | ||
""" | ||
|
||
from django.apps import AppConfig | ||
|
||
|
||
class CoreConfig(AppConfig): | ||
""" | ||
Application configuration for core application. | ||
""" | ||
name = 'edx_exams.apps.core' | ||
|
||
def ready(self): | ||
""" | ||
Connect handlers to signals. | ||
""" | ||
from .signals import handlers # pylint: disable=unused-import,import-outside-toplevel |
Empty file.
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,20 @@ | ||
""" | ||
Signal handlers for the edx-exams application. | ||
""" | ||
from django.dispatch import receiver | ||
|
||
from openedx_events.event_bus import get_producer | ||
from openedx_events.learning.signals import EXAM_ATTEMPT_SUBMITTED | ||
|
||
@receiver(EXAM_ATTEMPT_SUBMITTED) | ||
def listen_for_exam_attempt_submitted(sender, signal, **kwargs): # pylint: disable=unused-argument | ||
""" | ||
Publish EXAM_ATTEMPT_SUBMITTED signals onto the event bus. | ||
""" | ||
get_producer().send( | ||
signal=EXAM_ATTEMPT_SUBMITTED, | ||
topic='exam-attempt-submitted', | ||
event_key_field='exam_attempt.course_key', | ||
event_data={'exam_attempt': kwargs['exam_attempt']}, | ||
event_metadata=kwargs['metadata'], | ||
) |
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,21 +1,33 @@ | ||
""" | ||
Signal definitions and functions to send those signals for the edx-exams application. | ||
""" | ||
|
||
from openedx_events.learning.data import ExamAttemptData, UserData, UserPersonalData | ||
from openedx_events.learning.signals import EXAM_ATTEMPT_SUBMITTED | ||
|
||
|
||
def emit_exam_attempt_submitted_event(user, course_key, usage_key): | ||
def emit_exam_attempt_submitted_event(user, course_key, usage_key, exam_type): | ||
""" | ||
Emit the EXAM_ATTEMPT_SUBMITTED Open edX event. | ||
""" | ||
name=user.full_name or '' | ||
user_data = UserData( | ||
id=user.id, | ||
is_active=user.is_active, | ||
pii=UserPersonalData( | ||
username=user.username, | ||
email=user.email, | ||
name=name | ||
) | ||
) | ||
|
||
# .. event_implemented_name: EXAM_ATTEMPT_SUBMITTED | ||
EXAM_ATTEMPT_SUBMITTED.send_event( | ||
exam_attempt=ExamAttemptData( | ||
student_user=UserData( | ||
id=user.id, | ||
is_active=user.is_active, | ||
pii=UserPersonalData( | ||
username=user.username, | ||
email=user.email, | ||
name=user.full_name | ||
) | ||
), | ||
student_user=user_data, | ||
course_key=course_key, | ||
usage_key=usage_key, | ||
exam_type=exam_type, | ||
requesting_user=user_data | ||
) | ||
) |
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