CodeLab Viewer: Edit and Run Program Examples
Turns program examples inserted with tiny_codelab into code editors that readers can edit and run, in pages, books, forums and quiz text.
Live demo: try the CodeLab plugins on codelab.tsp.edu.rs. Look around as a guest (Python runs in the browser), or use the demo accounts teacher and student (password Demo-2026) to run every language, the debugger and SQL. Everything is reset every night.
Important: after installing, switch the filter On in Site administration, Plugins, Filters, Manage filters. Until then, readers see the examples as plain code and cannot edit or run them.
What's New in v1.11.1
- Dark output panel: with the dark theme the output below the editor is dark too, with readable status and error colours.
- From 1.11.0, flowchart: on a site with the Algorithm plugins, Python examples get a Flowchart button that draws the code as a flowchart which runs step by step, with its variables and trace table.
- From 1.10, class view: students' changed copies of an example and the result of their last run reach the teacher, who clicks Class to see them as cards, shows one large on the projector or opens it in their own editor. Separate groups are respected and the Privacy API covers the copies.
- From 1.8.0, complexity: Python examples get a Complexity button: the lines run for n from 10 to 500 are drawn beside n, n log n and n², the growth is named, and a second version can be kept on the same chart.
- Debugger: with CodeLab for TinyMCE 1.6 and 1.7 the Step panel has Step back, a timeline slider and a memory view with arrows, cells and index variables.
- From 1.5.1, toolbar in one row on phones: Run, Step and Stop on the left; restore, copy, theme and full screen as icons on the right.
- From 1.5.0, themes: readers switch between light and dark on any example; the site default and dark mode are followed.
Core features
- Run: the program is compiled and run on the Jobe server of tiny_codelab. The output appears under the editor, with an input field prefilled with the example's default input.
- Python in the browser: input asks in the console while the program runs. Step marks the line that runs next and shows the variables, with changed values highlighted. Stop also ends an endless loop.
- The reader's own copy: the reader's changes are kept in their browser, so they are still there after a reload. Restore original brings back the teacher's code.
- Fast pages: an editor is built only when its example comes near the screen. Lessons with dozens of examples stay quick.
- Copy button, and read-only examples with syntax highlighting.
The CodeLab plugins
- CodeLab for TinyMCE: inserts examples in the TinyMCE editor. The other two plugins use its editor and runner.
- CodeLab filter (this plugin): turns examples into code editors that readers can edit and run.
- CodeLab question type: programming questions graded on Jobe with tests.
Requirements
- Moodle: 4.5 LTS to 5.3 (PHP as required by your Moodle version).
- tiny_codelab: version 1.11.0 or newer, with a Jobe server in its settings. After installing, switch the filter On in Site administration, Plugins, Filters, Manage filters.
Privacy
For the class view the filter keeps the last changed copy of an example of each student with the result of its last run; the Moodle Privacy API exports and deletes these copies. The reader's copy also stays in the browser's local storage. Programs are run on the Jobe server of tiny_codelab, and Python can run in the reader's browser.
Developed by Boban Blagojević. Languages: English and Serbian (Latin and Cyrillic).
Source, documentation and issue tracker:
github.com/blagojevicboban/moodle-filter_codelab
Licensed under the GNU GPL v3 or later.