-
Notifications
You must be signed in to change notification settings - Fork 4.2k
Allow tests for Extracted & Builtin LTI XBlock #36020
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: master
Are you sure you want to change the base?
Conversation
ba481cd to
8343717
Compare
d132ef3 to
eaf2743
Compare
8a886fd to
48be2e4
Compare
cf6d9cc to
995261a
Compare
|
@kdmccormick With the flag ( I'm sharing the output diff here. Please take a look, and guide me what could be the possible way-outs. |
f5560d2 to
efc6cb7
Compare
Note: I don't have technical depth of the mongo calls working, it needs to be explored |
|
@farhan
Seems like this is causing the issue. Let me try things around first, and IMO decreasing the count by 1 in the test case (inside |
373aa3e to
58f8e54
Compare
324c681 to
9c4c049
Compare
9c4c049 to
b5f2551
Compare
4164531 to
b2ffa96
Compare
|
@mphilbrick211 |
c6d0b64 to
80773ab
Compare
ae9edf1 to
faf53a8
Compare
|
|
||
| @ddt.data(*PER_COURSE_ANONYMIZED_XBLOCKS) | ||
| def test_per_course_anonymized_id(self, xblock_class): | ||
| if settings.USE_EXTRACTED_LTI_BLOCK and not hasattr(xblock_class, 'bind_for_student'): |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Why we only need it in case of Extracted LTI block.
As per discussion we need to explore bind_for_student.
Perhaps if its necessary for the block we should do it in the extracted block rather than only do it in the test case.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
No, we don't need to add bind_for_student method as it's not specific to LTIBlock. This method is called while loading the preview (cms/djangoapps/contentstore/views/preview.py) by the runtime. So there's no need to add it in the LTIBlock class.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
As per discussion further testing is required in case of Extracted LTI block, how the block behaves on following code.
_prepare_runtime_for_preview(request, block)
block.bind_for_student(
request.user.id,
[wrapper]
)
return blockThere was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I've tested this by putting a debugger, in both cases (built-in and extracted), bind_for_student method is being called form XModuleMixin.
4268a6b to
3004f24
Compare
|
We per discussion this XBlock needs to be properly tested on the Content Library - V2 like we have tested the other XBlocks. Here is some crash logs while testing on content-library: Traceback (most recent call last):
File "/openedx/venv/lib/python3.11/site-packages/django/core/handlers/exception.py", line 55, in inner
response = get_response(request)
^^^^^^^^^^^^^^^^^^^^^
File "/openedx/venv/lib/python3.11/site-packages/django/core/handlers/base.py", line 197, in _get_response
response = wrapped_callback(request, *callback_args, **callback_kwargs)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/opt/pyenv/versions/3.11.8/lib/python3.11/contextlib.py", line 81, in inner
return func(*args, **kwds)
^^^^^^^^^^^^^^^^^^^
File "/openedx/venv/lib/python3.11/site-packages/django/views/decorators/csrf.py", line 65, in _view_wrapper
return view_func(request, *args, **kwargs)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/openedx/venv/lib/python3.11/site-packages/django/views/generic/base.py", line 105, in view
return self.dispatch(request, *args, **kwargs)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/openedx/venv/lib/python3.11/site-packages/rest_framework/views.py", line 515, in dispatch
response = self.handle_exception(exc)
^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/openedx/venv/lib/python3.11/site-packages/rest_framework/views.py", line 475, in handle_exception
self.raise_uncaught_exception(exc)
File "/openedx/venv/lib/python3.11/site-packages/rest_framework/views.py", line 486, in raise_uncaught_exception
raise exc
File "/openedx/venv/lib/python3.11/site-packages/rest_framework/views.py", line 512, in dispatch
response = handler(request, *args, **kwargs)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/openedx/venv/lib/python3.11/site-packages/rest_framework/decorators.py", line 50, in handler
return func(*args, **kwargs)
^^^^^^^^^^^^^^^^^^^^^
File "/openedx/venv/lib/python3.11/site-packages/django/views/decorators/clickjacking.py", line 86, in _view_wrapper
response = view_func(*args, **kwargs)
^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/openedx/edx-platform/openedx/core/djangoapps/xblock/rest_api/views.py", line 118, in embed_block_view
fragment = _render_block_view(block, view_name, request.user)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/openedx/edx-platform/openedx/core/djangoapps/xblock/api.py", line 261, in render_block_view
fragment = block.render(view_name)
^^^^^^^^^^^^^^^^^^^^^^^
File "/mnt/xblock/xblock/core.py", line 818, in render
return self.runtime.render(self, view, context)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/openedx/edx-platform/openedx/core/djangoapps/xblock/runtime/runtime.py", line 415, in render
fragment = super().render(block, view_name, context)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/openedx/edx-platform/openedx/core/djangoapps/xblock/runtime/shims.py", line 41, in render
return super().render(block, view_name, context)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/mnt/xblock/xblock/runtime.py", line 823, in render
frag = view_fn(context)
^^^^^^^^^^^^^^^^
File "/mnt/xblocks-contrib/xblocks_contrib/lti/lti.py", line 536, in student_view
"templates/lti.html", self.get_context(),
^^^^^^^^^^^^^^^^^^
File "/mnt/xblocks-contrib/xblocks_contrib/lti/lti.py", line 508, in get_context
'input_fields': self.get_input_fields(),
^^^^^^^^^^^^^^^^^^^^^^^
File "/mnt/xblocks-contrib/xblocks_contrib/lti/lti.py", line 438, in get_input_fields
client_key, client_secret = self.get_client_key_secret()
^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/mnt/xblocks-contrib/xblocks_contrib/lti/lti.py", line 994, in get_client_key_secret
course = self.get_course()
^^^^^^^^^^^^^^^^^
File "/mnt/xblocks-contrib/xblocks_contrib/lti/lti.py", line 767, in get_course
return self.runtime.modulestore.get_course(self.location.course_key)
^^^^^^^^^^^^^^^^^^^^^^^^
AttributeError: 'LearningCoreXBlockRuntime' object has no attribute 'modulestore'
Internal Server Error: /xblocks/v2/lb:axim:lib1:lti:28d163a1-8bdb-4ce4-919d-7dcff9bb739c/embed/student_view/
Traceback (most recent call last):
File "/openedx/venv/lib/python3.11/site-packages/django/core/handlers/exception.py", line 55, in inner
response = get_response(request)
^^^^^^^^^^^^^^^^^^^^^
File "/openedx/venv/lib/python3.11/site-packages/django/core/handlers/base.py", line 197, in _get_response
response = wrapped_callback(request, *callback_args, **callback_kwargs)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/opt/pyenv/versions/3.11.8/lib/python3.11/contextlib.py", line 81, in inner
return func(*args, **kwds)
^^^^^^^^^^^^^^^^^^^
File "/openedx/venv/lib/python3.11/site-packages/django/views/decorators/csrf.py", line 65, in _view_wrapper
return view_func(request, *args, **kwargs)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/openedx/venv/lib/python3.11/site-packages/django/views/generic/base.py", line 105, in view
return self.dispatch(request, *args, **kwargs)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/openedx/venv/lib/python3.11/site-packages/rest_framework/views.py", line 515, in dispatch
response = self.handle_exception(exc)
^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/openedx/venv/lib/python3.11/site-packages/rest_framework/views.py", line 475, in handle_exception
self.raise_uncaught_exception(exc)
File "/openedx/venv/lib/python3.11/site-packages/rest_framework/views.py", line 486, in raise_uncaught_exception
raise exc
File "/openedx/venv/lib/python3.11/site-packages/rest_framework/views.py", line 512, in dispatch
response = handler(request, *args, **kwargs)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/openedx/venv/lib/python3.11/site-packages/rest_framework/decorators.py", line 50, in handler
return func(*args, **kwargs)
^^^^^^^^^^^^^^^^^^^^^
File "/openedx/venv/lib/python3.11/site-packages/django/views/decorators/clickjacking.py", line 86, in _view_wrapper
response = view_func(*args, **kwargs)
^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/openedx/edx-platform/openedx/core/djangoapps/xblock/rest_api/views.py", line 118, in embed_block_view
fragment = _render_block_view(block, view_name, request.user)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/openedx/edx-platform/openedx/core/djangoapps/xblock/api.py", line 261, in render_block_view
fragment = block.render(view_name)
^^^^^^^^^^^^^^^^^^^^^^^
File "/mnt/xblock/xblock/core.py", line 818, in render
return self.runtime.render(self, view, context)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/openedx/edx-platform/openedx/core/djangoapps/xblock/runtime/runtime.py", line 415, in render
fragment = super().render(block, view_name, context)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/openedx/edx-platform/openedx/core/djangoapps/xblock/runtime/shims.py", line 41, in render
return super().render(block, view_name, context)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/mnt/xblock/xblock/runtime.py", line 823, in render
frag = view_fn(context)
^^^^^^^^^^^^^^^^
File "/mnt/xblocks-contrib/xblocks_contrib/lti/lti.py", line 536, in student_view
"templates/lti.html", self.get_context(),
^^^^^^^^^^^^^^^^^^
File "/mnt/xblocks-contrib/xblocks_contrib/lti/lti.py", line 508, in get_context
'input_fields': self.get_input_fields(),
^^^^^^^^^^^^^^^^^^^^^^^
File "/mnt/xblocks-contrib/xblocks_contrib/lti/lti.py", line 438, in get_input_fields
client_key, client_secret = self.get_client_key_secret()
^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/mnt/xblocks-contrib/xblocks_contrib/lti/lti.py", line 994, in get_client_key_secret
course = self.get_course()
^^^^^^^^^^^^^^^^^
File "/mnt/xblocks-contrib/xblocks_contrib/lti/lti.py", line 767, in get_course
return self.runtime.modulestore.get_course(self.location.course_key)
^^^^^^^^^^^^^^^^^^^^^^^^
AttributeError: 'LearningCoreXBlockRuntime' object has no attribute 'modulestore'
2026-01-05 14:13:39,088 ERROR 25 [django.request] [user None] [ip None] log.py:253 - Internal Server Error: /xblocks/v2/lb:axim:lib1:lti:28d163a1-8bdb-4ce4-919d-7dcff9bb739c/embed/student_view/
Traceback (most recent call last):
File "/openedx/venv/lib/python3.11/site-packages/django/core/handlers/exception.py", line 55, in inner
response = get_response(request)
^^^^^^^^^^^^^^^^^^^^^
File "/openedx/venv/lib/python3.11/site-packages/django/core/handlers/base.py", line 197, in _get_response
response = wrapped_callback(request, *callback_args, **callback_kwargs)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/opt/pyenv/versions/3.11.8/lib/python3.11/contextlib.py", line 81, in inner
return func(*args, **kwds)
^^^^^^^^^^^^^^^^^^^
File "/openedx/venv/lib/python3.11/site-packages/django/views/decorators/csrf.py", line 65, in _view_wrapper
return view_func(request, *args, **kwargs)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/openedx/venv/lib/python3.11/site-packages/django/views/generic/base.py", line 105, in view
return self.dispatch(request, *args, **kwargs)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/openedx/venv/lib/python3.11/site-packages/rest_framework/views.py", line 515, in dispatch
response = self.handle_exception(exc)
^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/openedx/venv/lib/python3.11/site-packages/rest_framework/views.py", line 475, in handle_exception
self.raise_uncaught_exception(exc)
File "/openedx/venv/lib/python3.11/site-packages/rest_framework/views.py", line 486, in raise_uncaught_exception
raise exc
File "/openedx/venv/lib/python3.11/site-packages/rest_framework/views.py", line 512, in dispatch
response = handler(request, *args, **kwargs)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/openedx/venv/lib/python3.11/site-packages/rest_framework/decorators.py", line 50, in handler
return func(*args, **kwargs)
^^^^^^^^^^^^^^^^^^^^^
File "/openedx/venv/lib/python3.11/site-packages/django/views/decorators/clickjacking.py", line 86, in _view_wrapper
response = view_func(*args, **kwargs)
^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/openedx/edx-platform/openedx/core/djangoapps/xblock/rest_api/views.py", line 118, in embed_block_view
fragment = _render_block_view(block, view_name, request.user)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/openedx/edx-platform/openedx/core/djangoapps/xblock/api.py", line 261, in render_block_view
fragment = block.render(view_name)
^^^^^^^^^^^^^^^^^^^^^^^
File "/mnt/xblock/xblock/core.py", line 818, in render
return self.runtime.render(self, view, context)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/openedx/edx-platform/openedx/core/djangoapps/xblock/runtime/runtime.py", line 415, in render
fragment = super().render(block, view_name, context)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/openedx/edx-platform/openedx/core/djangoapps/xblock/runtime/shims.py", line 41, in render
return super().render(block, view_name, context)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/mnt/xblock/xblock/runtime.py", line 823, in render
frag = view_fn(context)
^^^^^^^^^^^^^^^^
File "/mnt/xblocks-contrib/xblocks_contrib/lti/lti.py", line 536, in student_view
"templates/lti.html", self.get_context(),
^^^^^^^^^^^^^^^^^^
File "/mnt/xblocks-contrib/xblocks_contrib/lti/lti.py", line 508, in get_context
'input_fields': self.get_input_fields(),
^^^^^^^^^^^^^^^^^^^^^^^
File "/mnt/xblocks-contrib/xblocks_contrib/lti/lti.py", line 438, in get_input_fields
client_key, client_secret = self.get_client_key_secret()
^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/mnt/xblocks-contrib/xblocks_contrib/lti/lti.py", line 994, in get_client_key_secret
course = self.get_course()
^^^^^^^^^^^^^^^^^
File "/mnt/xblocks-contrib/xblocks_contrib/lti/lti.py", line 767, in get_course
return self.runtime.modulestore.get_course(self.location.course_key)
^^^^^^^^^^^^^^^^^^^^^^^^
AttributeError: 'LearningCoreXBlockRuntime' object has no attribute 'modulestore' |
|
Sandbox deployment failed 💥 |
|
Sandbox deployment successful 🚀 |
3004f24 to
f9e7c57
Compare
f9e7c57 to
f6edf0b
Compare
|
Sandbox deployment successful 🚀 |
|
Sandbox deployment successful 🚀 |
|
Sandbox deployment successful 🚀 |
|
Sandbox deployment successful 🚀 |
I've opened an issue to fix this: openedx/xblocks-contrib#132 |
Test the LTI XBlock in both built-in and extracted modes to keep them in sync.
Related to: #36281