Package: xblock-problem-builder
Problem Builder and Step BuilderThis repository provides two XBlocks: Problem Builder and Step Builder.Both blocks allow to create questions of various types. They can be
used to simulate the workflow of real-life mentoring, within an edX
course.Supported features include:Free-form answers(textarea) which can be shared accross
different XBlock instances (for example, to allow a student to
review and edit an answer they gave before).Self-assessment MCQs(multiple choice questions), to display
predetermined feedback to a student based on his choices in the
self-assessment. Supports rating scales and arbitrary answers.MRQs (Multiple Response Questions), a type of multiple choice
question that allows the student to select more than one choice.Answer recapsthat display a read-only summary of a user's
answer to a free-form question asked earlier in the course.Progression tracking, to require that the student has
completed a particular step before allowing them to complete the
next step. Provides a link to the next step to the student.Tables, which allow to present answers from the student to
free-form answers in a concise way. Supports custom headers.Dashboards, for displaying a summary of the student's answers
to multiple choice questions.DetailsThe following screenshot shows an example of a Problem Builder block
containing a free-form question, two MCQs and one MRQ:InstallationYou can install Problem Builder fromPyPIusing this command:pipinstallxblock-problem-builderFor full details, see "Open edX Installation", below.UsageSeeUsage InstructionsWorkbench Installation and SettingsPrerequisitesPython 3.5+Compiler/build tool chainPython headersMySQL development libraries and headersVirtualenvOn Ubuntu 16.04, these can be installed by runningsudoapt-getinstallbuild-essentiallibpython3-devlibmysqlclient-devvirtualenvDeveloper InstallationFor developers, you can install this XBlock into an XBlock SDK workbench's virtualenv.First, create a Python3 virtualenv:~/xblock_development$virtualenv-ppython3venv
~/xblock_development$.venv/bin/activateNow run the following commands from the problem builder repo
root to install the problem builder dependencies:(venv)~/xblock_development/problem-builder$pipinstall-rrequirements.txt(venv)~/xblock_development/problem-builder$pipinstall-rrequirements-dev.txtSwitch to the created XBlock SDK repository, install its dependencies, and
create its migrations:(venv)~/xblock_development/problem-builder$cd../venv/src/xblock-sdk(venv)~/xblock_development/venv/src/xblock-sdk$makerequirementsCreate the following configuration file inworkbench/settings_pb.py:fromsettingsimport*INSTALLED_APPS+=('problem_builder',)Testingproblem-builderin the workbench requires MySQL instead of the standard SQLite
configuration it uses. You can quickly spin up an instance of MySQL with Docker using the
following command:# -d for detach modedockerrun--rm-it-p3307:3306-eMYSQL_ROOT_PASSWORD=rootpw-eMYSQL_DATABASE=db-dmysql:5.6By default, thexblock-sdkuses the SQLite database but MySQL
can be used by specifying an environment variableWORKBENCH_DATABASESin
the following format.exportWORKBENCH_DATABASES='{"default": {"ENGINE": "django.db.backends.mysql", "NAME": "db", "USER": "root", "PASSWORD": "rootpw", "HOST": "127.0.0.1", "PORT": "3306"}}'Ensure that the database name and credentials match the ones configured in the docker container.Run this from the XBlock repository root:./manage.pymigrate--settings=workbench.settings_pbRunning the workbench./manage.pyrunserver8000--settings=workbench.settings_pbAccess it athttp://localhost:8000/.Running testsThe integration tests require a recent Firefox and geckodriver (CI
uses Firefox 70 and geckodriver 0.26). These can be installed locally for
testing if required. For example on Linux:mkdirexternalcdexternal
wgethttps://archive.mozilla.org/pub/firefox/releases/70.0.1/linux-x86_64/en-US/firefox-70.0.1.tar.bz2
tarjxffirefox-70.0.1.tar.bz2
wgethttps://github.com/mozilla/geckodriver/releases/download/v0.26.0/geckodriver-v0.26.0-linux64.tar.gz
tarxzfgeckodriver-v0.26.0-linux64.tar.gzexportPATH="$(pwd):$(pwd)/firefox/:$PATH"# now can run integration tests using this firefox versioncd..
maketest.integrationFrom the problem-builder repository root, run the tests with the
following command:maketestSee also the following for more scoped tests:makequality
maketest.unit
maketest.integrationDebugging CI FailuresSometimes it can be hard to figure out why some tests fail in the CI.
When Circle CI browser based tests fail for unknown reasons, it can be helpful to run them with VNC enabled
so that you can observe the browser (or even interact with it) while the tests are running.To enable VNC on Circle CI, first re-run the failing test with SSH enabled: in the Circle CI UI,
click the "Rerun" dropdown and select "Rerun Job with SSH". The job will be re-run with SSH enabled.
You can find the IP/port combination that lets you log into the VM with your github SSH key under the "Enable SSH"
step in the pipeline UI.SSH into the VM, forwarding the VNC port:ssh-p<port><ip-address>-L5900:localhost:5900Install the required packages:sudoapt-getinstall-yqxvfbx11vncfluxboxStart up xvfb and the VNC server:rm-f/tmp/.X$(echo${DISPLAY:-:0}|cut-b2-)-lock
Xvfb${DISPLAY:-:0}-ac-listentcp-screen01440x900x24&/usr/bin/fluxbox-display${DISPLAY:-:0}-screen0&x11vnc-display${DISPLAY:-:0}-forever-noxdamage-rfbport5900-quiet-passwdpass&You should now be able to connect to the server via VNC. On macOS, you can use the built-in VNC viewer
that you can launch by opening Finder and choosing the "Go -> Connect to Server.." from the menu.
Type inlocalhost:5900and enterpasswhen asked for the password.You are all set up to run integration tests with screen sharing enabled.
For some reason Firefox does not want to start in foreground mode when run as non-root,
so you'll have to run the tests as root.unsetMOZ_HEADLESScd/home/circleci/projectsourcevenv/bin/activate
maketestWorking with TranslationsFor information about working with translations, see theInternationalization Supportsection of theOpen edX XBlock Tutorial.Prepare your virtualenvand ensure that theTransifex authentication file(~/.transifexrc) is properly set up.Push new strings to Transifex:$makeextract_translations
$makepush_translationsTo get the latest translations from Transifex:$makepull_translations
$makecompile_translationsFor testing purposes it's faster to avoid Transifex and work on dummy Esperanto translations:$makebuild_dummy_translationsThe Transifex configuration is stored in.tx. For more information readtransifex's documentationIf you want to add a new language:Add language toproblem_builder/translations/config.yamlMake sure all tagged strings have been extracted and push to Transifex as described above.Go to Transifex and translate both of theProblem Builderand theProblem Builder JSresources.When you're done with the translations pull from Transifex as described above.Adding custom scenarios to the workbenchWithin the xblock-problem-builder repository, create thetemplates/xmland
add XML scenarios to it - all files with the*.xmlextension will be
automatically loaded by the workbench:$mkdirtemplates/xml
$cat>templates/xml/my_pb_scenario.xmlRestart the workbench to take the new scenarios into account.Upgrading from Version 1To upgrade a course from xblock-mentoring ("v1") to xblock-problem-builder
("v2"), run the following command on a system with edx-platform,
xblock-mentoring, and xblock-problem-builder installed:$SERVICE_VARIANT=cmsDJANGO_SETTINGS_MODULE="cms.envs.devstack"python-mproblem_builder.v1.upgrade"Org/Course/Run"Where "Org/Course/Run" is replaced with the ID of the course to upgrade.Open edX InstallationProblem Builder releases are tagged with a version number, e.g.v2.6.0,v2.6.5.  We recommend installing the most recently tagged
version, with the exception of the following compatibility issues:edx-platformversionopen-release/ironwood.2and earlier must use versions < 4.0.0. SeePR 262for details.edx-platformversionopen-release/eucalyptus.2and earlier must use
≤v2.6.0.  SeePR 128for details.edx-platformversionnamed-release/dogwood.3and earlier must usev2.0.0.Theedx-platformmasterbranch will generally always be compatible with the most recent Problem Builder tag.  Seethe EDXAPP_PRIVATE_REQUIREMENTS settingfor the version
currently installed onedx.org.To install new versions of Problem Builder (v3.1.3+), usepip install xblock-problem-builderor specify a version using e.g.pip install xblock-problem-builder==3.1.3. To do this on Open edX could look like:$sudo-Huedxappbash
edxapp$cd&&.edxapp_env&&../venvs/edxapp/bin/activate&&cdedx-platform/
edxapp$pipinstallxblock-problem-builder
edxapp$./manage.pylmsmigrate--settings=aws# or openstack, as appropriateThen, restart the edxapp services:$sudo/edx/bin/supervisorctlrestartedxapp:
$sudo/edx/bin/supervisorctlrestartedxapp_workers:To install old verions of Problem Builder (< v3.1.3) on an Open edX installation, choose the tag you wish to install, follow the above instructions but instead of thepip install xblock-problem-buildercommand, use:TAG='v2.6.5'pipinstall"git+https://github.com/open-craft/problem-builder.git@$TAG#egg=xblock-problem-builder==$TAG"Note that Problem Builder requiresxblock-utils.
If you are installing it into a virtualenv used by edx-platform, xblock-utils should
already be installed. But if you are installing it into another virtualenv, you may
need to first install xblock-utils manually (recent versions of it are not available
on PyPI so will not be automatically installed).SeeUsage Instructionsfor how to enable in Studio.Publishing to PyPIWhenever we tag a new version, e.g.v3.1.3and push it to GitHub, CircleCI will
build it and deploy it to PyPI automatically. For details on how this works, seethis pull request.LicenseThis XBlock is available under the GNU Affero General Public License (AGPLv3).