Native XBlocks Morning Session
Attendees |
---|
API Example: https://github.com/open-craft/problem-builder/blob/master/doc/Native%20APIs.md
Part of the Course Blocks API
What is in the XBlock API - Student View State
- Student View Data API
- Provides all the data needed to render the View
- Example of this in the Video API
- Student View User state API
- Provides all the data for the user
- Call right before loading
- Call the Xblock handler to save/submit the users state
Example - New video xblock
- Implement Student View Data
- Returns all the data you need to render the API
- Render the mobile UX from this
- Implement Student View User State to retrieve the current state
Offline mode is still a challenge
- Answers are not available to API calls are required in both directions to submit answers and grade
- Can we encrypt the answers on the device?
- Could we use JavaScript to render xBlocks rather than the Native languages?
Example / Recommended Xblock: Poll
Braden recommends if someone wants to try implementing a native (iOS or Anroid) XBlock frontend, do it for poll or survey:
Code: https://github.com/open-craft/xblock-poll
Native API docs: https://github.com/open-craft/xblock-poll#api-for-native-mobile-frontends
Current APIs available for xBlocks
Drag and Drop: https://github.com/edx-solutions/xblock-drag-and-drop-v2
What we worked on
- Setting up 1-click, Regis's: J'aime O, Cliff Dyer, Régis Behmo
- Xblock: poll running against localhost: José Antonio Gonzalez, J'aime O, Albert (AJ) St. Aubin (Deactivated), Cliff Dyer, Régis Behmo
- The process for extracting django template translations for an XBlock and building fake eo translation is still quite manual, and this would be a great thing to fix . Ideally we'd have an "xblock-extract-strings" script or similar, or change the edx-i18n-tools script to work with xblocks as well as edx-platform code
- See the JS fix to cookiecutter https://github.com/edx/cookiecutter-xblock/pull/4 for inspiratio
- Bryan Wilson, Jillian Vogel (Deactivated), Julia Eskew (Deactivated)
- Xblock native against poll: José Antonio Gonzalez, J'aime O, Albert (AJ) St. Aubin (Deactivated)
- Xblock web against poll: Amir Tadrisi, Rocio Aramberri
- API demo, follow-up documentation: Braden MacDonald
- Accessibility direction
OpenCraft's repository: demo-courses
- this contains repos with courses for xblock demos
XBlock Internationalization
Now it works!
How:
- If your XBlock renders its UI using Django templates:
- You need to use xblock-utils 1.1.1 or higher:
- The code that implements i18n for django templates is https://github.com/edx/xblock-utils/pull/48 and https://github.com/edx/xblock-utils/pull/49
- If you use master or any release post this PR, you have it already
- In order for an XBlock's template strings to be translated, the XBlock must:
- Require the
i18n
service, see e.g. xblock-drag-and-drop-v2@XBlock.needs('i18n') class MyXBlock(XBlock): ...
- Render templates using
ResourceLoader.render_django_template
, passing thei18n
service, e.g.:def studio_view(self, context): fragment = Fragment() fragment.add_content(loader.render_django_template('/templates/html/studio_edit.html', i18n_service=self.runtime.service(self, 'i18n'))
- In the HTML template, load the
i18n
template tags:{% load i18n %}
- Mark translatable strings using the
trans
andblocktrans
tags, as described in the Django documentation. - Extract and generate the translation
.po
and.mo
files in your XBlock'stranslations
directory, as described in the XBlock tutorial.
- Require the
- You need to use xblock-utils 1.1.1 or higher:
- If your XBlock renders its UI using strings defined in Javascript:
- OpenCraft implemented a fix to django-statici18n which you need: https://github.com/zyegfryed/django-statici18n/pull/41
- It's now included in django-statici18n v1.7.1, but edx-platform master is currently using 1.4.0 so you need to bump that: https://github.com/edx/edx-platform/pull/18302
- We have a PR waiting for review that adds the code you need to the XBlock cookie cutter repo: https://github.com/edx/cookiecutter-xblock/pull/4
- Example of using that in an XBlock: https://github.com/edx-solutions/xblock-drag-and-drop-v2/pull/156
- OpenCraft implemented a fix to django-statici18n which you need: https://github.com/zyegfryed/django-statici18n/pull/41
- The process for extracting django template translations and building a fake po translation for an XBlock is still quite manual, and this would be a great thing to fix
- See the JS fix to cookiecutter https://github.com/edx/cookiecutter-xblock/pull/4 for inspiration