Skip to content
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

Add Waffle flags to roll out the extracted XBlocks #35549

Draft
wants to merge 7 commits into
base: master
Choose a base branch
from
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion cms/lib/xblock/tagging/tagging.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,6 @@
from xblock.fields import Dict, Scope

from common.djangoapps.edxmako.shortcuts import render_to_string
from xmodule.capa_block import ProblemBlock # lint-amnesty, pylint: disable=wrong-import-order
from xmodule.x_module import AUTHOR_VIEW # lint-amnesty, pylint: disable=wrong-import-order

_ = lambda text: text
Expand Down Expand Up @@ -42,6 +41,7 @@ def student_view_aside(self, block, context): # pylint: disable=unused-argument
Display the tag selector with specific categories and allowed values,
depending on the context.
"""
from xmodule.capa_block import ProblemBlock
if isinstance(block, ProblemBlock):
tags = []
for tag in self.get_available_tags():
Expand Down
6 changes: 6 additions & 0 deletions lms/djangoapps/courseware/views/views.py
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,8 @@
from django.views.generic import View
from edx_django_utils.monitoring import set_custom_attribute, set_custom_attributes_for_course_key
from ipware.ip import get_client_ip
from xblock.core import XBlock

from lms.djangoapps.static_template_view.views import render_500
from markupsafe import escape
from opaque_keys import InvalidKeyError
Expand Down Expand Up @@ -1562,6 +1564,10 @@ def render_xblock(request, usage_key_string, check_if_enrolled=True, disable_sta
set_custom_attributes_for_course_key(course_key)
set_custom_attribute('usage_key', usage_key_string)
set_custom_attribute('block_type', usage_key.block_type)
block_class = XBlock.load_class(usage_key.block_type)
if hasattr(block_class, 'is_extracted'):
is_extracted = getattr(block_class, 'is_extracted')
set_custom_attribute('block_extracted', is_extracted)

requested_view = request.GET.get('view', 'student_view')
if requested_view != 'student_view' and requested_view != 'public_view': # lint-amnesty, pylint: disable=consider-using-in
Expand Down
8 changes: 0 additions & 8 deletions requirements/common_constraints.txt
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,6 @@
# Note: Changes to this file will automatically be used by other repos, referencing
# this file from Github directly. It does not require packaging in edx-lint.


# using LTS django version
Django<5.0

Expand All @@ -26,13 +25,6 @@ elasticsearch<7.14.0

# django-simple-history>3.0.0 adds indexing and causes a lot of migrations to be affected

# Cause: https://github.com/openedx/event-tracking/pull/290
# event-tracking 2.4.1 upgrades to pymongo 4.4.0 which is not supported on edx-platform.
# We will pin event-tracking to do not break existing installations
# This can be unpinned once https://github.com/openedx/edx-platform/issues/34586
# has been resolved and edx-platform is running with pymongo>=4.4.0


# Cause: https://github.com/openedx/edx-lint/issues/458
# This can be unpinned once https://github.com/openedx/edx-lint/issues/459 has been resolved.
pip<24.3
6 changes: 6 additions & 0 deletions requirements/edx/base.txt
Original file line number Diff line number Diff line change
Expand Up @@ -345,6 +345,7 @@ django-statici18n==2.5.0
# lti-consumer-xblock
# xblock-drag-and-drop-v2
# xblock-poll
# xblocks-contrib
django-storages==1.14.3
# via
# -c requirements/edx/../constraints.txt
Expand Down Expand Up @@ -480,6 +481,7 @@ edx-i18n-tools==1.5.0
# -c requirements/edx/../constraints.txt
# -r requirements/edx/bundled.in
# ora2
# xblocks-contrib
edx-milestones==0.6.0
# via -r requirements/edx/kernel.in
edx-name-affirmation==3.0.1
Expand Down Expand Up @@ -809,6 +811,7 @@ openedx-django-pyfs==3.7.0
# via
# lti-consumer-xblock
# xblock
# xblocks-contrib
openedx-django-require==2.1.0
# via -r requirements/edx/kernel.in
openedx-django-wiki==2.1.0
Expand Down Expand Up @@ -1277,6 +1280,7 @@ xblock[django]==5.1.0
# xblock-drag-and-drop-v2
# xblock-google-drive
# xblock-utils
# xblocks-contrib
xblock-drag-and-drop-v2==4.0.3
# via -r requirements/edx/bundled.in
xblock-google-drive==0.7.0
Expand All @@ -1287,6 +1291,8 @@ xblock-utils==4.0.0
# via
# edx-sga
# xblock-poll
xblocks-contrib==0.1.0
# via -r requirements/edx/bundled.in
xmlsec==1.3.14
# via python3-saml
xss-utils==0.6.0
Expand Down
1 change: 1 addition & 0 deletions requirements/edx/bundled.in
Original file line number Diff line number Diff line change
Expand Up @@ -47,3 +47,4 @@ ora2>=4.5.0 # Open Response Assessment XBlock
xblock-poll # Xblock for polling users
xblock-drag-and-drop-v2 # Drag and Drop XBlock
xblock-google-drive # XBlock for google docs and calendar
xblocks-contrib # Package having multiple core XBlocks, https://github.com/openedx/xblocks-contrib?tab=readme-ov-file#xblocks-being-moved-here
8 changes: 8 additions & 0 deletions requirements/edx/development.txt
Original file line number Diff line number Diff line change
Expand Up @@ -565,6 +565,7 @@ django-statici18n==2.5.0
# lti-consumer-xblock
# xblock-drag-and-drop-v2
# xblock-poll
# xblocks-contrib
django-storages==1.14.3
# via
# -c requirements/edx/../constraints.txt
Expand Down Expand Up @@ -760,6 +761,7 @@ edx-i18n-tools==1.5.0
# -r requirements/edx/doc.txt
# -r requirements/edx/testing.txt
# ora2
# xblocks-contrib
edx-lint==5.4.1
# via -r requirements/edx/testing.txt
edx-milestones==0.6.0
Expand Down Expand Up @@ -1357,6 +1359,7 @@ openedx-django-pyfs==3.7.0
# -r requirements/edx/testing.txt
# lti-consumer-xblock
# xblock
# xblocks-contrib
openedx-django-require==2.1.0
# via
# -r requirements/edx/doc.txt
Expand Down Expand Up @@ -2257,6 +2260,7 @@ xblock[django]==5.1.0
# xblock-drag-and-drop-v2
# xblock-google-drive
# xblock-utils
# xblocks-contrib
xblock-drag-and-drop-v2==4.0.3
# via
# -r requirements/edx/doc.txt
Expand All @@ -2275,6 +2279,10 @@ xblock-utils==4.0.0
# -r requirements/edx/testing.txt
# edx-sga
# xblock-poll
xblocks-contrib==0.1.0
# via
# -r requirements/edx/doc.txt
# -r requirements/edx/testing.txt
xmlsec==1.3.14
# via
# -r requirements/edx/doc.txt
Expand Down
6 changes: 6 additions & 0 deletions requirements/edx/doc.txt
Original file line number Diff line number Diff line change
Expand Up @@ -415,6 +415,7 @@ django-statici18n==2.5.0
# lti-consumer-xblock
# xblock-drag-and-drop-v2
# xblock-poll
# xblocks-contrib
django-storages==1.14.3
# via
# -c requirements/edx/../constraints.txt
Expand Down Expand Up @@ -560,6 +561,7 @@ edx-i18n-tools==1.5.0
# -c requirements/edx/../constraints.txt
# -r requirements/edx/base.txt
# ora2
# xblocks-contrib
edx-milestones==0.6.0
# via -r requirements/edx/base.txt
edx-name-affirmation==3.0.1
Expand Down Expand Up @@ -972,6 +974,7 @@ openedx-django-pyfs==3.7.0
# -r requirements/edx/base.txt
# lti-consumer-xblock
# xblock
# xblocks-contrib
openedx-django-require==2.1.0
# via -r requirements/edx/base.txt
openedx-django-wiki==2.1.0
Expand Down Expand Up @@ -1572,6 +1575,7 @@ xblock[django]==5.1.0
# xblock-drag-and-drop-v2
# xblock-google-drive
# xblock-utils
# xblocks-contrib
xblock-drag-and-drop-v2==4.0.3
# via -r requirements/edx/base.txt
xblock-google-drive==0.7.0
Expand All @@ -1583,6 +1587,8 @@ xblock-utils==4.0.0
# -r requirements/edx/base.txt
# edx-sga
# xblock-poll
xblocks-contrib==0.1.0
# via -r requirements/edx/base.txt
xmlsec==1.3.14
# via
# -r requirements/edx/base.txt
Expand Down
6 changes: 6 additions & 0 deletions requirements/edx/testing.txt
Original file line number Diff line number Diff line change
Expand Up @@ -444,6 +444,7 @@ django-statici18n==2.5.0
# lti-consumer-xblock
# xblock-drag-and-drop-v2
# xblock-poll
# xblocks-contrib
django-storages==1.14.3
# via
# -c requirements/edx/../constraints.txt
Expand Down Expand Up @@ -584,6 +585,7 @@ edx-i18n-tools==1.5.0
# -c requirements/edx/../constraints.txt
# -r requirements/edx/base.txt
# ora2
# xblocks-contrib
edx-lint==5.4.1
# via -r requirements/edx/testing.in
edx-milestones==0.6.0
Expand Down Expand Up @@ -1023,6 +1025,7 @@ openedx-django-pyfs==3.7.0
# -r requirements/edx/base.txt
# lti-consumer-xblock
# xblock
# xblocks-contrib
openedx-django-require==2.1.0
# via -r requirements/edx/base.txt
openedx-django-wiki==2.1.0
Expand Down Expand Up @@ -1671,6 +1674,7 @@ xblock[django]==5.1.0
# xblock-drag-and-drop-v2
# xblock-google-drive
# xblock-utils
# xblocks-contrib
xblock-drag-and-drop-v2==4.0.3
# via -r requirements/edx/base.txt
xblock-google-drive==0.7.0
Expand All @@ -1682,6 +1686,8 @@ xblock-utils==4.0.0
# -r requirements/edx/base.txt
# edx-sga
# xblock-poll
xblocks-contrib==0.1.0
# via -r requirements/edx/base.txt
xmlsec==1.3.14
# via
# -r requirements/edx/base.txt
Expand Down
14 changes: 12 additions & 2 deletions xmodule/annotatable_block.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,18 +7,20 @@
from web_fragments.fragment import Fragment
from xblock.core import XBlock
from xblock.fields import Scope, String
from xblocks_contrib.annotatable import AnnotatableBlock as _ExtractedAnnotatableBlock

from openedx.core.djangolib.markup import HTML, Text
from xmodule.editing_block import EditingMixin
from xmodule.raw_block import RawMixin
from xmodule.toggles import USE_EXTRACTED_ANNOTATABLE_BLOCK
from xmodule.util.builtin_assets import add_webpack_js_to_fragment, add_css_to_fragment
from xmodule.xml_block import XmlMixin
from xmodule.x_module import (
ResourceTemplates,
shim_xmodule_js,
XModuleMixin,
XModuleToXBlockMixin,
)
from xmodule.xml_block import XmlMixin

log = logging.getLogger(__name__)

Expand All @@ -28,7 +30,7 @@


@XBlock.needs('mako')
class AnnotatableBlock(
class _BuiltInAnnotatableBlock(
RawMixin,
XmlMixin,
EditingMixin,
Expand All @@ -40,6 +42,8 @@ class AnnotatableBlock(
Annotatable XBlock.
"""

is_extracted = False

data = String(
help=_("XML data for the annotation"),
scope=Scope.content,
Expand Down Expand Up @@ -197,3 +201,9 @@ def studio_view(self, _context):
add_webpack_js_to_fragment(fragment, 'AnnotatableBlockEditor')
shim_xmodule_js(fragment, self.studio_js_module_name)
return fragment


AnnotatableBlock = (
_ExtractedAnnotatableBlock if USE_EXTRACTED_ANNOTATABLE_BLOCK.is_enabled()
else _BuiltInAnnotatableBlock
)
14 changes: 12 additions & 2 deletions xmodule/html_block.py
Original file line number Diff line number Diff line change
Expand Up @@ -15,15 +15,17 @@
from web_fragments.fragment import Fragment
from xblock.core import XBlock
from xblock.fields import Boolean, List, Scope, String
from xblocks_contrib.html import HtmlBlock as _ExtractedHtmlBlock

from common.djangoapps.xblock_django.constants import ATTR_KEY_DEPRECATED_ANONYMOUS_USER_ID
from xmodule.contentstore.content import StaticContent
from xmodule.editing_block import EditingMixin
from xmodule.edxnotes_utils import edxnotes
from xmodule.html_checker import check_html
from xmodule.stringify import stringify_children
from xmodule.util.misc import escape_html_characters
from xmodule.toggles import USE_EXTRACTED_HTML_BLOCK
from xmodule.util.builtin_assets import add_webpack_js_to_fragment, add_css_to_fragment
from xmodule.util.misc import escape_html_characters
from xmodule.x_module import (
ResourceTemplates,
shim_xmodule_js,
Expand All @@ -50,6 +52,8 @@ class HtmlBlockMixin( # lint-amnesty, pylint: disable=abstract-method
The HTML XBlock mixin.
This provides the base class for all Html-ish blocks (including the HTML XBlock).
"""
is_extracted = False

display_name = String(
display_name=_("Display Name"),
help=_("The display name for this component."),
Expand Down Expand Up @@ -353,7 +357,7 @@ def index_dictionary(self):


@edxnotes
class HtmlBlock(HtmlBlockMixin): # lint-amnesty, pylint: disable=abstract-method
class _BuiltInHtmlBlock(HtmlBlockMixin): # lint-amnesty, pylint: disable=abstract-method
"""
This is the actual HTML XBlock.
Nothing extra is required; this is just a wrapper to include edxnotes support.
Expand Down Expand Up @@ -489,3 +493,9 @@ def safe_parse_date(date):
return datetime.strptime(date, '%B %d, %Y')
except ValueError: # occurs for ill-formatted date values
return datetime.today()


HtmlBlock = (
_ExtractedHtmlBlock if USE_EXTRACTED_HTML_BLOCK.is_enabled()
else _BuiltInHtmlBlock
)
Loading
Loading