The edX LMS and Studio have several features that are extensions of the core XBlock libraries (https://xblock.readthedocs.org). These features are listed below.
You can also render an individual XBlock in HTML with the XBlock URL.
These are properties and methods available on self.runtime
when a view or
handler is executed by the LMS.
self.runtime.publish(self, event_type, event)
. The
event_type
parameter enables downstream processing of the event since it
uniquely identifies the schema. This call will cause the runtime to save the
event data in the application event stream. XBlocks should publish events
whenever a significant state change occurs. Post-hoc analysis of the event
stream can yield insight about how the XBlock is used in the context of the
application. Ideally interesting state of the XBlock could be reconstructed
at any point in history through careful analysis of the event stream.In the future, these are likely to become more formal XBlock services (one related to users, and the other to event publishing).
These are class attributes or functions that can be provided by an XBlock to customize behavior in the LMS.
other
, video
, or
problem
), and determines which icon appears in edx sequence headers.
There is currently no way to provide a different icon.To participate in the course grade, an XBlock should set has_score
to
True
, and should publish
a grade
event whenever the grade changes.
The grade
event is a dictionary of the following form.
{
'value': <number>,
'max_value': <number>,
'user_id': <number>,
}
The grade event represents a grade of value/max_value
for the current user.
The user_id
field is optional, the currently logged in user’s ID will be
used if it is omitted.
A block cannot modify the value of any field with a scope where the user
property is UserScope.NONE
.
xblock.fields.Field
objects that should not be displayed in the default editing view for Studio.A block cannot modify the value of any field with a scope where the user
property is not UserScope.NONE
.
These instructions are temporary. Once XBlocks are fully supported by edx-platform (both the LMS and Studio), installation and testing will be much more straightforward.
To enable an XBlock for testing in your devstack (https://github.com/edx/configuration/wiki/edX-Developer-Stack), follow these steps.
Install your block.
$ vagrant ssh
vagrant@precise64:~$ sudo -u edxapp /edx/bin/pip.edxapp install /path/to/your/block
Enable the block.
In edx-platform/lms/envs/common.py
, uncomment:
# from xmodule.x_module import prefer_xmodules
# XBLOCK_SELECT_FUNCTION = prefer_xmodules
In edx-platform/cms/envs/common.py
, uncomment:
# from xmodule.x_module import prefer_xmodules
# XBLOCK_SELECT_FUNCTION = prefer_xmodules
In edx-platform/cms/envs/common.py
, change:
'ALLOW_ALL_ADVANCED_COMPONENTS': False,
to:
'ALLOW_ALL_ADVANCED_COMPONENTS': True,
Add the block to your courses’ advanced settings in Studio.
"advanced_modules"
to
["your-block"]
Add your block into your course.
Note the name your-block
used in Studio must exactly match the key you used
to add your block to your setup.py
entry_points
list. (If you are still
discovering XBlocks and simply used the workbench-make-new.py
script as
described in the Open edX XBlock Tutorial, look in the
setup.py
file that was created.)
To deploy your block to your own hosted version of edx-platform, you need to
install it into the virtualenv that the platform is running out of, and add to
the list of ADVANCED_COMPONENT_TYPES
in
edx-platform/cms/djangoapps/contentstore/views/component.py
.
The XBlock URL supports HTML rendering of an individual XBlock without the user interface of the LMS.
To use the XBlock URL and return the HTML rendering of an individual XBlock, you use the following URL path for an XBlock on an edX site.
https://{host}/xblock/{usage_id}
usage_id
¶The usage_id
is the unique identifier for the problem, video, text, or
other course content component, or for sequential or vertical course container
component. There are several ways to find the usage_id
for an XBlock in the
LMS, including viewing either the staff debug info or the page source. For more
information, see
Finding the Usage ID for Course Content.
In addition, API developers can call the Course Blocks API
/api/courses/v1/blocks
to find the usage_id
for a course’s XBlocks. For
more information, see Courses API Overview.
For example, a video component in the “Creating Video for the edX Platform” course on the edx.org site has the following URL.
https://courses.edx.org/courses/course-v1:edX+VideoX+1T2016/courseware/ccc7c32c65d342618ac76409254ac238/1a52e689bcec4a9eb9b7da0bf16f682d/
This video component appears as follows in the LMS.
To construct the XBlock URL for the same video component, you obtain its
usage_id
and then use the following URL format.
https://courses.edx.org/xblock/block-v1:edX+VideoX+1T2016+type@video+block@47faf3a03c4f4023b187528c25932e0a
When you use this URL, the video component appears in your browser as follows.
For courses created prior to October 2014, the usage_id
begins with
i4x://
, as in the following example.
https://courses.edx.org/xblock/i4x://edX/DemoX.1/problem/47bf6dbce8374b789e3ebdefd74db332