Skip to content

Commit e580b96

Browse files
authored
fix: lms compatibility with descriptor->block rename (#370)
Fixes compatibility issue with recent LMS changes to refactor item/module/block/descriptor terminology.
1 parent 61fb278 commit e580b96

3 files changed

Lines changed: 18 additions & 14 deletions

File tree

CHANGELOG.rst

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,10 @@ Please See the `releases tab <https://github.com/openedx/xblock-lti-consumer/rel
1616
Unreleased
1717
~~~~~~~~~~
1818

19+
9.4.0 - 2023-05-08
20+
------------------
21+
* Fix broken call to LMS `get_block_for_descriptor_internal` due to descriptor->block rename.
22+
1923
9.3.0 - 2023-05-05
2024
------------------
2125
* Added handling for the ACS scope and ACS actions

lti_consumer/__init__.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,4 +4,4 @@
44
from .apps import LTIConsumerApp
55
from .lti_xblock import LtiConsumerXBlock
66

7-
__version__ = '9.3.0'
7+
__version__ = '9.4.0'

lti_consumer/plugin/compat.py

Lines changed: 13 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -90,7 +90,7 @@ def load_enough_xblock(location): # pragma: nocover
9090
# pylint: disable=import-error,import-outside-toplevel
9191
from xmodule.modulestore.django import modulestore
9292

93-
# Retrieve descriptor from modulestore
93+
# Retrieve block from modulestore
9494
return modulestore().get_item(location)
9595

9696

@@ -103,35 +103,35 @@ def load_block_as_user(location): # pragma: nocover
103103
from lms.djangoapps.courseware.block_render import get_block_for_descriptor_internal
104104
from openedx.core.lib.xblock_utils import request_token
105105

106-
# Retrieve descriptor from modulestore
107-
descriptor = load_enough_xblock(location)
106+
# Retrieve block from modulestore
107+
block = load_enough_xblock(location)
108108
user = get_current_user()
109109
request = get_current_request()
110110
if user and request:
111-
# If we're in request scope, the descriptor may already be a block bound to a user
111+
# If we're in request scope, the block may already be bound to a user
112112
# and we don't need to do any more loading
113-
if descriptor.scope_ids.user_id is not None and user.id == descriptor.scope_ids.user_id:
114-
return descriptor
113+
if block.scope_ids.user_id is not None and user.id == block.scope_ids.user_id:
114+
return block
115115

116116
# If not load this block to bind it onto the user
117117
get_block_for_descriptor_internal(
118118
user=user,
119-
descriptor=descriptor,
119+
block=block,
120120
student_data=None,
121121
course_id=location.course_key,
122122
track_function=None,
123123
request_token=request_token(request),
124124
)
125-
return descriptor
125+
return block
126126
else:
127-
return _load_block_as_anonymous_user(location, descriptor)
127+
return _load_block_as_anonymous_user(location, block)
128128

129129

130-
def _load_block_as_anonymous_user(location, descriptor): # pragma: nocover
130+
def _load_block_as_anonymous_user(location, block): # pragma: nocover
131131
"""
132132
Load a block as the anonymous user because no user is available.
133133
134-
This uses a few internal courseware methods to retrieve the descriptor
134+
This uses a few internal courseware methods to retrieve the block
135135
and bind an AnonymousUser to it, in a similar fashion as a `noauth` XBlock
136136
handler.
137137
"""
@@ -147,14 +147,14 @@ def _load_block_as_anonymous_user(location, descriptor): # pragma: nocover
147147
# Load block, attaching it to AnonymousUser
148148
get_block_for_descriptor_internal(
149149
user=user,
150-
descriptor=descriptor,
150+
block=block,
151151
student_data=None,
152152
course_id=location.course_key,
153153
track_function=None,
154154
request_token="",
155155
)
156156

157-
return descriptor
157+
return block
158158

159159

160160
def get_user_from_external_user_id(external_user_id): # pragma: nocover

0 commit comments

Comments
 (0)