md2qti 0.0.0-stage → 0.1.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/LICENSE ADDED
@@ -0,0 +1,21 @@
1
+ MIT License
2
+
3
+ Copyright (c) 2026 Code Coaching
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in all
13
+ copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21
+ SOFTWARE.
package/README.md CHANGED
@@ -1,3 +1,186 @@
1
- # Temporary Holding Version
1
+ # md2qti
2
2
 
3
- This version is a temporary placeholder for this package. An operational version to replace this has been submitted for review and is awaiting a staged release.
3
+ Convert Markdown question banks to QTI 2.1 packages for Blackboard Ultra.
4
+
5
+ You write questions in plain Markdown, in English or Dutch. md2qti checks them, makes screenshots for matching questions, and builds one zip per bank that Ultra imports as a question bank.
6
+
7
+ This README is also [in Dutch](README.nl.md).
8
+
9
+ ## Install
10
+
11
+ md2qti needs Node 20 or later. Run it without installing:
12
+
13
+ ```sh
14
+ npx md2qti --help
15
+ ```
16
+
17
+ Or pin it in a project, so a new release can't change a bank by surprise:
18
+
19
+ ```sh
20
+ npm i -D md2qti
21
+ ```
22
+
23
+ Only banks with automatic screenshots need a browser. For those, also install `playwright-core`:
24
+
25
+ ```sh
26
+ npm i -D playwright-core
27
+ ```
28
+
29
+ md2qti uses the Google Chrome on your computer. Without Chrome, run `npx playwright install chromium`.
30
+
31
+ ## Quick start
32
+
33
+ ```sh
34
+ npx md2qti init flexbox.md # start a bank from the template
35
+ npx md2qti --check flexbox # show every problem, make screenshots
36
+ npx md2qti flexbox # build dist/flexbox.zip
37
+ ```
38
+
39
+ Then [import the zip in Ultra](#import-in-blackboard-ultra).
40
+
41
+ ## Usage
42
+
43
+ ```sh
44
+ npx md2qti # every question bank under the current folder
45
+ npx md2qti banks # every bank under this folder
46
+ npx md2qti banks/css.md # one file
47
+ npx md2qti css forms # by name (the file name without .md)
48
+ npx md2qti --check # validate and refresh screenshots, no zip
49
+ npx md2qti --out banks/dist # output folder (default: ./dist)
50
+ npx md2qti --watch # rebuild a bank when it or its images change
51
+ npx md2qti --check --reporter json # problems as JSON, for scripts and CI
52
+ npx md2qti init flexbox.md # copy the English template to start a new bank
53
+ npx md2qti init flexbox.md --lang nl # same, Dutch template
54
+ npx md2qti --lang nl --check # Dutch CLI messages
55
+ ```
56
+
57
+ | Option | What it does |
58
+ | ------------------------- | ---------------------------------------------------------------------------------------------------------------------- |
59
+ | `--check` | Validate and refresh screenshots, write no zip. |
60
+ | `--watch` | Build, then keep running and rebuild a bank when it or its images change. Stop with Ctrl+C. |
61
+ | `--out <dir>` | Output folder for the zips. Default: `./dist` in the current folder. |
62
+ | `--reporter <text\|json>` | `text` (default): one line per problem on stderr. `json`: one JSON array on stdout. |
63
+ | `--lang <en\|nl>` | Language of the CLI messages and of the `init` template. Default: `MD2QTI_LANG`, else the system locale, else English. |
64
+ | `-h`, `--help` | Show the help. |
65
+ | `-v`, `--version` | Show the version. |
66
+
67
+ **Which files are banks.** A bank is a `.md` file with at least one question heading (`## Question ...` or `## Vraag ...`). md2qti skips `dist/`, `assets/`, `node_modules/`, `.git/`, the output folder, and names that start with `_`. Two banks with the same name are an error. A `.md` you name on the command line is always used.
68
+
69
+ **Output.** One `<bank>.zip` per bank, flat in the output folder. The bank name is the file name: `flexbox.md` becomes `dist/flexbox.zip`. Screenshots go to `assets/auto/` next to the `.md`: commit the images.
70
+
71
+ ## Writing questions
72
+
73
+ `npx md2qti init <name>.md` gives you a template with an example of every question type, including a matching question with automatic screenshots. A comment at the top of the template explains how to use it. Replace the examples with your own questions and run `npx md2qti --check` to see what is wrong.
74
+
75
+ ## Question types in Ultra
76
+
77
+ | Ultra type | md2qti | Markdown |
78
+ | -------------------------------------- | ------------------------ | --------------------------------------------------------------- |
79
+ | True or false | yes | `Answer: True` or `Answer: False` |
80
+ | Multiple choice, 1 correct | yes | `Option n` blocks, one `Correct answer` |
81
+ | Multiple answer (all or nothing) | yes | several `Correct answer` |
82
+ | Fill in the blank, exact match | yes, 1 or more blanks | `[Blank n]` in the text, `Blank n` with accepted answers |
83
+ | Essay | yes | the editor line, model solution under `### ...` |
84
+ | Matching | emulated as fill-in | `**Fragment X**` and `**Screenshot X**` headings, pairing lines |
85
+ | Fill in the blank, contains or pattern | not possible via QTI 2.1 | |
86
+ | Jumbled sentence | not possible via QTI 2.1 | |
87
+ | Hot spot | not possible via QTI 2.1 | |
88
+
89
+ The last three can't be imported/exported with QTI 2.1.
90
+
91
+ ### JSON for scripts and CI
92
+
93
+ `--reporter json` prints one JSON array on stdout and nothing else:
94
+
95
+ ```sh
96
+ npx md2qti --check --reporter json
97
+ ```
98
+
99
+ ```json
100
+ [
101
+ {
102
+ "file": "banks/flexbox.md",
103
+ "line": 12,
104
+ "severity": "error",
105
+ "message": "flexbox question 2: Blank 1 has no answer"
106
+ }
107
+ ]
108
+ ```
109
+
110
+ `severity` is always `error` or `warning`, whatever the CLI language. Progress lines and errors that don't belong to a line in a bank (such as a file that can't be read) go to stderr as text.
111
+
112
+ ### Problems inline in VS Code
113
+
114
+ Copy this complete file to `.vscode/tasks.json` (or add the task to the `tasks` array of the one you have). Then run it with **Terminal > Run Task… > md2qti: check this bank** while a bank is open, and its errors show up in the Problems panel and in the editor:
115
+
116
+ ```json
117
+ {
118
+ "version": "2.0.0",
119
+ "tasks": [
120
+ {
121
+ "label": "md2qti: check this bank",
122
+ "type": "shell",
123
+ "command": "npx md2qti --check '${file}'",
124
+ "options": { "cwd": "${workspaceFolder}" },
125
+ "problemMatcher": [
126
+ {
127
+ "owner": "md2qti",
128
+ "source": "md2qti",
129
+ "severity": "error",
130
+ "fileLocation": ["relative", "${workspaceFolder}"],
131
+ "pattern": {
132
+ "regexp": "^(?:ERROR|FOUT) (.+?):(\\d+): (.*)$",
133
+ "file": 1,
134
+ "line": 2,
135
+ "message": 3
136
+ }
137
+ },
138
+ {
139
+ "owner": "md2qti",
140
+ "source": "md2qti",
141
+ "severity": "warning",
142
+ "fileLocation": ["relative", "${workspaceFolder}"],
143
+ "pattern": {
144
+ "regexp": "^(?:WARNING|WAARSCHUWING) (.+?):(\\d+): (.*)$",
145
+ "file": 1,
146
+ "line": 2,
147
+ "message": 3
148
+ }
149
+ }
150
+ ]
151
+ }
152
+ ]
153
+ }
154
+ ```
155
+
156
+ ## Library
157
+
158
+ The pipeline is also a library, without file system or console. It has three steps: `parse`, `toQti` and `zip`.
159
+
160
+ ```js
161
+ import { readFileSync, existsSync, writeFileSync } from "node:fs";
162
+ import { parse, toQti, zip } from "md2qti";
163
+
164
+ const images = { exists: existsSync, read: (path) => readFileSync(path) };
165
+
166
+ const bank = parse(readFileSync("flexbox.md", "utf8"), {
167
+ name: "flexbox",
168
+ baseDir: process.cwd(),
169
+ });
170
+ const qti = toQti(bank, { images });
171
+ const problems = [...bank.problems, ...qti.problems];
172
+ if (problems.length === 0) {
173
+ writeFileSync("flexbox.zip", zip(qti, images));
174
+ }
175
+ ```
176
+
177
+ - `parse(text, { name, baseDir, file?, cliLang? })` returns a `ParsedBank`: the title, the bank language, the questions without problems, and `problems` (`{ file, line, severity, message }`). It never throws on bad input. `baseDir` is the folder that image paths are relative to.
178
+ - `toQti(bank, { images, cliLang? })` returns the XML files of the package and the images it needs, plus `problems` such as a missing image.
179
+ - `zip(qti, images)` returns the zip as a `Uint8Array`. The same input gives a byte-identical zip.
180
+ - `images` is `{ exists(absolutePath), read(absolutePath) }`, so the images can also come from memory.
181
+
182
+ Screenshots are not part of the library: run the CLI with `--check` for those.
183
+
184
+ ## License
185
+
186
+ MIT
package/README.nl.md ADDED
@@ -0,0 +1,186 @@
1
+ # md2qti
2
+
3
+ Zet vragenbanken in Markdown om naar QTI 2.1-pakketten voor Blackboard Ultra.
4
+
5
+ Je schrijft de vragen in gewone Markdown, in het Engels of het Nederlands. md2qti controleert ze, maakt de screenshots voor koppelvragen en bouwt per vragenbank een zip die je in Ultra als vragenbank importeert.
6
+
7
+ Deze README bestaat ook [in het Engels](README.md).
8
+
9
+ ## Installeren
10
+
11
+ md2qti heeft Node 20 of nieuwer nodig. Je kan het gebruiken zonder te installeren:
12
+
13
+ ```sh
14
+ npx md2qti --help
15
+ ```
16
+
17
+ Of zet een vaste versie in een project, zodat een nieuwe release een vragenbank niet onverwacht verandert:
18
+
19
+ ```sh
20
+ npm i -D md2qti
21
+ ```
22
+
23
+ Enkel vragenbanken met automatische screenshots hebben een browser nodig. Installeer daarvoor ook `playwright-core`:
24
+
25
+ ```sh
26
+ npm i -D playwright-core
27
+ ```
28
+
29
+ md2qti gebruikt de Google Chrome op je computer. Heb je geen Chrome, voer dan `npx playwright install chromium` uit.
30
+
31
+ ## Snel aan de slag
32
+
33
+ ```sh
34
+ npx md2qti init flexbox.md --lang nl # begin een vragenbank van het sjabloon
35
+ npx md2qti --check flexbox # toon elk probleem en maak de screenshots
36
+ npx md2qti flexbox # bouw dist/flexbox.zip
37
+ ```
38
+
39
+ [Importeer](#importeren-in-blackboard-ultra) daarna de zip in Ultra.
40
+
41
+ ## Gebruik
42
+
43
+ ```sh
44
+ npx md2qti # elke vragenbank onder de huidige map
45
+ npx md2qti vragenbanken # elke vragenbank onder deze map
46
+ npx md2qti vragenbanken/css.md # een bestand
47
+ npx md2qti css forms # op naam (de bestandsnaam zonder .md)
48
+ npx md2qti --check # controleer en vernieuw de screenshots, geen zip
49
+ npx md2qti --out vragenbanken/dist # uitvoermap (standaard: ./dist)
50
+ npx md2qti --watch # bouw een vragenbank opnieuw als ze of haar afbeeldingen wijzigen
51
+ npx md2qti --check --reporter json # problemen als JSON, voor scripts en CI
52
+ npx md2qti init flexbox.md --lang nl # kopieer het Nederlandse sjabloon voor een nieuwe vragenbank
53
+ npx md2qti init flexbox.md # hetzelfde, met het Engelse sjabloon
54
+ npx md2qti --lang nl --check # meldingen in het Nederlands
55
+ ```
56
+
57
+ | Optie | Wat ze doet |
58
+ | ------------------------- | -------------------------------------------------------------------------------------------------------------------------- |
59
+ | `--check` | Controleer en vernieuw de screenshots, maak geen zip. |
60
+ | `--watch` | Bouw, blijf daarna draaien en bouw een vragenbank opnieuw als ze of haar afbeeldingen wijzigen. Stoppen doe je met Ctrl+C. |
61
+ | `--out <map>` | Uitvoermap voor de zips. Standaard: `./dist` in de huidige map. |
62
+ | `--reporter <text\|json>` | `text` (standaard): een regel per probleem op stderr. `json`: een JSON-array op stdout. |
63
+ | `--lang <en\|nl>` | Taal van de meldingen en van het sjabloon voor `init`. Standaard: `MD2QTI_LANG`, anders de systeemtaal, anders Engels. |
64
+ | `-h`, `--help` | Toon de hulp. |
65
+ | `-v`, `--version` | Toon de versie. |
66
+
67
+ **Welke bestanden vragenbanken zijn.** Een vragenbank is een `.md`-bestand met minstens een vraagkop (`## Vraag ...` of `## Question ...`). md2qti slaat `dist/`, `assets/`, `node_modules/`, `.git/`, de uitvoermap en namen die met `_` beginnen over. Twee vragenbanken met dezelfde naam geven een fout. Een `.md` die je zelf op de opdrachtregel noemt, gebruikt md2qti altijd.
68
+
69
+ **Uitvoer.** Een `<naam>.zip` per vragenbank, rechtstreeks in de uitvoermap. De naam van de vragenbank is de bestandsnaam: `flexbox.md` wordt `dist/flexbox.zip`. De screenshots komen in `assets/auto/` naast de `.md`. Commit de afbeeldingen.
70
+
71
+ ## Vragen schrijven
72
+
73
+ `npx md2qti init <naam>.md --lang nl` geeft je een sjabloon met een voorbeeld van elk vraagtype, ook een koppelvraag met automatische screenshots. Een commentaar bovenaan het sjabloon legt uit hoe je het gebruikt. Vervang de voorbeelden door je eigen vragen en voer `npx md2qti --check` uit om te zien wat er fout is.
74
+
75
+ ## Vraagtypes in Ultra
76
+
77
+ | Type in Ultra | md2qti | Markdown |
78
+ | ------------------------------------ | ------------------------- | ------------------------------------------------------------ |
79
+ | Waar of onwaar | ja | `Antwoord: Waar` of `Antwoord: Onwaar` |
80
+ | Meerkeuze, 1 juist antwoord | ja | blokken `Optie n`, een keer `Juist antwoord` |
81
+ | Meerdere antwoorden (alles of niets) | ja | meerdere keren `Juist antwoord` |
82
+ | Invullen, exacte overeenkomst | ja, 1 of meer invulvelden | `[Leeg n]` in de tekst, `Leeg n` met de aanvaarde antwoorden |
83
+ | Essay | ja | de regel voor de editor, modeloplossing onder `### ...` |
84
+ | Koppelen | nagebootst als invulvraag | koppen `**Fragment X**` en `**Screenshot X**`, koppelregels |
85
+ | Invullen, bevat of patroon | niet mogelijk met QTI 2.1 | |
86
+ | Door elkaar gehaalde zin | niet mogelijk met QTI 2.1 | |
87
+ | Hotspot | niet mogelijk met QTI 2.1 | |
88
+
89
+ De laatste drie kan je niet importeren/exporteren met QTI 2.1.
90
+
91
+ ### JSON voor scripts en CI
92
+
93
+ `--reporter json` schrijft een JSON-array op stdout en verder niets:
94
+
95
+ ```sh
96
+ npx md2qti --check --reporter json
97
+ ```
98
+
99
+ ```json
100
+ [
101
+ {
102
+ "file": "oefentoetsen/flexbox.md",
103
+ "line": 12,
104
+ "severity": "error",
105
+ "message": "flexbox vraag 2: Leeg 1 heeft geen antwoord"
106
+ }
107
+ ]
108
+ ```
109
+
110
+ `severity` is altijd `error` of `warning`, in welke taal de CLI ook draait. De voortgang en fouten die niet bij een regel in een vragenbank horen (bv. een bestand dat md2qti niet kan lezen), komen als tekst op stderr.
111
+
112
+ ### Problemen in VS Code
113
+
114
+ Kopieer dit volledige bestand naar `.vscode/tasks.json` (of voeg de taak toe aan de array `tasks` van het bestand dat je al hebt). Open een vragenbank en kies **Terminal > Run Task… > md2qti: check this bank**. De fouten verschijnen dan in het venster Problems en in de editor:
115
+
116
+ ```json
117
+ {
118
+ "version": "2.0.0",
119
+ "tasks": [
120
+ {
121
+ "label": "md2qti: check this bank",
122
+ "type": "shell",
123
+ "command": "npx md2qti --check '${file}'",
124
+ "options": { "cwd": "${workspaceFolder}" },
125
+ "problemMatcher": [
126
+ {
127
+ "owner": "md2qti",
128
+ "source": "md2qti",
129
+ "severity": "error",
130
+ "fileLocation": ["relative", "${workspaceFolder}"],
131
+ "pattern": {
132
+ "regexp": "^(?:ERROR|FOUT) (.+?):(\\d+): (.*)$",
133
+ "file": 1,
134
+ "line": 2,
135
+ "message": 3
136
+ }
137
+ },
138
+ {
139
+ "owner": "md2qti",
140
+ "source": "md2qti",
141
+ "severity": "warning",
142
+ "fileLocation": ["relative", "${workspaceFolder}"],
143
+ "pattern": {
144
+ "regexp": "^(?:WARNING|WAARSCHUWING) (.+?):(\\d+): (.*)$",
145
+ "file": 1,
146
+ "line": 2,
147
+ "message": 3
148
+ }
149
+ }
150
+ ]
151
+ }
152
+ ]
153
+ }
154
+ ```
155
+
156
+ ## Library
157
+
158
+ Je kan md2qti ook als library gebruiken, zonder bestandssysteem of console. Het werkt in drie stappen: `parse`, `toQti` en `zip`.
159
+
160
+ ```js
161
+ import { readFileSync, existsSync, writeFileSync } from "node:fs";
162
+ import { parse, toQti, zip } from "md2qti";
163
+
164
+ const images = { exists: existsSync, read: (path) => readFileSync(path) };
165
+
166
+ const bank = parse(readFileSync("flexbox.md", "utf8"), {
167
+ name: "flexbox",
168
+ baseDir: process.cwd(),
169
+ });
170
+ const qti = toQti(bank, { images });
171
+ const problems = [...bank.problems, ...qti.problems];
172
+ if (problems.length === 0) {
173
+ writeFileSync("flexbox.zip", zip(qti, images));
174
+ }
175
+ ```
176
+
177
+ - `parse(text, { name, baseDir, file?, cliLang? })` geeft een `ParsedBank` terug: de titel, de taal van de vragenbank, de vragen zonder problemen, en `problems` (`{ file, line, severity, message }`). Bij foute invoer gooit `parse` nooit een exception. `baseDir` is de map waarvan de paden van de afbeeldingen vertrekken.
178
+ - `toQti(bank, { images, cliLang? })` geeft de XML-bestanden van het pakket en de afbeeldingen die het nodig heeft terug, plus `problems`, bijvoorbeeld voor een afbeelding die ontbreekt.
179
+ - `zip(qti, images)` geeft de zip terug als `Uint8Array`. Dezelfde invoer geeft een zip die byte voor byte gelijk is.
180
+ - `images` is `{ exists(absolutePath), read(absolutePath) }`, dus de afbeeldingen kunnen ook uit het geheugen komen.
181
+
182
+ De screenshots zitten niet in de library. Gebruik daarvoor de CLI met `--check`.
183
+
184
+ ## Licentie
185
+
186
+ MIT
package/dist/cli.d.ts ADDED
@@ -0,0 +1 @@
1
+ export declare function main(args: Array<string>): Promise<number>;