Skip to content

Commit

Permalink
fix: Allow LTI fallback on ExternalIdTypes for older edx-platform ver…
Browse files Browse the repository at this point in the history
…sions (#299)

* fix: Allow LTI fallback on ExternalIdTypes for older edx-platform versions

Older versions don't have the XAPI and Caliper types.
  • Loading branch information
bmtcril authored May 18, 2023
1 parent 8839a03 commit 8310ab3
Show file tree
Hide file tree
Showing 3 changed files with 17 additions and 2 deletions.
5 changes: 5 additions & 0 deletions CHANGELOG.rst
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,11 @@ Change Log
Unreleased
~~~~~~~~~~

[5.3.1]
~~~~~~~

* Allow External ID type to fall back to LTI on older versions of edx-platform
to preserve backward compatibility

[5.3.0]
~~~~~~~
Expand Down
2 changes: 1 addition & 1 deletion event_routing_backends/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,6 @@
Various backends for receiving edX LMS events..
"""

__version__ = '5.3.0'
__version__ = '5.3.1'

default_app_config = 'event_routing_backends.apps.EventRoutingBackendsConfig' # pylint: disable=invalid-name
12 changes: 11 additions & 1 deletion event_routing_backends/helpers.py
Original file line number Diff line number Diff line change
Expand Up @@ -63,7 +63,17 @@ def get_anonymous_user_id(username_or_id, external_type):

anonymous_id = str(uuid.uuid4())
else:
type_name = getattr(ExternalIdType, external_type)
# Older versions of edx-platform do not have the XAPI or
# Caliper ExternalIdTypes, so we fall back to LTI here.
# Eventually this will be a problem when those instances
# upgrade and their actor id's all change, unless we
# eventually add a setting to force LTI here instead of the
# usual type.
try:
type_name = getattr(ExternalIdType, external_type)
except AttributeError: # pragma: no cover
type_name = ExternalIdType.LTI

external_id, _ = ExternalId.add_new_user_id(user, type_name)
if not external_id:
raise ValueError("External ID type: %s does not exist" % type_name)
Expand Down

0 comments on commit 8310ab3

Please sign in to comment.