Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: Render Word cloud and conditional block editor [FC-0076] #36199

Open
wants to merge 4 commits into
base: master
Choose a base branch
from

Conversation

ChrisChV
Copy link
Contributor

@ChrisChV ChrisChV commented Jan 31, 2025

Description

  • The xmodule-type to render is MetadataOnlyEditingDescriptor and SequenceDescriptor
  • The xmodule type MetadataOnlyEditingDescriptor and SequenceDescriptor renders a <div> with the block metadata in the data-metadata attribute. But is necessary to call XBlockEditorView.xblockReady() to run the scripts to build the editor using the metadata.
  • To call XBlockEditorView.xblockReady() we need a specific require.config
  • Which edX user roles will this change impact? "Course Author"

Supporting information

Issue from testing: Word Cloud, Conditional
Internal ticket: https://tasks.opencraft.com/browse/FAL-4029

Testing instructions

  • Update LIBRARY_SUPPORTED_BLOCKS="problem,video,html,word_cloud,conditional" in .env.development of frontend-app-learning
  • Go to a unit and create a Word cloud and a Conditional.
  • Copy both blocks and paste them into a library.
  • Open the editor of the Word Cloud and verify that the editor is rendered.
  • Verify that you can cancel and you can save the block.
  • Open the editor of the Conditional and verify that the editor is rendered.
  • Verify that you can cancel and you can save the block (See Other information about save issue)

Deadline

No rush

Other information

  • In the Conditional block there are errors when saving It's out of the scope of this task. It will be resolved in another PR later.

- The xmodule-type to render is MetadataOnlyEditingDescriptor
- The xmodule type `MetadataOnlyEditingDescriptor` renders a `<div>` with the block metadata in the `data-metadata` attribute. But is necessary to call `XBlockEditorView.xblockReady()` to run the scripts to build the editor using the metadata.
- To call XBlockEditorView.xblockReady() we need a specific require.config
@openedx-webhooks openedx-webhooks added the open-source-contribution PR author is not from Axim or 2U label Jan 31, 2025
@openedx-webhooks
Copy link

openedx-webhooks commented Jan 31, 2025

Thanks for the pull request, @ChrisChV!

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

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.


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.

@ChrisChV ChrisChV marked this pull request as draft January 31, 2025 18:39
@ChrisChV ChrisChV marked this pull request as ready for review February 1, 2025 00:50
Copy link
Contributor

@rpenido rpenido left a comment

Choose a reason for hiding this comment

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

LGTM 👍
Thank you for your work @ChrisChV!

  • I tested this using the instructions from the PR
  • I read through the code
  • I checked for accessibility issues
  • Includes documentation

Copy link
Contributor

@pomegranited pomegranited left a comment

Choose a reason for hiding this comment

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

Hi @ChrisChV , this is working fine for Word Clouds 👍
But I can't paste a Conditional into a Library at all -- see comment for traceback.

return {
'result': 'success',
}

Copy link
Contributor

Choose a reason for hiding this comment

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

I can add Conditional blocks to courses with no issue. 👍
But I'm unable to test pasting a Conditional block into a library due to this error during re-indexing:

cms-1  | 2025-02-04 00:27:28,772 INFO 1640 [openedx.core.djangoapps.content.search.tasks] [user 6] [ip 172.24.0.1] tasks.py:55 - Updating content index document for library block with id: lb:OpenCraft:FAL-4029:conditional:f021eaec-5964-4ce7-8f1c-89f1f2f2ab04
cms-1  | 2025-02-04 00:27:28,806 ERROR 1640 [celery_utils.logged_task] [user 6] [ip 172.24.0.1] logged_task.py:48 - [2f7df8e9-8d8d-4e3b-9989-8ffd2d575f77] failed due to Traceback (most recent call last):
cms-1  |   File "/openedx/edx-platform/xmodule/xml_block.py", line 399, in parse_xml_new_runtime
cms-1  |     return super().parse_xml_new_runtime(node, runtime, keys)
cms-1  |            ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
cms-1  | AttributeError: 'super' object has no attribute 'parse_xml_new_runtime'
cms-1  |
cms-1  | During handling of the above exception, another exception occurred:
cms-1  |
cms-1  | Traceback (most recent call last):
cms-1  |   File "/openedx/venv/lib/python3.11/site-packages/celery/app/trace.py", line 453, in trace_task
cms-1  |     R = retval = fun(*args, **kwargs)
cms-1  |                  ^^^^^^^^^^^^^^^^^^^^
cms-1  |   File "/openedx/venv/lib/python3.11/site-packages/celery/app/autoretry.py", line 38, in run
cms-1  |     return task._orig_run(*args, **kwargs)
cms-1  |            ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
cms-1  |   File "/openedx/venv/lib/python3.11/site-packages/edx_django_utils/monitoring/internal/code_owner/utils.py", line 195, in new_function
cms-1  |     return wrapped_function(*args, **kwargs)
cms-1  |            ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
cms-1  |   File "/openedx/edx-platform/openedx/core/djangoapps/content/search/tasks.py", line 57, in upsert_library_block_index_doc
cms-1  |     api.upsert_library_block_index_doc(usage_key)
cms-1  |   File "/openedx/edx-platform/openedx/core/djangoapps/content/search/api.py", line 639, in upsert_library_block_index_doc
cms-1  |     searchable_doc_for_library_block(library_block_metadata)
cms-1  |   File "/openedx/edx-platform/openedx/core/djangoapps/content/search/documents.py", line 381, in searchable_doc_for_library_block
cms-1  |     block = xblock_api.load_block(xblock_metadata.usage_key, user=None)
cms-1  |             ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
cms-1  |   File "/openedx/edx-platform/openedx/core/djangoapps/xblock/api.py", line 117, in load_block
cms-1  |     return runtime.get_block(usage_key, version=version)
cms-1  |            ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
cms-1  |   File "/openedx/edx-platform/openedx/core/djangoapps/xblock/runtime/learning_core_runtime.py", line 217, in get_block
cms-1  |     block = block_class.parse_xml_new_runtime(xml_node, runtime=self, keys=keys)
cms-1  |             ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
cms-1  |   File "/openedx/edx-platform/xmodule/xml_block.py", line 401, in parse_xml_new_runtime
cms-1  |     return super().parse_xml(node, runtime, keys)
cms-1  |            ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
cms-1  |   File "/mnt/xblock/xblock/core.py", line 763, in parse_xml
cms-1  |     block.runtime.add_node_as_child(block, child)
cms-1  |   File "/openedx/edx-platform/openedx/core/djangoapps/xblock/runtime/runtime.py", line 267, in add_node_as_child
cms-1  |     raise NotImplementedError("XML Serialization is only supported with LearningCoreXBlockRuntime")
cms-1  | NotImplementedError: XML Serialization is only supported with LearningCoreXBlockRuntime

Copy link
Contributor Author

Choose a reason for hiding this comment

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

@pomegranited I can't reproduce this error. Copying creates the block without any problems. Maybe there is an additional context that I'm ignoring?

Copy link
Contributor

@pomegranited pomegranited Feb 4, 2025

Choose a reason for hiding this comment

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

Ok weird.. I'm still seeing this issue? I don't get an error in the frontend at all, but the pasted Conditional block never appears.

I tried:

  • checking all my mounted dependencies to make sure i'm running the platform required versions (esp XBlock)
  • reindexing studio -- edit these errors don't show up in the shell to, e.g. "Error indexing library component xblock.v1:conditional:33a7bf8b-bf02-4783-9e76-941097b53c36: XML Serialization is only supported with LearningCoreXBlockRuntime"
  • checking Django Admin -- the conditional blocks show up in the learning package's component list?

Copy link
Contributor

Choose a reason for hiding this comment

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

@ChrisChV Could you share the course you used? Maybe there's something wrong with the configuration I chose... grasping at straws here :)

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Yes, it seems strange. I have created a new course and it works fine. Here I attach the course: course.q8xomjt4.tar.gz

@rpenido Did you have any problems with it, suddenly we have some configurations that we forgot to mention?

Copy link
Contributor

Choose a reason for hiding this comment

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

No, I didn't have any problems.
The block seems pasted, but an indexing error prevents it from being listed, right?
@pomegranited

Copy link
Contributor

Choose a reason for hiding this comment

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

Could you check if the staged content (http://studio.local.edly.io:8001/admin/content_staging/stagedcontent/) has something weird on it?

Nothing weird I can see, can you?

image

Yes, it seems strange. I have created a new course and it works fine. Here I attach the course: course.q8xomjt4.tar.gz

My issues are getting weirder.. I've imported this course, but all I can see is Section > Subsection > Unit, but there are no blocks in that unit! I can see them in the drafts folder of the zip file, just not in my course.

So maybe there's something fundamental going on with my devstack. Will rebuild, and see if someone else is available to review this :)

Comment on lines +318 to +337
@XBlock.json_handler
def studio_submit(self, submissions, suffix=''): # pylint: disable=unused-argument
"""
Change the settings for this XBlock given by the Studio user
"""
if 'display_name' in submissions:
self.display_name = submissions['display_name']
if 'instructions' in submissions:
self.instructions = submissions['instructions']
if 'num_inputs' in submissions:
self.num_inputs = submissions['num_inputs']
if 'num_top_words' in submissions:
self.num_top_words = submissions['num_top_words']
if 'display_student_percents' in submissions:
self.display_student_percents = submissions['display_student_percents'] == 'True'

return {
'result': 'success',
}

Copy link
Member

Choose a reason for hiding this comment

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

@irtazaakram @farhan This PR makes a fix to the built-in Word Cloud block. If it is relevant, could you please ensure the fix is applied to the extracted Word Cloud as well?

Copy link
Member

Choose a reason for hiding this comment

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

(context for OpenCraft: We are in the process of extracting WordCloud from edx-platform)

@mphilbrick211 mphilbrick211 added the FC Relates to an Axim Funded Contribution project label Feb 5, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
FC Relates to an Axim Funded Contribution project 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.

6 participants