moth/docs/development.md

212 lines
5.1 KiB
Markdown
Raw Permalink Normal View History

2023-12-11 11:36:18 -07:00
Developing Content: Structure
================
2023-12-11 11:36:18 -07:00
![Content Layout](content-layout.png)
2023-12-11 11:40:21 -07:00
MOTH content heirarchy consists of three layers:
categories, puzzles, and attachments.
2023-12-11 11:36:18 -07:00
Category
-------
2023-12-11 11:36:18 -07:00
A category consists of one or more puzzles.
Each puzzle is named by its point value,
and each point value must be unique.
For instance,
you cannot have two 5-point puzzles in a category.
2023-12-11 11:36:18 -07:00
Scoring is usually calculated by summing the
*percentage of available points per category*.
This allows content developers to focus only on point values within a single category:
how points are assigned in other categories doesn't matter.
2023-12-11 11:36:18 -07:00
Puzzle
-----
2023-12-11 11:36:18 -07:00
A puzzle consists of a few static fields,
a main puzzle body,
and optionally attached files.
2023-12-11 11:36:18 -07:00
At a minimum,
a puzzle must contain `puzzle.md`:
a
[CommonMark Markdown](https://spec.commonmark.org/dingus/)
file with metadata.
2023-12-11 11:36:18 -07:00
Example:
2023-12-11 11:36:18 -07:00
```markdown
---
authors:
- Neale Pickett
answers:
- one of its legs are both the same
- One of its legs are both the same
- one of its legs are both the same.
- One of its legs are both the same.
---
2023-12-11 11:36:18 -07:00
This puzzle consists of a joke.
2023-12-11 11:36:18 -07:00
What is the difference between a duck?
```
2023-12-11 11:36:18 -07:00
### Puzzle Metadata
2023-12-11 11:36:18 -07:00
Puzzle metadata is the section of `puzzle.md` between `---`.
This section consists of [YAML](https://yaml.org/),
describing various metadata aspects of the puzzle.
2023-12-11 11:36:18 -07:00
At a minimum,
each puzzle should contain:
2023-12-11 11:36:18 -07:00
* authors: who created the puzzle
* answers: a list of answers that are considered "correct"
2023-12-11 11:36:18 -07:00
Other metadata a puzzle can contain:
2023-12-11 11:36:18 -07:00
* debug: information used only in development mode
* summary: text summarizing what this puzzle is about
* notes: any additional notes you think it's important to record
* hints: a list of hints that could aid an instructor
* objective: what the goal of this puzzle is
* ksas: a list of NICE KSAs covered by this puzzle
* success: criteria for success
* acceptable: criterion for acceptably succeeding at the task
* mastery: criterion for mastery of the task
* attachments: a list of files to attach to this puzzle (see below)
2023-12-11 11:36:18 -07:00
### Body
2023-12-11 11:36:18 -07:00
The body of a puzzle is interpreted as
[CommonMark Markdown](https://spec.commonmark.org/dingus/)
and rendered as HTML.
2023-12-11 11:40:21 -07:00
Attachments
-------
2023-12-11 11:36:18 -07:00
Any filenames listed under `attachments` in the metadata will be included
with the puzzle.
2023-12-11 11:40:21 -07:00
Usually,
these are listed at the bottom of each puzzle,
one by one.
But you can also refer to attachments from the puzzle body
with either links or inline images.
```markdown
This is a [link](attachment-document.html).
And this is an inline image: ![alt text](attachment-image.png)
```
2023-12-11 11:36:18 -07:00
Developing Content: Source vs Mothballs
=============================
2023-12-11 11:36:18 -07:00
As a developer,
you will begin by running MOTH in development mode.
In development mode,
MOTH will provide answers for each puzzle alongside the puzzle.
2023-12-11 11:36:18 -07:00
In order to run in production mode,
each category must be "transpiled" into a "mothball".
This is done to reduce the amount of dynamic code running on a production server,
as a way of decreasing the attack surface of the server.
2023-12-11 11:36:18 -07:00
To obtain a mothball,
simply click the "download" button on the puzzles list of a development server.
Mothballs have the file extension `.mb`.
2023-12-11 11:36:18 -07:00
Setting Up Your Workstation
=====================
2023-12-11 11:36:18 -07:00
You will need two things to develop content:
a MOTH server,
and a text editor.
2023-12-11 11:36:18 -07:00
MOTH Server
-----------
2023-12-11 11:36:18 -07:00
### Windows
2023-12-11 11:36:18 -07:00
Windows users can unzip the zip file provided by the MOTH development team,
and run `moth-devel.bat`.
You can close this window whenever you're done developing.
2023-12-11 11:36:18 -07:00
Once started,
open
http://localhost:8080/
to connect to your development server.
2023-12-11 11:36:18 -07:00
### Linux
2023-12-11 11:36:18 -07:00
Linux users with Docker can run the following to get started
2023-12-11 11:36:18 -07:00
```sh
mkdir -p puzzles
docker run --rm -it -p 8080:8080 -v $(pwd)/puzzles:/puzzles:ro ghcr.io/dirtbags/moth-devel
```
Hit Control-C to terminate MOTH.
2023-12-11 11:36:18 -07:00
Text Editor
---------
2023-12-11 11:36:18 -07:00
We like Visual Studio Code,
but any text editor will work:
you only need to edit the `puzzle.md` (Markdown) files.
Your First Category
================
Open the `puzzles` directory/folder created where you launched the server.
Create a new directory/folder named `test-category`.
Within that directory/folder,
create a directory/folder named `1`.
And within `1`,
create a new file named `puzzle.md`.
Paste the following text into that file:
```markdown
---
authors:
- YOUR NAME HERE
answers:
- Elephant
- elephant
---
# Animal Time
Do you like animals? I do!
Can you guess my favorite animal?
```
Now,
open http://localhost:8080/ in a web browser.
You should see a "test-category" category,
with a single 1-point puzzle.
Click that puzzle,
and you should see your animal puzzle presented.
The two answers we're accepting can be improved,
because some people might use the plural.
Edit `puzzle.md` to add two new answers:
`Elephants` and `elephants`.
Reload the web page,
and check the debug section to verify that all four answers are now accepted.
Next Steps
==========
2023-12-11 11:36:18 -07:00
The [Writing Puzzles](writing-puzzles.md) document
has some tips on how we approach puzzle writing.
There may be something in here that will help you out!
Once your category is set up the way you like it,
download a mothball for it,
2023-12-11 11:36:18 -07:00
and you're ready for [getting started](getting-started.md)
with the production server.