Run and edit Khan Academy Python programs offline
Overview
Khan Academy (KA) Python programs reach learners as standalone programs in the computing topic and through python-program widgets in Perseus items. The KA content integration skips the topic, and the widgets load their programs from khanacademy.org. This tracking issue covers running, editing and scoring these programs offline.
Scope
- Standalone Python programs in the
computingtopic, and programs inpython-programwidgets. - An offline Python runtime, shipped as a shared
html5_dependency. - The content integration in kolibri-library, and rendering, editing, saving learner edits and scoring in Kolibri.
Guidance
- The Perseus
python-programwidget shows the khanacademy.org URL each program loads from.
Strategy
- The runtime is upstream Pyodide with only the standard library, as KA ships it (KA's build: 0.26.3, Python 3.12.7). It ships with a CodeMirror 6 editor, which KA's Python page also uses, and a test runner that runs each step's
unittestmodules as KA's does. All three ship as one sharedhtml5_dependencyof about 14 MB. - Standalone Challenges and Projects become HTML5 nodes whose bootstrap loads the runtime with
dependencyUrl(). Widget programs go into.perseusarchives, and an embeddedContentViewerreceives them throughrequestData(). - Pyodide is tested on Chrome and Firefox 112+ and Safari 16.4+, above Kolibri's floor of Chrome 49, Firefox 52 and Safari 11.1. Python programs need a "not supported in this browser" state.
- KA's export has no challenge code, instructions or tests. Fetching them needs a
LearningEquality_*query from KA, like the existingLearningEquality_assessmentItems.
Acceptance Criteria
- [ ] A KA channel includes the standalone Python programs from the
computingtopic, and each runs offline. - [ ]
python-programwidgets run their program offline, with no standin. - [ ] Learners can edit any Python program, and each program's edits persist across sessions.
- [ ] Graded Python programs score in Kolibri.
- [ ] A device stores the Python runtime once, however many programs use it.
AI usage
I scoped this to follow #15940's approach and asked for the runtime to be investigated before writing the children. Claude Code read KA's production bundles and content export to find the runtime, editor, test runner and course contents, and drafted the sections with me.
Replaced the Strategy with the investigation results: the runtime (upstream Pyodide, standard library only, as KA ships it), CodeMirror 6 for the editor, a unittest step runner, the browser floor gap, and the KA query needed for challenge content. Updated the Overview and AI usage to match.
@rtibbles can you assign this issue for me /assign
Hi! 👋
Thanks so much for your interest! This issue is not open for contribution. Visit Contributing guidelines to learn about the contributing process and how to find suitable issues. If there are no unassigned 'help wanted' issues available, please wait until new ones are added.
We really appreciate your willingness to help. 😊
Are you preparing for Google Summer of Code? See our GSoC guidelines.