diff --git a/xmodule/capa_block.py b/xmodule/capa_block.py index c1c650144b05..bf70d9738404 100644 --- a/xmodule/capa_block.py +++ b/xmodule/capa_block.py @@ -55,6 +55,7 @@ from .fields import Date, ListScoreField, ScoreField, Timedelta from .progress import Progress +from .toggles import USE_EXTRACTED_PROBLEM_BLOCK log = logging.getLogger("edx.courseware") @@ -134,7 +135,7 @@ def from_json(self, value): @XBlock.needs('sandbox') @XBlock.needs('replace_urls') @XBlock.wants('call_to_action') -class ProblemBlock( +class _BuiltInProblemBlock( ScorableXBlockMixin, RawMixin, XmlMixin, @@ -161,6 +162,8 @@ class ProblemBlock( """ INDEX_CONTENT_TYPE = 'CAPA' + is_extracted = False + resources_dir = None has_score = True @@ -2509,3 +2512,11 @@ def randomization_bin(seed, problem_id): r_hash.update(str(problem_id).encode()) # get the first few digits of the hash, convert to an int, then mod. return int(r_hash.hexdigest()[:7], 16) % NUM_RANDOMIZATION_BINS + + +ProblemBlock = ( + # TODO: Revert following + # _ExractedProblemBlock if USE_EXTRACTED_PROBLEM_BLOCK.is_enabled() + _BuiltInProblemBlock if USE_EXTRACTED_PROBLEM_BLOCK.is_enabled() + else _BuiltInProblemBlock +) diff --git a/xmodule/discussion_block.py b/xmodule/discussion_block.py index 89e573c07c83..dad8fb7d7654 100644 --- a/xmodule/discussion_block.py +++ b/xmodule/discussion_block.py @@ -19,6 +19,7 @@ from openedx.core.djangoapps.discussions.models import DiscussionsConfiguration, Provider from openedx.core.djangolib.markup import HTML, Text from openedx.core.lib.xblock_utils import get_css_dependencies, get_js_dependencies +from xmodule.toggles import USE_EXTRACTED_DISCUSSION_BLOCK from xmodule.xml_block import XmlMixin @@ -36,10 +37,11 @@ def _(text): @XBlock.needs('user') # pylint: disable=abstract-method @XBlock.needs('i18n') @XBlock.needs('mako') -class DiscussionXBlock(XBlock, StudioEditableXBlockMixin, XmlMixin): # lint-amnesty, pylint: disable=abstract-method +class _BuiltInDiscussionXBlock(XBlock, StudioEditableXBlockMixin, XmlMixin): # lint-amnesty, pylint: disable=abstract-method """ Provides a discussion forum that is inline with other content in the courseware. """ + is_extracted = False completion_mode = XBlockCompletionMode.EXCLUDED discussion_id = String(scope=Scope.settings, default=UNIQUE_ID) @@ -275,3 +277,11 @@ def _apply_metadata_and_policy(cls, block, node, runtime): for field_name, value in metadata.items(): if field_name in block.fields: setattr(block, field_name, value) + + +DiscussionXBlock = ( + # TODO: Revert following + # _ExractedDiscussionXBlock if USE_EXTRACTED_DISCUSSION_BLOCK.is_enabled() + _BuiltInDiscussionXBlock if USE_EXTRACTED_DISCUSSION_BLOCK.is_enabled() + else _BuiltInDiscussionXBlock +) diff --git a/xmodule/html_block.py b/xmodule/html_block.py index 2db198360107..fdfeb97390fc 100644 --- a/xmodule/html_block.py +++ b/xmodule/html_block.py @@ -22,6 +22,7 @@ from xmodule.edxnotes_utils import edxnotes from xmodule.html_checker import check_html from xmodule.stringify import stringify_children +from xmodule.toggles import USE_EXTRACTED_HTML_BLOCK from xmodule.util.misc import escape_html_characters from xmodule.util.builtin_assets import add_webpack_js_to_fragment, add_sass_to_fragment from xmodule.x_module import ( @@ -50,6 +51,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."), @@ -353,7 +356,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. @@ -489,3 +492,11 @@ def safe_parse_date(date): return datetime.strptime(date, '%B %d, %Y') except ValueError: # occurs for ill-formatted date values return datetime.today() + + +HtmlBlock = ( + # TODO: Revert following + # _ExractedHtmlBlock if USE_EXTRACTED_HTML_BLOCK.is_enabled() + _BuiltInHtmlBlock if USE_EXTRACTED_HTML_BLOCK.is_enabled() + else _BuiltInHtmlBlock +) diff --git a/xmodule/lti_block.py b/xmodule/lti_block.py index 55f940b381c2..ce8715b5e6a5 100644 --- a/xmodule/lti_block.py +++ b/xmodule/lti_block.py @@ -84,6 +84,7 @@ ) from xmodule.lti_2_util import LTI20BlockMixin, LTIError from xmodule.raw_block import EmptyDataRawMixin +from xmodule.toggles import USE_EXTRACTED_LTI_BLOCK from xmodule.util.builtin_assets import add_webpack_js_to_fragment, add_sass_to_fragment from xmodule.xml_block import XmlMixin from xmodule.x_module import ( @@ -274,7 +275,7 @@ class LTIFields: @XBlock.needs("mako") @XBlock.needs("user") @XBlock.needs("rebind_user") -class LTIBlock( +class _BuiltInLTIBlock( LTIFields, LTI20BlockMixin, EmptyDataRawMixin, @@ -366,6 +367,7 @@ class LTIBlock( Otherwise error message from LTI provider is generated. """ + is_extracted = False resources_dir = None uses_xmodule_styles_setup = True @@ -984,3 +986,11 @@ def is_past_due(self): else: close_date = due_date return close_date is not None and datetime.datetime.now(UTC) > close_date + + +LTIBlock = ( + # TODO: Revert following + # _ExractedLTIBlock if USE_EXTRACTED_LTI_BLOCK.is_enabled() + _BuiltInLTIBlock if USE_EXTRACTED_LTI_BLOCK.is_enabled() + else _BuiltInLTIBlock +) diff --git a/xmodule/poll_block.py b/xmodule/poll_block.py index f09889f506e6..5871c2076860 100644 --- a/xmodule/poll_block.py +++ b/xmodule/poll_block.py @@ -21,6 +21,7 @@ from openedx.core.djangolib.markup import Text, HTML from xmodule.mako_block import MakoTemplateBlockBase from xmodule.stringify import stringify_children +from xmodule.toggles import USE_EXTRACTED_POLL_BLOCK from xmodule.util.builtin_assets import add_webpack_js_to_fragment, add_sass_to_fragment from xmodule.x_module import ( ResourceTemplates, @@ -36,7 +37,7 @@ @XBlock.needs('mako') -class PollBlock( +class _BuiltInPollBlock( MakoTemplateBlockBase, XmlMixin, XModuleToXBlockMixin, @@ -44,6 +45,9 @@ class PollBlock( XModuleMixin, ): # pylint: disable=abstract-method """Poll Block""" + + is_extracted = False + # Name of poll to use in links to this poll display_name = String( help=_("The display name for this component."), @@ -244,3 +248,10 @@ def add_child(xml_obj, answer): # lint-amnesty, pylint: disable=unused-argument add_child(xml_object, answer) return xml_object + +PollBlock = ( + # TODO: Revert following + # _ExractedPollBlock if USE_EXTRACTED_POLL_BLOCK.is_enabled() + _BuiltInPollBlock if USE_EXTRACTED_POLL_BLOCK.is_enabled() + else _BuiltInPollBlock +) diff --git a/xmodule/video_block/video_block.py b/xmodule/video_block/video_block.py index 782645c373b0..795ebd85c3af 100644 --- a/xmodule/video_block/video_block.py +++ b/xmodule/video_block/video_block.py @@ -70,6 +70,7 @@ from .video_handlers import VideoStudentViewHandlers, VideoStudioViewHandlers from .video_utils import create_youtube_string, format_xml_exception_message, get_poster, rewrite_video_url from .video_xfields import VideoFields +from ..toggles import USE_EXTRACTED_VIDEO_BLOCK # The following import/except block for edxval is temporary measure until # edxval is a proper XBlock Runtime Service. @@ -119,7 +120,7 @@ @XBlock.wants('settings', 'completion', 'i18n', 'request_cache') @XBlock.needs('mako', 'user') -class VideoBlock( +class _BuiltInVideoBlock( VideoFields, VideoTranscriptsMixin, VideoStudioViewHandlers, VideoStudentViewHandlers, EmptyDataRawMixin, XmlMixin, EditingMixin, XModuleToXBlockMixin, ResourceTemplates, XModuleMixin, LicenseMixin): @@ -134,6 +135,7 @@ class VideoBlock( """ + is_extracted = False has_custom_completion = True completion_mode = XBlockCompletionMode.COMPLETABLE @@ -1260,3 +1262,11 @@ def _poster(self): edx_video_id=self.edx_video_id.strip() ) return None + + +VideoBlock = ( + # TODO: Revert following + # _ExractedVideoBlock if USE_EXTRACTED_VIDEO_BLOCK.is_enabled() + _BuiltInVideoBlock if USE_EXTRACTED_VIDEO_BLOCK.is_enabled() + else _BuiltInVideoBlock +)