@intellectif/lk-core 0.2.0 → 0.3.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/README.md +70 -0
- package/dist/activity-zdcAMtFB.d.cts +626 -0
- package/dist/activity-zdcAMtFB.d.ts +626 -0
- package/dist/chunk-3YAVDV5F.js +47 -0
- package/dist/chunk-3YAVDV5F.js.map +1 -0
- package/dist/chunk-55O4M45K.js +57 -0
- package/dist/chunk-55O4M45K.js.map +1 -0
- package/dist/chunk-5GJJHGY5.js +576 -0
- package/dist/chunk-5GJJHGY5.js.map +1 -0
- package/dist/{chunk-ZHOX6TO4.js → chunk-HS7BYCGE.js} +65 -7
- package/dist/chunk-HS7BYCGE.js.map +1 -0
- package/dist/chunk-PIMX4B4D.cjs +47 -0
- package/dist/chunk-PIMX4B4D.cjs.map +1 -0
- package/dist/chunk-QOAORTA4.cjs +576 -0
- package/dist/chunk-QOAORTA4.cjs.map +1 -0
- package/dist/chunk-QSVBYTNM.js +94 -0
- package/dist/chunk-QSVBYTNM.js.map +1 -0
- package/dist/{chunk-PJFDAP54.cjs → chunk-RUGIOQZY.cjs} +66 -8
- package/dist/chunk-RUGIOQZY.cjs.map +1 -0
- package/dist/chunk-THSZMZND.cjs +94 -0
- package/dist/chunk-THSZMZND.cjs.map +1 -0
- package/dist/chunk-YNTYWHZI.cjs +57 -0
- package/dist/chunk-YNTYWHZI.cjs.map +1 -0
- package/dist/index.cjs +185 -6
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +253 -7
- package/dist/index.d.ts +253 -7
- package/dist/index.js +188 -9
- package/dist/index.js.map +1 -1
- package/dist/schemas.cjs +29 -2
- package/dist/schemas.cjs.map +1 -1
- package/dist/schemas.d.cts +312 -31
- package/dist/schemas.d.ts +312 -31
- package/dist/schemas.js +32 -5
- package/dist/scoring.cjs +13 -3
- package/dist/scoring.cjs.map +1 -1
- package/dist/scoring.d.cts +29 -5
- package/dist/scoring.d.ts +29 -5
- package/dist/scoring.js +12 -2
- package/dist/xapi.cjs +3 -3
- package/dist/xapi.cjs.map +1 -1
- package/dist/xapi.d.cts +40 -2
- package/dist/xapi.d.ts +40 -2
- package/dist/xapi.js +2 -2
- package/package.json +12 -2
- package/dist/activity-D5tqgx8A.d.cts +0 -330
- package/dist/activity-D5tqgx8A.d.ts +0 -330
- package/dist/chunk-2T3IL7VL.js +0 -147
- package/dist/chunk-2T3IL7VL.js.map +0 -1
- package/dist/chunk-3JMLUUFS.cjs +0 -124
- package/dist/chunk-3JMLUUFS.cjs.map +0 -1
- package/dist/chunk-6VOCV4EX.js +0 -25
- package/dist/chunk-6VOCV4EX.js.map +0 -1
- package/dist/chunk-DCDOTQNH.cjs +0 -147
- package/dist/chunk-DCDOTQNH.cjs.map +0 -1
- package/dist/chunk-DV466SBJ.cjs +0 -25
- package/dist/chunk-DV466SBJ.cjs.map +0 -1
- package/dist/chunk-GZ73G2TS.js +0 -124
- package/dist/chunk-GZ73G2TS.js.map +0 -1
- package/dist/chunk-PJFDAP54.cjs.map +0 -1
- package/dist/chunk-ZHOX6TO4.js.map +0 -1
package/README.md
ADDED
|
@@ -0,0 +1,70 @@
|
|
|
1
|
+
# @intellectif/lk-core
|
|
2
|
+
|
|
3
|
+
Framework-free TypeScript core of [learning-kit](https://github.com/intellectif/learning-kit): Zod-based **activity schemas**, a pure **scoring engine**, and an **xAPI 1.0.3 statement builder + validator**. Zero React, zero DOM — usable in Node, browsers, edge, or as the data layer behind `@intellectif/lk-react`.
|
|
4
|
+
|
|
5
|
+
```bash
|
|
6
|
+
pnpm add @intellectif/lk-core
|
|
7
|
+
# or
|
|
8
|
+
npm install @intellectif/lk-core
|
|
9
|
+
```
|
|
10
|
+
|
|
11
|
+
> Already using `@intellectif/lk-react`? It declares `@intellectif/lk-core` as a peer; install both together.
|
|
12
|
+
|
|
13
|
+
## What's in the box
|
|
14
|
+
|
|
15
|
+
- **Activity schemas (Zod 4)** for `multiple-choice` and `fill-in-the-blanks` with semantic refinements (e.g. *at least one correct option*, *single-select ⇒ exactly one correct*, *passage ↔ blank-id bijection*, *image/embed require `alt`*).
|
|
16
|
+
- **`validateActivity(type, data)`** — the authoritative runtime validator. Returns a typed `{ success, data }` or a structured `{ success: false, errors[] }`.
|
|
17
|
+
- **JSON Schema (Draft-7) export** — `multipleChoiceJsonSchema` / `fillInTheBlanksJsonSchema`, suitable for form generators or AI prompting.
|
|
18
|
+
- **Scoring engine** — `score(activityType, data, response)` returning `{ score ∈ [0,1], maxScore: 1, passed, feedback, details }`. Pure, deterministic, 100 % test coverage enforced.
|
|
19
|
+
- **`computePassThreshold(data, score)`** — single source of truth for pass/fail (default `0.7`).
|
|
20
|
+
- **xAPI builder** — `xAPIBuilder.buildAnsweredStatement(...)` / `buildCompletedStatement(...)` emit well-formed xAPI 1.0.3 statements with `crypto.randomUUID()` ids and an ISO-8601 timestamp.
|
|
21
|
+
- **xAPI validator** — `validateXAPIStatement(statement)` (Zod-backed; throws in dev, warns in prod).
|
|
22
|
+
- **Errors** — `ActivitySchemaError`, `UnknownActivityTypeError` with structured payloads.
|
|
23
|
+
- **Types** — `ActivityData`, `ActivityResult`, `ScoringResult`, `XAPIStatement`, `ThemeTokens`, … all exported with JSDoc.
|
|
24
|
+
|
|
25
|
+
## Quick example
|
|
26
|
+
|
|
27
|
+
```ts
|
|
28
|
+
import { validateActivity, score, xAPIBuilder } from '@intellectif/lk-core';
|
|
29
|
+
|
|
30
|
+
const data = await fetch('/api/activities/capital-jp').then((r) => r.json());
|
|
31
|
+
|
|
32
|
+
const v = validateActivity('multiple-choice', data);
|
|
33
|
+
if (!v.success) throw new Error(JSON.stringify(v.errors));
|
|
34
|
+
|
|
35
|
+
const result = score('multiple-choice', v.data, {
|
|
36
|
+
type: 'multiple-choice',
|
|
37
|
+
selectedOptionIds: ['tokyo'],
|
|
38
|
+
});
|
|
39
|
+
// result.score === 1, result.passed === true
|
|
40
|
+
|
|
41
|
+
const statement = xAPIBuilder.buildAnsweredStatement({
|
|
42
|
+
actor: { objectType: 'Agent', mbox: 'mailto:learner@example.com' },
|
|
43
|
+
object: { id: 'urn:learning-kit:activity:capital-jp', name: { 'en-US': data.title } },
|
|
44
|
+
scoringResult: result,
|
|
45
|
+
timeSpentMs: 4200,
|
|
46
|
+
response: 'tokyo',
|
|
47
|
+
});
|
|
48
|
+
// statement is a valid xAPI 1.0.3 Statement
|
|
49
|
+
```
|
|
50
|
+
|
|
51
|
+
## Subpath exports
|
|
52
|
+
|
|
53
|
+
| Import | Contents |
|
|
54
|
+
|---|---|
|
|
55
|
+
| `@intellectif/lk-core` | Everything (barrel) |
|
|
56
|
+
| `@intellectif/lk-core/schemas` | Zod schemas + `validateActivity` + JSON Schema export |
|
|
57
|
+
| `@intellectif/lk-core/scoring` | `score`, `computePassThreshold` |
|
|
58
|
+
| `@intellectif/lk-core/xapi` | `xAPIBuilder`, `XAPIVerb`, `validateXAPIStatement` |
|
|
59
|
+
|
|
60
|
+
All exports ship as ESM + CJS with `.d.ts` types. Tree-shakeable.
|
|
61
|
+
|
|
62
|
+
## Documentation
|
|
63
|
+
|
|
64
|
+
- [Authoring & content storage](https://github.com/intellectif/learning-kit/blob/main/docs/authoring.md) — data model, validation, fetch → validate → render flow.
|
|
65
|
+
- [Project README](https://github.com/intellectif/learning-kit#readme) — the full picture, including the React renderers.
|
|
66
|
+
- [Contributing](https://github.com/intellectif/learning-kit/blob/main/CONTRIBUTING.md) — adding a new activity type.
|
|
67
|
+
|
|
68
|
+
## License
|
|
69
|
+
|
|
70
|
+
MIT © [Intellectif LLC](https://intellectif.com)
|