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
- 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:
- 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 the i18n
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: - Mark translatable strings using the
trans
and blocktrans
tags, as described in the Django documentation. - Extract and generate the translation
.po
and .mo
files in your XBlock's translations
directory, as described in the XBlock tutorial.
- If your XBlock renders its UI using strings defined in Javascript:
- 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