@interlacejs/quiz 0.1.0 → 0.1.3
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/README.md +50 -0
- package/package.json +8 -4
package/README.md
ADDED
|
@@ -0,0 +1,50 @@
|
|
|
1
|
+
# @interlacejs/quiz
|
|
2
|
+
|
|
3
|
+
The canonical quiz content type for [Interlace](https://github.com/farayolaj/interlace): single-choice questions with rich media, authored and played back through one package.
|
|
4
|
+
|
|
5
|
+
## What's inside
|
|
6
|
+
|
|
7
|
+
- **`QuizContentType`** — the `ContentType` implementation (editor + playback) registered under the id `quiz-editor`, data-format version 1.
|
|
8
|
+
- **`QuizEditorType` / `unmountQuizEditor`** — the authoring surface: question list (add/remove/switch), per-question text and media, option rows with thumbnails, correctness select, and a focus-preserving controller.
|
|
9
|
+
- **`renderQuizPlayback` / `unmountQuizPlayback`** — the playback renderer: one question at a time ("Question i of n"), reveal/lock on answer (correct ✓ / incorrect ✕), review-only **Previous**, **Next** gated on answering — and one point per correctly answered question, reported once via `callbacks.onComplete(correctCount)` on the final question.
|
|
10
|
+
- **`validateQuizData`** — canonical-only structural validation (≥ 1 question, non-empty text/options, resolvable correctness).
|
|
11
|
+
|
|
12
|
+
## Install
|
|
13
|
+
|
|
14
|
+
```bash
|
|
15
|
+
pnpm add @interlacejs/quiz @interlacejs/core
|
|
16
|
+
```
|
|
17
|
+
|
|
18
|
+
## One data format
|
|
19
|
+
|
|
20
|
+
```ts
|
|
21
|
+
import type { QuizData, QuizQuestionSpec } from "@interlacejs/quiz";
|
|
22
|
+
|
|
23
|
+
type QuizData = {
|
|
24
|
+
questions: Array<{
|
|
25
|
+
id: string; // e.g. "q-0"
|
|
26
|
+
text: string;
|
|
27
|
+
media?: { src: string; alt?: string };
|
|
28
|
+
options: Array<{ id: string; text: string; media?: { src: string; alt?: string } }>;
|
|
29
|
+
correctOptionId: string | null;
|
|
30
|
+
}>;
|
|
31
|
+
};
|
|
32
|
+
```
|
|
33
|
+
|
|
34
|
+
Every document — authored, serialized, or played back — uses this shape; there is no separate legacy format.
|
|
35
|
+
|
|
36
|
+
## Use as a content type
|
|
37
|
+
|
|
38
|
+
```ts
|
|
39
|
+
import { QuizContentType } from "@interlacejs/quiz";
|
|
40
|
+
import { ContentTypeRegistry } from "@interlacejs/core";
|
|
41
|
+
|
|
42
|
+
const registry = new ContentTypeRegistry();
|
|
43
|
+
registry.register(QuizContentType); // authoring + playback wired at once
|
|
44
|
+
```
|
|
45
|
+
|
|
46
|
+
Register it in the `registry` you pass to `@interlacejs/editor` (authoring) and `@interlacejs/player` (playback) — the demo's snapshots of this in `apps/demo/src/registry.ts`.
|
|
47
|
+
|
|
48
|
+
## License
|
|
49
|
+
|
|
50
|
+
ISC
|
package/package.json
CHANGED
|
@@ -1,13 +1,17 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@interlacejs/quiz",
|
|
3
|
-
"version": "0.1.
|
|
3
|
+
"version": "0.1.3",
|
|
4
4
|
"description": "Interlace quiz content type: data schema, validation, and playback contract.",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"main": "./dist/index.js",
|
|
7
|
-
"module": "./dist/index.
|
|
7
|
+
"module": "./dist/index.js",
|
|
8
8
|
"types": "./dist/index.d.ts",
|
|
9
9
|
"exports": {
|
|
10
|
-
".":
|
|
10
|
+
".": {
|
|
11
|
+
"types": "./dist/index.d.ts",
|
|
12
|
+
"import": "./dist/index.js",
|
|
13
|
+
"require": "./dist/index.cjs"
|
|
14
|
+
}
|
|
11
15
|
},
|
|
12
16
|
"sideEffects": false,
|
|
13
17
|
"files": [
|
|
@@ -37,7 +41,7 @@
|
|
|
37
41
|
"vitest": "^2.1.9"
|
|
38
42
|
},
|
|
39
43
|
"dependencies": {
|
|
40
|
-
"@interlacejs/core": "0.1.
|
|
44
|
+
"@interlacejs/core": "0.1.3"
|
|
41
45
|
},
|
|
42
46
|
"scripts": {
|
|
43
47
|
"build": "tsup",
|