Skip to content

CodeExerciseLesson

Generated from front/ui/catalogue/examples/CodeExerciseLesson.json

learning · interactive (ships a small web component) · no children. All components: component playground.

A code exercise (JavaScript or TypeScript): the task, the learner’s files in labelled text areas, the visible tests and their results. The code runs only in a sandboxed runner frame on the tenant content origin; results are practice grades reported through the learner session.

Rendered from the example props below with the real component. Theme: coffee · oncall · nightsky · gravity · poland · ulam · platform · open on its own

{
"component": "CodeExerciseLesson",
"props": {
"src": "https://content.localhost/runtime/code-runner/1/runner.html",
"title": "Make sum add",
"topicId": 42,
"language": "javascript",
"files": [
{
"path": "sum.js",
"content": "export function sum(a, b) {\n return 0;\n}\n"
}
],
"tests": [
{
"path": "sum.test.js",
"content": "import { sum } from './sum.js';\n\ntest('adds two numbers', () => expect(sum(1, 2)).toBe(3));\ntest('adds negative numbers', () => expect(sum(-1, -2)).toBe(-3));\n"
}
],
"timeoutMs": 5000,
"passScore": 100,
"completionRule": "on_pass",
"text": "Change `sum` so that it returns the sum of its two arguments. Press **Run tests** to check your work.",
"locale": "en"
}
}
Prop Type Required Notes
src string (href) yes The runner page on the content origin (from POST /api/code-exercises/launches/{topic}). max length 2048
title string yes Title. max length 160
topicId integer Topic id for the attempts call (omitted in a preview: nothing is tracked). ≥ 0
language "javascript" | "typescript" Language of the exercise. default "javascript"
files array of objects yes The learner’s starter files. max 20 items
files[].path string yes Relative path of the file. max length 80
files[].content string yes Starter content. max length 65536
tests array of objects yes The visible test files. max 10 items
tests[].path string yes Relative path of the test file. max length 80
tests[].content string yes Test source. max length 65536
timeoutMs integer A run is stopped after this many milliseconds. ≥ 500, ≤ 30000, default 5000
passScore integer Percentage of passing tests that completes the topic. ≥ 1, ≤ 100
completionRule "on_pass" | "on_attempt" When the topic completes. default "on_pass"
text string The task (Markdown). max length 20000
locale string Language of the interface texts. max length 16, default "en"
attempts object The learner’s attempts so far
attempts.count integer yes Attempts so far. ≥ 0
attempts.best_score integer Best score in percent. ≥ 0
id string Anchor id for in-page links (letters, digits, dashes). max length 40

What a text-only client, an unknown renderer or a plain-text channel shows for the example above.

Make sum add

A node whose props fail the schema never breaks the page: the renderer shows the plain-text fallback instead (and logs the issues in development).

{
"src": "javascript:alert(1)",
"title": "Unsafe",
"files": [],
"tests": []
}

Issues:

  • /src unsafe or empty link

Rendered as:

Unsafe

axe-core: 26 rules passed, 0 violations, 0 need manual review. Run at build time on the server-rendered HTML in jsdom. Colour contrast and layout rules need a browser and are covered by the Playwright axe scans of the reference frontend.