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.14.1
- Accessibility: screen readers hear the end of a run with its output; the console scrolls with the keyboard.
- Class view: filter the copies by status, each with its count; in separate groups the teacher's students come first.
- Cleanup: a daily task deletes left-over copies and copies older than the setting Keep copies for (365 days by default).
- From 1.13.0, the same copy on every device: a changed example opens on another computer or phone too, and stays with its example when the page changes.
- From 1.12.0, AI explanations of errors: with tiny_codelab 1.17 and the AI provider of the site; never writes the fix. Off by default.
- Also through tiny_codelab: the call tree of recursion, turtle graphics for Python, zoom, tooltips and a dark output panel (1.11.1).
Core features
- Run: the program is compiled and run on the server set in CodeLab for TinyMCE, a Jobe server or the CodeLab runner. 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. Stop also ends an endless loop.
- Debugger: Step for Python and C/C++ marks the line that runs next and shows the variables, with Step back, a timeline slider, the call stack and a memory view with arrows, cells and index variables.
- Tooltips and zoom: with CodeLab for TinyMCE 1.13.3, resting the mouse on a variable while stepping shows its value, on a keyword, an operator or a printf format a short explanation, and on a number its hexadecimal, binary and octal forms. Ctrl and the mouse wheel zoom the code for a projector.
- 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.
- 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.
- 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.
- 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.
- Themes and phones: readers switch between light and dark on any example, and on phones the toolbar fits in one row.
- 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 with tests on Jobe or the CodeLab runner.
Requirements
- Moodle: 4.5 LTS to 5.3 (PHP as required by your Moodle version).
- tiny_codelab: version 1.18.0 or newer, with a Jobe server or, from 1.13, the CodeLab runner 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 and their input are sent to the server set in tiny_codelab, Jobe or the CodeLab runner, to be compiled and run, 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.