Scaffolding toward Blockstore-based XBlock runtime [LX-73]

Description

*❗This PR has been superseded by https://github.com/edx/edx-platform/pull/20645*

--------

This is a new XBlock runtime edx-platform, designed to be used for pure XBlocks (not XModules) that are stored in Blockstore. (In the future, it will also support XBlocks that are stored in some optimized format derived from Blockstore.)

  1.  

    1.  

      1. Goals are:

  • Be able to run alongside the existing XBlock runtime + modulestore without interfering with them (any XBlock in modulestore will use the old runtime, and in Blockstore will use the new runtime with no overlap, and they'll store user state etc. in different database tables)

  • Be able to load XBlock data (OLX) directly from Blockstore, including draft bundles, and (in the future) from some more optimized format.

  • Have little or no dependencies on the rest of the edx-platform codebase, so that we can separate the runtime in the future.

  • Support XBlock sandboxing by allowing XBlock frontend code to call XBlock handlers without needing any cookies (this lets us block XBlock frontend code from seeing any of the user's edX cookies at all)

  • First-class support for anonymous users (allow users who aren't logged in to still save state in the session, like Studio does, if the XBlock supports it)

  1.  

    1.  

      1. Non-goals:

  • Support XModules

  • Support Modulestore

  • Support `course`, `section`, or `subsection` XModules

  1.  

    1.  

      1. Status:

  • Can load an individual XBlock's OLX from Blockstore, instantiate that XBlock, render its `author_view` or `student_view`, then return the resulting HTML+JS+CSS via an API endpoint. The idea is that a React frontend would consume this API and add the JS runtime, displaying the XBlock.

  • In progress: persist user state for registered users

Not ready for wide review.

  1.  

    1. Testing instructions

So far I only have confirmed this works with a Drag and Drop XBlock (that said, it should work with any pure XBlock). Haven't yet tested XModules or blocks with children, but they probably aren't working yet.

1. [Set up `blockstore` on your docker devstack](https://github.com/open-craft/blockstore#using-with-docker-devstack)
1. Also install and configure [openedx-blockstore-relay](https://github.com/open-craft/openedx-blockstore-relay)
1. Check out this branch.
1. Run `make studio-shell` then `pip install -e .` to update the required entry points. Restart Studio (`make studio-restart` on the host).
1. Create a course in Studio with a Drag and Drop v2 XBlock. Customize the drag and drop XBlock, changing the title, descriptions, mode, and other settings (but don't change the image). Publish the changes.
1. Import the drag and drop xblock into blockstore. See the [relay README](https://github.com/open-craft/openedx-blockstore-relay/blob/master/README.rst) for instructions. The command should look like: `./manage.py cms transfer_to_blockstore --verbosity=2 --collection-uuid "PUT_UUID_HERE" --block-key "block-v1:OpenCraft+B+1+type@drag-and-drop-v2+block@blah"`
1. Note the *UUID* from the resulting bundle. Put them into the URL and visit in in your browser:
```
http://localhost:18010/api/bundles/v0/bundle/UUID_GOES_HERE/blocks/
```
1. The resulting API response should include a URL for each XBlock in the bundle, like http://localhost:18010/api/bundles/v0/block/gblock-v1:ec2566b7-e618-429b-8d97-b3ded042b862:drag-and-drop-v2:971aadaaaa5a4886b37fee3ced711b30/ . Go to that URL. Check the resulting HTML / fragment data.

  1.  

    1.  

      1. Todos:

  • [ ] Add tests

  • [ ] Fix outdated docstring: "each XBlock gets its own instance of XBlockRuntime."

  • [ ] Test with XBlocks with children

  • [x] Cleanup: Current XBlockruntime is overly coupled to Blockstore KVS - calls `collect_parsed_fields()` within `parse_xml_file()`: fixed in https://github.com/open-craft/edx-platform/pull/146

  • [x] Develop an opaque ID format for definitions within blockstore and usages based thereon: https://github.com/open-craft/edx-platform/pull/146

  • [ ] Be able to persist edits back to Blockstore, creating an updated draft

  1.  

    1.  

      1. Outline of future PRs:

  • Implement user state storage for registered users

  • Implement user state storage for anonymous users

  • Create pluggable "learning context" model, including a simple content library implementation which defines how permissions work ( In `edxapp`, there would be a `libraries` model that associates a library bundle UUID with metadata such as the users who have permission to edit it, and a `class LibraryContext(LearningContext)` implementation which defines how to determine if the given user has permission to view and/or edit XBlocks in the given context.

  • Add Permissions checks

  • Connect with grades & completion systems

  • Consider changing the XBlock API to make working with XML less painful?

Won't Do

Assignee

Unassigned

Reporter

Open Source Pull Request Bot

Labels

None

Contributor Name

Braden MacDonald

Repo

edx/edx-platform

Customer

Epic Link

None

OSCM Assignee

None

Platform Map Area (Levels 1 & 2)

None

Platform Map Area (Levels 3 & 4)

None

Blended Hour Utilization Percentage

None

edX Theme

None

edX Squad

None

Github Lines Added

1426

Github Lines Deleted

24

Priority

Unset