@molecule/api-ai-quiz-generation 1.0.0 → 1.0.1
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 +188 -0
- package/package.json +13 -7
package/README.md
ADDED
|
@@ -0,0 +1,188 @@
|
|
|
1
|
+
<!--
|
|
2
|
+
AUTO-GENERATED — DO NOT EDIT THIS FILE.
|
|
3
|
+
Generated by `mlcl sync-docs` from the package's src/index.ts JSDoc + mlcl/registry.json.
|
|
4
|
+
Edits here are overwritten on the next commit (molecule's pre-commit hook regenerates).
|
|
5
|
+
To change this document, edit the module-level JSDoc in src/index.ts.
|
|
6
|
+
Generated: 2026-08-04T01:47:35.229Z
|
|
7
|
+
-->
|
|
8
|
+
|
|
9
|
+
# @molecule/api-ai-quiz-generation
|
|
10
|
+
|
|
11
|
+
> **Auto-generated, AI-first package reference** for the [molecule.dev](https://molecule.dev) ecosystem.
|
|
12
|
+
> It is written to be read by coding agents as much as by people, and is generated from this
|
|
13
|
+
> package's source — edit `src/index.ts` JSDoc, not this file.
|
|
14
|
+
|
|
15
|
+
`@molecule/api-ai-quiz-generation` — generate quizzes from source
|
|
16
|
+
material + auto-grade student responses via the bonded AI provider.
|
|
17
|
+
|
|
18
|
+
Extracted from ai-study-buddy flagship. For pure rule-based grading
|
|
19
|
+
(multiple-choice → exact match), use `@molecule/api-utilities-quiz-grading`.
|
|
20
|
+
This package adds AI-assisted generation + free-response grading.
|
|
21
|
+
|
|
22
|
+
## Quick Start
|
|
23
|
+
|
|
24
|
+
```ts
|
|
25
|
+
import { generateQuiz, gradeResponses } from '@molecule/api-ai-quiz-generation'
|
|
26
|
+
|
|
27
|
+
const quiz = await generateQuiz({
|
|
28
|
+
source: chapterText,
|
|
29
|
+
questionCount: 10,
|
|
30
|
+
types: ['multiple_choice', 'short_answer'],
|
|
31
|
+
difficulty: 'medium',
|
|
32
|
+
})
|
|
33
|
+
|
|
34
|
+
const result = await gradeResponses({
|
|
35
|
+
quiz,
|
|
36
|
+
responses: studentAnswers,
|
|
37
|
+
})
|
|
38
|
+
```
|
|
39
|
+
|
|
40
|
+
## Type
|
|
41
|
+
|
|
42
|
+
`utility`
|
|
43
|
+
|
|
44
|
+
## Installation
|
|
45
|
+
|
|
46
|
+
```bash
|
|
47
|
+
npm install @molecule/api-ai-quiz-generation @molecule/api-ai @molecule/api-bonds-default-express @molecule/api-database @molecule/api-i18n @molecule/api-middleware-validation
|
|
48
|
+
```
|
|
49
|
+
|
|
50
|
+
## API
|
|
51
|
+
|
|
52
|
+
### Interfaces
|
|
53
|
+
|
|
54
|
+
#### `GradedResponse`
|
|
55
|
+
|
|
56
|
+
AI-graded result for a single student response, including correctness, score, and feedback.
|
|
57
|
+
|
|
58
|
+
```typescript
|
|
59
|
+
interface GradedResponse {
|
|
60
|
+
question_id: string
|
|
61
|
+
submitted: string
|
|
62
|
+
correct: boolean
|
|
63
|
+
score: number
|
|
64
|
+
feedback?: string
|
|
65
|
+
}
|
|
66
|
+
```
|
|
67
|
+
|
|
68
|
+
#### `GradeResult`
|
|
69
|
+
|
|
70
|
+
Aggregated grading outcome for a full set of student responses.
|
|
71
|
+
|
|
72
|
+
```typescript
|
|
73
|
+
interface GradeResult {
|
|
74
|
+
responses: GradedResponse[]
|
|
75
|
+
total: number
|
|
76
|
+
earned: number
|
|
77
|
+
percentage: number
|
|
78
|
+
}
|
|
79
|
+
```
|
|
80
|
+
|
|
81
|
+
#### `Question`
|
|
82
|
+
|
|
83
|
+
A single quiz question with prompt, answer, and optional metadata.
|
|
84
|
+
|
|
85
|
+
```typescript
|
|
86
|
+
interface Question {
|
|
87
|
+
id: string
|
|
88
|
+
type: QuestionType
|
|
89
|
+
prompt: string
|
|
90
|
+
/** For multiple_choice / true_false. */
|
|
91
|
+
options?: string[]
|
|
92
|
+
/** The correct answer (or one of the accepted forms). */
|
|
93
|
+
answer: string
|
|
94
|
+
/** Why this is the right answer — surfaced after submission. */
|
|
95
|
+
explanation?: string
|
|
96
|
+
difficulty?: Difficulty
|
|
97
|
+
}
|
|
98
|
+
```
|
|
99
|
+
|
|
100
|
+
#### `Quiz`
|
|
101
|
+
|
|
102
|
+
A generated quiz containing an ordered list of questions and an optional source summary.
|
|
103
|
+
|
|
104
|
+
```typescript
|
|
105
|
+
interface Quiz {
|
|
106
|
+
questions: Question[]
|
|
107
|
+
source_summary?: string
|
|
108
|
+
}
|
|
109
|
+
```
|
|
110
|
+
|
|
111
|
+
### Types
|
|
112
|
+
|
|
113
|
+
#### `Difficulty`
|
|
114
|
+
|
|
115
|
+
Relative difficulty level for a question or generated quiz.
|
|
116
|
+
|
|
117
|
+
```typescript
|
|
118
|
+
type Difficulty = 'easy' | 'medium' | 'hard'
|
|
119
|
+
```
|
|
120
|
+
|
|
121
|
+
#### `QuestionType`
|
|
122
|
+
|
|
123
|
+
Union of supported quiz question formats.
|
|
124
|
+
|
|
125
|
+
```typescript
|
|
126
|
+
type QuestionType = 'multiple_choice' | 'true_false' | 'short_answer' | 'fill_in_the_blank'
|
|
127
|
+
```
|
|
128
|
+
|
|
129
|
+
### Functions
|
|
130
|
+
|
|
131
|
+
#### `generateQuiz(opts)`
|
|
132
|
+
|
|
133
|
+
Generates a quiz from source material using the bonded AI provider, returning structured questions.
|
|
134
|
+
|
|
135
|
+
```typescript
|
|
136
|
+
function generateQuiz(opts: {
|
|
137
|
+
source: string
|
|
138
|
+
questionCount?: number
|
|
139
|
+
types?: QuestionType[]
|
|
140
|
+
difficulty?: Difficulty
|
|
141
|
+
model?: string
|
|
142
|
+
}): Promise<Quiz>
|
|
143
|
+
```
|
|
144
|
+
|
|
145
|
+
#### `gradeResponses(opts)`
|
|
146
|
+
|
|
147
|
+
Grades a set of student responses against the quiz answer key using the bonded AI provider.
|
|
148
|
+
|
|
149
|
+
```typescript
|
|
150
|
+
function gradeResponses(opts: {
|
|
151
|
+
quiz: Quiz
|
|
152
|
+
responses: Array<{ question_id: string; submitted: string }>
|
|
153
|
+
model?: string
|
|
154
|
+
}): Promise<GradeResult>
|
|
155
|
+
```
|
|
156
|
+
|
|
157
|
+
## Injection Notes
|
|
158
|
+
|
|
159
|
+
### Requirements
|
|
160
|
+
|
|
161
|
+
Peer dependencies:
|
|
162
|
+
|
|
163
|
+
- `@molecule/api-bonds-default-express` ^1.0.1
|
|
164
|
+
- `@molecule/api-database` ^1.0.1
|
|
165
|
+
- `@molecule/api-i18n` ^1.0.1
|
|
166
|
+
- `@molecule/api-middleware-validation` ^1.0.1
|
|
167
|
+
- `@molecule/api-ai` ^1.0.1
|
|
168
|
+
|
|
169
|
+
### Runtime Dependencies
|
|
170
|
+
|
|
171
|
+
- `@molecule/api-ai`
|
|
172
|
+
- `@molecule/api-bonds-default-express`
|
|
173
|
+
- `@molecule/api-database`
|
|
174
|
+
- `@molecule/api-i18n`
|
|
175
|
+
- `@molecule/api-middleware-validation`
|
|
176
|
+
|
|
177
|
+
Requires a bonded `ai` chat provider (`@molecule/api-ai`) — both functions
|
|
178
|
+
throw if none is bonded.
|
|
179
|
+
|
|
180
|
+
Failure shapes (no rejection): malformed model output — or a provider API
|
|
181
|
+
failure, which arrives as an in-band `error` event this package does not
|
|
182
|
+
treat as fatal — makes `generateQuiz()` resolve `{ questions: [] }` and
|
|
183
|
+
`gradeResponses()` resolve `{ responses: [], earned: 0, percentage: 0 }`.
|
|
184
|
+
An empty `questions` array means the model output failed to parse, not
|
|
185
|
+
"the source had nothing to ask" — surface a retry instead of rendering an
|
|
186
|
+
empty quiz, and don't record a 0% grade whose `responses` array is empty.
|
|
187
|
+
`total`/`percentage` are computed from the quiz's own question count, so a
|
|
188
|
+
partially-parsed grading under-reports `earned`, never over-reports.
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@molecule/api-ai-quiz-generation",
|
|
3
|
-
"version": "1.0.
|
|
3
|
+
"version": "1.0.1",
|
|
4
4
|
"description": "AI quiz generation from source material + auto-grading",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"main": "dist/index.js",
|
|
@@ -17,7 +17,8 @@
|
|
|
17
17
|
}
|
|
18
18
|
},
|
|
19
19
|
"files": [
|
|
20
|
-
"dist"
|
|
20
|
+
"dist",
|
|
21
|
+
"README.md"
|
|
21
22
|
],
|
|
22
23
|
"keywords": [
|
|
23
24
|
"molecule",
|
|
@@ -27,16 +28,21 @@
|
|
|
27
28
|
"grading"
|
|
28
29
|
],
|
|
29
30
|
"license": "Apache-2.0",
|
|
31
|
+
"repository": {
|
|
32
|
+
"type": "git",
|
|
33
|
+
"url": "https://github.com/molecule-dev/molecule.git",
|
|
34
|
+
"directory": "packages/api/ai/quiz-generation"
|
|
35
|
+
},
|
|
30
36
|
"devDependencies": {
|
|
31
37
|
"@types/node": "26.1.2",
|
|
32
38
|
"typescript": "6.0.3",
|
|
33
39
|
"vitest": "4.1.10"
|
|
34
40
|
},
|
|
35
41
|
"peerDependencies": {
|
|
36
|
-
"@molecule/api-bonds-default-express": "^1.0.
|
|
37
|
-
"@molecule/api-database": "^1.0.
|
|
38
|
-
"@molecule/api-i18n": "^1.0.
|
|
39
|
-
"@molecule/api-middleware-validation": "^1.0.
|
|
40
|
-
"@molecule/api-ai": "^1.0.
|
|
42
|
+
"@molecule/api-bonds-default-express": "^1.0.1",
|
|
43
|
+
"@molecule/api-database": "^1.0.1",
|
|
44
|
+
"@molecule/api-i18n": "^1.0.1",
|
|
45
|
+
"@molecule/api-middleware-validation": "^1.0.1",
|
|
46
|
+
"@molecule/api-ai": "^1.0.1"
|
|
41
47
|
}
|
|
42
48
|
}
|