Skip to content

Commit 4cdcd20

Browse files
committed
chore: Chagnes in word cloud block
1 parent e7a0660 commit 4cdcd20

File tree

3 files changed

+65
-3
lines changed

3 files changed

+65
-3
lines changed

xmodule/tests/test_word_cloud.py

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@
33
import json
44
from unittest.mock import Mock
55

6+
import pytest
67
from django.test import TestCase
78
from fs.memoryfs import MemoryFS
89
from lxml import etree
@@ -14,6 +15,7 @@
1415
from . import get_test_descriptor_system, get_test_system
1516

1617

18+
@pytest.mark.django_db
1719
class WordCloudBlockTest(TestCase):
1820
"""
1921
Logic tests for Word Cloud Block.

xmodule/toggles.py

Lines changed: 52 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -12,12 +12,62 @@
1212
# .. toggle_warning: Not production-ready until https://github.com/openedx/edx-platform/issues/34840 is done.
1313
# .. toggle_use_cases: temporary
1414
# .. toggle_default: False
15+
# .. toggle_implementation:
16+
# .. toggle_creation_date: 10th Nov, 2024
1517
USE_EXTRACTED_WORD_CLOUD_BLOCK = WaffleFlag('xmodule.use_extracted_block.word_cloud', __name__)
16-
# TODO: Add flag docs once above approved
18+
# .. toggle_name: USE_EXTRACTED_ANNOTATABLE_BLOCK
19+
# .. toggle_description: Enables the use of the extracted annotatable XBlock, which has been shifted to the 'openedx/xblocks-contrib' repo.
20+
# .. toggle_warning: Not production-ready until https://github.com/openedx/edx-platform/issues/34841 is done.
21+
# .. toggle_use_cases: temporary
22+
# .. toggle_default: False
23+
# .. toggle_implementation:
24+
# .. toggle_creation_date: 10th Nov, 2024
1725
USE_EXTRACTED_ANNOTATABLE_BLOCK = WaffleFlag('xmodule.use_extracted_block.annotatable', __name__)
18-
USE_EXTRACTED_POLL_BLOCK = WaffleFlag('xmodule.use_extracted_block.poll', __name__)
26+
# .. toggle_name: USE_EXTRACTED_POLL_QUESTION_BLOCK
27+
# .. toggle_description: Enables the use of the extracted poll question XBlock, which has been shifted to the 'openedx/xblocks-contrib' repo.
28+
# .. toggle_warning: Not production-ready until https://github.com/openedx/edx-platform/issues/34839 is done.
29+
# .. toggle_use_cases: temporary
30+
# .. toggle_default: False
31+
# .. toggle_implementation:
32+
# .. toggle_creation_date: 10th Nov, 2024
33+
USE_EXTRACTED_POLL_QUESTION_BLOCK = WaffleFlag('xmodule.use_extracted_block.poll_question', __name__)
34+
# .. toggle_name: USE_EXTRACTED_LTI_BLOCK
35+
# .. toggle_description: Enables the use of the extracted lti XBlock, which has been shifted to the 'openedx/xblocks-contrib' repo.
36+
# .. toggle_warning: Not production-ready until relevant subtask https://github.com/openedx/edx-platform/issues/34827 is done.
37+
# .. toggle_use_cases: temporary
38+
# .. toggle_default: False
39+
# .. toggle_implementation:
40+
# .. toggle_creation_date: 10th Nov, 2024
1941
USE_EXTRACTED_LTI_BLOCK = WaffleFlag('xmodule.use_extracted_block.lti', __name__)
42+
# .. toggle_name: USE_EXTRACTED_HTML_BLOCK
43+
# .. toggle_description: Enables the use of the extracted html XBlock, which has been shifted to the 'openedx/xblocks-contrib' repo.
44+
# .. toggle_warning: Not production-ready until relevant subtask https://github.com/openedx/edx-platform/issues/34827 is done.
45+
# .. toggle_use_cases: temporary
46+
# .. toggle_default: False
47+
# .. toggle_implementation:
48+
# .. toggle_creation_date: 10th Nov, 2024
2049
USE_EXTRACTED_HTML_BLOCK = WaffleFlag('xmodule.use_extracted_block.html', __name__)
50+
# .. toggle_name: USE_EXTRACTED_DISCUSSION_BLOCK
51+
# .. toggle_description: Enables the use of the extracted discussion XBlock, which has been shifted to the 'openedx/xblocks-contrib' repo.
52+
# .. toggle_warning: Not production-ready until relevant subtask https://github.com/openedx/edx-platform/issues/34827 is done.
53+
# .. toggle_use_cases: temporary
54+
# .. toggle_default: False
55+
# .. toggle_implementation:
56+
# .. toggle_creation_date: 10th Nov, 2024
2157
USE_EXTRACTED_DISCUSSION_BLOCK = WaffleFlag('xmodule.use_extracted_block.discussion', __name__)
58+
# .. toggle_name: USE_EXTRACTED_PROBLEM_BLOCK
59+
# .. toggle_description: Enables the use of the extracted problem XBlock, which has been shifted to the 'openedx/xblocks-contrib' repo.
60+
# .. toggle_warning: Not production-ready until relevant subtask https://github.com/openedx/edx-platform/issues/34827 is done.
61+
# .. toggle_use_cases: temporary
62+
# .. toggle_default: False
63+
# .. toggle_implementation:
64+
# .. toggle_creation_date: 10th Nov, 2024
2265
USE_EXTRACTED_PROBLEM_BLOCK = WaffleFlag('xmodule.use_extracted_block.problem', __name__)
66+
# .. toggle_name: USE_EXTRACTED_VIDEO_BLOCK
67+
# .. toggle_description: Enables the use of the extracted video XBlock, which has been shifted to the 'openedx/xblocks-contrib' repo.
68+
# .. toggle_warning: Not production-ready until relevant subtask https://github.com/openedx/edx-platform/issues/34827 is done.
69+
# .. toggle_use_cases: temporary
70+
# .. toggle_default: False
71+
# .. toggle_implementation:
72+
# .. toggle_creation_date: 10th Nov, 2024
2373
USE_EXTRACTED_VIDEO_BLOCK = WaffleFlag('xmodule.use_extracted_block.video', __name__)

xmodule/word_cloud_block.py

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,7 @@
1515
from xblock.fields import Boolean, Dict, Integer, List, Scope, String
1616
from xmodule.editing_block import EditingMixin
1717
from xmodule.raw_block import EmptyDataRawMixin
18+
from xmodule.toggles import USE_EXTRACTED_WORD_CLOUD_BLOCK
1819
from xmodule.util.builtin_assets import add_webpack_js_to_fragment, add_css_to_fragment
1920
from xmodule.xml_block import XmlMixin
2021
from xmodule.x_module import (
@@ -23,6 +24,7 @@
2324
XModuleMixin,
2425
XModuleToXBlockMixin,
2526
)
27+
from xblocks_contrib.word_cloud import WordCloudBlock as _ExtractedWordCloudBlock
2628
log = logging.getLogger(__name__)
2729

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

4244

4345
@XBlock.needs('mako')
44-
class WordCloudBlock( # pylint: disable=abstract-method
46+
class _BuiltInWordCloudBlock( # pylint: disable=abstract-method
4547
EmptyDataRawMixin,
4648
XmlMixin,
4749
EditingMixin,
@@ -53,6 +55,8 @@ class WordCloudBlock( # pylint: disable=abstract-method
5355
Word Cloud XBlock.
5456
"""
5557

58+
is_extracted = False
59+
5660
display_name = String(
5761
display_name=_("Display Name"),
5862
help=_("The display name for this component."),
@@ -308,3 +312,9 @@ def index_dictionary(self):
308312
xblock_body["content_type"] = "Word Cloud"
309313

310314
return xblock_body
315+
316+
317+
WordCloudBlock = (
318+
_ExtractedWordCloudBlock if USE_EXTRACTED_WORD_CLOUD_BLOCK.is_enabled()
319+
else _BuiltInWordCloudBlock
320+
)

0 commit comments

Comments
 (0)