@playcademy/sdk 0.16.0 → 0.16.1-beta.10

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 CHANGED
@@ -116,6 +116,45 @@ await client.timeback.startActivity(
116
116
  )
117
117
  ```
118
118
 
119
+ Hosted assessments use the same methods locally and when deployed:
120
+
121
+ ```typescript
122
+ const attempt = await client.timeback.assessments.start({
123
+ activityId: 'math-diagnostic',
124
+ purpose: 'diagnostic',
125
+ subject: 'Math',
126
+ grade: 5,
127
+ })
128
+
129
+ const saved = await client.timeback.assessments.save(attempt.attemptId, {
130
+ expectedResponseVersion: attempt.responseVersion,
131
+ responses: {
132
+ [attempt.assessment.items[0].identifier]: { RESPONSE: 'A' },
133
+ },
134
+ })
135
+
136
+ const completed = await client.timeback.assessments.submit(attempt.attemptId, {
137
+ expectedResponseVersion: saved.responseVersion,
138
+ submissionId: crypto.randomUUID(),
139
+ })
140
+ ```
141
+
142
+ `start()` resumes a compatible unfinished attempt or selects content for a fixed test or standards
143
+ review. Save payloads merge at both the item and response levels; omitted values remain unchanged,
144
+ and `null` clears one response. Keep the returned `responseVersion` and send it with the next
145
+ mutation.
146
+
147
+ For local development, import the current ordered catalog before starting the dev host:
148
+
149
+ ```bash
150
+ playcademy timeback assessments import
151
+ playcademy dev
152
+ ```
153
+
154
+ The host reads `.playcademy/timeback/assessment-fixtures.json` and keeps local attempts in memory.
155
+ Restarting the dev host resets mutable attempt state. Deployed games use TimeBack automatically;
156
+ game code never selects the provider or reads fixture content.
157
+
119
158
  ### `client.backend`
120
159
 
121
160
  HTTP client for game-specific backend functions deployed via `playcademy deploy`.
@@ -134,6 +173,46 @@ OAuth provider connections (Discord, Google, etc.).
134
173
  await client.identity.connect({ provider: 'discord' })
135
174
  ```
136
175
 
176
+ ### `client.embed`
177
+
178
+ Launch other Playcademy games as embedded children (platform mode only). With `timeback`, the child's play time and completion are recorded on this game's Timeback course. Interrupted launches resume automatically when the child streams checkpoints; the `resume` option tunes or disables the persistence.
179
+
180
+ ```typescript
181
+ const session = client.embed.launch({
182
+ slug: 'math-cakes',
183
+ container: overlayEl,
184
+ intent: { lessonId: 'two-digit-add', eLevel: 'E2' },
185
+ timeback: { activityId: 'two-digit-add-e2', grade: 2, subject: 'Math' },
186
+ })
187
+
188
+ const activity = await session.finished
189
+
190
+ if (activity.status === 'completed') {
191
+ await activity.end({
192
+ correctQuestions: activity.correct,
193
+ totalQuestions: activity.total,
194
+ xpAwarded: 10,
195
+ })
196
+ }
197
+
198
+ await session.closed // iframe unmounted; dismiss surrounding UI
199
+ ```
200
+
201
+ ### `client.parent`
202
+
203
+ The launch context when this game was launched by a parent game (`mode: 'child'`); `null` in every other mode. In child mode, activity reporting is relayed to the parent automatically, and `xpAwarded` becomes a suggestion the parent may override. Stream `client.parent.checkpoint(state)` to make interrupted launches resumable; the state comes back as `client.parent.resume`. Narrow with `isChildLaunched()` to get the relaxed types.
204
+
205
+ ```typescript
206
+ import { isChildLaunched } from '@playcademy/sdk'
207
+
208
+ if (isChildLaunched(client)) {
209
+ const { lessonId, eLevel } = client.parent.intent
210
+ startLesson(lessonId, eLevel)
211
+ // ...later: xpAwarded may be omitted; the parent decides the award
212
+ await client.timeback.endActivity({ correctQuestions, totalQuestions })
213
+ }
214
+ ```
215
+
137
216
  ### `client.demo`
138
217
 
139
218
  Demo mode for anonymous players on the landing page.