Skip to content

Interactive exercises in plain HTML

Open-source TypeScript building blocks for interactive exercises. Write HTML with answers, play it in an accessible player, and grade it in the browser or on your server.

This exercise runs in this page. Type an answer, pick one, then press each question's "Check". The engine compiles the source in your browser and grades it there; nothing is sent anywhere.

exercise.html
<astl-doc lang="en">
<p>An elephant is <astl-gap id="g1" answer="grey"><astl-alt>gray</astl-alt></astl-gap>.</p>
<astl-choice id="q1">
<astl-prompt>How many legs does a spider have?</astl-prompt>
<astl-option id="a" correct>Eight</astl-option>
<astl-option id="b">Six</astl-option>
</astl-choice>
</astl-doc>

An elephant is gray.

How many legs does a spider have? Eight Six

The source is plain HTML with the answers in it: answer on the gap, correct on the option. The engine turns it into a public view without answers and a private answer key, so the same file also works with a backend that keeps the answers on the server.

Each one is an HTML element with its own page: attributes, scoring, issue codes, starters and a live example.

HTML with answers

One script tag, no backend. The page compiles and grades in the browser, so the answers are in the page source. Good for homework pages, blogs and quick practice. Start here.

HTML + backend

Your server compiles the source, keeps the answer key and serves only the view. The player grades through two JSON endpoints. Good for tests and anything with stakes. Start here.

Accessible by default

WCAG 2.2 AA. Every component works with the keyboard, and a verdict always shows an icon and a word, never colour alone. Accessibility.

Answers stay out of views

The engine splits a source into a view without answers and a private answer key, with opaque ids. Security.

Loads on first use

The player loads a component's code when a page first uses it: a page with only gaps downloads only the gap.

Three looks, your tokens

The default look, playful and notebook, or your own --astl-* tokens and style templates. Looks.

TipTap or your editor

<astl-editor> brings TipTap. The authoring kit also plugs into the editor you already have. Any editor.

i18n-ready

Every string comes from message catalogs, with real plural forms; the interface language and the content language are set apart. Polish and English are built in. Languages.

Checks in your pipeline

The astl CLI validates and compiles exercises and runs the conformance suite, and /llms.txt gives agents the format. The CLI.

Your own components

A component is one folder: a manifest, a definition, an element, an editor descriptor and messages. Nothing in the core changes. Start here.

Package What it does
@astl/astrolabe Everything on by default: @astl/astrolabe/engine, /player, /editor and /server with every built-in, and the script-tag bundles in dist/cdn/ (astrolabe.js grades in the browser, astrolabe-player.js plays views graded by a server, astrolabe-editor.js is the editor, astrolabe.standalone.js is all of it in one classic script).
@astl/core Contracts (TypeScript interfaces) and the i18n runtime. No dependencies.
@astl/engine Parse, sanitise, validate, compile (view, answer key, metadata) and grade. Runs in browsers, Node, Deno, Bun and Workers.
@astl/server The grading endpoint (check and submit) on the standard Fetch API.
@astl/player <astl-player>: pages, practice and test modes, snapshots, accessible chrome. No answer logic.
@astl/editor The authoring kit for any WYSIWYG editor: insert menu, inspector, issues, preview and a textarea adapter. No WYSIWYG engine.
@astl/editor-tiptap <astl-editor>: the kit around a TipTap surface, loaded only when no other editor is plugged in.
@astl/components Every built-in component, one folder per type.
@astl/tokens Neutral --astl-* design tokens with light, dark and high-contrast themes, and the built-in looks playful and notebook.
@astl/devkit The astl CLI: validate, compile, conformance.
  • Contracts first. Every boundary is a TypeScript interface in @astl/core, so each part can be swapped. Contracts.
  • One schema per component. The manifest drives validation, the view, the player, the editor and the reference.
  • No lock-in. No framework and no backend required; any editor through one adapter.