The worksheet file format - application/vnd.edufeed.worksheet+json
Von Edufeed ·
The worksheet file format
A worksheet is one JSON file. This is what the edufeed worksheet editor stores, what it uploads when a sheet is published, and what another tool has to read to draw or change a sheet.
-
Media type:
application/vnd.edufeed.worksheet+json - Encoding: UTF-8. All lengths are millimetres unless a key says otherwise.
-
The editor is in development; its source is not public yet. This article is a copy of the format description kept with that source (
docs/sheet-format.md), where the reader (parseSheet) and the block views are the reference.
How a published sheet is found and fetched (a kind 30142 event that names this file by address and SHA-256) is described in the article edufeed-editable-source, nostr:naddr1qqtk2er4vejk2epdv4jxjarpvfkx2ttnda6hycm9qythwumn8ghj7un9d3shjtn9v36kvet9vshx7un8qgstmssljwc79jm4vzxwe4aq5q9809memym8mjte30vlyylsdj2mcjqrqsqqq7rzszcrtc.
The sheet
{
"v": 1,
"title": "Brüche kürzen",
"license": "https://creativecommons.org/licenses/by/4.0/",
"basedOn": [
{
"address": "30142:<pubkey hex>:<d>",
"title": "Brüche",
"author": "Ada",
"license": "https://creativecommons.org/licenses/by/4.0/",
"url": "https://…/view/naddr1…"
}
],
"page": { "format": "A4", "margin": 20 },
"defaults": { "font": "Open Sans", "fontSize": 10.5 },
"pages": [{ "blocks": [] }]
}
| Key | Type | Meaning |
|---|---|---|
v |
number | Format version. Now 1. A reader refuses a version it does not know. |
title |
string | The sheet's title. Optional, default empty. |
license |
string | Address of the licence the sheet is shared under: CC0, CC BY or CC BY-SA (any version). Optional. For a published sheet the licence in the event counts. |
basedOn |
list | Published sheets this one was copied from or took a task from, at most 50. address is the Nostr address of the source's event, url (optional, https) where it can be looked at. A copy inherits its source's list. |
page |
object | The paper, see below. |
defaults |
object | Document-wide settings, see below. |
pages |
list | At least one page; each is { "blocks": [...] }. |
page
| Key | Type | Meaning |
|---|---|---|
format |
string | "A4" (210 × 297). |
margin |
number | Margin of every side, 0 to 100. |
margins |
object | Optional: top, right, bottom, left, each 0 to 100, overriding margin for that side. |
landscape |
boolean | Optional: the paper lies on its side (297 × 210). |
punch |
boolean | Optional: a mark at the middle of the left edge for the hole punch. |
defaults
| Key | Type | Meaning |
|---|---|---|
font |
string | Font family name: letters, digits, space, _, -; at most 60 characters. |
fontSize |
number | In points, 4 to 72. |
lang |
string | Language of the texts (de, en, …), used for hyphenation and as the event's language. |
hyphens |
boolean | Automatic hyphenation. |
gap |
object | Look of cloze gaps: style, width. |
number |
object | How tasks are counted: kind (1, a, A), look. |
meta |
object | Texts for the header's placeholders (name, date, class, …). |
pointKinds |
list | The kinds of points the sheet counts. |
A block
{
"id": "b1f3a9c2",
"type": "task",
"x": 0,
"y": 85,
"w": 170,
"h": 12,
"autoHeight": true,
"z": 1,
"rotation": 0,
"locked": false,
"data": {},
"style": {},
"rights": {
"license": "<url>",
"credit": "…",
"source": "<url>",
"x": "<sha256>",
"url": "<url>"
}
}
-
id: unique in the sheet. -
type: one of the types below. A reader draws an unknown type as a placeholder and keeps its data. -
x,y: the upper left corner, relative to the page's content box (inside the margins).w,h: size, both above 0. -
autoHeight: the block is as high as its content;his then its last measured height. -
z: layer order.rotation: degrees.locked: safe from moving and deleting in the editor. -
data: what the block says; its keys depend ontype. -
style: overrides of the block's look (fill, border, font, size, alignment, numbering, points, visibility, text wrap, …). Only the keys and values the editor's style cleaner (cleanStyle) knows are used; anything else is dropped. -
rights: only on blocks that hold a file (an image): the licence, whom to credit, the source, the file's SHA-256 (x) and its address. They are what the publisher claims; they follow the licence attestations of kind 1063 the editor writes for uploaded images. - Task numbers are not stored. They follow from the blocks' positions, top to bottom.
Rich text
Texts with formatting are ProseMirror JSON as tiptap writes it: { "type": "doc", "content": [ … ] }. Only the nodes and marks listed here are kept.
-
Nodes:
doc,paragraph,text,hardBreak,bulletList,orderedList,listItem, andformula(inline, attributetex: LaTeX). -
Marks:
bold,italic,underline,strike,code,link(attributehref:http(s):ormailto:only),sub,sup, and four of our own:-
gap: a word the pupil fills in; drawn as a blank unless solutions are shown. -
hl: underlining, attributeskind(underline,double) andcolor(text,blue,red,green,yellow). -
color: text colour, attributecolor(blue,red,green,yellow,grey). -
sol: a marking only the solution sheet shows, attributeskind(underline,double,yellow,strike) andcolor(text,blue,red,green).
-
What a reader must check
A sheet can come from a stranger. Before anything of it reaches HTML or CSS:
-
Refuse the file when it is not JSON, when
vis unknown, whentitleis not a string, whenpage.marginis not a number from 0 to 100, whenpagesis not a non-empty list, when a block has no stringidandtype, a repeatedid, a non-finitex,y,w,h,zorrotation, a size of 0 or less, ordataorstylethat is not an object. -
Refuse a
licensethat is not CC0, CC BY or CC BY-SA, and abasedOnthat is not a list of at most 50 entries with a well-formedaddress, shorttitleandauthor, an openlicenseand anhttps://url. -
Take
fontandfontSizeonly inside the limits above. -
Use a value from
dataorstylein a class name, a style or an attribute only after picking it from a list of allowed values or checking its range (the editor'spick,lookup,cleanStyleandpageBox). Anything else falls back to a default. -
Render rich text only through the schema above; link only
http(s):andmailto:addresses. -
Load images only from
https://addresses.
Block types
For each type: the keys its data starts with, as the editor creates the block. A block's form may add further optional keys; the editor's source (src/lib/blocks/<type>/) is the reference. points: null means the task carries no points yet.
abc
ABC Notation.
-
description: rich text -
abc: string
anagram
Anagramm (a task: numbered, may carry points).
-
prompt: rich text -
words: list of string -
seed: number -
points: null
arithmetic
Rechenaufgabe (a task: numbered, may carry points).
-
prompt: rich text -
rules: list of { template: string, weight: number } -
variables: list of { name: string, rule: string, min: number, max: number, decimals: number } -
columns: number -
rows: number -
seed: number -
points: null
background
Hintergrund (as large as the paper).
-
url: string -
showCaption: boolean -
cover: boolean -
opacity: number
choice-table
Auswahltabelle (a task: numbered, may carry points).
-
prompt: rich text -
columns: list of string -
rows: list of { text: string, answer: number } -
points: null
cloze
Lückentext (a task: numbered, may carry points).
-
prompt: rich text -
body: rich text -
points: null
code
Quellcode.
-
title: string -
code: string -
language: string -
showLanguage: boolean
credits
Bildnachweis.
-
title: string
crossword
Kreuzworträtsel (a task: numbered, may carry points).
-
prompt: rich text -
entries: list of { word: string, clue: string } -
showClues: boolean -
points: null
crossword-legend
KWR-Legende.
No data.
definition
Begriffsdefinition.
-
term: string -
body: rich text
dialog
Dialog (a task: numbered, may carry points).
-
prompt: rich text -
lines: list of { speaker: string, text: string } -
points: null
footer
Fußzeile.
-
rows: list of string
formula
Formel.
-
tex: string
free-points
Freie Punkte.
-
points: number
function
Funktion.
-
name: string -
expr: string
grade
Benotung.
-
label: string
grade-table
Notenspiegel.
-
title: string -
grades: list of { name: string, from: number } -
showPoints: boolean -
resultsRow: boolean
header
Kopfzeile.
-
rows: list of string
heading
Überschrift.
-
text: string -
look: string -
underline: boolean
hint
Hinweis.
-
body: rich text
image
Bild.
-
url: string -
caption: rich text -
showCaption: boolean
info-text
Informationstext.
-
body: rich text
line
Linie/Pfeil.
-
points: list of { x: number, y: number } -
start: string -
end: string -
style: string -
width: string
logo
Logo.
-
url: string -
showCaption: boolean
multiple-choice
Multiple-Choice (a task: numbered, may carry points).
-
prompt: rich text -
options: list of { text: string, correct: boolean } -
points: null
number-line
Zahlenstrahl (a task: numbered, may carry points).
-
prompt: rich text -
min: number -
max: number -
scales: list of { step: number, label: string, weight: string, dir: string, length: string } -
colorEvery: number -
values: list of string -
points: null
number-sort
Zahlen sortieren (a task: numbered, may carry points).
-
prompt: rich text -
values: list of string -
operator: string -
seed: number -
points: null
ordering
Sortieraufgabe (a task: numbered, may carry points).
-
prompt: rich text -
items: list of string -
seed: number -
points: null
pairs
Paare bilden (a task: numbered, may carry points).
-
prompt: rich text -
pairs: list of { left: string, right: string } -
seed: number -
points: null
paper
Kästchen (beschreibbar).
-
pattern: string -
size: number
plot
Math. Zeichnung.
-
xMin: number -
xMax: number -
yMin: number -
yMax: number -
show: string
points-total
Gesamtpunktzahl.
No data.
qr
QR-Code.
-
text: string -
caption: rich text -
showCaption: boolean
quote
Ausspruch.
-
body: rich text -
author: string
ruled-text
Lineatur (beschreibbar).
-
body: rich text -
spacing: number
schedule
Zeitplan.
-
title: string -
rows: list of { time: string, text: string }
sentence-order
Sätze ordnen (a task: numbered, may carry points).
-
prompt: rich text -
sentences: list of string -
seed: number -
points: null
shape
Formen.
-
shape: string -
fillColor: string -
text: string
signature
Unterschrift.
-
label: string
source-text
Textquelle.
-
prefix: string -
title: string -
body: rich text -
source: string -
lineNumbers: boolean
speech-bubble
Sprechblase.
-
body: rich text -
shape: string
sticky-note
Klebezettel.
-
body: rich text
table
Tabelle.
-
cells: list of list of object -
headerRow: boolean
task
Aufgabenstellung (a task: numbered, may carry points).
-
prompt: rich text -
points: null
text-card
Textkarte.
-
body: rich text
tree
Baumdiagramm (a task: numbered, may carry points).
-
prompt: rich text -
levels: number -
children: number -
points: null
value-table
Wertetabelle.
-
xs: list of string -
decimals: number
word-bank
Wörter zuordnen (a task: numbered, may carry points).
-
prompt: rich text -
body: rich text -
points: null
word-problem
Mathe-Textaufgabe (a task: numbered, may carry points).
-
prompt: rich text -
answer: rich text -
variables: list of { name: string, rule: string, min: number, max: number, decimals: number } -
seed: number -
points: null
word-search
Wortsuchrätsel (a task: numbered, may carry points).
-
prompt: rich text -
words: list of string -
cols: number -
rows: number -
showWords: boolean -
seed: number -
points: null
writing-area
Linien und Kästchen.
-
pattern: string -
size: number
youtube
YouTube-Video.
-
url: string -
title: rich text -
description: rich text -
showLink: boolean