-> bind_for_student() and friends change the user_id
-> DraftVersioningModuleStore.update_item() mutates .location which mutates scope_ids.def_id and scope_ids.usage_id in a way that seems totally wrong
Writing to the deprecated props is just to enable backwards compatibility (for now), so shouldn't be a warning.
Reading from them is the problematic thing that we need to warn about and fix.
Also, the stacklevel was wrong, resulting in unhelpful warnings like this:
/openedx/edx-platform/xmodule/x_module.py:1486: DeprecationWarning: `runtime.course_id` is deprecated. Use `context_key` instead: `runtime.scope_ids.usage_id.context_key`.
block = self.load_item(usage_id, for_parent=for_parent)
/openedx/venv/lib/python3.8/site-packages/django/test/utils.py:387: DeprecationWarning: runtime.anonymous_student_id is deprecated. Please use the user service instead.
return func(*args, **kwargs)
/opt/pyenv/versions/3.8.12/lib/python3.8/unittest/case.py:633: DeprecationWarning: runtime.anonymous_student_id is deprecated. Please use the user service instead.
method()
/opt/pyenv/versions/3.8.12/lib/python3.8/unittest/case.py:633: DeprecationWarning: runtime.cache is deprecated. Please use the cache service instead.
method()
/openedx/venv/lib/python3.8/site-packages/django/test/utils.py:387: DeprecationWarning: runtime.can_execute_unsafe_code is deprecated. Please use the sandbox service instead.
return func(*args, **kwargs)
After changes from #31472, the user service of a "leaf" XBlock gets overridden
with the one created for its parent (SequenceBlock). Therefore, the
`requires_per_student_anonymous_id` is ignored in these XBlocks. The
subsequent renders of an XBlock (e.g., when requesting the solution) use
the student-specific IDs.
This removes choosing the proper ID (course-specific or student-specific) from
the runtime initialization. Instead, both IDs are passed to the user service.
There are only two XBlocks that relied on the
`requires_per_student_anonymous_id` - `ProblemBlock` and `HtmlBlock`. They
now request the "deprecated" (student-specific) user ID directly from the user
service.
Most of the methods in `XmlMixin` act as wrappers for the official API for
serialization and deserialization (parse_xml() and add_xml_to_node()).
`XmlParserMixin` contains the code which does the actual serialization and
deserialization.
This attribute is already deprecated for XBlocks in favour of directly
retrieving it like `block.scope_ids.usage_id.context_key`.
This commit also removes some redundant logging code which was omitted in the
Datadog removal in #19420.
This argument was officially used only by the ProblemBlock.
If you need to get the base URL for static assets in your XBlock, please use
`settings.STATIC_URL` directly, instead of `runtime.STATIC_URL`.
This setting allows loading of Resource Templates from outside the
edx-platform codebase.
Operators will be able to add their own custom resource templates
without needing to fork the codebase.
It's safe to remove this because non-staff [1] users cannot access [2]
an `ErrorBlock`. We were able to reproduce this with and without this commit
with the following results:
1. Staff users were seeing the `ErrorBlock`.
2. Non-staff users were getting an empty `<div class="vert-mod"></div>`.
In theory, error blocks should be hidden in the Learning MFE because of this
option [3]. However, when we manually set `hide_access_error_blocks` to
`False`, we kept getting identical results (with and without this commit), so
it looks that the removal `NonStaffErrorBlock` was just omitted at some point.
[1] a4ec4c1b8e/lms/djangoapps/courseware/access.py (L419-L436)
[2] a4ec4c1b8e/lms/djangoapps/courseware/access.py (L150-L151)
[3] 92ca176fde/lms/djangoapps/courseware/views/views.py (L1547-L1551)
There are many `field_data` usages in the platform. Let's categorize them and determine,
which are related to this change and in what way.
- ModuleSystem's argument. This is what we're removing.
- Runtime.field_data. Directly related, as Runtime is ModuleSystem's superclass.
Analysis below this list is centered around this.
- XBlock.field_data. Not related anymore. Runtime.construct_xblock was passing
runtime's field_data to the XBlock's constructor, but that was ~8 years ago.
- DescriptorSystem.field_data. Not related anymore. field_data has been removed
from the constructor long time ago, but you still can see its ancestors
instantiated with field_data=<value> here and there. It's important to note,
that it has been added here in the first place, because field_data was required in Runtime.
- DummySystem, CachingDescriptorSystem, ImportSystem. Not related anymore.
All these classes inherit MakoDescriptorSystem, which inherits DescriptorSystem itself.
So, see the previous item.
- PreviewModuleSystem, TestModuleSystem, LmsModuleSystem — ModuleSystem's ancestors. Directly related.
Basing on that, the only necessary check is to search for ModuleSystem's ancestors using
`field_data` or `_deprecated_per_instance_field_data`. As there are no such cases, it's safe to remove `field_data`.
Co-authored-by: Paulo Viadanna <paulo@opencraft.com>
Co-authored-by: DubeySandeep <dubeysandeep.in@gmail.com>
- Moving xmodule folder to root as we're dissolving sub-projects of common folder in edx-platform
- More info: https://openedx.atlassian.net/browse/BOM-2579
- -e common/lib/xmodule has been removed from the requirements as xmodule has itself become the part of edx-platform and not being installed through requirements
- The test files common/lib/xmodule/test_files/ have been removed as they are not being used anymore