Skip to content

refactor: slash-and-burn Word Cloud BuiltIn XBlock - #38745

Open
irfanuddinahmad wants to merge 4 commits into
masterfrom
irfanuddinahmad/slash-and-burn-word-cloud-block
Open

irfanuddinahmad wants to merge 4 commits into
masterfrom
irfanuddinahmad/slash-and-burn-word-cloud-block

Conversation

@irfanuddinahmad

@irfanuddinahmad irfanuddinahmad commented Jun 11, 2026 •

Copy link
Copy Markdown
Contributor

Summary

Removes the built-in Word Cloud XBlock. xblock_word_cloud.WordCloudBlock has been the default since USE_EXTRACTED_WORD_CLOUD_BLOCK = True, so the built-in code no longer runs.

Step 2 of 8 of the Slash-n-Burn Built-In XBlocks epic. Closes openedx/public-engineering#534

Merge status: ✅ ready for re-review. The requested changes are addressed: both platform test files are kept and run against the extracted block, with test names and assertions unchanged.
Known gaps: none.
Translations hold: merge only after openedx/xblocks-core#329 and openedx/openedx-translations#85196 are live and the xblock_* catalogs are confirmed. Until then the extracted block is translated only through the built-in xmodule msgids that this PR deletes.

Changes

Deleted: xmodule/word_cloud_block.py, xmodule/assets/word_cloud/ (JS, D3 vendor libs, its own webpack.config.js), lms/templates/word_cloud.html, WordCloudBlockDisplay.css, the WordCloudBlockDisplay/WordCloudBlockEditor webpack entries, the built-in word_cloud entrypoint, and the USE_EXTRACTED_WORD_CLOUD_BLOCK toggle.

Tests:

Epic Step 1: Post-extraction commit review

Toggle flipped 2025-12-16 (e662394398). All 3 later commits to word_cloud_block.py are cosmetic (deprecation markers #38174, import sorting, lint-amnesty). Nothing to port.

Test plan

Tested on a local Tutor nightly (master 6f85d63c7f + xblocks-core 2.0.0) through the REST APIs and a headless browser, because PR sandboxes aren't deploying (open-craft/pr-sandbox-automation#28). A box is ticked only if that flow actually ran.

  • LMS student view
  • CMS course unit
  • CMS V2 Library
  • CI: pytest xmodule/tests/ (732 passed locally) and lms/djangoapps/courseware/tests/test_word_cloud.py (6 passed), npm run build
V2 Library checklist: 11/12 pass (L10 export diff not done)

Content Libraries V2: smoke tests (historically the most fragile area for extracted blocks: openedx/xblocks-core#123, openedx/xblocks-core#132, openedx/xblocks-core#243, openedx/xblocks-core#274)

  • L1. Create the block in a V2 library; the preview renders with no 500 or console errors
  • L2. Edit → save → reload the page → reopen the editor: every field kept its value
  • L3. Publish the component; its status changes to Published
  • L4. Copy to clipboard from the library, then paste into the library and into a course unit
  • L5. In a library unit: add the block as new content, then add it as existing library content (watch for "There was an error linking the content to this container", [Test failure] TC-00338: Libraries: Unable to add existing component to a unit wg-build-test-release#556)
  • L6. Reuse in a course: add it through "Library content" in a unit, and reuse a library unit containing it from the course outline. Both render in Studio and in the LMS student view
  • L7. Sync: edit and publish in the library, then accept the update in the course and also ignore one
  • L8. Override the title on the reused copy in the course
  • L9. Library search: filtering by content type finds the block
  • L10. OLX: import as a pointer tag and inline, export as a pointer tag, and diff the export against master (which still has the built-in block) — not ticked: inline and pointer-tag import and pointer-tag export pass; the export diff against the built-in block wasn't done

Word Cloud-specific:

Library checklist compiled from the Aximprovements manual test doc (Extracted Block Tests tab) and the Ulmo test sheet's library cases. Generated using Claude Code.

Screenshots

5 screenshots (LMS, Studio unit, V2 Library)

Local Tutor nightly, 2026-11-12

Captured automatically during the local smoke tests (the sandbox isn't reachable yet, see open-craft/pr-sandbox-automation#28). All images: irfanuddinahmad/edx-platform@snb-smoke-screenshots/38745.

LMS student view (imported block) Studio course unit (authoring MFE)
lms_inline studio_unit
V2 library home V2 library component preview
library_home lib_preview
LMS: copy reused from the library (after sync + title override)
lms_reused

🤖 Generated with Claude Code

Settings

# Workaround for open-craft/pr-sandbox-automation#28: the openedx-permissions image name gets mangled.
DOCKER_IMAGE_PERMISSIONS: docker.io/overhangio/openedx-permissions:23.0.0-main

@openedx-webhooks openedx-webhooks added open-source-contribution PR author is not from Axim or 2U core contributor PR author is a Core Contributor (who may or may not have write access to this repo). labels Jun 11, 2026
@openedx-webhooks

openedx-webhooks commented Jun 11, 2026 •

Copy link
Copy Markdown

Thanks for the pull request, @irfanuddinahmad!

This repository is currently maintained by @openedx/wg-maintenance-openedx-platform-oncall.

Once you've gone through the following steps feel free to tag them in a comment and let them know that your changes are ready for engineering review.

🔘 Get product approval

If you haven't already, check this list to see if your contribution needs to go through the product review process.

  • If it does, you'll need to submit a product proposal for your contribution, and have it reviewed by the Product Working Group.
    • This process (including the steps you'll need to take) is documented here.
  • If it doesn't, simply proceed with the next step.
🔘 Provide context

To help your reviewers and other members of the community understand the purpose and larger context of your changes, feel free to add as much of the following information to the PR description as you can:

  • Dependencies

    This PR must be merged before / after / at the same time as ...

  • Blockers

    This PR is waiting for OEP-1234 to be accepted.

  • Timeline information

    This PR must be merged by XX date because ...

  • Partner information

    This is for a course on edx.org.

  • Supporting documentation
  • Relevant Open edX discussion forum threads
🔘 Get a green build

If one or more checks are failing, continue working on your changes until this is no longer the case and your build turns green.

Details
Where can I find more information?

If you'd like to get more details on all aspects of the review process for open source pull requests (OSPRs), check out the following resources:

When can I expect my changes to be merged?

Our goal is to get community contributions seen and reviewed as efficiently as possible.

However, the amount of time that it takes to review and merge a PR can vary significantly based on factors such as:

  • The size and impact of the changes that it introduces
  • The need for product review
  • Maintenance status of the parent repository

💡 As a result it may take up to several weeks or months to complete a review and merge your PR.

@github-project-automation github-project-automation Bot moved this to Needs Triage in Contributions Jun 11, 2026
@irfanuddinahmad
irfanuddinahmad force-pushed the irfanuddinahmad/slash-and-burn-word-cloud-block branch from db987da to ed55494 Compare June 11, 2026 12:52
@mphilbrick211 mphilbrick211 moved this from Needs Triage to Waiting on Author in Contributions Jun 11, 2026
@irfanuddinahmad
irfanuddinahmad force-pushed the irfanuddinahmad/slash-and-burn-word-cloud-block branch 2 times, most recently from 19618f9 to 3313f57 Compare June 12, 2026 16:55
@farhan farhan linked an issue Jul 3, 2026 that may be closed by this pull request
9 of 11 tasks
@farhan
farhan force-pushed the irfanuddinahmad/slash-and-burn-word-cloud-block branch from 3313f57 to 4a47320 Compare July 3, 2026 08:04
@farhan

farhan commented Jul 3, 2026 •

Copy link
Copy Markdown
Contributor

@irfanuddinahmad I have rebased the branch with master checks are failing.

Adding screenshots of testing word cloud block of xblocks-core will be great.

@farhan

farhan commented Jul 3, 2026 •

Copy link
Copy Markdown
Contributor

Test coverage gap for the extracted Word Cloud block

After the extraction of the Word Cloud block into xblocks-contrib (openedx/xblocks-core#4), #36199 was merged in this repo, adding Studio editing support (studio_submit handler) so the Word Cloud block editor renders and saves in a Libraries v2 context (the handler was later generalized into EditingMixin by #36265). It also added test_studio_submit_handler to xmodule/tests/test_word_cloud.py, which this PR deletes.

The extracted block was never updated with this change — it uses StudioEditableXBlockMixin (submit_studio_edits) instead of the legacy studio_submit pathway, and xblocks-contrib has no equivalent test coverage for it.

The following scenarios from #36199 should be thoroughly tested against the extracted block before removing the built-in one:

  1. Studio editor rendering in a Libraries v2 context — the original bug fixed by fix: Render Word cloud block editor in libraries [FC-0076] #36199 was that the editor did not render for the word cloud block in libraries.
  2. Saving settings through the Studio editor (equivalent of test_studio_submit_handler) — submit display_name, instructions, num_inputs, num_top_words, and display_student_percents via the editor and verify each value persists on the block.
  3. Boolean field handling on save — the legacy handler received display_student_percents as the string 'True'/'False'; verify the submit_studio_edits pathway persists the correct boolean value.
  4. Save and Cancel buttons in the editor work correctly (added as part of the fix: Render Word cloud block editor in libraries [FC-0076] #36199 fix).

-- Comment has been written assisted with @claude

@farhan farhan Jul 3, 2026 •

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think it shouldn't be removed and test should run testing xblocks-core word cloud block.

It can also be moved to xblocks-core here if feasible.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Confirmed — the extracted block's tests (xblocks_contrib/word_cloud/tests/test_word_cloud.py) didn't have equivalent coverage for the scenarios this file exercises against the extracted block. Ported them in openedx/xblocks-core#273 (OLX import/export, indexibility, AJAX handler dispatch, submit_studio_edits). See the summary comment above for the full analysis.

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I am not seeing any test from this file moved to xblocks-core.
Can you please look into?

@farhan farhan Jul 8, 2026 •

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Confirmed — none of the six integration tests from this file were migrated in xblocks-core#273. That PR only ports unit-level scenarios from xmodule/tests/test_word_cloud.py. Full breakdown and next steps are in #38745 (comment). Any new coverage will go in a separate PR.

| Generated using Claud Code

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Done. This file is kept in openedx-platform and now tests only the extracted block.

  • All 6 integration tests are unchanged in name and logic. They still run through BaseTestXmodule with the multi-user clients.
  • Removed only: TestWordCloudBuiltIn, the override_settings decorators, importlib.reload(word_cloud_block), and the if settings.USE_EXTRACTED_WORD_CLOUD_BLOCK: / else: branches (collapsed to the extracted path that already existed).

CI is green on d4fd4a8815.

| Generated using Claude Code

Comment thread xmodule/tests/test_word_cloud.py Resolved
@irfanuddinahmad

Copy link
Copy Markdown
Contributor Author

Thanks for the detailed write-up, @farhan — really useful. I dug into this and wanted to share what I found before we decide what (if anything) still needs to change here.

Why no source-code port is needed

The studio_submit/EditingMixin machinery added in #36199 and generalized in #36265 only applies to the legacy XModule-style editing descriptors (MetadataOnlyEditingDescriptor / SequenceDescriptor) — see the xblock_iframe.html diff in #36199, where the manual metadata-editor JS and the studio_submit handler call are explicitly gated on data['xmodule-type'] being one of those two. That code path only ever applied to the built-in word_cloud_block.py (and the pre-extraction lti_block.py).

The extracted xblocks_contrib.word_cloud.WordCloudBlock uses StudioEditableXBlockMixin instead — a different, already-standard editing pathway with its own submit_studio_edits handler that's used across many other XBlocks. It never goes through EditingMixin.studio_submit at all, so there's nothing from #36199/#36265 to port into it.

The other half of #36199 — the RequireJS/baseURL fix in xblock_iframe.html — is generic, platform-owned infrastructure, not tied to the specific block implementation. The extracted block already benefits from it automatically since it's rendered through the same iframe template.

But the test-coverage gap was real

You're right that this repo's xmodule/tests/test_word_cloud.py and lms/djangoapps/courseware/tests/test_word_cloud.py currently exercise the extracted block too (via @override_settings(USE_EXTRACTED_WORD_CLOUD_BLOCK=True)), and this PR deletes those files with no replacement. Comparing against xblocks_contrib/word_cloud/tests/test_word_cloud.py, these scenarios genuinely had no equivalent there:

  • OLX import/export round-trip
  • Search indexing (index_dictionary)
  • Handler-dispatch-level AJAX calls (going through block.handle(...), not just calling the method directly)
  • The submit_studio_edits Save pathway, including the boolean handling for display_student_percents — this is exactly scenario 2/3 from your list above, and it was already being exercised against the extracted block by the very test this PR deletes.

I opened openedx/xblocks-core#273 to port those scenarios into this repo's own suite before they're lost. All 13 tests (8 existing + 5 new) pass, and the full xblocks_contrib suite is unaffected (839 passed, no regressions).

Manual verification (scenarios 1 and 4)

Editor rendering in a Library v2 context and the Save/Cancel buttons were never covered by automated tests even in the original #36199 fix — they were verified manually, which lines up with your screenshot request from 2026-07-03. I did that manual pass in a local Tutor devstack:

  1. Created a v2 Content Library and added a Word Cloud component to it.
  2. The Studio editor rendered correctly with all 5 fields (Display Name, Inputs, Instructions, Maximum Words, Show Percents).
  3. Edited display_name, instructions, num_inputs (5→3), and display_student_percents (True→False), clicked Save — all changes persisted (confirmed via the Preview tab, which immediately showed the new title, instructions text, and exactly 3 input boxes).
  4. Clicked Cancel after making an unsaved edit — got an "Exit the editor? Any unsaved changes will be lost" confirmation, and "Discard Changes and Exit" correctly reverted to the last-saved state.

Screenshots of each step:

Library created library created
Word Cloud component added component added
Student preview renders in Library v2 student preview
Studio editor renders with correct defaults editor renders
Fields edited (incl. boolean toggle) fields edited
Save persisted correctly save persisted
Cancel — unsaved edit in progress cancel in progress
Cancel discarded the change cancel discarded

(full gist: https://gist.github.com/irfanuddinahmad/df358e2dc74bdf7b6c73db1d99b4abaf)

Given all of the above, I think this is safe to merge once #273 lands. Let me know if you'd like anything else checked.

@irfanuddinahmad
irfanuddinahmad requested a review from farhan July 7, 2026 10:24
@farhan

farhan commented Jul 8, 2026 •

Copy link
Copy Markdown
Contributor

Thanks for the work on openedx/xblocks-core#273. I reviewed what was migrated from the two test files this PR deletes. Sharing a clearer breakdown below.

Migrated in openedx/xblocks-core#273 (from xmodule/tests/test_word_cloud.py)

Original test Migrated as Notes
test_xml_import_export_cycle test_xml_import_export_cycle ✅ Ported
test_indexibility test_indexibility ✅ Ported
test_bad_ajax_request test_bad_dispatch_request ✅ Ported (adapted for @json_handler / NoSuchHandlerError)
test_studio_submit_handler test_submit_studio_edits ✅ Ported (adapted for submit_studio_edits handler)
test_good_ajax_request test_handle_submit_state_request ⚠️ Partially ported — see below

Gap: test_good_ajax_request → test_handle_submit_state_request

The original test seeds pre-existing learner aggregate data before submit:

'all_words': {'cat': 10, 'dog': 5, 'mom': 1, 'dad': 2},

and asserts the merged result (total_count == 22, global student_words, top_words including mom/dad). The migrated test uses a fresh block with empty all_words, so it only asserts total_count == 4 — it no longer exercises the merge-with-existing-aggregates path that the original test was written for.

Not migrated (from lms/djangoapps/courseware/tests/test_word_cloud.py)

None of the integration tests from this file appear in xblocks-core#273:

  • test_initial_state
  • test_post_words
  • test_collective_users_submits
  • test_unicode
  • test_handle_ajax_incorrect_dispatch
  • test_word_cloud_constructor

These are platform integration tests (mongo modulestore, multi-user HTTP clients, fragment rendering via BaseTestXmodule) and cannot be dropped into xblocks-core as-is. We should decide separately whether a slim extracted-block-only version stays in openedx-platform, or whether that coverage is acceptable to lose.

Guidelines for completing the migration

For the remaining gaps, we will open a new PR (separate from #273 / #38745). When doing that:

  1. Keep original test names where possible — e.g. prefer test_good_ajax_request over renaming to test_handle_submit_state_request within the scope of a migration PR.
  2. Keep the original test logic as intact as possible — adapt only what the extracted block API requires (handler name, request format), not the assertions or setup unless strictly necessary.
  3. Reference the migration PR — tests ported from openedx-platform should note they originate from openedx/xblocks-core#273 / the deleted xmodule/tests/test_word_cloud.py and lms/djangoapps/courseware/tests/test_word_cloud.py files.

Once the test_good_ajax_request gap is fixed and we have a plan for the lms integration coverage, I think we can unblock this PR.

| Generated using Claud Code

@mphilbrick211 mphilbrick211 moved this from Waiting on Author to In Eng Review in Contributions Jul 13, 2026
@irfanuddinahmad
irfanuddinahmad force-pushed the irfanuddinahmad/slash-and-burn-word-cloud-block branch from e5ec0e9 to d4fd4a8 Compare November 4, 2026 11:10
@irfanuddinahmad

Copy link
Copy Markdown
Contributor Author

@farhan thanks for the detailed review. I've addressed it by keeping both test files in openedx-platform and pointing them at the extracted block, rather than relying on the port in xblocks-core#273. The branch is also rebased onto current master.

File Tests (master → this PR) What changed
xmodule/tests/test_word_cloud.py 5 → 5, same names reset_class() → WordCloudBlock; removed the TestWordCloudBuiltIn twin, override_settings and built-in-only branches
lms/djangoapps/courseware/tests/test_word_cloud.py 6 → 6, same names Removed TestWordCloudBuiltIn, override_settings, importlib.reload and built-in-only branches

Assertions on the extracted path are unchanged, including the pre-seeded all_words merge path in test_good_ajax_request that you flagged. Nothing else in either file was modified. Both test files are now listed under Changes in the PR description.

All 46 checks pass on d4fd4a8815. Could you take another look when you have a moment?

Separately, I'll update xblocks-core#273 so it doesn't duplicate this coverage.

| Generated using Claude Code

@irfanuddinahmad irfanuddinahmad added the create-sandbox open-craft-grove should create a sandbox environment from this PR label Nov 5, 2026
irfanuddinahmad added a commit to irfanuddinahmad/xblocks-core that referenced this pull request Nov 10, 2026
… seed and assertions

Restores the pre-seeded all_words/top_words merge path that the
handler-level port in openedx#273 (test_handle_submit_state_request) does not
assert. Name, setup and assertions match
openedx-platform xmodule/tests/test_word_cloud.py (openedx/openedx-platform#38745).

Co-Authored-By: Claude Opus 5.5 <[email protected]>
Irfan Ahmad and others added 4 commits November 10, 2026 12:58
Removes the built-in Word Cloud XBlock and all associated assets now that
USE_EXTRACTED_WORD_CLOUD_BLOCK has been True, making xblocks_contrib the
active implementation.

- Remove USE_EXTRACTED_WORD_CLOUD_BLOCK toggle from common.py
- Remove word_cloud entrypoint from pyproject.toml
- Delete xmodule/word_cloud_block.py (built-in class + shim)
- Delete xmodule/assets/word_cloud/ (JS assets including D3 vendor libs
  and custom webpack config)
- Delete lms/templates/word_cloud.html
- Delete xmodule/static/css-builtin-blocks/WordCloudBlockDisplay.css
- Remove WordCloudBlockDisplay/WordCloudBlockEditor webpack entries from
  webpack.builtinblocks.config.js and webpack.common.config.js
- Delete xmodule/tests/test_word_cloud.py and
  lms/djangoapps/courseware/tests/test_word_cloud.py

Closes openedx/public-engineering#534

Co-Authored-By: Claude Sonnet 4.6 <[email protected]>
…dBlock

Per review on this PR, keep xmodule/tests/test_word_cloud.py and
lms/djangoapps/courseware/tests/test_word_cloud.py in openedx-platform
instead of deleting them. They already exercised the extracted block
(USE_EXTRACTED_WORD_CLOUD_BLOCK=True), and xblocks-core does not yet have
equivalent coverage (openedx/xblocks-core#273 is still open; the LMS
integration tests cannot move there as-is).

Only the BuiltIn variants, the toggle overrides and the built-in-only
branches are removed. Test names and assertions are unchanged, including
the pre-seeded all_words merge path in test_good_ajax_request.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
xblocks-core 2.0.0 (#38473) removed the xblocks_contrib package. Point the
platform entrypoint, imports and mock.patch targets at the new per-block
packages (e.g. xblocks_contrib.video.video -> xblock_video.block).

Co-Authored-By: Claude Opus 5.5 <[email protected]>
@irfanuddinahmad
irfanuddinahmad force-pushed the irfanuddinahmad/slash-and-burn-word-cloud-block branch from d4fd4a8 to 4f87536 Compare November 10, 2026 10:25

This branch has not been deployed

No deployments
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

core contributor PR author is a Core Contributor (who may or may not have write access to this repo). create-sandbox open-craft-grove should create a sandbox environment from this PR open-source-contribution PR author is not from Axim or 2U

Projects

Status: In Eng Review

Development

Successfully merging this pull request may close these issues.

[Refactor] Slash-n-Burn Word Cloud BuiltIn XBlock

3 participants