Skip to main content

core xblocks

Project description

This repository is the new home for XBlocks which are part of the base openedx-platform installation.

Project Overview

XBlocks are modular components that enable rich interactive learning experiences in Open edX courses. Historically, the XBlock code was tightly coupled with the edx-platform, making it challenging to manage and extend. By extracting XBlocks into this dedicated repository, we can reduce the complexity of the edx-platform, making it more maintainable and scalable.

XBlocks Being Moved Here

These are the XBlocks being moved here, and each of their statuses:

  • poll_question – Ready to Use

  • word_cloud – Ready to Use

  • annotatable – Ready to Use

  • lti – Ready to Use

  • pdf – Done

  • html – Ready to Use

  • discussion – In Development

  • problem – In Development

  • video – In Development

The possible XBlock statuses are:

  • Placeholder: It’s just a cookiecutter thumbs-up block.

  • In Development: We’re building and testing this block.

  • Ready to Use: You can try this on your site using the Waffle flag.

  • Done The built-in block has been removed. The setup.py entrypoint has been removed from edx-platform and added to xblock-contrib.

Additional XBlocks that belong here

Over time, more XBlocks may be moved here. An XBlock belongs here if and only if both of the following are true:

  1. It needs to be part of the out-of-the-box Open edX experience, as agreed upon by the Product Working Group. Otherwise, perhaps the block belongs in xblocks-extra, or it belongs in a community repository outside of the openedx GitHub organization.

  2. The maintainers of this repository have capacity to maintain the additional block. Otherwise, perhaps the block belongs in its own repository with a separate dedicated maintainer, such as ora2.

Developing a new XBlock

There’s a handy script utils/create_xblock.sh that you can use to create XBlock here. just run

$ utils/create_xblock.sh

It will ask for XBlock name and XBlock class name that you want to use. Just enter these values and XBlock should be ready to work.

If faced with permission or access error run:

$ chmod +x utils/create_xblock.sh

and run it.

Testing with Docker

This XBlock comes with a Docker test environment ready to build, based on the xblock-sdk workbench. To build and run it:

$ make dev.run

The XBlock SDK Workbench, including this XBlock, will be available on the list of XBlocks at http://localhost:8000

Translating

Internationalization (i18n) is when a program is made aware of multiple languages. Localization (l10n) is adapting a program to local language and cultural habits.

For information on how to enable translations, visit the Open edX XBlock tutorial on Internationalization.

The included Makefile contains targets for extracting, compiling and validating translatable strings. The general steps to provide multilingual messages for a Python program (or an XBlock) are:

  1. Mark translatable strings.

  2. Run i18n tools to create raw message catalogs.

  3. Create language specific translations for each message in the catalogs.

  4. Use gettext to translate strings.

5. Mark translatable strings

Mark translatable strings in python:

from django.utils.translation import ugettext as _

# Translators: This comment will appear in the `.po` file.
message = _("This will be marked.")

See edx-developer-guide for more information.

You can also use gettext to mark strings in javascript:

// Translators: This comment will appear in the `.po` file.
var message = gettext("Custom message.");

See edx-developer-guide for more information.

2. Run i18n tools to create Raw message catalogs

After marking strings as translatable we have to create the raw message catalogs. These catalogs are created in .po files. For more information see GNU PO file documentation. These catalogs can be created by running:

$ make extract_translations

This command will create the necessary .po files under xblocks-contrib/xblocks_contrib/<xblock name>/conf/locale/en/LC_MESSAGES/text.po. The text.po file is created from the django-partial.po file created by django-admin makemessages (makemessages documentation), this is why you will not see a django-partial.po file.

You will need to have edx-i18n-tools that you can get by:

$ make requirements

3. Create language specific translations

3.1 Add translated strings

After creating the raw message catalogs, all translations should be filled out by the translator. One or more translators must edit the entries created in the message catalog, i.e. the .po file(s). The format of each entry is as follows:

#  translator-comments
A. extracted-comments
#: reference…
#, flag…
#| msgid previous-untranslated-string
msgid 'untranslated message'
msgstr 'mensaje traducido (translated message)'

For more information see GNU PO file documentation.

To use translations from transifex use the follow Make target to pull translations:

$ make pull_translations

See config instructions for information on how to set up your transifex credentials.

See transifex documentation for more details about integrating django with transiflex.

3.2 Compile translations

Once translations are in place, use the following Make target to compile the translation catalogs .po into .mo message files:

$ make compile_translations

The previous command will compile .po files using django-admin compilemessages (compilemessages documentation). After compiling the .po file(s), django-statici18n is used to create language specific catalogs. See django-statici18n documentation for more information.

To upload translations to transiflex use the follow Make target:

$ make push_translations

See config instructions for information on how to set up your transifex credentials.

See transifex documentation for more details about integrating django with transiflex.

Note: The dev.run make target will automatically compile any translations.

Note: To check if the source translation files (.po) are up-to-date run:

$ make detect_changed_source_translations

4. Use gettext to translate strings

Django will automatically use gettext and the compiled translations to translate strings.

Troubleshooting

If there are any errors compiling .po files run the following command to validate your .po files:

$ make validate

See django’s i18n troubleshooting documentation for more information.

Change Log

Unreleased

0.12.0 - 2026-03-02

Added

  • Implemented the Problem XBlock, extracted from edx-platform.

0.11.1 - 2026-02-27

Fixed

  • Package data for PDF block (templates, static assets) was missing and is now included.

0.11.0 - 2026-01-26

Added

  • Implemented PDF Block, extracted from third party plugin.

0.6.0 – 2025-08-13

Added

  • Restore get_html in the extracted Annotatable XBlock to match existing edx-platform

0.5.0 – 2025-08-8

Added

  • Implemented the poll XBlock & HTML XBlock, extracted from edx-platform.

0.4.0 – 2025-05-7

Added

  • Implemented the LTI XBlock, extracted from edx-platform.

0.3.0 – 2025-04-8

Added

  • Added support for django 5.2.

  • Implemented the Annotatable XBlock, extracted from edx-platform.

0.2.0 – 2025-02-12

Added

  • Implemented the Word Cloud Block, extracted from edx-platform.

0.1.0 – 2024-07-04

Added

  • First release on PyPI.

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

xblocks_contrib-0.12.0.tar.gz (3.3 MB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

xblocks_contrib-0.12.0-py2.py3-none-any.whl (3.4 MB view details)

Uploaded Python 2Python 3

File details

Details for the file xblocks_contrib-0.12.0.tar.gz.

File metadata

  • Download URL: xblocks_contrib-0.12.0.tar.gz
  • Upload date:
  • Size: 3.3 MB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.1.0 CPython/3.13.7

File hashes

Hashes for xblocks_contrib-0.12.0.tar.gz
Algorithm Hash digest
SHA256 7ee51222e7512fe72d27cb28d6a131e9a759439d83552d1438eeec90c3779ead
MD5 6b3635bd5d79c88b6791828232cc3019
BLAKE2b-256 0a3719384c1655de1fff0bf6d192cab787e8518abf3442b146d2c55e781ec09c

See more details on using hashes here.

File details

Details for the file xblocks_contrib-0.12.0-py2.py3-none-any.whl.

File metadata

File hashes

Hashes for xblocks_contrib-0.12.0-py2.py3-none-any.whl
Algorithm Hash digest
SHA256 76f19ca162a313eb5993d7de3d518fd3dd4298b30fda3e83f04e2af75787af6e
MD5 b171e31f4c44ba9500d1e68367b92b72
BLAKE2b-256 d418e3e184622c8184660c1328b723c68c746fae8e1c8db2dbd8f531dfc25c00

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page