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.3
- Zoom in the code editor: Ctrl and the mouse wheel, Ctrl and plus or minus, Ctrl and 0 for the default size. All editors on the page follow and the browser remembers the size, which helps on a projector.
- Word wrap: Alt+Z turns it on and off, as in Visual Studio Code.
- Tooltips on the code: 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.
- 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
- Jobe, your own runner or a hosted runner: choose the server for running and grading, with a page that tests the servers and measures their speed.
- 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: programs are compiled and run on your server, with an input field. There is a rate limit per user and a size limit.
- Interactive runs: with the CodeLab runner, programs ask for their input while they run, as in a terminal; each session token is for one language and each site can have a secret of its own.
- 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.
- Default input: saved with the example, so readers start from it.
- Simple markup: an example is a pre element with class names, 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 (open source, github.com/blagojevicboban/codelab-runner), your own or a hosted one. Python in the browser works without a server.
- 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.