Skip to content

Commit

Permalink
chore: chore
Browse files Browse the repository at this point in the history
  • Loading branch information
farhan committed Oct 11, 2024
1 parent 3508234 commit deaa9fa
Show file tree
Hide file tree
Showing 6 changed files with 69 additions and 6 deletions.
13 changes: 12 additions & 1 deletion xmodule/capa_block.py
Original file line number Diff line number Diff line change
Expand Up @@ -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")

Expand Down Expand Up @@ -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,
Expand All @@ -161,6 +162,8 @@ class ProblemBlock(
"""
INDEX_CONTENT_TYPE = 'CAPA'

is_extracted = False

resources_dir = None

has_score = True
Expand Down Expand Up @@ -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
)
12 changes: 11 additions & 1 deletion xmodule/discussion_block.py
Original file line number Diff line number Diff line change
Expand Up @@ -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


Expand All @@ -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)
Expand Down Expand Up @@ -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
)
13 changes: 12 additions & 1 deletion xmodule/html_block.py
Original file line number Diff line number Diff line change
Expand Up @@ -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 (
Expand Down Expand Up @@ -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."),
Expand Down Expand Up @@ -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.
Expand Down Expand Up @@ -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
)
12 changes: 11 additions & 1 deletion xmodule/lti_block.py
Original file line number Diff line number Diff line change
Expand Up @@ -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 (
Expand Down Expand Up @@ -274,7 +275,7 @@ class LTIFields:
@XBlock.needs("mako")
@XBlock.needs("user")
@XBlock.needs("rebind_user")
class LTIBlock(
class _BuiltInLTIBlock(
LTIFields,
LTI20BlockMixin,
EmptyDataRawMixin,
Expand Down Expand Up @@ -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

Expand Down Expand Up @@ -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
)
13 changes: 12 additions & 1 deletion xmodule/poll_block.py
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand All @@ -36,14 +37,17 @@


@XBlock.needs('mako')
class PollBlock(
class _BuiltInPollBlock(
MakoTemplateBlockBase,
XmlMixin,
XModuleToXBlockMixin,
ResourceTemplates,
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."),
Expand Down Expand Up @@ -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
)
12 changes: 11 additions & 1 deletion xmodule/video_block/video_block.py
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand Down Expand Up @@ -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):
Expand All @@ -134,6 +135,7 @@ class VideoBlock(
<source src=".../mit-3091x/M-3091X-FA12-L21-3_100.ogv"/>
</video>
"""
is_extracted = False
has_custom_completion = True
completion_mode = XBlockCompletionMode.COMPLETABLE

Expand Down Expand Up @@ -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
)

0 comments on commit deaa9fa

Please sign in to comment.