Skip to content

Commit 72e66cc

Browse files
authored
feat: Add event for LTI Launches (#501)
Adds an LTI launch event with data related to LTI Launches.
1 parent cd863e8 commit 72e66cc

File tree

5 files changed

+148
-1
lines changed

5 files changed

+148
-1
lines changed

CHANGELOG.rst

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,15 @@ Change Log
1616
Unreleased
1717
__________
1818

19+
[10.3.0] - 2025-05-23
20+
---------------------
21+
22+
Added
23+
~~~~~
24+
25+
* Added new ``LTI_PROVIDER_LAUNCH_SUCCESS`` event in learning.
26+
27+
1928
[10.2.1] - 2025-05-13
2029
---------------------
2130

openedx_events/__init__.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,4 +5,4 @@
55
more information about the project.
66
"""
77

8-
__version__ = "10.2.1"
8+
__version__ = "10.3.0"
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,91 @@
1+
{
2+
"name": "CloudEvent",
3+
"type": "record",
4+
"doc": "Avro Event Format for CloudEvents created with openedx_events/schema",
5+
"fields": [
6+
{
7+
"name": "launch_data",
8+
"type": {
9+
"name": "LtiProviderLaunchData",
10+
"type": "record",
11+
"fields": [
12+
{
13+
"name": "user",
14+
"type": {
15+
"name": "UserData",
16+
"type": "record",
17+
"fields": [
18+
{
19+
"name": "id",
20+
"type": "long"
21+
},
22+
{
23+
"name": "is_active",
24+
"type": "boolean"
25+
},
26+
{
27+
"name": "pii",
28+
"type": {
29+
"name": "UserPersonalData",
30+
"type": "record",
31+
"fields": [
32+
{
33+
"name": "username",
34+
"type": "string"
35+
},
36+
{
37+
"name": "email",
38+
"type": "string"
39+
},
40+
{
41+
"name": "name",
42+
"type": "string"
43+
}
44+
]
45+
}
46+
}
47+
]
48+
}
49+
},
50+
{
51+
"name": "course_key",
52+
"type": "string"
53+
},
54+
{
55+
"name": "usage_key",
56+
"type": "string"
57+
},
58+
{
59+
"name": "launch_params",
60+
"type": {
61+
"name": "LtiProviderLaunchParamsData",
62+
"type": "record",
63+
"fields": [
64+
{
65+
"name": "roles",
66+
"type": "string"
67+
},
68+
{
69+
"name": "context_id",
70+
"type": "string"
71+
},
72+
{
73+
"name": "user_id",
74+
"type": "string"
75+
},
76+
{
77+
"name": "extra_params",
78+
"type": {
79+
"type": "map",
80+
"values": "string"
81+
}
82+
}
83+
]
84+
}
85+
}
86+
]
87+
}
88+
}
89+
],
90+
"namespace": "org.openedx.learning.lti_provider.launch.success.v1"
91+
}

openedx_events/learning/data.py

Lines changed: 34 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -656,3 +656,37 @@ class ExternalGraderScoreData:
656656
module_id = attr.ib(type=str)
657657
queue_key = attr.ib(type=str)
658658
queue_name = attr.ib(type=str)
659+
660+
661+
@attr.s(frozen=True)
662+
class LtiProviderLaunchParamsData:
663+
"""
664+
Data required for a successful LTI launch.
665+
666+
Attributes:
667+
roles (str): A comma-separated list of roles (as per LTI Spec) of the User.
668+
context_id (str): An ID for the launch context of LTI content.
669+
user_id (str): External (LTI) User ID of user performing the launch.
670+
extra_params (dict): A dictionary of other optional launch parameters.
671+
"""
672+
roles = attr.ib(type=str)
673+
context_id = attr.ib(type=str)
674+
user_id = attr.ib(type=str)
675+
extra_params = attr.ib(type=dict[str, str], factory=dict)
676+
677+
678+
@attr.s(frozen=True)
679+
class LtiProviderLaunchData:
680+
"""
681+
Class that encapsulates LTI data for an LTI launch event.
682+
683+
Attributes:
684+
user (UserData): The user data for the Open edX user initiating the launch.
685+
course_key (CourseKey): The unique course ID for the course to which the launched content belongs.
686+
usage_key (UsageKey): The usage key for the content being luanched via LtiProviderLaunchParamsData.
687+
launch_params (LtiProviderLaunchParamsData): The LTI parameters used for the launch.
688+
"""
689+
user = attr.ib(type=UserData)
690+
course_key = attr.ib(type=CourseKey)
691+
usage_key = attr.ib(type=UsageKey)
692+
launch_params = attr.ib(type=LtiProviderLaunchParamsData)

openedx_events/learning/signals.py

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,7 @@
2121
DiscussionThreadData,
2222
ExamAttemptData,
2323
ExternalGraderScoreData,
24+
LtiProviderLaunchData,
2425
ORASubmissionData,
2526
PersistentCourseGradeData,
2627
ProgramCertificateData,
@@ -504,3 +505,15 @@
504505
"score": ExternalGraderScoreData,
505506
}
506507
)
508+
509+
510+
# .. event_type: org.openedx.learning.lti_provider.launch.success.v1
511+
# .. event_name: LTI_PROVIDER_LAUNCH_SUCCESS
512+
# .. event_description: emitted when a student accesses learning content via LTI
513+
# .. event_data: LtiProviderLaunchData
514+
LTI_PROVIDER_LAUNCH_SUCCESS = OpenEdxPublicSignal(
515+
event_type="org.openedx.learning.lti_provider.launch.success.v1",
516+
data={
517+
"launch_data": LtiProviderLaunchData,
518+
}
519+
)

0 commit comments

Comments
 (0)