Research
Security News
Quasar RAT Disguised as an npm Package for Detecting Vulnerabilities in Ethereum Smart Contracts
Socket researchers uncover a malicious npm package posing as a tool for detecting vulnerabilities in Etherium smart contracts.
xblock-drag-and-drop-v2
Advanced tools
This XBlock implements a friendly drag-and-drop style problem, where the learner has to drag items to zones on a target image.
The editor is fully guided. Features include:
The XBlock supports progressive grading and keeps progress across refreshes. All checking and record keeping is done on the server side.
The following screenshot shows the Drag and Drop XBlock rendered inside the edX LMS before the user starts solving the problem:
This screenshot shows the XBlock after the learner successfully completed the Drag and Drop problem:
Install the requirements into the Python virtual environment of your
edx-platform
installation by running the following command from the
root folder:
$ pip install -r requirements.txt
The Drag and Drop XBlock ships with an alternate theme called "Apros"
that you can enable by adding the following entry to XBLOCK_SETTINGS
in lms.env.json
:
"drag-and-drop-v2": {
"theme": {
"package": "drag_and_drop_v2",
"locations": ["public/themes/apros.css"]
}
}
You can use the same approach to apply a custom theme:
"package"
can refer to any Python package in your virtualenv, which
means you can develop and maintain your own theme in a separate
package. There is no need to fork or modify this repository in any way
to customize the look and feel of your Drag and Drop problems.
"locations"
is a list of relative paths pointing to CSS files
belonging to your theme. While the XBlock loads, files will be added
to it in the order that they appear in this list. (This means that if
there are rules with identical selectors spread out over different
files, rules in files that appear later in the list will take
precedence over those that appear earlier.)
Finally, note that the default (unthemed) appearance of the Drag and Drop XBlock has been optimized for accessibility, so its use is encouraged -- especially for courses targeting large and/or potentially diverse audiences.
Drag and Drop v2 XBlock is already included in Open edX.
You will find it in "Add New Component"
box in Studio:
click the green Problem
button, choose the the Advanced
tab
and choose Drag and Drop
.
The Drag and Drop XBlock features an interactive editor. Add the Drag
and Drop component to a lesson, then click the EDIT
button.
In the first step, you can set some basic properties of the component, such as the title, the problem mode, the maximum number of attempts, the maximum score, the problem text to render above the background image, the introductory feedback (shown initially), and the final feedback (shown after the learner successfully completes the drag and drop problem, or when the learner runs out of attempts).
There are two problem modes available:
In the next step, you set the URL and description for the background image and define the properties of the drop zones. For each zone you can specify the text that should be rendered inside it (the "zone label"), how wide and tall it should be, and where it should be placed on the background image. In this step you can also specify whether you would like zone labels to be shown to learners or not, as well as whether or not to display borders outlining the zones. It is possible to define an arbitrary number of drop zones as long as their labels are unique.
You can specify the alignment for items once they are dropped in the zone. Centered alignment is the default, and places items from top to bottom along the center of the zone. Left alignment causes dropped items to be placed from left to right across the zone. Right alignment causes the items to be placed from right to left across the zone. Items dropped in a zone will not overlap, but if the zone is not made large enough for all its items, they will overflow the bottom of the zone, and potentially overlap the zones below.
In the final step, you define the background and text color for drag items, as well as the drag items themselves. A drag item can contain either text or an image. You can define custom success and error feedback for each item. In standard mode, the feedback text is displayed in a popup after the learner drops the item on a zone - the success feedback is shown if the item is dropped on a correct zone, while the error feedback is shown when dropping the item on an incorrect drop zone. In assessment mode, the success feedback texts are not used, while error feedback texts are shown when learner submits a solution.
You can select any number of zones for an item to belong to using the checkboxes; all zones defined in the previous step are available. You can leave all of the checkboxes unchecked in order to create a "decoy" item that doesn't belong to any zone.
You can define an arbitrary number of drag items, each of which may be attached to any number of zones.
"Maximum items per Zone" setting controls how many items can be dropped into a single zone, allowing some degree of control over items overlapping zones below.
Student assessment scores for the Drag and Drop XBlock are calculated according to the following formula:
score = (C + D) / T
Where C is the number of correctly placed regular items, D is the number of decoy items that were correctly left unplaced, and T is the total number of items available.
Example: consider a Drag and Drop instance configured with a total of four
items, of which three are regular items and one is a decoy. If a learner
places two of the normal items correctly and one incorrectly (C = 2
), and
wrongly places the decoy item onto a drop zone (D = 0
), that learner's score
will be 50%
, as given by:
score = (2 + 0) / 4
If the learner were to then move the decoy item back to the bank (D = 1
) and
move the wrongly placed regular item to the correct dropzone (C = 3
), their
score would be 100%
:
score = (3 + 1) / 4
Optionally, there is an alternative grading that can be enabled, by setting the
waffle flag drag_and_drop_v2.grading_ignore_decoys
, which will drop
the decoy items entirely from the score calculation. The formula will change to:
score = C / R
Where C is the number of correctly placed regular items, R is the number of required regular items.
Export of a demo course that showcases various Drag and Drop v2 features is available at github.com/open-craft/demo-courses/archive/drag-and-drop-v2.tar.gz.
The following analytics events are provided by this block.
edx.drag_and_drop_v2.loaded
Fired when the Drag and Drop XBlock is finished loading.
Example ("common" fields that are not interesting in this context have been left out):
{
...
"event": {},
"event_source": "server", -- Common field, contains event source.
"event_type": "edx.drag_and_drop_v2.loaded", -- Common field, contains event name.
...
Real event example (taken from a devstack):
{
"username": "staff",
"event_type": "edx.drag_and_drop_v2.loaded",
"ip": "10.0.2.2",
"agent": "Mozilla/5.0 (Macintosh; Intel Mac OS X 10.11; rv:43.0) Gecko/20100101 Firefox/43.0",
"host": "precise64",
"referer": "http://example.com/courses/course-v1:DnD+DnD+DnD/courseware/ec546c58d2f447b7a9223c57b5de7344/756071f8de7f47c3b0ae726586ebbe16/1?activate_block_id=block-v1%3ADnD%2BDnD%2BDnD%2Btype%40vertical%2Bblock%40d2fc47476ca14c55816c4a1264a27280",
"accept_language": "en;q=1.0, en;q=0.5",
"event": {},
"event_source": "server",
"context": {
"course_user_tags": {},
"user_id": 5,
"org_id": "DnD",
"module": {
"usage_key": "block-v1:DnD+DnD+DnD+type@drag-and-drop-v2+block@6b80ce1e8b78426898b47a834d72ffd3",
"display_name": "Drag and Drop"
},
"course_id": "course-v1:DnD+DnD+DnD",
"path": "/courses/course-v1:DnD+DnD+DnD/xblock/block-v1:DnD+DnD+DnD+type@drag-and-drop-v2+block@6b80ce1e8b78426898b47a834d72ffd3/handler/publish_event"
},
"time": "2016-01-13T01:52:41.330049+00:00",
"page": "x_module"
}
edx.drag_and_drop_v2.item.picked_up
Fired when a learner picks up a draggable item.
Example ("common" fields that are not interesting in this context have been left out):
{
...
"event": {
"item_id": 0, -- ID of the draggable item.
},
"event_source": "server", -- Common field, contains event source.
"event_type": "edx.drag_and_drop_v2.picked_up", -- Common field, contains event name.
...
Real event example (taken from a devstack):
{
"username": "staff",
"event_type": "edx.drag_and_drop_v2.item.picked_up",
"ip": "10.0.2.2",
"agent": "Mozilla/5.0 (Macintosh; Intel Mac OS X 10.11; rv:43.0) Gecko/20100101 Firefox/43.0",
"host": "precise64",
"referer": "http://example.com/courses/course-v1:DnD+DnD+DnD/courseware/ec546c58d2f447b7a9223c57b5de7344/756071f8de7f47c3b0ae726586ebbe16/1?activate_block_id=block-v1%3ADnD%2BDnD%2BDnD%2Btype%40vertical%2Bblock%40d2fc47476ca14c55816c4a1264a27280",
"accept_language": "en;q=1.0, en;q=0.5",
"event": {
"item_id": 0,
},
"event_source": "server",
"context": {
"course_user_tags": {},
"user_id": 5,
"org_id": "DnD",
"module": {
"usage_key": "block-v1:DnD+DnD+DnD+type@drag-and-drop-v2+block@6b80ce1e8b78426898b47a834d72ffd3",
"display_name": "Drag and Drop"
},
"course_id": "course-v1:DnD+DnD+DnD",
"path": "/courses/course-v1:DnD+DnD+DnD/xblock/block-v1:DnD+DnD+DnD+type@drag-and-drop-v2+block@6b80ce1e8b78426898b47a834d72ffd3/handler/publish_event"
},
"time": "2016-01-13T01:58:44.395935+00:00",
"page": "x_module"
}
edx.drag_and_drop_v2.item.dropped
Fired when a learner drops a draggable item.
This event will be emitted when a learner drops a draggable item.
Example ("common" fields that are not interesting in this context have been left out):
{
...
"event": {
"is_correct": true, -- Whether the draggable item has been placed in the correct location.
"item": "Goes to the top", -- Name, or in the absence thereof, image URL of the draggable item.
"item_id": 0, -- ID of the draggable item.
"location": "The Top Zone", -- Name of the location the item was dragged to.
"location_id": 1, -- ID of the location the item was dragged to.
},
"event_source": "server", -- Common field, contains event source.
"event_type": "edx.drag_and_drop_v2.dropped", -- Common field, contains event name.
...
Real event example (taken from a devstack):
{
"username": "staff",
"event_type": "edx.drag_and_drop_v2.item.dropped",
"ip": "10.0.2.2",
"agent": "Mozilla/5.0 (Macintosh; Intel Mac OS X 10.11; rv:43.0) Gecko/20100101 Firefox/43.0",
"host": "precise64",
"referer": "http://example.com/courses/course-v1:DnD+DnD+DnD/courseware/ec546c58d2f447b7a9223c57b5de7344/756071f8de7f47c3b0ae726586ebbe16/1?activate_block_id=block-v1%3ADnD%2BDnD%2BDnD%2Btype%40vertical%2Bblock%40d2fc47476ca14c55816c4a1264a27280",
"accept_language": "en;q=1.0, en;q=0.5",
"event": {
"is_correct": true,
"location": "The Top Zone",
"location_id": 1,
"item": "Goes to the top",
"item_id": 0,
},
"event_source": "server",
"context": {
"course_user_tags": {},
"user_id": 5,
"org_id": "DnD",
"module": {
"usage_key": "block-v1:DnD+DnD+DnD+type@drag-and-drop-v2+block@6b80ce1e8b78426898b47a834d72ffd3",
"display_name": "Drag and Drop"
},
"course_id": "course-v1:DnD+DnD+DnD",
"path": "/courses/course-v1:DnD+DnD+DnD/xblock/block-v1:DnD+DnD+DnD+type@drag-and-drop-v2+block@6b80ce1e8b78426898b47a834d72ffd3/handler/do_attempt"
},
"time": "2016-01-13T01:58:45.202313+00:00",
"page": "x_module"
}
edx.drag_and_drop_v2.feedback.opened
Fired when the feedback pop-up is opened.
Example ("common" fields that are not interesting in this context have been left out):
{
...
"event": {
"content": "Correct! This one belongs to The Top Zone.", -- Content of the feedback popup.
"truncated": false, -- Boolean indicating whether "content" field was truncated.
},
"event_source": "server", -- Common field, contains event source.
"event_type": "edx.drag_and_drop_v2.feedback.opened", -- Common field, contains event name.
...
Real event example (taken from a devstack):
{
"username": "staff",
"event_type": "edx.drag_and_drop_v2.feedback.opened",
"ip": "10.0.2.2",
"agent": "Mozilla/5.0 (Macintosh; Intel Mac OS X 10.11; rv:43.0) Gecko/20100101 Firefox/43.0",
"host": "precise64",
"referer": "http://example.com/courses/course-v1:DnD+DnD+DnD/courseware/ec546c58d2f447b7a9223c57b5de7344/756071f8de7f47c3b0ae726586ebbe16/1?activate_block_id=block-v1%3ADnD%2BDnD%2BDnD%2Btype%40vertical%2Bblock%40d2fc47476ca14c55816c4a1264a27280",
"accept_language": "en;q=1.0, en;q=0.5",
"event": {
"content": "Correct! This one belongs to The Top Zone.",
"truncated": false,
},
"event_source": "server",
"context": {
"course_user_tags": {},
"user_id": 5,
"org_id": "DnD",
"module": {
"usage_key": "block-v1:DnD+DnD+DnD+type@drag-and-drop-v2+block@6b80ce1e8b78426898b47a834d72ffd3",
"display_name": "Drag and Drop"
},
"course_id": "course-v1:DnD+DnD+DnD",
"path": "/courses/course-v1:DnD+DnD+DnD/xblock/block-v1:DnD+DnD+DnD+type@drag-and-drop-v2+block@6b80ce1e8b78426898b47a834d72ffd3/handler/publish_event"
},
"time": "2016-01-13T01:58:45.844986+00:00",
"page": "x_module"
}
edx.drag_and_drop_v2.feedback.closed
Fired when the feedback popup is closed.
Example ("common" fields that are not interesting in this context have been left out):
{
...
"event": {
"content": "No, this item does not belong here. Try again." -- Message of the feedback popup that was closed.
"manually": true, -- Whether or not the user closed the feedback window manually or if it was auto-closed.
"truncated": false, -- Boolean indicating whether "content" field was truncated.
},
"event_source": "server", -- Common field, contains event source.
"event_type": "edx.drag_and_drop_v2.feedback.closed", -- Common field, contains event name.
...
Real event example (taken from a devstack):
{
"username": "staff",
"event_type": "edx.drag_and_drop_v2.feedback.closed",
"ip": "10.0.2.2",
"agent": "Mozilla/5.0 (Macintosh; Intel Mac OS X 10.11; rv:43.0) Gecko/20100101 Firefox/43.0",
"host": "precise64",
"referer": "http://example.com/courses/course-v1:DnD+DnD+DnD/courseware/ec546c58d2f447b7a9223c57b5de7344/756071f8de7f47c3b0ae726586ebbe16/1?activate_block_id=block-v1%3ADnD%2BDnD%2BDnD%2Btype%40vertical%2Bblock%40d2fc47476ca14c55816c4a1264a27280",
"accept_language": "en;q=1.0, en;q=0.5",
"event": {
"content": "No, this item does not belong here. Try again."
"manually": true
"truncated": false,
},
"event_source": "server",
"context": {
"course_user_tags": {},
"user_id": 5,
"org_id": "DnD",
"module": {
"usage_key": "block-v1:DnD+DnD+DnD+type@drag-and-drop-v2+block@13d1b859a2304c858e1810ccc23f29b2",
"display_name": "Drag and Drop"
},
"course_id": "course-v1:DnD+DnD+DnD",
"path": "/courses/course-v1:DnD+DnD+DnD/xblock/block-v1:DnD+DnD+DnD+type@drag-and-drop-v2+block@13d1b859a2304c858e1810ccc23f29b2/handler/publish_event"
},
"time": "2016-01-13T02:07:00.988534+00:00",
"page": "x_module"
}
Inside a fresh virtualenv, cd
into the root folder of this repository
(xblock-drag-and-drop-v2
) and run:
$ make requirements
You can then run the entire test suite via:
$ make test
To run specific test groups, use one of the following commands:
$ make test.unit
$ make test.quality
$ make test.translations
To run individual unit tests, use:
$ make test.unit TEST=tests/unit/test_basics.py::BasicTests::test_student_view_data
To run tests without tox, use:
$ make requirements_python
$ make test.python TEST=tests/unit/test_basics.py::BasicTests::test_student_view_data
According to edX docs on XBlock i18n, LMS runtime is capable of supporting XBlock i18n and l10n.
To comply with l10n requirements, XBlock is supposed to provide translations in
xblock_package_root/translations/locale_code/LC_MESSAGES/text.po
folder in GNU Gettext Portable Object file format.
Drag and Drop v2 XBlock aims to comply with i18n requirements for Open edX platform, including a stricter set of
requirements for edx.org
itself, thus providing the required files. So far only two translations are available:
Updates to translated strings are supposed to be propagated to text.po
files. EdX i18n_tools is used here along GNU Gettext and a Makefile for automation.
Note: currently translations
directory is a symbolic link to conf/locale
directory. Also, 'text.po' file for locale code en
is a symbolic link to conf/locale/en/LC_MESSAGES/django.po
file. Both links works as a transition step to fully moving translation files to openedx-translations repository
$ make extract_translations
Note that this command generates text.po
which is supposed to contain
all translatable strings.
To check if text.po
is correct, one can run:
$ make compile_translations
If everything is correct, it will create translations/en/LC_MESSAGES/text.mo
and locale/en/LC_MESSAGES/text.js
files.
As previously said, this fake translation mainly exists for testing reasons. For edX platform it is built using Dummy translator from edX i18n-tools.
$ make dummy_translations
Further information on the API for native mobile applications can be found here.
To release a new version, update .travis.yml and setup.py to point to your new intended version number and create a new release with that version tag via Github.
Remove Transifex calls and bundled translation files for the OEP-58 proposal.
BREAKING CHANGE: This version removes translations for Quince and earlier releases.
xblockutils.*
imports with xblock.utils.*
. The old imports are used as a fallback for compatibility with older releases.make extract_translations
now uses msgcat
instead of tail
to combine djangojs-partial.po
into django.po
. This is to avoid the possibility of having message compilation failure because of duplicate strings (strings shared between both files)Use the replace_urls
service instead of a runtime property.
BREAKING CHANGE: This version is no longer compatible with Maple.
conf/locale
directory is now the source of truth for translations.translations
directory is now a symbolic link for backwards compatibility.locale
symbolic link is deleted to avoid too many symbolic links.en
translations are now extracted into django.po
instead of text.po
.en
text.po
is now a symbolic link to django.po
for backwards compatibility.bleach==6.0.0
and bleach<6.0.0
css
extras explicit.Sanitize HTML tags to prevent XSS vulnerabilities.
BREAKING CHANGE: Disallowed HTML tags (e.g. <script>
) will no longer be rendered in LMS and Studio.
Travis
with GitHub CI
.DeprecatedEdxPlatformImportWarning
.progress
event explicitly when it is marked as complete.A brand new release of the Drag and Drop XBlock, featuring major UX improvements, new features, and accessibility enhancements.
FAQs
XBlock - Drag-and-Drop v2
We found that xblock-drag-and-drop-v2 demonstrated a healthy version release cadence and project activity because the last version was released less than a year ago. It has 1 open source maintainer collaborating on the project.
Did you know?
Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.
Research
Security News
Socket researchers uncover a malicious npm package posing as a tool for detecting vulnerabilities in Etherium smart contracts.
Security News
Research
A supply chain attack on Rspack's npm packages injected cryptomining malware, potentially impacting thousands of developers.
Research
Security News
Socket researchers discovered a malware campaign on npm delivering the Skuld infostealer via typosquatted packages, exposing sensitive data.