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.13.4
- Review fixes: the speed test uses Moodle's HTTP client, so proxy settings apply.
- From 1.13.3, zoom: Ctrl and the mouse wheel, plus or minus, or 0 for the default size; all editors follow, which helps on a projector. Alt+Z turns word wrap on and off.
- From 1.13.3, tooltips: rest the mouse on a variable while stepping to see its value, on a keyword, an operator or a printf / scanf format such as %5.2lf for a short explanation, and on a number to see it in hexadecimal, binary and octal.
- From 1.13.3, easier to read code: sticky scroll keeps the enclosing function and loop on top, and bracket pairs are coloured with a guide line.
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, and Stop also ends an endless loop.
- Debugger: breakpoints, Step over and out, call stack, 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. 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.