From e0f7fa3c255f3e96c31d3d1c3f36a76f095b69f7 Mon Sep 17 00:00:00 2001 From: "kshitij.sobti" Date: Mon, 19 May 2025 15:44:25 +0530 Subject: [PATCH 1/3] feat: Add event for LTI Launches --- CHANGELOG.rst | 9 ++ openedx_events/__init__.py | 2 +- ...lti_provider+launch+success+v1_schema.avsc | 91 +++++++++++++++++++ openedx_events/learning/data.py | 28 ++++++ openedx_events/learning/signals.py | 13 +++ 5 files changed, 142 insertions(+), 1 deletion(-) create mode 100644 openedx_events/event_bus/avro/tests/schemas/org+openedx+learning+lti_provider+launch+success+v1_schema.avsc diff --git a/CHANGELOG.rst b/CHANGELOG.rst index c8310954..6928ff70 100644 --- a/CHANGELOG.rst +++ b/CHANGELOG.rst @@ -16,6 +16,15 @@ Change Log Unreleased __________ +[10.3.0] - 2025-05-23 +--------------------- + +Added +~~~~~ + +* Added new ``LTI_PROVIDER_LAUNCH_SUCCESS`` event in learning. + + [10.2.1] - 2025-05-13 --------------------- diff --git a/openedx_events/__init__.py b/openedx_events/__init__.py index fcbd00c9..3be70d9a 100644 --- a/openedx_events/__init__.py +++ b/openedx_events/__init__.py @@ -5,4 +5,4 @@ more information about the project. """ -__version__ = "10.2.1" +__version__ = "10.3.0" diff --git a/openedx_events/event_bus/avro/tests/schemas/org+openedx+learning+lti_provider+launch+success+v1_schema.avsc b/openedx_events/event_bus/avro/tests/schemas/org+openedx+learning+lti_provider+launch+success+v1_schema.avsc new file mode 100644 index 00000000..6738f548 --- /dev/null +++ b/openedx_events/event_bus/avro/tests/schemas/org+openedx+learning+lti_provider+launch+success+v1_schema.avsc @@ -0,0 +1,91 @@ +{ + "name": "CloudEvent", + "type": "record", + "doc": "Avro Event Format for CloudEvents created with openedx_events/schema", + "fields": [ + { + "name": "launch_data", + "type": { + "name": "LtiProviderLaunchData", + "type": "record", + "fields": [ + { + "name": "user", + "type": { + "name": "UserData", + "type": "record", + "fields": [ + { + "name": "id", + "type": "long" + }, + { + "name": "is_active", + "type": "boolean" + }, + { + "name": "pii", + "type": { + "name": "UserPersonalData", + "type": "record", + "fields": [ + { + "name": "username", + "type": "string" + }, + { + "name": "email", + "type": "string" + }, + { + "name": "name", + "type": "string" + } + ] + } + } + ] + } + }, + { + "name": "course_key", + "type": "string" + }, + { + "name": "usage_key", + "type": "string" + }, + { + "name": "launch_params", + "type": { + "name": "LtiProviderLaunchParamsData", + "type": "record", + "fields": [ + { + "name": "roles", + "type": "string" + }, + { + "name": "context_id", + "type": "string" + }, + { + "name": "user_id", + "type": "string" + }, + { + "name": "extra_params", + "type": { + "type": "map", + "values": "string" + } + } + ] + } + } + ] + } + } + ], + "namespace": "org.openedx.learning.lti_provider.launch.success.v1" +} \ No newline at end of file diff --git a/openedx_events/learning/data.py b/openedx_events/learning/data.py index eb12708c..7ebf4488 100644 --- a/openedx_events/learning/data.py +++ b/openedx_events/learning/data.py @@ -656,3 +656,31 @@ class ExternalGraderScoreData: module_id = attr.ib(type=str) queue_key = attr.ib(type=str) queue_name = attr.ib(type=str) + + +@attr.s(frozen=True) +class LtiProviderLaunchParamsData: + """ + Data required for a successful LTI launch. + + Attributes: + roles (str): A comma-separated list of roles (as per LTI Spec) of the User. + context_id (str): An ID for the launch context of LTI content. + user_id (str): User ID of user performing the launch. + extra_params (dict): A dictionary of other optional launch parameters. + """ + roles = attr.ib(type=str) + context_id = attr.ib(type=str) + user_id = attr.ib(type=str) + extra_params = attr.ib(type=dict[str, str], factory=dict) + + +@attr.s(frozen=True) +class LtiProviderLaunchData: + """ + Class that encapsulates LTI data for an LTI launch event. + """ + user = attr.ib(type=UserData) + course_key = attr.ib(type=CourseKey) + usage_key = attr.ib(type=UsageKey) + launch_params = attr.ib(type=LtiProviderLaunchParamsData) diff --git a/openedx_events/learning/signals.py b/openedx_events/learning/signals.py index d5b7c1ff..89bdce85 100644 --- a/openedx_events/learning/signals.py +++ b/openedx_events/learning/signals.py @@ -21,6 +21,7 @@ DiscussionThreadData, ExamAttemptData, ExternalGraderScoreData, + LtiProviderLaunchData, ORASubmissionData, PersistentCourseGradeData, ProgramCertificateData, @@ -504,3 +505,15 @@ "score": ExternalGraderScoreData, } ) + + +# .. event_type: org.openedx.learning.lti_provider.launch.success.v1 +# .. event_name: LTI_PROVIDER_LAUNCH_SUCCESS +# .. event_description: emitted when a student accesses learning content via LTI +# .. event_data: LtiProviderLaunchData +LTI_PROVIDER_LAUNCH_SUCCESS = OpenEdxPublicSignal( + event_type="org.openedx.learning.lti_provider.launch.success.v1", + data={ + "launch_data": LtiProviderLaunchData, + } +) From a290182e91c68eb03e822b0836e104973e468265 Mon Sep 17 00:00:00 2001 From: Kshitij Sobti Date: Mon, 30 Jun 2025 23:26:58 +0530 Subject: [PATCH 2/3] fixup! feat: Add event for LTI Launches --- openedx_events/learning/data.py | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/openedx_events/learning/data.py b/openedx_events/learning/data.py index 7ebf4488..5cbda0ed 100644 --- a/openedx_events/learning/data.py +++ b/openedx_events/learning/data.py @@ -679,6 +679,12 @@ class LtiProviderLaunchParamsData: class LtiProviderLaunchData: """ Class that encapsulates LTI data for an LTI launch event. + + Attributes: + user (UserData): The user data for the Open edX user initiating the launch. + course_key (CourseKey): The unique course ID for the course to which the launched content belongs. + usage_key (UsageKey): The usage key for the content being luanched via LtiProviderLaunchParamsData. + launch_params (LtiProviderLaunchParamsData): The LTI parameters used for the launch. """ user = attr.ib(type=UserData) course_key = attr.ib(type=CourseKey) From 78d9c0353dca7a3ad030c573d340dbc6d8821f35 Mon Sep 17 00:00:00 2001 From: Kshitij Sobti Date: Wed, 2 Jul 2025 17:31:11 +0530 Subject: [PATCH 3/3] fixup! fixup! feat: Add event for LTI Launches --- openedx_events/learning/data.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/openedx_events/learning/data.py b/openedx_events/learning/data.py index 5cbda0ed..014c53ec 100644 --- a/openedx_events/learning/data.py +++ b/openedx_events/learning/data.py @@ -666,7 +666,7 @@ class LtiProviderLaunchParamsData: Attributes: roles (str): A comma-separated list of roles (as per LTI Spec) of the User. context_id (str): An ID for the launch context of LTI content. - user_id (str): User ID of user performing the launch. + user_id (str): External (LTI) User ID of user performing the launch. extra_params (dict): A dictionary of other optional launch parameters. """ roles = attr.ib(type=str)