Prototype: React-enabled XBlocks
Nobody has claimed this yet.
- Dominant language
- Python
- Stars
- 470
- Forks
- 231
- Avg merge
- 1d 1h
- Merged PRs (30d)
- 6
Description
Background
See https://github.com/openedx/XBlock/issues/635
Goals
- On branches of edx-platform, frontend-app-learning, and any existing xblock:
- Add a React-based student view to the XBlock.
- Get it to render in the Learning MFE.
- Write up a recommendation for how this could be generalized for all XBlocks & all views (student, public, author, and studio) and implemented.
Suggested approach
Here's how I would do it, but that doesn't mean it's the only way it could be done!
Choose an XBlock, ideally one of the ones that is defined in its own respository. Make these changes:
- Add a
student_view_datamethod, which will return a JSON representation of the block's student view. Example that exists in master today (it was used by alternative block frontends for the LabXChange project). - In the same repo, create an NPM package containing a new student view as a React component named
StudentView. The student_view_data should be expected to be passed in via the component's props. - Publish the NPM package to a user account.
- Add a new class-level field to the XBlock:
whereclass SomeBlock(XBlock): react_views = "someblock/path/to/view/module.js""path/to/view/module.js"is replaced by a path that the Learning MFE can dynamicallyimport(...)in order to load this block'sStudentViewcomponent.
In edx-platform:
- Enhance the MFE Configuration API (defined in lms/djangoapps/mfe_config) to also return a dictionary of all "React-enabled" XBlocks, mapping from the XBlock tag to the React module path:
{
"someblock": "someblock/path/to/view/module.js"
...
}
This will allow the Learning MFE to dynamically discover the full list of React-enabled blocks.
In the Learning MFE:
- Install the new NPM package.
- Upon initialization, look at the list of React-enabled XBlocks returned by the MFE Config API. Load the
StudentViewof each block. - In courseware, if a unit is comprised entirely of React-enabled blocks, then render each block's
StudentViewcomponent instead of rendering the standard iframe to edx-platform.
Notes
See parent issue for more ideas and discussion.
Contributor guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
Start with the parent issue 635 and the XBlock student_view_data example linked in the issue. Then inspect lms/djangoapps/mfe_config, the Learning MFE courseware path, and the XBlock React-enabled field described here. Done means a working prototype across the named branches plus a recommendation for generalizing React views across XBlock types and views.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- python, react
- Domain
- api, backend, documentation, frontend
- Issue type
- Feature
- Difficulty
- 5/5
- Estimated time
- Over a week
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 18/100