Prepare VPS handover: bootstrap, doctor, DB backup, systemd unit, backend deploy, operations guide; commit docs sources previously ignored

Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
This commit is contained in:
denis
2026-10-16 23:15:14 +02:00
parent fb3c539eee
commit a4df92a7c6
43 changed files with 2369 additions and 8 deletions
+44
View File
@@ -0,0 +1,44 @@
# The level editor
A built-in tool to write a level **without hand-writing YAML**, and without a server.
## Opening it
1. Run `make dev` (or open your instance).
2. In **Settings**, turn on **Author mode**.
3. Click **Open the level editor** (page `/author.html`).
Learners do not see this link while author mode is off.
!!! note "On a protected server"
If the instance has the Django backend, opening `/author.html` requires signing in (an account authorised by an
administrator in the Django administration, see [Deployment](../host/deploy.md)). Once signed
in, the editor header shows your name and a **Sign out** button (the session lasts 8 hours). Locally (`make dev`) there
is no login and no button.
## What it does
- **Forms** for the level information, steps (explanation or code exercise), tests, hints, solutions and the
mission. Each text is entered in French **and** English, side by side.
- **Live checks**: schema conformity (targeted messages), missing translations, `requires`, missing solutions,
inconsistent tests, invalid regular expressions, a reminder to generate the narration. A button jumps to the
field concerned.
- **Run the exercises**: runs each solution with the browser's **real Python**, like `make test`. The solution
must pass its tests and the starter code must not.
- **Try it**: plays the level as a learner, in the real interface (progress is never saved).
- **Export**: downloads `level.yaml` in the project's style, shows the line to add to the manifest and the next
steps. You can also **import** a file or load an existing level to edit it.
- Your **draft** is saved in the browser.
## After exporting
1. Put `level.yaml` in `levels/NN-slug/` and add the manifest line.
2. `make validate-levels` and `make test`.
3. `make voice` for narrated steps.
4. Open your merge request ([contribution flow](flow.md)).
## Limits
- Narration cannot be generated in the browser: `make voice` is needed (the editor reminds you).
- Scripted inputs are entered one per line; an empty input in the middle is possible, not in last position.
- The editor helps but does not replace review: the `make` commands remain the reference.
+49
View File
@@ -0,0 +1,49 @@
# Contribution flow
You can propose a **level**, a **fix** or a **translation**. You do not need to know how the app works inside to
write a level.
## Steps
1. **Branch**: one branch per contribution (`level-08-functions`, `fix-hint-typo`…). One level per merge request is
easier to review.
2. **Prepare**: `make install` (tools and Python engine), then `make dev` to try it in the browser
(`http://127.0.0.1:8000/`).
3. **Write** your level, preferably with the [level editor](author-editor.md), or your fix.
4. **Check**: `make ci` runs the tests, the check of **all reference solutions** with real Python, type checking
and the build. With Chromium installed, `make ci-e2e` adds the real-browser journeys.
5. **Commits**: messages in English, short, imperative ("Add level 08 functions").
6. **Propose** your contribution (pull request or merge request); the description template is in
`docs/ci/pull_request_template.md`.
7. **Review** by a maintainer (see `docs/MAINTAINERS.md`: pedagogy, tone, correctness, English version, tests,
accessibility, security), then merge.
By contributing you agree that your contribution is published under the project licence (MIT).
## Conventions
- Code, identifiers, file names and commit messages in **English**; comments in **French**.
- **4-space** indentation everywhere (tabs only for `make`).
- JavaScript: ES2022 classes and native modules, no framework without a written justification.
- Python: typed, `pyright`-clean (`make typecheck`).
- UI and teaching content **bilingual fr/en**.
- No dependency on a paid or proprietary service.
## Useful commands
| Command | Purpose |
|---|---|
| `make dev` | development server |
| `make dev-sync` | same, with the sync backend |
| `make validate-levels` | schema, manifest, translations, starter code compiles |
| `make test` | JS, Python, backend tests, level validation, narration up to date |
| `make test-e2e` | journeys in Chromium |
| `make voice` | generate the narration (Piper) |
| `make docs` | build this documentation |
| `make ci` / `make ci-e2e` | the whole verification chain |
## Voice narration
An `explain` step with `voice: true` needs its audio files (`make voice`, which downloads the voices and requires
`ffmpeg`). `make ci` fails if they are missing. If you cannot generate them, set `voice: false`: a maintainer will
enable narration before merging. Voices and licences: `levels/AUDIO-CREDITS.md`.
+106
View File
@@ -0,0 +1,106 @@
# Writing a level
A level is a **YAML** file: `levels/NN-slug/level.yaml`. The `id` must equal the folder name
(`^[0-9]{2}-[a-z0-9-]+$`). No application code to touch.
!!! tip "The easy way"
The [level editor](author-editor.md) fills this file for you, checks live and runs your solutions. This page
describes the format, to understand it or finish by hand.
## Structure
```yaml
id: 05-decide
title:
fr: Prendre des décisions
en: Making decisions
difficulty: 3 # 0 to 10
xp: 70 # granted when the mission is completed
requires:
- 04-math
steps:
- type: explain
voice: true # "Listen" button (pre-generated narration)
text:
fr: "Avec `if`, le programme choisit ce qu'il fait."
en: "With `if`, the program chooses what to do."
- type: code
starter: |
age = 15
# Show "Majeur" if age is 18 or more
instruction:
fr: "Complète le programme."
en: "Complete the program."
tests:
- kind: stdout_equals
value: "Mineur\n"
hints:
fr: ["Utilise `if age >= 18:`.", "N'oublie pas `else:`."]
en: ["Use `if age >= 18:`.", "Don't forget `else:`."]
solution: |
age = 15
if age >= 18:
print("Majeur")
else:
print("Mineur")
mission:
title: {fr: Le portier, en: The doorman}
goal: {fr: "…", en: "…"}
starter: "…"
tests: []
solution: "…"
reward_sound: success_big # success_small | success_big | level_unlocked
```
The full schema is `levels/schema/level.schema.json`. A model to copy: `levels/01-hello/level.yaml`.
## Teaching rules
- **One new notion** per step, short sentences, encouraging tone, never guilt-inducing.
- Alternate `explain` and `code` steps.
- Each `code` step: a `starter` that runs as is, an `instruction`, `tests`, `hints` (from vaguest to most precise)
and a `solution`.
- A motivating final `mission`, with a `reward_sound`.
- **French and English** for every text. Python identifiers in the code stay in English.
- Texts may contain `code` between backticks.
## Reference solutions
Every `code` step and every mission with tests must have a `solution`. `make test` runs them with real Python: it
must **pass** its tests, and the starter code must **not** pass them. For random code, test the shape of the output
(regular expression) and the use of a function (`code_contains`), not a precise value.
## Scripted inputs (`inputs`)
For a program that calls `input()`, add `inputs` to the test: the code is **replayed** in isolation, each `input()`
receiving the next value in the list. Validation is deterministic, whatever the learner actually typed.
```yaml
tests:
- kind: stdout_equals
value: "Bonjour Ada\n"
inputs: ["Ada"]
```
## Files and drawing
- Levels that read or write files must use the **`data/`** folder (the only one kept between sessions).
- Drawing levels use the `canvas` module (see [Writing and running code](../learn/code.md)) and the `drawing_*`
tests ([Validation tests](../reference/tests.md)).
## Add the level and validate
1. Add it to `levels/manifest.json` (order and `requires`).
2. `make validate-levels`, then `make test` (checks all solutions), then `make voice` if steps have `voice: true`
(commit the generated mp3 files in `levels/<id>/audio/`).
3. Propose your contribution: see the [contribution flow](flow.md).
## Security
A level **never contains code run by the application**, apart from the starter and solution shown to the learner.
Any new kind of validation is added to the engine, not to a level file.
## Accessibility
No information may be conveyed by colour or sound alone. A decorative image has an empty `alt`; a meaningful
illustration is described in the text.