Skip to content

Commit

Permalink
chore: Chagnes in word cloud block
Browse files Browse the repository at this point in the history
  • Loading branch information
farhan committed Nov 13, 2024
1 parent 9890712 commit 8948e1b
Show file tree
Hide file tree
Showing 3 changed files with 65 additions and 3 deletions.
2 changes: 2 additions & 0 deletions xmodule/tests/test_word_cloud.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
import json
from unittest.mock import Mock

import pytest
from django.test import TestCase
from fs.memoryfs import MemoryFS
from lxml import etree
Expand All @@ -14,6 +15,7 @@
from . import get_test_descriptor_system, get_test_system


@pytest.mark.django_db
class WordCloudBlockTest(TestCase):
"""
Logic tests for Word Cloud Block.
Expand Down
54 changes: 52 additions & 2 deletions xmodule/toggles.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,12 +12,62 @@
# .. toggle_warning: Not production-ready until https://github.com/openedx/edx-platform/issues/34840 is done.
# .. toggle_use_cases: temporary
# .. toggle_default: False
# .. toggle_implementation:
# .. toggle_creation_date: 10th Nov, 2024
USE_EXTRACTED_WORD_CLOUD_BLOCK = WaffleFlag('xmodule.use_extracted_block.word_cloud', __name__)
# TODO: Add flag docs once above approved
# .. toggle_name: USE_EXTRACTED_ANNOTATABLE_BLOCK
# .. toggle_description: Enables the use of the extracted annotatable XBlock, which has been shifted to the 'openedx/xblocks-contrib' repo.
# .. toggle_warning: Not production-ready until https://github.com/openedx/edx-platform/issues/34841 is done.
# .. toggle_use_cases: temporary
# .. toggle_default: False
# .. toggle_implementation:
# .. toggle_creation_date: 10th Nov, 2024
USE_EXTRACTED_ANNOTATABLE_BLOCK = WaffleFlag('xmodule.use_extracted_block.annotatable', __name__)
USE_EXTRACTED_POLL_BLOCK = WaffleFlag('xmodule.use_extracted_block.poll', __name__)
# .. toggle_name: USE_EXTRACTED_POLL_QUESTION_BLOCK
# .. toggle_description: Enables the use of the extracted poll question XBlock, which has been shifted to the 'openedx/xblocks-contrib' repo.
# .. toggle_warning: Not production-ready until https://github.com/openedx/edx-platform/issues/34839 is done.
# .. toggle_use_cases: temporary
# .. toggle_default: False
# .. toggle_implementation:
# .. toggle_creation_date: 10th Nov, 2024
USE_EXTRACTED_POLL_QUESTION_BLOCK = WaffleFlag('xmodule.use_extracted_block.poll_question', __name__)
# .. toggle_name: USE_EXTRACTED_LTI_BLOCK
# .. toggle_description: Enables the use of the extracted lti XBlock, which has been shifted to the 'openedx/xblocks-contrib' repo.
# .. toggle_warning: Not production-ready until relevant subtask https://github.com/openedx/edx-platform/issues/34827 is done.
# .. toggle_use_cases: temporary
# .. toggle_default: False
# .. toggle_implementation:
# .. toggle_creation_date: 10th Nov, 2024
USE_EXTRACTED_LTI_BLOCK = WaffleFlag('xmodule.use_extracted_block.lti', __name__)
# .. toggle_name: USE_EXTRACTED_HTML_BLOCK
# .. toggle_description: Enables the use of the extracted html XBlock, which has been shifted to the 'openedx/xblocks-contrib' repo.
# .. toggle_warning: Not production-ready until relevant subtask https://github.com/openedx/edx-platform/issues/34827 is done.
# .. toggle_use_cases: temporary
# .. toggle_default: False
# .. toggle_implementation:
# .. toggle_creation_date: 10th Nov, 2024
USE_EXTRACTED_HTML_BLOCK = WaffleFlag('xmodule.use_extracted_block.html', __name__)
# .. toggle_name: USE_EXTRACTED_DISCUSSION_BLOCK
# .. toggle_description: Enables the use of the extracted discussion XBlock, which has been shifted to the 'openedx/xblocks-contrib' repo.
# .. toggle_warning: Not production-ready until relevant subtask https://github.com/openedx/edx-platform/issues/34827 is done.
# .. toggle_use_cases: temporary
# .. toggle_default: False
# .. toggle_implementation:
# .. toggle_creation_date: 10th Nov, 2024
USE_EXTRACTED_DISCUSSION_BLOCK = WaffleFlag('xmodule.use_extracted_block.discussion', __name__)
# .. toggle_name: USE_EXTRACTED_PROBLEM_BLOCK
# .. toggle_description: Enables the use of the extracted problem XBlock, which has been shifted to the 'openedx/xblocks-contrib' repo.
# .. toggle_warning: Not production-ready until relevant subtask https://github.com/openedx/edx-platform/issues/34827 is done.
# .. toggle_use_cases: temporary
# .. toggle_default: False
# .. toggle_implementation:
# .. toggle_creation_date: 10th Nov, 2024
USE_EXTRACTED_PROBLEM_BLOCK = WaffleFlag('xmodule.use_extracted_block.problem', __name__)
# .. toggle_name: USE_EXTRACTED_VIDEO_BLOCK
# .. toggle_description: Enables the use of the extracted video XBlock, which has been shifted to the 'openedx/xblocks-contrib' repo.
# .. toggle_warning: Not production-ready until relevant subtask https://github.com/openedx/edx-platform/issues/34827 is done.
# .. toggle_use_cases: temporary
# .. toggle_default: False
# .. toggle_implementation:
# .. toggle_creation_date: 10th Nov, 2024
USE_EXTRACTED_VIDEO_BLOCK = WaffleFlag('xmodule.use_extracted_block.video', __name__)
12 changes: 11 additions & 1 deletion xmodule/word_cloud_block.py
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@
from xblock.fields import Boolean, Dict, Integer, List, Scope, String
from xmodule.editing_block import EditingMixin
from xmodule.raw_block import EmptyDataRawMixin
from xmodule.toggles import USE_EXTRACTED_WORD_CLOUD_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 (
Expand All @@ -23,6 +24,7 @@
XModuleMixin,
XModuleToXBlockMixin,
)
from xblocks_contrib.word_cloud import WordCloudBlock as _ExtractedWordCloudBlock
log = logging.getLogger(__name__)

# Make '_' a no-op so we can scrape strings. Using lambda instead of
Expand All @@ -41,7 +43,7 @@ def pretty_bool(value):


@XBlock.needs('mako')
class WordCloudBlock( # pylint: disable=abstract-method
class _BuiltInWordCloudBlock( # pylint: disable=abstract-method
EmptyDataRawMixin,
XmlMixin,
EditingMixin,
Expand All @@ -53,6 +55,8 @@ class WordCloudBlock( # pylint: disable=abstract-method
Word Cloud XBlock.
"""

is_extracted = False

display_name = String(
display_name=_("Display Name"),
help=_("The display name for this component."),
Expand Down Expand Up @@ -308,3 +312,9 @@ def index_dictionary(self):
xblock_body["content_type"] = "Word Cloud"

return xblock_body


WordCloudBlock = (
_ExtractedWordCloudBlock if USE_EXTRACTED_WORD_CLOUD_BLOCK.is_enabled()
else _BuiltInWordCloudBlock
)

0 comments on commit 8948e1b

Please sign in to comment.