Skip to content
Workbench and example xblocks
JavaScript Python CSS HTML Other
Branch: master
Clone or download
Latest commit 331e50b Nov 4, 2019
Permalink
Type Name Latest commit message Commit time
Failed to load latest commit information.
bin [INCR-98] and [INCR-99] Run Python modernize -w . (#147) Feb 27, 2019
doc [INCR-98] and [INCR-99] Run Python modernize -w . (#147) Feb 27, 2019
prototype run isort to fix quality May 27, 2019
requirements Upgrade xblock. Oct 2, 2019
sample_xblocks Upgrade xblock. Oct 2, 2019
var Make var directory Dec 24, 2015
workbench -added log Oct 30, 2019
.coveragerc Testing and quality upgrades (#123) Feb 15, 2018
.dockerignore Don't bother copying the Dockerfile to the context Aug 5, 2016
.gitignore Add support for the LTI Consumer XBlock (#142) Mar 1, 2019
.isort.cfg Testing and quality upgrades (#123) Feb 15, 2018
.travis.yml Upgrade xblock. Oct 2, 2019
AUTHORS added myself to authors Oct 26, 2015
CHANGELOG.rst Bump version to 0.1.5. Update README/CHANGELOG. Sep 7, 2017
Dockerfile Install nodejs in docker container Aug 27, 2019
LICENSE.TXT Ned says all XBlock repos should be Apache, not AGPL. Propagating cha… Nov 12, 2016
MANIFEST.in Add tox testing and use tox during travis testing. Sep 7, 2017
Makefile OEP-18 compliance May 27, 2019
README.rst Update requirements, move to pip-compile, remove unused nose params (#… Feb 16, 2018
codecov.yml Testing and quality upgrades (#123) Feb 15, 2018
constraints.txt [INCR 75] only require futures for python 2.7 (#144) Feb 22, 2019
manage.py [INCR-98] and [INCR-99] Run Python modernize -w . (#147) Feb 27, 2019
openedx.yaml Upgrade xblock. Oct 2, 2019
pylintrc Testing and quality upgrades (#123) Feb 15, 2018
pylintrc_tweaks Testing and quality upgrades (#123) Feb 15, 2018
settings.py [INCR-98] and [INCR-99] Run Python modernize -w . (#147) Feb 27, 2019
setup.cfg Testing and quality upgrades (#123) Feb 15, 2018
setup.py version-bump Nov 4, 2019
tox.ini Upgrade xblock. Oct 2, 2019

README.rst

XBlock SDK build-status coverage-status

This repository consists of three main components to assist in the creation of new XBlocks:

  • a template-based generator for new XBlocks (found in the prototype directory)
  • sample XBlocks that can be the basis for new XBlock work (found in the sample_xblocks directory)
  • Workbench runtime, a simple runtime for viewing and testing XBlocks in a browser (found in the workbench directory)

Installation

This code runs on Python 2.7.

  1. Install standard development libraries. Here's how you do it on Ubuntu or Debian:

    $ sudo apt-get install python-dev libxml2-dev libxslt-dev lib32z1-dev libjpeg62-dev
    
  2. Get a local copy of this repo.

  3. Create and activate a virtualenv to work in.

  4. Install the requirements and register the XBlock entry points:

    $ make install
    
  5. Run the Django development server:

    $ python manage.py runserver
    
  6. Open a web browser to: http://127.0.0.1:8000

Docker

Alternatively, you can build and run the xblock-sdk in Docker.

After cloning this repository locally, go into the repository directory and build the Docker image:

$ docker build -t xblock-sdk .

You can then run the locally-built version using the following command:

$ docker run -d -p 8000:8000 --name xblock-sdk xblock-sdk

You should now be able to access the XBlock SDK environment in your browser at http://localhost:8000

Testing

Testing is done via tox to test all supported versions:

  1. Create and activate a virtualenv to work in.

  2. Run just unit tests via tox:

    $ tox
    

For each supported version of Django (currently 1.8 and 1.11) this will run:

  • Integration tests of XBlocks running within the workbench.
  • Individual tests written for the demo XBlocks

To run the unit tests in your virtualenv you can use:

$ make test

To run all tox unit tests and quality checks:

$ make test-all

To run just the quality checks:

$ make quality

You can test XBlocks through a browser using Selenium. We have included an example Selenium test for thumbs that uses Django's LiveServerTestCase. It runs as part of the test suite as executed by the above command.

To update and view test coverage:

$ make coverage

See the coverage.py docs for more info and options.

Using the workbench

When you open the workbench, you'll see a list of sample XBlock configurations (scenarios). Each will display a page showing the XBlocks composited together, along with internal information like the "database" contents.

The workbench database defaults to a sqlite3 database. If you're using devstack, you may want to set WORKBENCH_DATABASES to point to your MySQL db.

If you want to experiment with different students, you can use a URL parameter to set the student ID, which defaults to 1:

http://127.0.0.1:8000/?student=17

Different students will see different student state, for example, while seeing the same content. The default student ID contains only digits but it is not necessary to limit student IDs to digits. Student IDs are represented as strings.

Making your own XBlock

Making an XBlock involves creating a Python class that conforms to the XBlock specification. See the sample_xblocks directory for examples and the XBlock tutorial for a full walk-through.

We provide a script to create a new XBlock project to help you get started. Run bin/workbench-make-xblock in a directory where you want to create your XBlock project. The script will prompt you for the name of the XBlock, and will create a minimal working XBlock, ready for you to begin development.

You can provide scenarios for the workbench to display: see the thumbs.py sample for an example, or the xblock/problem.py file. The scenarios are written in a simple XML language. Note this is not an XML format we are proposing as a standard.

Once you install your XBlock into your virtualenv, the workbench will automatically display its scenarios for you to experiment with.

If you are interested in making an XBlock to run for your course on edx.org, please get in touch with us as soon as possible -- in the ideation and design phase is ideal. See our XBlock review guidelines for more information (note that this is not needed for XBlocks running on your own instance of Open edX, or released to the wider community).

Example XBlocks

Included in this repository are some example XBlocks that demonstrate how to use various aspects of the XBlock SDK. You can see a more detailed description of those examples in the README located in that repository:

There is a rich community of XBlock developers that have put together a large number of XBlocks that have been used in various contexts, mostly on the edx-platform. You can see examples of what that community has done in the edx-platform wiki.

License

The code in this repository is licensed under version 3 of the AGPL unless otherwise noted.

Please see LICENSE.txt for details.

How to Contribute

Contributions are very welcome. The easiest way is to fork this repo, and then make a pull request from your fork. The first time you make a pull request, you will be asked to sign a Contributor Agreement.

Please see our contributor's guide for more information on contributing.

Reporting Security Issues

Please do not report security issues in public. Please email security@edx.org

Mailing List and IRC Channel

You can discuss this code on the edx-code Google Group or in the #edx-code IRC channel on Freenode.

You can’t perform that action at this time.