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

feat: [FC-0044] XBlock's children API as DRF #34055

Merged

Conversation

ruzniaievdm
Copy link
Contributor

@ruzniaievdm ruzniaievdm commented Jan 15, 2024

Settings

TUTOR_GROVE_WAFFLE_FLAGS:
  - name: contentstore.new_studio_mfe.use_new_unit_page
    everyone: true

TUTOR_GROVE_MFE_LMS_COMMON_SETTINGS:
  MFE_CONFIG:
    ENABLE_UNIT_PAGE: true

Description

This PR addresses a need in the development of the Course Unit Page feature within the frontend-app-course-authoring repository. The core objective is the implement of a DRF endpoint designed to render and deliver children data for container xblock.

This PR also includes:

  • adding unit type to create_xblock_info handler. It needs to display type of unit icons for the unit course page. Each unit must have one of the following types: video, vertical, problem, lock.
  • resolving problem with 500 error if user adds a Content Experiment (also needs to discuss)

Testing instructions

  1. Run master devstack.
  2. Start platform make dev.up.lms+cms and make checkout on this branch.
  3. Go to http://localhost:18010/api-docs.
  4. Find the required API endpoint /api/contentstore/v1/container/vertical/{usage_key_string}/children.
  5. Open needed unit page in cms http://localhost:18010/container/{usage_key_string} and make sure nothing has changed.
  6. Copy usage_key_string from previous step and paste it to required API endpoint to get data for unit.

How to reproduce an error

The problem arose at the stage of defining icons for children xblock's of the unit.
Just when we tried to get get_icon() for xblock which have split_test children.

  1. Go to Advanced settings page and add "split_test" to Advanced module list
  2. Go to Group configurations page and create group in Experiment group configurations section
  3. Go to Course Outline, create new unit, go to unit page
  4. In the Advanced select "Content Experiment"
File "/edx/app/edxapp/edx-platform/xmodule/vertical_block.py", line 254, in get_icon_class
    child_classes = {child.get_icon_class() for child in self.get_children()}
  File "/edx/app/edxapp/edx-platform/xmodule/vertical_block.py", line 254, in <setcomp>
    child_classes = {child.get_icon_class() for child in self.get_children()}
  File "/edx/app/edxapp/edx-platform/xmodule/split_test_block.py", line 398, in get_icon_class
    return self.child.get_icon_class() if self.child else 'other'
  File "/edx/app/edxapp/venvs/edxapp/lib/python3.8/site-packages/django/utils/functional.py", line 48, in __get__
    res = instance.__dict__[self.name] = self.func(instance)
  File "/edx/app/edxapp/edx-platform/xmodule/split_test_block.py", line 176, in child
    if self.child_block is not None:
  File "/edx/app/edxapp/venvs/edxapp/lib/python3.8/site-packages/django/utils/functional.py", line 48, in __get__
    res = instance.__dict__[self.name] = self.func(instance)
  File "/edx/app/edxapp/edx-platform/xmodule/split_test_block.py", line 166, in child_block
    child_blocks = self.get_child_blocks()
  File "/edx/app/edxapp/edx-platform/xmodule/split_test_block.py", line 216, in get_child_blocks
    group_id = self.get_group_id()
  File "/edx/app/edxapp/edx-platform/xmodule/split_test_block.py", line 243, in get_group_id
    user_service = self.runtime.service(self, 'user')
  File "/edx/app/edxapp/edx-platform/xmodule/modulestore/split_mongo/caching_descriptor_system.py", line 245, in service
    return super().service(block, service_name)
  File "/edx/app/edxapp/edx-platform/xmodule/x_module.py", line 1502, in service
    service = super().service(block=block, service_name=service_name)
  File "/edx/app/edxapp/venvs/edxapp/lib/python3.8/site-packages/xblock/runtime.py", line 1125, in service
    raise NoSuchServiceError(f"Service {service_name!r} is not available.")
xblock.exceptions.NoSuchServiceError: Service 'user' is not available.

@openedx-webhooks openedx-webhooks added the open-source-contribution PR author is not from Axim or 2U label Jan 15, 2024
@openedx-webhooks
Copy link

Thanks for the pull request, @ruzniaievdm! Please note that it may take us up to several weeks or months to complete a review and merge your PR.

Feel free to add as much of the following information to the ticket as you can:

  • supporting documentation
  • Open edX discussion forum threads
  • timeline information ("this must be merged by XX date", and why that is)
  • partner information ("this is a course on edx.org")
  • any other information that can help Product understand the context for the PR

All technical communication about the code itself will be done via the GitHub pull request interface. As a reminder, our process documentation is here.

Please let us know once your PR is ready for our review and all tests are green.

@ruzniaievdm ruzniaievdm changed the title feat: XBlock's children API as DRF draft: feat: XBlock's children API as DRF Jan 15, 2024
@ruzniaievdm ruzniaievdm changed the title draft: feat: XBlock's children API as DRF feat: XBlock's children API as DRF Jan 15, 2024
@ruzniaievdm ruzniaievdm changed the title feat: XBlock's children API as DRF DRAFT: feat: XBlock's children API as DRF Jan 15, 2024
@mphilbrick211
Copy link

Hi @ruzniaievdm! Just flagging that there's a couple failing checks. Would you mind taking a look? Thanks!

@ruzniaievdm ruzniaievdm force-pushed the ruzniaievdm/feat/unit-children branch 4 times, most recently from 36c9991 to 417187a Compare January 24, 2024 21:08
@ruzniaievdm ruzniaievdm force-pushed the ruzniaievdm/feat/unit-children branch from 417187a to 3543267 Compare February 7, 2024 16:29
@ruzniaievdm ruzniaievdm changed the title DRAFT: feat: XBlock's children API as DRF feat: [FC-0044] XBlock's children API as DRF Feb 7, 2024
@monteri monteri requested a review from KristinAoki February 14, 2024 13:06
@arbrandes arbrandes added the create-sandbox open-craft-grove should create a sandbox environment from this PR label Feb 14, 2024
@arbrandes arbrandes self-assigned this Feb 14, 2024
@mphilbrick211 mphilbrick211 added the waiting for eng review PR is ready for review. Review and merge it, or suggest changes. label Feb 21, 2024
Copy link
Contributor

@arbrandes arbrandes left a comment

Choose a reason for hiding this comment

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

I have tested this in the sandbox and locally as described, and cannot find any problems.

I think a second opinion is warranted on how to solve the split_test bug. (Plus, I'm technically not a CC here, so can't give final approval.)

# List of categories to check for presence in the children of the XBlock.
# This list is used to determine if all of the specified categories are absent
# in the categories of the children XBlock instances otherwise icon class variable will be set to `None`.
CATEGORIES_WITH_ABSENT_ICON = ["split_test"]
Copy link
Contributor

Choose a reason for hiding this comment

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

This seems difficult to maintain, but I can't think of a cheaper workaround. The question is if there's a more architecturally sound way of doing it, and if we want to hold off on merging this until we find one.

@kdmccormick or @feanil, thoughts?

Copy link
Member

@kdmccormick kdmccormick Feb 23, 2024

Choose a reason for hiding this comment

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

@arbrandes Agreed, we should not hard code block types if at all possible. There are places that do it already, but I would rather avoid adding more.

The comment is somewhat confusing to me. What is the meaning of an item being in this list? Is it that is type should be ignored when determining the icon?

@ruzniaievdm ruzniaievdm force-pushed the ruzniaievdm/feat/unit-children branch from 3543267 to 6f45f44 Compare March 6, 2024 14:23
* fix: wrap into try/except block getting icon for xblock

* fix: revision after review
@ruzniaievdm ruzniaievdm force-pushed the ruzniaievdm/feat/unit-children branch from 6f45f44 to 8979134 Compare March 6, 2024 14:25
@open-craft-grove
Copy link

Sandbox deployment successful 🚀
🎓 LMS
📝 Studio
ℹ️ Grove Config, Tutor Config, Tutor Requirements

@ruzniaievdm
Copy link
Contributor Author

@arbrandes I apologize for confusing you, indeed, in the previous version namely up to and including the second commit, you did not see the error, there was a workaround to this problem. And if you had made these changes, you would have seen the problem.

"xblock_type": get_icon(xblock) if is_xblock_unit and all_excluded_categories_absent else None"xblock_type": get_icon(xblock)

@arbrandes @kdmccormick After reviewing your comments we decided to take a different approach to solving this problem. Please review again.

@ruzniaievdm ruzniaievdm requested a review from arbrandes March 6, 2024 15:11
@ruzniaievdm ruzniaievdm requested a review from kdmccormick March 6, 2024 15:11
Copy link
Contributor

@arbrandes arbrandes left a comment

Choose a reason for hiding this comment

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

I have no objections, this time around.

log.warning(
"Error while getting block instance for descriptor with location: [%s]",
self.location
)
Copy link
Contributor

Choose a reason for hiding this comment

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

Ok, this feels much more manageable. 👍🏼

@KristinAoki KristinAoki merged commit cd5c4c9 into openedx:master Mar 12, 2024
47 checks passed
@openedx-webhooks
Copy link

@ruzniaievdm 🎉 Your pull request was merged! Please take a moment to answer a two question survey so we can improve your experience in the future.

@edx-pipeline-bot
Copy link
Contributor

2U Release Notice: This PR has been deployed to the edX staging environment in preparation for a release to production.

@edx-pipeline-bot
Copy link
Contributor

2U Release Notice: This PR has been deployed to the edX production environment.

@edx-pipeline-bot
Copy link
Contributor

2U Release Notice: This PR has been deployed to the edX staging environment in preparation for a release to production.

@edx-pipeline-bot
Copy link
Contributor

2U Release Notice: This PR has been deployed to the edX production environment.

1 similar comment
@edx-pipeline-bot
Copy link
Contributor

2U Release Notice: This PR has been deployed to the edX production environment.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
create-sandbox open-craft-grove should create a sandbox environment from this PR open-source-contribution PR author is not from Axim or 2U waiting for eng review PR is ready for review. Review and merge it, or suggest changes.
Projects
Archived in project
Development

Successfully merging this pull request may close these issues.

8 participants