Content format 1
An Astrolabe exercise is HTML: one <astl-doc> root, optional pages, rich text and component elements. Authors (and
agents) write the source, which contains the answers. The engine compiles it into a public view without
answers, a private answer key and public metadata.
<astl-doc lang="en"> <astl-page id="warm-up" label="Warm-up"> <p>An elephant is <astl-gap id="g1" answer="grey"><astl-alt>gray</astl-alt></astl-gap>.</p> <astl-choice id="q1" multiple> <astl-prompt>Which animals are mammals?</astl-prompt> <astl-option id="a" correct>Otter</astl-option> <astl-option id="b">Trout</astl-option> <astl-option id="c" correct>Mole</astl-option> </astl-choice> </astl-page> <astl-page id="numbers" label="Numbers"> <p>Half of one is <astl-gap id="g2" type="number" answer="0.5"></astl-gap>.</p> </astl-page></astl-doc>The same file works in both usage modes: paste it into a page with astrolabe.js and it grades in the browser
(answers visible in the page source), or compile it on a server and ship only the view (see the guides).
Document
Section titled “Document”| Element | Attributes | Content |
|---|---|---|
<astl-doc> |
lang (required, BCP 47), format (optional, 1), dir (optional, as in HTML but without auto; default from lang), kind (optional, exercise or book; default exercise), style (Authors' styles) |
<astl-page> elements only, or flow content (= one implicit page) |
<astl-page> |
id (required), label (optional, shown as the page heading), check (optional boolean: its own Check in practice, see Help for students), style |
flow content; pages do not nest |
- Exactly one
<astl-doc>; whitespace and comments around it are ignored. Before its content it may hold named styles. - Do not mix pages and loose content at the top level (
DOC_MIXED_PAGES). langis required (DOC_LANG_MISSING). Text in another language goes in<span lang="en">.kindis how the document shows, never how it grades:exercise(the default) one page at a time;booktwo pages side by side (1-2, 3-4, ...) once the player is at least 56rem wide, one page at a time narrower (Books). Another value isATTRIBUTE_INVALID.- Limits: at most 1,000,000 characters (UTF-16 code units,
SOURCE_TOO_LARGE), at most 256 attributes on one element (SOURCE_TOO_COMPLEX) and at most 100 levels of nested elements, counting<astl-doc>as level 1 (SOURCE_TOO_DEEP). They stop validation before anything else is checked, and they are enforced before or while parsing, so no input can make the HTML parser slow. The attribute check reads tag-shaped text anywhere, also inside comments and scripts, so it never misses a real tag.
- Pattern
[A-Za-z][A-Za-z0-9_-]{0,63}, unique in the document (ID_INVALID,ID_DUPLICATE). - Pages, components and Check elements need an id. Child ids (such as option ids) are local to their component and unique inside it.
- Editors assign ids; the engine never invents them, so answer keys stay stable across edits.
- Views never contain source ids: every id becomes an opaque id (
k+ 16 base32 characters) derived with HMAC-SHA-256 from the host secret, the compile salt and the source id.
Rich text
Section titled “Rich text”The allow-list of @astl/core (generated from content.ts):
| Kind | Elements | Attributes |
|---|---|---|
| Blocks | p, h2, h3, h4, ul, ol, li, blockquote, hr |
start on ol |
| Picture with a caption (a block) | figure: one img and at most one figcaption |
none |
| Table (a block) | table, caption, thead, tbody, tr, th, td, at most 12 columns and 50 rows; see Tables |
scope, colspan, rowspan on th; colspan, rowspan on td |
| Inline | strong, em, b, i, u, s, sub, sup, code, mark, span, a, br, img |
href on a; src, alt, width, height on img |
Every element above also takes lang, dir, style (as in HTML).
hrefonagoes through the URL policy (http:,https:,mailto:by default); the picture attributes onimgare explained below.- A list item holds text or paragraphs (the editor writes every item's text in a
<p>). Both look the same: an item's first paragraph starts on its marker's line, also with the marker inside (list-style-position: inside), and paragraphs add no space between items. - Removed together with their content (warning
ELEMENT_REMOVED):script,style,template,iframe,object,embed,noscript,svg,math,video,audio,form,input,select,textarea,button. Video and audio come as components. - Other HTML elements are unwrapped: the element goes, its content stays (warning
ELEMENT_REMOVED). - Unknown custom elements (a tag with a hyphen that no registered component declares) are errors
(
ELEMENT_UNKNOWN): a typo or a missing component must not be silently dropped. styleis kept as far as an allow-list says, on every element (Authors' styles);classnames a style of the document (Named styles).- Other attributes (
on*,data-*, ...) are removed (warningATTRIBUTE_REMOVED). - Comments are removed.
Pictures
Section titled “Pictures”<figure> <img src="https://assets.example.org/tree.svg" alt="An old apple tree in a meadow" width="320" height="200"> <figcaption>Many animals live in and around <strong>trees</strong>.</figcaption></figure><p><img src="https://assets.example.org/robin.svg" alt="A robin" width="72" height="48"> A robin lays its eggs in a <astl-gap id="robin" answer="nest"></astl-gap>.</p><img>is inline: it sits in text, headings, list items, links and captions, and in the rich children of components (prompts, options, cards), so they can show pictures. Text-only children (accepted alternatives) drop it (ELEMENT_REMOVED).srcis required and goes through the URL policy. A missing address (ATTRIBUTE_REQUIRED) or one the policy blocks (URL_BLOCKED, an error here, a warning for links) stops the compile: a picture without its address cannot be shown. The default policy accepts absolutehttp:andhttps:addresses; relative paths need a wider policy.altis required (IMG_ALT_MISSING): describe what the picture shows, without giving an answer away.alt=""marks a decorative picture, which screen readers skip.widthandheightare optional positive integers (ATTRIBUTE_INVALIDotherwise): the space in pixels the picture takes while it loads. It scales down to the width of the column and keeps its aspect ratio.- Besides
styleandclass, as on any element, nothing else stays:srcset,loading,titleand event handlers are removed (ATTRIBUTE_REMOVED). The player addsloading="lazy"anddecoding="async". <figure>is a block for a picture with a caption: directly on a page (or in the document, or in a column of a layout), like a block component (PLACEMENT_INVALIDelsewhere). It holds exactly one<img>and at most one<figcaption>, before or after it, and nothing else (FIGURE_INVALID). In a prompt, an option or a card a figure is unwrapped (ELEMENT_REMOVED): use an<img>there, the option's text is its caption.<figcaption>holds rich inline text, inline components included (a gap in a caption). Outside a figure it is unwrapped.- The player shows a picture in text as
display: var(--astl-picture-display, inline), never wider than its column; a picture in a figure is always a block. A component that puts the pictures of a child on lines of their own (the picture of a card above its label, as thecardsvariant of<astl-choice>does) sets--astl-picture-display: blockon that child from its shadow root: its own CSS cannot reach the pictures inside. - In HTML with answers the browser may fetch the pictures of the source as the page loads, before the engine checks them: the source is part of the page.
Horizontal rules
Section titled “Horizontal rules”<p>The sun comes up in the <astl-gap id="sunrise" answer="morning"></astl-gap>.</p><hr><p>The moon shines at <astl-gap id="moon" answer="night"></astl-gap>.</p><hr style="border-top: 3px dashed #2f6bd8; width: 50%"><hr>is a block that holds nothing, wherever a paragraph may be: a page, the document, a column of a layout, a rich block such as a callout, the help for students. In a prompt, an option or a card it is removed (ELEMENT_REMOVED). Screen readers read it as a separator.- The player draws it as a thin line in the muted ink colour, as wide as its column. The line is its top border, so
the author's border styles are its look:
border-top(orborder-block-start) for its colour, style and width,widthfor a shorter rule, which stays centred, andmarginfor the space around it. Acolorchanges the line too. A tag's rule (<astl-style for="hr">) and named styles reach it as any element. - In the dark theme its line keeps at least 3:1 on its ground, the minimum for graphics that carry meaning; in
hcit takes the text colour (Authors' styles).
Badges
Section titled “Badges”<h2><astl-badge id="lesson" shape="shield" palette="1">7</astl-badge> The planets</h2><p>Level <astl-badge id="level-a" palette="2">A</astl-badge>: the largest planet is <astl-gap id="largest" answer="Jupiter"></astl-gap>.</p><figcaption><astl-badge id="new" shape="tag" fill="soft">new</astl-badge> The inner planets.</figcaption><astl-badge>is a number or a short text in a shape: a lesson number in a shield, a level pill, a tag. It sits in text where an inline component may (a paragraph, a heading, a list item, a quote, a caption, help, the text of a rich block such as a callout), never in a link or in a component's children (a prompt, an option): there it isPLACEMENT_INVALIDand its text stays as text.- It holds plain text: formatting in it goes (
ELEMENT_REMOVED), its text stays. More than 24 characters isBADGE_TOO_LONG(a warning): it shows whole, wrapping inside when it is wider than its line. idis required, as on any element an editor selects (ID_MISSING,ID_DUPLICATE); no view holds it.shape:pill(the default),circle,square(both as tall as they are wide, whatever the text size),shield,tag(pointed at the start).fill:solid(the default),soft(a tint),outline.palette: 1 to 8, the author palette; without it, the look's accent. Another value isATTRIBUTE_INVALID.- Its size follows the text around it (a heading's badge is larger), never under the small text size. Its text keeps
4.5:1 on its fill in the light and the dark theme; in
hcit has no fill, and its line and text take the text colour. Screen readers read it as part of the line. styleandclasswork on it as on any element, and so does a tag's rule (<astl-style for="astl-badge">).
Authors' styles
Section titled “Authors' styles”<h2 style="color: #2f56d9; text-align: center">Animal homes</h2><figure style="float: right; width: 40%; margin: 0 0 8px 16px">...</figure><p style="background-color: #fff8e1; padding: 8px 12px; border-left: 4px solid #b58900">Bees live in a <astl-gap id="bees" answer="hive" style="font-weight: 700"></astl-gap>.</p>style works on every element of rich text, a picture, a figure and its caption, a component and its children, a page,
the document, a layout, a frame and a task. Each declaration is checked by property and by value. What is not in the table goes, one
declaration at a time (warning STYLE_REMOVED, naming the property); the rest of the style stays. Lengths may be
px, pt, em or rem (1em counts as 16px, 1pt as 4/3 px) and the bounds are in px.
| Property | Values and bounds |
|---|---|
color |
#rgb, #rrggbb, with alpha too, rgb(), rgba(), var(--astl-palette-1) to -8, and -soft, currentcolor; alpha at least 0.4; no named colours |
background-color, background (a colour only) |
as color, any alpha, and transparent |
font-family |
at most 8 names of at most 64 characters: letters, digits, spaces, _, - |
font-size |
xx-small to xx-large, 10 to 96 px, 62.5% to 600% |
font-weight, font-style |
normal, bold, bolder, lighter, 100 to 900; normal, italic, oblique |
text-decoration, -line, -style, -color |
lines, solid, double, dotted, dashed, wavy, a colour |
text-align, text-indent, text-transform |
left, right, center, justify, start, end; 0 to 64 px, 0 to 25%; none, uppercase, lowercase, capitalize |
line-height, letter-spacing |
normal, a number from 0.8 to 4, 8 to 160 px, 80% to 400%; normal, 0 to 16 px |
margin and its sides |
auto, 0 to 128 px, 0 to 50% |
padding and its sides |
0 to 64 px, 0 to 25% |
border and its sides, -width, -style, -color |
thin, medium, thick, 0 to 16 px; none, hidden, solid, dashed, dotted, double, groove, ridge, inset, outset; a colour (border-image only as none, which browsers write with border) |
border-radius and its corners |
0 to 128 px, 0 to 50% |
box-shadow |
none, or at most 3 shadows: offsets 0 to 32 px, blur 0 to 64, spread 0 to 16, inset, a colour |
width, inline-size, max-width, max-inline-size |
auto (none for a maximum), 8 to 1200 px, 1% to 100% |
float, clear |
none, left, right, inline-start, inline-end; and both |
display, vertical-align |
block, inline, inline-block; baseline, top, middle, bottom, sub, super, text-top, text-bottom |
list-style, -type, -position |
none, disc, circle, square, decimal, decimal-leading-zero, lower-alpha, upper-alpha, lower-latin, upper-latin, lower-roman, upper-roman, lower-greek; inside, outside |
gap, column-gap, row-gap |
normal, 0 to 64 px, 0 to 10% |
align-items, flex-grow |
normal, stretch, start, end, center, baseline, flex-start, flex-end; 0 to 12 |
- Nothing else stays: not
position,transform,z-index,opacity,filter,overflow,visibility,content,cursor,pointer-events,clip-path,mask,animation,transitionorbackground-image, and in no valueurl(),image-set(),expression(),@, comments, backslash escapes,!important, custom properties, any othervar()or a negative length. - A style of more than 2000 characters is removed whole (warning
STYLE_TOO_LONG). STYLE_LOW_CONTRASTwarns about text below 4.5:1, on each element wherecolororbackground-coloris declared, once per pair of colours, against the light theme's page where the other colour is not declared (the optiongroundColors, whichcreateEngineanddefineEditorof@astl/astrolabepass; without it, only colours declared together). Palette colours andcurrentcolorhave no value to compare and are skipped.- A style stays in the view, and the player checks it again. The module that does it loads only for a view with a style
or a layout; without it (a chunk that fails to load) the style goes and the exercise plays. It writes through the
CSSOM, so a strict CSP (
style-src 'self') allows it, and it changes what it writes in four ways:- colours follow the theme:
light-dark(as written, the lightness inverted), text keeping at least 4.5:1 on its ground in the dark, and the line of a horizontal rule 3:1. Inhc, authors' colours are off, sizes and layout stay. Palette colours stay as they are; - a font size is clamped to 10 to 96 px, because relative sizes compound through nesting;
- no width passes its column, whatever is nested in it, so a page never scrolls sideways;
- in a player narrower than 30rem floats and side margins give way, so a phone reads one column.
- colours follow the theme:
- On a page of HTML with answers the source is part of the page, so the browser itself reports each of its
styleattributes under a strict CSP, before the engine sees them. Nothing is drawn from them, and the player draws what the allow-list keeps: to have no reports, keep the source out of the page (HTML + backend).
Layouts
Section titled “Layouts”<astl-columns style="gap: 24px; align-items: center"> <astl-column style="flex-grow: 2"> <p>Which of these lives in a tree?</p> <astl-choice id="q1">...</astl-choice> </astl-column> <astl-column> <figure>...</figure> </astl-column></astl-columns><astl-columns>goes directly on a page, in the document, or in a frame or a task that is in no column, and holds 2 to 4<astl-column>, nothing else; a column holds rich blocks, figures, block components, frames and tasks (COLUMNS_INVALIDotherwise, also for a layout in a column however deep or a column outside one, andPLACEMENT_INVALIDfor a layout inside a component or a rich block).- Columns wrap by themselves: a phone gets one column, in reading order. A layout starts below a floated picture, not
squeezed beside it. Their settings are styles:
gapandalign-itemson the layout,flex-growon a column. <astl-match>has a child of the same name: in a match,<astl-column>is the match's.
Tables
Section titled “Tables”<table> <caption>Rocky planets</caption> <thead><tr><th scope="col">Planet</th><th scope="col">Moons</th></tr></thead> <tbody> <tr><th scope="row">Venus</th><td style="text-align: right"><astl-gap id="venus" type="number" answer="0"></astl-gap></td></tr> </tbody></table>- A table is a block wherever a figure may be: a page, the document, a column, a frame, a task, a rich block, help.
Its
caption(optional, first) holds rich inline text; then rows (tr) in a head (thead, optional, once, before the bodies) and bodies (tbody); a row holds cells,th(a header, withscope:row,col,rowgroup,colgroup) andtd, both withcolspanandrowspan. A header cell holds inline content: text, formatting, pictures and inline components, which keep their ids and slots as anywhere (a block in it is unwrapped,ELEMENT_REMOVED). A data cell holds the same and rich blocks (paragraphs, lists), and one block component, a question standing in the cell (a choice, true or false, a long answer), text before it if any; a second one, or one in a header cell or deeper in a cell, isPLACEMENT_INVALID. No frame, figure, layout or table goes in a cell. - The source is read as a browser reads it: a cell outside a row gets its row, rows written directly in a table a body,
and text or a block between rows goes before the table. What stays broken is
TABLE_INVALID: parts out of order (a head after a body, a caption after rows), parts the format has not (tfoot,colgroup), rows that cover different columns, a span past the rows of its part, no rows at all. At most 12 columns and 50 rows (TABLE_TOO_LARGE); a span is a whole number up to those (ATTRIBUTE_INVALID). - Authors' styles apply to the table, its rows and cells (borders, background, padding,
text-align,vertical-align, andborder-collapseandborder-spacingfor rounded corners); a rulefor="th"styles every header cell. In a table in a prompt, an option or a card (inline content), its parts go and its text stays. - The player draws it as wide as its column, its head tinted and its row headers lighter, in high contrast with lines only. A table too wide for its column scrolls sideways in a box of its own, never the page: when it cannot fit even wrapped tight it gets more room, as wide as its content wants up to a third more than that tightest layout, with a fading edge where there is more to see; the box is then a stop of the keyboard (a region named by the caption, else "Table"), so the arrows scroll it. Fields in its cells keep their size and their words whole, and scroll with it; a question in a cell keeps the width it works at (10em at least), its row as tall as it is.
Frames
Section titled “Frames”<astl-box title-place="border" variant="soft" icon="book" palette="2"> <astl-box-title>Work with the text</astl-box-title> <astl-box-tag>worksheet</astl-box-tag> <p>Read the story, then answer.</p> <astl-choice id="q1">...</astl-choice></astl-box><astl-box>groups text and components under a title: a "work with the text" box, a review card, a project sheet. It goes directly on a page, in the document, in a column of a layout or in a task, and nowhere else (PLACEMENT_INVALID: not in a component, a rich block, help or text). A frame in a frame isBOX_NESTED, however deep, and what it holds is still checked. It may hold a layout, but not in a column: two layout levels at most.- Its first child may be
<astl-box-title>, then<astl-box-tag>, a second, outlined part of the title ("WORKSHEET"). Both hold text with formatting, a badge or a picture, whosealtnames the frame when it is the title; not a component. Elsewhere either isPLACEMENT_INVALID. Then the frame holds what a page holds: rich blocks, figures, block components, layouts, tasks and Check elements. - Its questions grade exactly as outside it, a Check element in it checks as on a page, and the Check of a question in it stays in it.
title-place:inside(the default, at the top inside),border(on the top border),pill(a pill across the top edge),tab(a tab above it).variant:outline(the default),soft(a tint, no border),card(the surface colour with a soft shadow, for tinted pages).icon, before the title:info,tip,warning,book,pencil,checklist,star.palette: 1 to 8, the author palette, for its border, title and tint; without it, the look's accent. Another value isATTRIBUTE_INVALID.- With a title it is a region named by the title's words (not its tag), or by its picture's
alt; without one, no landmark. Each title place works on a 320 px phone: a long title wraps, growing down into the frame, never over what is above it. Text on a filled title (a pill, a tab) keeps 4.5:1; inhca frame keeps its colours, with a border for a card. styleandclasswork on it, its title and its tag as on any element: another border, a radius, a shadow. So does a tag's rule (<astl-style for="astl-box">).<astl-callout>stays as it is, for rich text only.
<astl-doc lang="en" task-numbering="doc"> <astl-task id="planets" level="2" check> <astl-instruction><strong>Read</strong> the sentences and <strong>finish</strong> them.</astl-instruction> <astl-tag icon="pair">in pairs</astl-tag> <astl-subtask level="A"><p>The Earth goes round the Sun in a <astl-gap id="year" answer="year"></astl-gap>.</p></astl-subtask> <astl-subtask level="B"><p>The Moon is the Earth's <astl-gap id="moon" answer="satellite"></astl-gap>.</p></astl-subtask> </astl-task></astl-doc><astl-task>is a numbered exercise of a page: its number in a circle, its instruction, its tags, its lettered sub-tasks and what it holds. It goes directly on a page, in the document, in a column or in a frame, and nowhere else (PLACEMENT_INVALID); a task in a task isTASK_NESTED, and what it holds is still checked. Itsidis required (ID_MISSING): its Check is addressed by it.- Its first child may be
<astl-instruction>(text with formatting, a badge or a picture; not a component), then up to 3<astl-tag>s, short labels with an optionalicon(pair,group,notebook). Out of place, each isPLACEMENT_INVALID. Then it holds what a page holds, and<astl-subtask>s among it: each a part lettered a), b), c) by the player, a page's content in it, withlevelAtoDfor a level pill. Levels change nothing in grading. - Its number: the document's
task-numberingsays how tasks count,page(the default: from 1 on each page),doc(through the document) ornone. A task's ownnumber(a whole number from 1) is its number, and the tasks after it count on from it. The engine writes each number into the view. level1 to 3 is a difficulty mark, that many stars, which a screen reader hears in words ("harder task" for 2).palette1 to 8 colours its number; without it, the look's accent. Another value isATTRIBUTE_INVALID.check: one Check for every graded question in the task, at its end ("Check the task"), as a Check element for them would be; its questions have no Check of their own. The view holds it as a Check element at the end of the task. A task with nothing to check isCHECK_EMPTY(a warning).- It is a region named by its number ("Task 3" in the player's language), its instruction its description; the number itself is not read twice. On a phone the number stands beside the instruction, which runs under it.
styleandclasswork on it and on its parts as on any element, and so does a tag's rule (<astl-style for="astl-task">).
Named styles
Section titled “Named styles”<astl-doc lang="en"> <astl-style name="note" label="Note box" style="padding: 8px; border-left: 4px solid #b58900"></astl-style> <astl-style for="h3" style="color: #2f56d9"></astl-style> <astl-style for="astl-doc" style="font-family: Georgia, serif"></astl-style> <p class="note">Bees live in a <astl-gap id="bees" answer="hive"></astl-gap>.</p></astl-doc><astl-style>comes first in<astl-doc>(PLACEMENT_INVALIDanywhere else), at most 100 of them. It hasnameandlabel, a style applied withclass, orfor, a tag that gets it everywhere (astl-docandastl-pagetoo, and a tag that is also a child of a component reaches that too:for="astl-column"reaches the columns of a match).- A name has letters, digits,
-and_, starts with a letter and does not start withastl-,tiptaporprosemirror(STYLE_NAME_INVALID). - The engine writes rules into each element, per property: the tag's rule, then the classes in order, then the
element's own
style. A view holds onlystyle: noclass, no<astl-style>. A class nothing defines gets a warning (STYLE_UNKNOWN), and at most 1,000,000 characters of styles may be written this way (STYLE_TOO_LARGE). classis not kept for anything else: it never reaches the view, and the editor keeps it only in the source.
Components
Section titled “Components”Every component is a custom element declared by a ComponentManifest (@astl/core). The manifest lists its
attributes, children, scoring modes and issue codes; each built-in has a page generated from it, linked below.
Elements
Section titled “Elements”Every built-in component and the children it declares (generated from the manifests):
| Component | Display | Holds |
|---|---|---|
<astl-audio> |
block, on a page | <astl-transcript> |
<astl-callout> |
block, on a page | rich content |
<astl-categorise> |
block, on a page | <astl-prompt>, <astl-category>, <astl-card> |
<astl-choice> |
block, on a page | <astl-prompt>, <astl-option> |
<astl-crossword> |
block, on a page | <astl-prompt>, <astl-crossword-word> |
<astl-drop> |
inline, in text | no children |
<astl-flash-cards> |
block, on a page | <astl-front>, <astl-back> |
<astl-gap> |
inline, in text | <astl-alt> |
<astl-hotspot> |
block, on a page | <astl-prompt>, <astl-hotspot-region> |
<astl-image-drop> |
block, on a page | <astl-prompt>, <astl-image-drop-zone>, <astl-image-drop-label> |
<astl-image-label> |
block, on a page | <astl-prompt>, <astl-image-label-pin> |
<astl-long-answer> |
block, on a page | <astl-prompt> |
<astl-mark-words> |
block, on a page | rich content, with <astl-prompt>, <astl-mark-word> inline in its text |
<astl-match> |
block, on a page | <astl-prompt>, <astl-row>, <astl-column> |
<astl-memory> |
block, on a page | <astl-prompt>, <astl-card-a>, <astl-card-b> |
<astl-order> |
block, on a page | <astl-prompt>, <astl-item> |
<astl-select> |
inline, in text | <astl-option> |
<astl-true-false> |
block, on a page | <astl-prompt>, <astl-statement> |
<astl-video> |
block, on a page | no children |
<astl-word-bank> |
block, on a page | <astl-word> |
<astl-word-search> |
block, on a page | <astl-prompt>, <astl-search-word> |
Their children, which never stand on their own:
| Child | Inside | Visibility | Attributes |
|---|---|---|---|
<astl-alt> |
<astl-gap>: 0 to 20, plain text |
private | none |
<astl-back> |
<astl-flash-cards>: 1 to 50, plain text |
public | none |
<astl-card> |
<astl-categorise>: 2 to 24, inline content |
public | id (public, required), category (private, required) |
<astl-card-a> |
<astl-memory>: 2 to 15, inline content |
public | id (public, required) |
<astl-card-b> |
<astl-memory>: 2 to 15, inline content |
public | id (public, required), pair (private, required) |
<astl-category> |
<astl-categorise>: 2 to 6, inline content |
public | id (public, required), palette (public) |
<astl-column> |
<astl-match>: 2 to 8, inline content |
public | id (public, required) |
<astl-crossword-word> |
<astl-crossword>: 1 or more, inline content |
public | id (public, required), answer (private, required), row (public, required), column (public, required), direction (public, required), number (derived), length (derived) |
<astl-front> |
<astl-flash-cards>: 1 to 50, inline content |
public | none |
<astl-hotspot-region> |
<astl-hotspot>: 2 to 30, plain text |
public | id (public, required), shape (public), x (public), y (public), width (public), height (public), r (public), points (public), label (public), correct (private) |
<astl-image-drop-label> |
<astl-image-drop>: 1 to 30, inline content |
public | id (public, required) |
<astl-image-drop-zone> |
<astl-image-drop>: 1 to 20, plain text |
public | id (public, required), x (public), y (public), width (public), height (public), label (public), answer (private, required) |
<astl-image-label-pin> |
<astl-image-label>: 1 to 20, plain text |
public | id (public, required), x (public, required), y (public, required), label (private, required), alternatives (private) |
<astl-item> |
<astl-order>: 3 to 20, inline content |
public | id (public, required) |
<astl-mark-word> |
<astl-mark-words>: 1 to 100, inline content, anywhere in its text |
public | id (public, required), correct (private) |
<astl-option> |
<astl-choice>: 2 to 12, inline content<astl-select>: 2 to 50, plain text |
public | id (public, required), correct (private) |
<astl-prompt> |
<astl-categorise>: 0 to 1, inline content<astl-choice>: 0 to 1, inline content<astl-crossword>: 0 to 1, inline content<astl-hotspot>: 0 to 1, inline content<astl-image-drop>: 0 to 1, inline content<astl-image-label>: 0 to 1, inline content<astl-long-answer>: 0 to 1, inline content<astl-mark-words>: 0 to 1, inline content, anywhere in its text<astl-match>: 0 to 1, inline content<astl-memory>: 0 to 1, inline content<astl-order>: 0 to 1, inline content<astl-true-false>: 0 to 1, inline content<astl-word-search>: 0 to 1, inline content |
public | none |
<astl-row> |
<astl-match>: 1 to 12, inline content |
public | id (public, required), column (private, required) |
<astl-search-word> |
<astl-word-search>: 1 to 20, inline content |
public | id (public, required), word (private), clue (derived) |
<astl-statement> |
<astl-true-false>: 1 to 12, inline content |
public | id (public, required), answer (private, required) |
<astl-transcript> |
<astl-audio>: 0 to 1, plain text |
public | none |
<astl-word> |
<astl-word-bank>: 1 to 30, inline content |
public | id (public, required), distractor (private) |
Placement:
- Inline components (
display: inline, e.g.astl-gap) sit inside text:p,h2-h4,li,blockquote, a caption or an inline element. Not insidea. Not directly inside a page (PLACEMENT_INVALID). - Block components (
display: block, e.g.astl-choice) are direct children of a page (or of the document when it has no pages), like a<figure>. - Components never nest (
COMPONENT_NESTED). - A rich block (a manifest with
content: 'flow': a callout, a passage to select words in) wraps rich content as a page holds it: paragraphs, headings, lists, quotes, figures, formatting and pictures, but no pages (PAGE_NESTED) and no components. Its declared children are inline children of that text (the words to select): they sit where an inline component may (PLACEMENT_INVALIDelsewhere, also directly in the block), never inside one another, and theirminandmaxcount them wherever they are. A child declared withplace: 'lead'(the prompt ofastl-mark-words) is the exception: it comes first, before the content (white space aside), and nowhere else (PLACEMENT_INVALID). - A child element outside every component that declares it is an error (
CHILD_OUTSIDE); in another component's children it is not accepted (CHILD_UNEXPECTED).
Attributes
Section titled “Attributes”Common attributes (generated from @astl/core):
| Attribute | Visibility | Meaning |
|---|---|---|
id |
public, required | Source id, unique in the document. Views carry an opaque id instead. On every component. |
v |
public | Element format version. Optional in sources (absent = 1); the compiler always writes the current one. On every component. |
style-template |
public | A look by name, from the style templates the host registers (the component scope); it wins over the document's. More: Looks. On every component. |
scoring |
private | One of the manifest's scoring modes; absent = the manifest's default mode. On graded components. |
points |
private | Points of the element's scoring group. On graded components. |
Types with variants also take variant (presentation only, never grading:
Variants and versions); <astl-doc> takes style-template too, the look
of the whole exercise (Looks).
Visibility, as declared in the manifest:
- public: kept in the view;
- private: only in the answer key; never in the view;
- derived: computed by the compiler for the view (authors cannot set it).
Attribute types: string, boolean (present = true; "false" is invalid), integer, number (a dot as the
decimal separator, with optional min / max), enum, id (a local id, opaque in the view) and url. A url
attribute goes through the URL policy like a[href]: a blocked URL is removed with a URL_BLOCKED warning, an
allowed one stays in the view when the attribute is public. Manifests cannot declare lang, dir or on*
attributes.
Slot kinds
Section titled “Slot kinds”A component's answers are slots, and each slot has a kind: how its answer is compared with the key. Each component
page lists the kinds its type produces; hosts may register more (slotKinds of createEngine).
| Kind | Answer | Graded |
|---|---|---|
text |
typed text, compared with the normalisation profile (below): a gap's word, a word search's span | yes |
number |
a number in the content language's notation, within a tolerance: a number gap, an item's position | yes |
choice |
one picked value: an option's opaque id, or a fixed public value such as true or false |
yes |
flag |
"true" when an option is selected (one slot per option) |
yes |
open |
text for the teacher, at most 2000 characters | no |
- Text compares with the normalisation profile: NFC, trimmed and collapsed spaces, edge punctuation ignored,
typographic quotes and dashes folded, capital letters and diacritics as the component says (a gap's
caseandmarks). With the defaultsżółwdoes not acceptzolw, andGrey.acceptsgrey. The profile is stored in the key, so a key grades the same way forever. - Numbers accept
.and, for languages that write a decimal comma (pl,de,fr,uk, ...),,as the decimal separator; spaces may group thousands.0,5is correct foranswer="0.5"in a Polish document. Where the language groups thousands with a dot (de,es,it,pt,nl,tr, ...),1.234means 1234; elsewhere a lone dot is a decimal separator. - A gap's
answerand every<astl-alt>are at most 500 characters (GAP_ANSWER_TOO_LONG): students' answers longer than that count as unanswered (see Scoring), so a longer accepted answer could never match.
Scoring
Section titled “Scoring”Each graded component is one scoring group, or one group per part when its definition grades it in parts (a crossword's words: a square in two words counts in both), each with the component's rule and points. With n slots, c of them correct and P points:
| Rule | Max | Score | Feedback |
|---|---|---|---|
all-correct |
P | P when c = n, else 0 | group verdict, never which slot is wrong; a right component marks every slot |
per-slot |
P x n | P x c | per slot |
proportional |
P | P x c / n (exact) | per slot |
Selection slots (flags): an unselected option gets no verdict, and a group with nothing selected scores 0 with
verdict empty. A slot is unanswered when its answer is missing, empty or longer than its kind allows: 500
characters, 2000 for an open slot, counted in Unicode code points (so a Polish or an English letter counts one).
Open answers
Section titled “Open answers”Ungraded types (graded: false, scoring: null) add nothing to the maximum. A type with slotKinds: ['open'] (a
long answer) still has answers: its open slots are stored with the attempt for the teacher and never graded.
- Graded types produce graded slot kinds only, ungraded types ungraded ones only (
createEnginechecks it). - The key holds an open slot like any other (
{ "kind": "open", "group": "<the component's id>", "key": {} }), but no scoring group does: it gets no verdict and no solution, and adds nothing tomaxScore. - The metadata counts open slots in
slots(asastl-readydoes) and lists their ids inopen, so a server or a teacher's view can pick these answers out of a submission. - The player never counts an empty open answer in the hand-in confirmation. After a hand-in, a result with nothing graded says the answers went to the teacher (no score); with graded parts too, the score covers those and a line says how many answers go to the teacher. A check says answers for the teacher are not checked. With nothing graded and no open answers either (flash cards alone), a check or a hand-in says it is practice only, instead of a score.
Worked examples
Section titled “Worked examples”A gap, a long answer or a select can be a worked example: answered already, so students see what to do before they
start (example, a public attribute). A gap and a long answer show the text of example; a select shows the option
whose id it holds as chosen.
<li>cat – <astl-gap id="cats" example="cats"></astl-gap></li><li>dog – <astl-gap id="dogs" answer="dogs"></astl-gap></li>- An example has no slot: it is not graded, adds nothing to
maxScore, never counts as unanswered and needs noanswer(a gap) orcorrectoption (a select). The engine warns when one has them anyway (GAP_EXAMPLE_WITH_ANSWER,SELECT_EXAMPLE_WITH_CORRECT: the example wins) and refuses a select's example that names none of its options (SELECT_EXAMPLE_UNKNOWN). A gap's example must fit its boxes like an answer (GAP_BOXES_MISFIT). - The player shows the value written in by hand (
--astl-font-hand, a system cursive stack by default, in--astl-example-ink), read-only and never a stop of the keyboard; a gap with boxes shows a letter in each box, a long answer its box with its paper. Screen readers read "Example:" and the value ("Przykład:" in Polish). Its part isexample. The player's numbers of inline questions leave examples out.
Help for students
Section titled “Help for students”Three elements give a student help: hints on request, an explanation, and feedback texts by the verdict. They sit
directly in a graded component (its help) or directly in a page, or in <astl-doc> without pages (the page's help).
<astl-choice id="planet"> <astl-prompt>Which planet is closest to the Sun?</astl-prompt> <astl-option id="mercury" correct>Mercury</astl-option> <astl-option id="venus">Venus</astl-option> <astl-hint><p>It is the smallest planet.</p></astl-hint> <astl-hint cost="0.25"><p>It shares its name with a Roman god.</p></astl-hint> <astl-explanation><p>It orbits about 58 million km from the Sun.</p></astl-explanation> <astl-feedback when="correct"><p>Well done.</p></astl-feedback> <astl-feedback when="incorrect"><p>Think of the order of the planets.</p></astl-feedback></astl-choice>| Element | Attributes | What it is |
|---|---|---|
<astl-hint> |
cost: a share of the points, 0 to 1 (default 0, free); the editor offers free, 0.1, 0.25 and 0.5 |
One hint; a student gets them one at a time, in source order |
<astl-explanation> |
none | Why the answer is what it is, under "Why?" after a check; one per element |
<astl-feedback> |
when (required): correct, incorrect, partial or omitted |
The text for that verdict; one per verdict |
- Content. Rich text: blocks (paragraphs, lists, pictures) in a block component and on a page; text with inline
formatting in an inline component (a gap), where the HTML parser allows nothing else. Never a component, and no
style: help shows in the player's own boxes, a feedback text on its verdict's colour, so a
styleorclassin it goes with anATTRIBUTE_REMOVEDwarning, and the document's rules (<astl-style for>) do not reach it. - Costs. A hint's cost is a share of the points of the element; the costs of the hints used add up, and a score
never goes below 0. The verdict stays what the answer earned. Grading takes
hintsUsed({ [element or page id]: count }), which the checker that gave the hints keeps. A page's hints are free: the editor writes none with a cost. One with a cost (a source written for 0.1) keeps costing that share of every group on its page. - A page's check.
<astl-page check>gives the page its own Check in practice ("Check this page"): one check of all its questions at once, after which the page's feedback and explanation show. A check of one question never brings a page's help. A page with help and withoutcheckgets the same Check from the player, and a warning,PAGE_HELP_UNCHECKED; "Check this page" in the editor's page head setscheckin one click. In<astl-doc>without pages there is no page element to carry it: its page's help needs nocheckand gets no warning. - Feedback. By the element's verdict, a page's by its score (all, some or none of its points).
partialfalls back toincorrect; an element with nothing answered getsomitted. - When. The attempt policy says when help comes (
hints,checkScope,feedback,explanations; see the protocol): in practice hints on request and feedback and explanations after each check, in a test nothing until the hand-in, and then only withreveal: 'answers'. - The view keeps none of it. Compiling moves the texts into the key (
help, below); the view keeps only what is offered:hints(the costs, in order),hint-points(what each takes off in points, when one of them costs something), a bareexplanation, andfeedback(the verdicts with a text), as in<astl-gap id="kbz4..." v="1" size="8" hints="0 0.5" feedback="correct incorrect" hint-points="0 0.5"></astl-gap>. A page keepscheckas the source has it. - Issues.
HINT_COST_INVALID,FEEDBACK_WHEN_INVALID,FEEDBACK_DUPLICATEandEXPLANATION_DUPLICATEare errors; help in an ungraded component (HELP_UNGRADED) or empty (HELP_EMPTY) is a warning, and is dropped; help on a page withoutcheckis the warningPAGE_HELP_UNCHECKED, and stays. Help anywhere else isPLACEMENT_INVALID.
Checks for several questions
Section titled “Checks for several questions”In practice that checks one question at a time (checkScope: 'interaction', the default of PRACTICE_POLICY), each
question has its own Check. A Check element gives several questions one Check instead: it checks them at once, as one
check (counted once against maxChecks), and they have no Check of their own. Their hints, feedback texts and "Why?"
stay theirs, under each question.
<astl-page id="p1"> <p>She <astl-gap id="g1" answer="plays"></astl-gap> tennis every Sunday.</p> <p>My parents <astl-gap id="g2" answer="live"></astl-gap> in London.</p> <p>The bus <astl-gap id="g3" answer="leaves"></astl-gap> at eight.</p> <astl-check id="check-1" for="g1 g2 g3"></astl-check></astl-page>| Attribute | What it is |
|---|---|
id |
Required; one id namespace with pages and components |
for |
The questions it checks: ids of graded questions of its own page, space separated, block questions too. Without it, the graded inline questions of the run of text right above it |
label |
The text of its button; without it, "Check" in the player's language |
lang, dir |
Of its label |
- Where. Directly on a page, in a column of a layout, in a frame, in a task or a sub-task, or in
<astl-doc>without pages: a block of its own. Anywhere else it isPLACEMENT_INVALID. - A task's own Check (
checkon a task) checks every graded question in the task, at its end; a frame's, a task's and each sub-task's content are runs of their own, between edges. - A run of text is what lies between two blocks of a page or of a column: between block components, Check elements
and a layout's edges; a heading (
h2toh4) starts a new one, as it usually starts a new exercise. Its paragraphs, lists, quotes and pictures are one run, and its graded inline questions (gaps, dropdowns, drop zones) are its questions. - One check each. A question belongs to one Check element at most: one that a Check element before it has already
is left out of the later one, with
CHECK_TARGET_TWICE. - Automatic Checks. Where practice checks one question at a time, the questions of a run of text that no Check element has share one Check after the last of them when there are two or more: three sentences in a row with a gap each get one Check after the third. A question alone keeps its own. The player works this out as it plays, so a view compiled before 0.3 gets it too; the editor shows it after the run as "automatic", with "Make it a button", which writes the Check element there.
- Elsewhere. In a test, and in practice that checks everything at once (
checkScope: 'exercise'), Check elements do not show and there are no automatic ones. A page's own Check (check) is as before. - The view keeps each check with its questions resolved:
fornames them by their opaque ids, also where the source had nofor, andidis opaque too. A check with nothing to check is left out. - Issues, all warnings, the view leaving out what they name:
CHECK_TARGET_UNKNOWN(no element has that id),CHECK_TARGET_NOT_GRADED(not a graded question),CHECK_TARGET_OTHER_PAGE,CHECK_TARGET_TWICEandCHECK_EMPTY(nothing to check). A check without anidisID_MISSING; any other attribute goes withATTRIBUTE_REMOVED.
The compiled view is what students download. For the example above (ids shortened):
<astl-doc format="1" lang="en" dir="ltr"> <astl-page id="k7q2..." label="Warm-up"> <p>An elephant is <astl-gap id="kd3f..." v="1" size="4"></astl-gap>.</p> <astl-choice id="kx91..." v="1" multiple><astl-prompt>Which animals are mammals?</astl-prompt><astl-option id="ka0b...">Otter</astl-option><astl-option id="k55c...">Trout</astl-option><astl-option id="kr2m...">Mole</astl-option></astl-choice> </astl-page>...</astl-doc>- Pages are always explicit, with opaque ids;
format,langanddirare always written;kindonly when it is notexercise(and so inMetadata.kind), so the view of an exercise is as it was before kinds. - Private attributes and children are gone, derived attributes are added,
vis written on every component. - Every component's view is checked against its manifest before it is written:
idandvfirst, only public and derived attributes, only declared public children, rich text insideinlinechildren limited to the allow-list above, no event handler attributes, noclassand no<astl-style>, no style the allow-list refuses, every URL through the URL policy, and none of the element's private strings or private child texts (unless the author also wrote them in public content). A violation fails the compile: it is a bug in the component's definition. - The view is what a browser builds from it: when unwrapping leaves nesting the HTML parser would rebuild (a list item directly in a list item, once a table around it is gone), the compiler writes the rebuilt structure.
- The view is deterministic for (source, secret, salt): the same input gives byte-identical output and the same
viewHash(SHA-256), so views can be cached forever under/v/{viewHash}.html.
Answer key
Section titled “Answer key”{ "format": 1, "lang": "en", "viewHash": "3b1f...", "pages": ["k7q2...", "k0p1..."], "slots": { "kd3f...": { "kind": "text", "group": "kd3f...", "page": "k7q2...", "key": { "accept": ["grey", "gray"], "profile": { "form": "NFC", "space": "collapse", "case": "insensitive", "marks": "strict", "punctuation": "ignore-edge", "quotes": "fold" }, "lang": "en" } }, "ka0b...": { "kind": "flag", "group": "kx91...", "page": "k7q2...", "key": { "correct": true } } }, "groups": [ { "id": "kd3f...", "rule": "all-correct", "points": 1, "slots": ["kd3f..."], "page": "k7q2..." }, { "id": "kx91...", "rule": "all-correct", "points": 1, "slots": ["ka0b...", "k55c...", "kr2m..."], "page": "k7q2..." } ]}Keys are immutable once published: the normalisation profile is stored inside each text key, so a key grades the same way forever.
A key whose source has help also holds help, by element or page id: { "hints": [{ "html", "cost" }], "explanation": html or null, "feedback": { "<verdict>": html } }, the HTML cleaned like the view's. Only the checker reads it, to
send what the policy allows; the key of a source without help has no help.