CodeLab: Runnable Program Examples in the VS Code Editor
Insert program examples in C, C++, Python, Java, C#, JavaScript, Pascal and PHP into any Moodle text, write them in the code editor of VS Code and run them on a Jobe server, on the CodeLab runner or in the browser.
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.
What's New in v1.20.0
- Accessibility: Windows high contrast, more contrast and reduced motion in every panel; screen readers hear the end of a run with its output.
- From 1.17.0, AI explanations of errors: optional, with the AI provider of the site; never writes the fix. In quizzes only for questions that allow it (1.19.0).
- Also since 1.13.3: stable block ids, templates, turtle graphics for Python, the call tree of recursion, zoom and tooltips.
Core features
- The code editor of VS Code: Monaco, with syntax highlighting, line numbers, bracket matching and search.
- Typing help for every language: for Python from Jedi, for the others keywords, snippets, library functions with their parameters, and members of strings, lists and Scanner. Teachers can turn it off for a single example.
- Run on Jobe or the CodeLab runner: choose the server for running and grading, with a page that tests the servers. Rate and size limits per user.
- Interactive runs: with the CodeLab runner, programs ask for their input while they run, as in a terminal.
- Python in the browser: with Pyodide, input asks for the input while the program runs. Step goes line by line with the variables, Stop also ends an endless loop, and turtle graphics draw under the console.
- Debugger: breakpoints, Step over and out, call stack and call tree, step back and a timeline, for Python and C/C++.
- Memory view: frames and the objects their variables point to, with arrows; C and C++ pointers too, down a linked list to NULL.
- Complexity: a Python example runs for sizes n from 10 to 500, its steps are drawn beside n, n log n and n², and the growth is named.
- Flowchart bridge: with the Algorithm plugins, Python examples are drawn as flowcharts, and a flowchart opens as a CodeLab example.
- VS Code themes and phones: Light, Dark and High Contrast with Auto dark mode; a check button sends input on phones.
- Simple markup: an example is a pre element with class names and its default input, which survive Moodle's HTML cleaning.
The CodeLab plugins
- CodeLab for TinyMCE (this plugin): inserts examples in the TinyMCE editor. The other two plugins use its editor and runner.
- CodeLab filter: 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).
- A server for running programs: a Jobe server, or the CodeLab runner on your own server (open source, github.com/blagojevicboban/codelab-runner). Python in the browser works without a server.
- Hosted runner (optional): a paid plan with a monthly quota of runs, provided by the author, Boban Blagojević. Ask for a connection key at boban.blagojevic@tsp.edu.rs. Nothing requires it: Jobe, your own runner and Python in the browser work without it.
- Python in the browser: Chrome or Edge 137 or newer. Other browsers run Python on Jobe.
- CodeLab filter: install it too and switch the filter On in Site administration, Plugins, Filters, Manage filters. Without it readers see the examples as plain code.
Privacy
Programs and their input are sent to the server set by the administrator (Jobe or the CodeLab runner, own or hosted) to be compiled and run. Interactive runs, the debugger and SQL always go to the CodeLab runner, with a short-lived signed token that holds only the numeric user id; the runner keeps nothing after the session ends. Nothing is stored in Moodle. When Python runs in the browser, the browser downloads Pyodide from the address in the settings, by default the jsDelivr CDN. It does not send the program or its input there. When the administrator turns on AI explanations, the program and the messages of the console are sent to the AI provider of the site through the AI subsystem of Moodle. The plugin implements the Moodle Privacy API.
Developed by Boban Blagojević. Languages: English and Serbian (Latin and Cyrillic). It bundles Monaco Editor (MIT).
Source, documentation and issue tracker:
github.com/blagojevicboban/moodle-tiny_codelab
Licensed under the GNU GPL v3 or later.