Code Execution
LearnHouse runs learners' code in a sandbox through Judge0. You use it in two places:
- The Code Playground block, a coding challenge you add to any Dynamic Page from the
/menu. - The Code task type in assignments, for graded code exercises.
Both run code the same way. This page covers the Code Playground block.
Code execution needs a Judge0 instance. On self-hosted installs set LEARNHOUSE_JUDGE0_API_URL (see Environment Variables).
Supported languages
Python 3, JavaScript (Node), TypeScript, Java, C++, C, Rust, Go, PHP, Ruby, Kotlin, C#, Swift, Scala, Perl, R, Dart, Haskell, Lua, Elixir, Clojure, SQL, Bash, Objective-C, Pascal, Fortran, Prolog, Common Lisp, PowerShell and Assembly (NASM). That is 30 languages. New blocks start in Python 3.
Setting up a challenge
Insert a Code Playground block and fill in its settings:
| Setting | What it does |
|---|---|
| The language learners write in. | |
| The challenge statement. Supports Markdown. | |
| The code learners start from. | |
| Each one has a label, an | |
| A list of hints learners can open one by one. | |
| Your model solution. Revealed to learners after enough attempts. | |
| How many test runs a learner needs before the solution unlocks. Default 3. | |
| Maximum run time per execution. Default 10 seconds. | |
| The time and space complexity you expect, shown to learners. | |
| Adds a countdown timer. Set its | |
Extra files available to the learner's code, such as data.txtutils.py |
For SQL challenges you can also upload a SQLite database (.sqlite, .db or .sqlite3). Learners' queries run against it.
Locked lines and blanks
Two markers in the starter code change how learners can edit it:
- Lines between two
// --- locked ---markers are read-only for learners. - Lines between two
// --- blank ---markers become fill-in-the-blank regions: learners only fill in that part.
What learners see
Learners write code in an editor with syntax highlighting and autocomplete, then run it.
- Run:
Ctrl+Enter(Cmd+Enteron macOS). With test cases, every case runs and the block shows which passed, the output against the expected output, and a score. - Reset code:
Ctrl+Shift+R(Cmd+Shift+Ron macOS) restores the starter code. - Own test cases: learners can add their own inputs to check edge cases.
- Errors: compile and runtime errors are marked on the line they come from.
- Solution: once the attempt count is reached, learners can open the solution and compare it with their own code side by side.
- Submission history: each learner's runs are saved, so they can go back to a previous attempt. The newest 500 per activity are kept.
Code Playground results are for practice. They are not graded. For graded code, use a Code task in an assignment.
Limits
| Limit | Value |
|---|---|
| Test cases per run | 50 |
| Single runs per learner | 60 per minute |
| Test case batches per learner | 20 per minute |
| Source code size | 65,536 characters |
| Input size per test case | 65,536 characters |
| Additional files | 20 files, 131,072 characters each |
API tokens cannot run code. Execution only works for signed-in users with access to the activity.