@interlacejs/quiz 0.1.0 → 0.1.2

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.
Files changed (2) hide show
  1. package/README.md +50 -0
  2. package/package.json +2 -2
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,6 +1,6 @@
1
1
  {
2
2
  "name": "@interlacejs/quiz",
3
- "version": "0.1.0",
3
+ "version": "0.1.2",
4
4
  "description": "Interlace quiz content type: data schema, validation, and playback contract.",
5
5
  "type": "module",
6
6
  "main": "./dist/index.js",
@@ -37,7 +37,7 @@
37
37
  "vitest": "^2.1.9"
38
38
  },
39
39
  "dependencies": {
40
- "@interlacejs/core": "0.1.0"
40
+ "@interlacejs/core": "0.1.2"
41
41
  },
42
42
  "scripts": {
43
43
  "build": "tsup",