@intellectif/lk-core 0.21.0 → 1.0.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/CHANGELOG.md +31 -0
- package/README.md +6 -5
- package/dist/{activity-xhGV-Aeh.d.cts → activity-DgpBJeBc.d.cts} +137 -22
- package/dist/{activity-xhGV-Aeh.d.ts → activity-DgpBJeBc.d.ts} +137 -22
- package/dist/ai-check.cjs +104 -16
- package/dist/ai-check.cjs.map +1 -1
- package/dist/ai-check.d.cts +9 -5
- package/dist/ai-check.d.ts +9 -5
- package/dist/ai-check.js +103 -15
- package/dist/ai-check.js.map +1 -1
- package/dist/{chunk-2CV6NU32.cjs → chunk-2JT2WUQ2.cjs} +77 -39
- package/dist/chunk-2JT2WUQ2.cjs.map +1 -0
- package/dist/{chunk-D4TOPSHV.cjs → chunk-DSDXL3JO.cjs} +1216 -1105
- package/dist/chunk-DSDXL3JO.cjs.map +1 -0
- package/dist/{chunk-D3GP5MET.js → chunk-FBKTION6.js} +1093 -982
- package/dist/chunk-FBKTION6.js.map +1 -0
- package/dist/{chunk-Q7MV3IXJ.js → chunk-IARLJ5MW.js} +15 -16
- package/dist/chunk-IARLJ5MW.js.map +1 -0
- package/dist/{chunk-IHOEP4EB.js → chunk-RCZCP5OE.js} +311 -25
- package/dist/chunk-RCZCP5OE.js.map +1 -0
- package/dist/{chunk-X5DAXBJI.js → chunk-SJVRUPJT.js} +2 -2
- package/dist/{chunk-EOFWSGLU.cjs → chunk-TJJFKKH2.cjs} +4 -4
- package/dist/{chunk-EOFWSGLU.cjs.map → chunk-TJJFKKH2.cjs.map} +1 -1
- package/dist/{chunk-WQVZPIN7.cjs → chunk-VSH7ECQL.cjs} +44 -45
- package/dist/chunk-VSH7ECQL.cjs.map +1 -0
- package/dist/{chunk-NRTP7WCW.cjs → chunk-W5KB3DNT.cjs} +315 -29
- package/dist/chunk-W5KB3DNT.cjs.map +1 -0
- package/dist/{chunk-Z7QQZ53L.js → chunk-XS6U2ARZ.js} +70 -32
- package/dist/chunk-XS6U2ARZ.js.map +1 -0
- package/dist/index-BVNeSCWC.d.ts +548 -0
- package/dist/index-BlOLlwOi.d.cts +548 -0
- package/dist/index.cjs +129 -198
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +175 -18
- package/dist/index.d.ts +175 -18
- package/dist/index.js +34 -103
- package/dist/index.js.map +1 -1
- package/dist/schemas.cjs +3 -94
- package/dist/schemas.cjs.map +1 -1
- package/dist/schemas.d.cts +2 -3
- package/dist/schemas.d.ts +2 -3
- package/dist/schemas.js +6 -97
- package/dist/scoring.cjs +3 -3
- package/dist/scoring.d.cts +2 -2
- package/dist/scoring.d.ts +2 -2
- package/dist/scoring.js +2 -2
- package/dist/xapi.cjs +3 -3
- package/dist/xapi.d.cts +1 -1
- package/dist/xapi.d.ts +1 -1
- package/dist/xapi.js +2 -2
- package/package.json +4 -4
- package/vectors/README.md +32 -2
- package/vectors/scoring.json +1 -498
- package/vectors/validation.json +6742 -0
- package/vectors/validation.mjs +195 -0
- package/dist/chunk-2CV6NU32.cjs.map +0 -1
- package/dist/chunk-D3GP5MET.js.map +0 -1
- package/dist/chunk-D4TOPSHV.cjs.map +0 -1
- package/dist/chunk-IHOEP4EB.js.map +0 -1
- package/dist/chunk-NRTP7WCW.cjs.map +0 -1
- package/dist/chunk-Q7MV3IXJ.js.map +0 -1
- package/dist/chunk-WQVZPIN7.cjs.map +0 -1
- package/dist/chunk-Z7QQZ53L.js.map +0 -1
- package/dist/index-BuD8Hc8o.d.cts +0 -2303
- package/dist/index-DnJ_PI4d.d.ts +0 -2303
- /package/dist/{chunk-X5DAXBJI.js.map → chunk-SJVRUPJT.js.map} +0 -0
package/dist/index.d.cts
CHANGED
|
@@ -1,10 +1,9 @@
|
|
|
1
|
-
import {
|
|
2
|
-
export { A as ActivityAiPermissions, c as ActivityFeedback, e as ActivityResult, h as AiBlankFact, i as AiDictationFacts,
|
|
1
|
+
import { x as AiSupportedActivityType, g as AiActivityInput, l as AiFeature, a4 as LearnerResponse, a3 as ItemOutcome, k as AiExplanationRequest, p as AiGrade, q as AiHintRequest, ak as ScoringDetail, r as AiItemFacts, y as AiTextResult, v as AiRefusal, F as AiWritingFeedbackRequest, E as AiWritingFeedback, a as ActivityData, ap as ValidationError, f as ActivityType, b as ActivityDataMap, I as CriterionScore, X as GradeRecord, ac as NativeControlHint, d as ActivityMedia, am as ScoringResult, K as DeferredScoringPartial, L as DictationData, N as DictationLearnerResponse, Q as FillInTheBlanksData, R as FillInTheBlanksLearnerResponse, U as GapSelectData, W as GapSelectLearnerResponse, a8 as MultipleChoiceData, a9 as MultipleChoiceLearnerResponse, ad as ReadAloudData, ag as ReadAloudLearnerResponse, ar as WrittenResponseData, as as WrittenResponseLearnerResponse } from './activity-DgpBJeBc.cjs';
|
|
2
|
+
export { A as ActivityAiPermissions, c as ActivityFeedback, e as ActivityResult, h as AiBlankFact, i as AiCriterionJudgement, j as AiDictationFacts, m as AiFillInTheBlanksFacts, n as AiGapFact, o as AiGapSelectFacts, s as AiMultipleChoiceFacts, t as AiOptionFact, u as AiProvenance, w as AiRubricCriterionFact, z as AiVerdict, B as AiWordFact, C as AiWritingCorrection, D as AiWritingFacts, G as AiWritingFeedbackResult, H as BlankConfig, J as DeferredReason, M as DictationEquivalence, O as DictationSlowMedia, P as DictationTolerance, S as GapSelectBank, T as GapSelectChoice, V as GapSelectGap, Y as Grader, Z as GraderKind, _ as GraderUsage, $ as GradingState, a0 as InlineCorrection, a1 as InteractionEvent, a2 as InteractionKind, a5 as LearnerResponseMap, a6 as MediaPlaybackPolicy, a7 as MediaTrack, aa as MultipleChoiceOption, ab as MultipleChoiceOptionMedia, ae as ReadAloudDimension, af as ReadAloudDimensionWeight, ah as ReadAloudSlowMedia, ai as RecordingBounds, aj as RecordingRef, al as ScoringOutcome, an as TextMatchPolicy, ao as TextMatchResult, aq as ValidationResult, at as WrittenResponseRubric, au as WrittenResponseRubricCriterion, av as XAPIActor, aw as XAPIConfig, ax as XAPIContext, ay as XAPIContextActivities, az as XAPIError, aA as XAPIObject, aB as XAPIResult, aC as XAPIScore, aD as XAPIStatement, aE as XAPIVerbObject, aF as levenshteinDistance, aG as matchText } from './activity-DgpBJeBc.cjs';
|
|
3
3
|
import { ResolvedItemScoringPolicy, ItemScoringPolicy, ScoredItem, RoundingPolicy, CompositionPolicy, AssessmentScore } from './scoring.cjs';
|
|
4
4
|
export { AssessmentSectionInput, Band, DEFAULT_ITEM_SCORING_POLICY, DEFAULT_PASS_THRESHOLD, DICTATION_MAX_ACCEPTED_TRANSCRIPTS, DICTATION_MAX_EQUIVALENCES, DICTATION_MAX_EQUIVALENCE_LENGTH, DICTATION_MAX_TEXT_LENGTH, DICTATION_MAX_TRANSCRIPT_LENGTH, DictationAlignment, DictationCharOp, DictationReference, DictationWordAlignment, EvaluateOptions, GradeReadAloudOptions, ITEM_SCORING_MAX_RETRIES, ItemScoringCount, ItemScoringPolicyIssue, ItemTriesOutcome, ItemTriesScore, ItemTry, ItemTryScore, PassFailureReason, READ_ALOUD_MAX_DIMENSION_WEIGHT, READ_ALOUD_MAX_REFERENCE_LENGTH, READ_ALOUD_MAX_SECONDS, READ_ALOUD_MAX_TAKES, ReadAloudWordAlignment, ReadAloudWordState, RoundingMode, SPEECH_ASSESSMENT_MAX_WORDS, ScoringOptions, SectionScore, SpeechAssessment, SpeechMeasurement, SpeechPhoneme, SpeechPhonemeCandidate, SpeechPlausibilityPolicy, SpeechSyllable, SpeechUnscorable, SpeechUnscorableCode, SpeechWord, SpeechWordError, WavInspection, WavInspectionPolicy, alignDictation, alignReadAloud, classifyBand, composeAssessmentScore, computePassThreshold, dictationReferenceWords, diffDictationChars, evaluate, evaluateTries, gradeReadAloud, gte, inspectWav, outcomeFromUnscorable, resolveItemScoringPolicy, roundGrade, score, scoreTries, validateItemScoringPolicy, validateSpeechAssessment } from './scoring.cjs';
|
|
5
|
-
import {
|
|
6
|
-
export {
|
|
7
|
-
import { z } from 'zod/v4';
|
|
5
|
+
import { p as SequenceSlot, S as SequenceEntry, I as ItemGroup, M as MediaProgress } from './index-BlOLlwOi.cjs';
|
|
6
|
+
export { a as MediaTimeline, R as RedactedActivity, b as RedactedBlankConfig, c as RedactedDictationData, d as RedactedDictationSlowMedia, e as RedactedFillInTheBlanksData, f as RedactedGapSelectBank, g as RedactedGapSelectChoice, h as RedactedGapSelectData, i as RedactedGapSelectGap, j as RedactedMultipleChoiceData, k as RedactedMultipleChoiceOption, l as RedactedMultipleChoiceOptionMedia, m as RedactedReadAloudData, n as RedactedStimulus, o as RedactedWrittenResponseData, q as SequenceSlotGroup, r as Stimulus, s as StimulusKind, T as TimelineChapter, t as TimelineCue, u as dictationJsonSchema, v as fillInTheBlanksJsonSchema, w as gapSelectJsonSchema, x as itemGroupJsonSchema, y as jsonSchemaFor, z as multipleChoiceJsonSchema, A as readAloudJsonSchema, B as stimulusJsonSchema, C as validateActivity, D as validateItemGroup, E as validateMedia, F as validateOptionMedia, G as writtenResponseJsonSchema } from './index-BlOLlwOi.cjs';
|
|
8
7
|
export { AnsweredStatementParams, CompletedStatementParams, SubmittedStatementParams, XAPIObjectParams, XAPIStatementParams, XAPIVerb, XAPIVerbKey, XAPI_VERB_DISPLAY, validateXAPIStatement, xAPIBuilder, xapiDefinitionFor } from './xapi.cjs';
|
|
9
8
|
|
|
10
9
|
/**
|
|
@@ -17,14 +16,18 @@ declare const AI_HINT_TYPES: readonly AiSupportedActivityType[];
|
|
|
17
16
|
/** The longest AI text shown, in code points. Longer is refused, not cut. */
|
|
18
17
|
declare const AI_TEXT_MAX_LENGTH = 2000;
|
|
19
18
|
/**
|
|
20
|
-
* Whether the SDK supports `feature` for this activity type
|
|
21
|
-
*
|
|
22
|
-
*
|
|
19
|
+
* Whether the SDK supports `feature` for this activity type: explanations and
|
|
20
|
+
* hints for the types it builds facts for, and writing feedback for a written
|
|
21
|
+
* response. A read-aloud, or a consumer's own type, has none.
|
|
23
22
|
*/
|
|
24
23
|
declare function aiSupports(activityType: string, feature: AiFeature): boolean;
|
|
25
24
|
/**
|
|
26
25
|
* Whether the item's author allows `feature`. Only an explicit `false`
|
|
27
26
|
* switches it off: an author can refuse a feature, never force one on.
|
|
27
|
+
*
|
|
28
|
+
* Writing feedback reads `explanations`: both are a model's words about the
|
|
29
|
+
* learner's own answer, and an author who switched one off has switched off
|
|
30
|
+
* the other.
|
|
28
31
|
*/
|
|
29
32
|
declare function aiAllowedByContent(data: AiActivityInput, feature: AiFeature): boolean;
|
|
30
33
|
/** A grade as an explanation must speak to it: all marks, some, or none. */
|
|
@@ -128,6 +131,59 @@ declare function checkAiHint(raw: unknown, request: AiHintRequest): {
|
|
|
128
131
|
*/
|
|
129
132
|
declare function hintRevealsAnswer(facts: AiItemFacts, hint: string): boolean;
|
|
130
133
|
|
|
134
|
+
/** The most corrections one piece of writing feedback may carry. More is refused, not cut. */
|
|
135
|
+
declare const AI_WRITING_MAX_CORRECTIONS = 20;
|
|
136
|
+
/** The longest quote, correction, explanation or criterion comment, in code points. */
|
|
137
|
+
declare const AI_WRITING_MAX_FIELD_LENGTH = 500;
|
|
138
|
+
/**
|
|
139
|
+
* The request for feedback on a draft, or `null` when there is none to give:
|
|
140
|
+
* not a written response, an author who switched explanations off (writing
|
|
141
|
+
* feedback reads `ai.explanations`), a redacted item — feedback is for
|
|
142
|
+
* practice, where the item is whole — or a draft with nothing in it.
|
|
143
|
+
*
|
|
144
|
+
* The facts are the task as the learner saw it, the draft verbatim with its
|
|
145
|
+
* word count recomputed as the grader will count it, and the rubric the answer
|
|
146
|
+
* will be graded on. `previousFeedback` is the text of the feedback already
|
|
147
|
+
* shown on earlier drafts, so a model can speak to what changed.
|
|
148
|
+
*/
|
|
149
|
+
declare function aiWritingFeedbackRequest(input: {
|
|
150
|
+
data: AiActivityInput;
|
|
151
|
+
response: LearnerResponse | null;
|
|
152
|
+
previousFeedback?: readonly string[];
|
|
153
|
+
learnerLocale?: string;
|
|
154
|
+
}): AiWritingFeedbackRequest | null;
|
|
155
|
+
/**
|
|
156
|
+
* Checks writing feedback a port returned for `request`, and turns it into what
|
|
157
|
+
* a learner is shown. The SDK shows a model's feedback whole or not at all: it
|
|
158
|
+
* never drops the part it doubts and shows the rest.
|
|
159
|
+
*
|
|
160
|
+
* - **The text** is read as every AI text is (`readAiTextResult`): plain text,
|
|
161
|
+
* not empty, at most {@link AI_TEXT_MAX_LENGTH} code points.
|
|
162
|
+
* - **Every correction must quote the draft** — the check only this SDK can run.
|
|
163
|
+
* The SDK finds each quote in the draft itself, typographic quotes and runs of
|
|
164
|
+
* whitespace aside, and anchors it there; a range the model claims must hold
|
|
165
|
+
* the quote. A correction of words the learner did not write refuses the
|
|
166
|
+
* whole reply as `misquotes-answer`, as a hint that gives the answer away
|
|
167
|
+
* refuses the hint. The `original` shown is the draft's own text at the range.
|
|
168
|
+
* At most {@link AI_WRITING_MAX_CORRECTIONS}; a correction that changes
|
|
169
|
+
* nothing is `malformed`.
|
|
170
|
+
* - **Criteria are judgements; the arithmetic is the SDK's.** Each names a
|
|
171
|
+
* criterion of the item's rubric, once; its score, when it has one, is a
|
|
172
|
+
* score out of its `maxScore`. The rubric's weights are attached, whatever
|
|
173
|
+
* the model sent. Anything else is `malformed`, as is any criterion on an
|
|
174
|
+
* item with no rubric.
|
|
175
|
+
* - **`indicativeScore`** is the rubric's weighted total, computed as
|
|
176
|
+
* `gradeFromRubric` computes a grade, when every criterion of the rubric was
|
|
177
|
+
* judged; `null` otherwise. An indication, never a grade.
|
|
178
|
+
*/
|
|
179
|
+
declare function checkAiWritingFeedback(raw: unknown, request: AiWritingFeedbackRequest): {
|
|
180
|
+
ok: true;
|
|
181
|
+
feedback: AiWritingFeedback;
|
|
182
|
+
} | {
|
|
183
|
+
ok: false;
|
|
184
|
+
refusal: AiRefusal;
|
|
185
|
+
};
|
|
186
|
+
|
|
131
187
|
/**
|
|
132
188
|
* How a paper is delivered: what a learner is shown around the questions, as
|
|
133
189
|
* the school running it decides — separately from the content, so that one
|
|
@@ -1160,6 +1216,80 @@ declare function serializeMediaPlayLedger(plan: AttemptPlan, entries: Readonly<R
|
|
|
1160
1216
|
*/
|
|
1161
1217
|
declare function restoreMediaPlayLedger(plan: AttemptPlan, stored: MediaPlayLedger): MediaPlayLedger;
|
|
1162
1218
|
|
|
1219
|
+
/**
|
|
1220
|
+
* Standard Schema v1 (https://standardschema.dev): the interface zod, valibot,
|
|
1221
|
+
* ArkType and other validators implement, so a library can accept a schema from
|
|
1222
|
+
* any of them without depending on one. Copied here, as the specification asks
|
|
1223
|
+
* a library to do, so lk-core depends on no validator's types.
|
|
1224
|
+
*
|
|
1225
|
+
* A registered activity type's `schema` and `redactedSchema` are Standard
|
|
1226
|
+
* Schemas. A zod 4 schema is one as written: `schema: z.object({ … })` needs no
|
|
1227
|
+
* adapter.
|
|
1228
|
+
*/
|
|
1229
|
+
/** A schema that validates unknown input and produces `Output`. */
|
|
1230
|
+
interface StandardSchemaV1<Input = unknown, Output = Input> {
|
|
1231
|
+
/** The Standard Schema properties. */
|
|
1232
|
+
readonly '~standard': StandardSchemaV1.Props<Input, Output>;
|
|
1233
|
+
}
|
|
1234
|
+
declare namespace StandardSchemaV1 {
|
|
1235
|
+
/** The Standard Schema properties interface. */
|
|
1236
|
+
interface Props<Input = unknown, Output = Input> {
|
|
1237
|
+
/** The version number of the standard. */
|
|
1238
|
+
readonly version: 1;
|
|
1239
|
+
/** The vendor name of the schema library. */
|
|
1240
|
+
readonly vendor: string;
|
|
1241
|
+
/**
|
|
1242
|
+
* Validates unknown input values. lk-core validates synchronously, so a
|
|
1243
|
+
* schema whose validation returns a Promise is refused when it is read.
|
|
1244
|
+
*/
|
|
1245
|
+
readonly validate: (value: unknown, options?: StandardSchemaV1.Options | undefined) => Result<Output> | Promise<Result<Output>>;
|
|
1246
|
+
/** Inferred types associated with the schema. */
|
|
1247
|
+
readonly types?: Types<Input, Output> | undefined;
|
|
1248
|
+
}
|
|
1249
|
+
/** The result interface of the validate function. */
|
|
1250
|
+
type Result<Output> = SuccessResult<Output> | FailureResult;
|
|
1251
|
+
/** The result interface if validation succeeds. */
|
|
1252
|
+
interface SuccessResult<Output> {
|
|
1253
|
+
/** The typed output value. */
|
|
1254
|
+
readonly value: Output;
|
|
1255
|
+
/** The absence of issues indicates success. */
|
|
1256
|
+
readonly issues?: undefined;
|
|
1257
|
+
}
|
|
1258
|
+
/** Options for the validate function. */
|
|
1259
|
+
interface Options {
|
|
1260
|
+
/** Implicit support for additional vendor-specific parameters, if needed. */
|
|
1261
|
+
readonly libraryOptions?: Record<string, unknown> | undefined;
|
|
1262
|
+
}
|
|
1263
|
+
/** The result interface if validation fails. */
|
|
1264
|
+
interface FailureResult {
|
|
1265
|
+
/** The issues of failed validation. */
|
|
1266
|
+
readonly issues: ReadonlyArray<Issue>;
|
|
1267
|
+
}
|
|
1268
|
+
/** The issue interface of the failure output. */
|
|
1269
|
+
interface Issue {
|
|
1270
|
+
/** The error message of the issue. */
|
|
1271
|
+
readonly message: string;
|
|
1272
|
+
/** The path of the issue, if any. */
|
|
1273
|
+
readonly path?: ReadonlyArray<PropertyKey | PathSegment> | undefined;
|
|
1274
|
+
}
|
|
1275
|
+
/** The path segment interface of the issue. */
|
|
1276
|
+
interface PathSegment {
|
|
1277
|
+
/** The key representing a path segment. */
|
|
1278
|
+
readonly key: PropertyKey;
|
|
1279
|
+
}
|
|
1280
|
+
/** The Standard Schema types interface. */
|
|
1281
|
+
interface Types<Input = unknown, Output = Input> {
|
|
1282
|
+
/** The input type of the schema. */
|
|
1283
|
+
readonly input: Input;
|
|
1284
|
+
/** The output type of the schema. */
|
|
1285
|
+
readonly output: Output;
|
|
1286
|
+
}
|
|
1287
|
+
/** Infers the input type of a Standard Schema. */
|
|
1288
|
+
type InferInput<Schema extends StandardSchemaV1> = NonNullable<Schema['~standard']['types']>['input'];
|
|
1289
|
+
/** Infers the output type of a Standard Schema. */
|
|
1290
|
+
type InferOutput<Schema extends StandardSchemaV1> = NonNullable<Schema['~standard']['types']>['output'];
|
|
1291
|
+
}
|
|
1292
|
+
|
|
1163
1293
|
/** ScoringResult without `passed` — the public `score()` / `evaluate()` fill that in. */
|
|
1164
1294
|
type PartialScoringResult = Omit<ScoringResult, 'passed'>;
|
|
1165
1295
|
/**
|
|
@@ -1237,8 +1367,9 @@ interface ActivityTypeAuthoring<TData> {
|
|
|
1237
1367
|
* length included, so report a rule about a whole list at the list's own path.
|
|
1238
1368
|
* A failure at the root of the draft is accounted for only by an issue at the
|
|
1239
1369
|
* root. A `null` the schema refuses, where nothing here reports it, comes back
|
|
1240
|
-
* as `null_not_allowed
|
|
1241
|
-
*
|
|
1370
|
+
* as `null_not_allowed`. A zod 4 schema tells a refused `null` from a rule of
|
|
1371
|
+
* yours that merely points at one, which keeps its own code; a schema from
|
|
1372
|
+
* another library cannot, so report such a rule here, at its path.
|
|
1242
1373
|
*
|
|
1243
1374
|
* A code documented in `docs/authoring.md` is reported with its documented
|
|
1244
1375
|
* severity. For a code of your own, a severity other than `'incomplete'` is
|
|
@@ -1252,14 +1383,38 @@ interface ActivityTypeAuthoring<TData> {
|
|
|
1252
1383
|
* descriptor makes `validateActivity`, `validateDraft`, `score`, `evaluate`,
|
|
1253
1384
|
* `redact`, and `jsonSchemaFor` work for the type — an activity type is a value,
|
|
1254
1385
|
* not a hardcoded union member (R1).
|
|
1386
|
+
*
|
|
1387
|
+
* Its schemas are Standard Schemas ({@link StandardSchemaV1}), so they can be
|
|
1388
|
+
* written with any library that implements the standard — a zod 4 schema is
|
|
1389
|
+
* one as it stands:
|
|
1390
|
+
*
|
|
1391
|
+
* ```ts
|
|
1392
|
+
* const pollType = defineActivityType<PollData, PollResponse>({
|
|
1393
|
+
* type: 'poll',
|
|
1394
|
+
* schema: z.looseObject({ type: z.literal('poll'), id: z.string(), … }),
|
|
1395
|
+
* scoring: { kind: 'sync', score: scorePoll },
|
|
1396
|
+
* });
|
|
1397
|
+
* registerActivityType(pollType);
|
|
1398
|
+
* ```
|
|
1255
1399
|
*/
|
|
1256
1400
|
interface ActivityTypeDescriptor<TData extends {
|
|
1257
1401
|
type: string;
|
|
1258
1402
|
}, TResponse> {
|
|
1259
1403
|
/** The `type` discriminator string (kebab-case by convention). */
|
|
1260
1404
|
readonly type: TData['type'];
|
|
1261
|
-
/**
|
|
1262
|
-
|
|
1405
|
+
/**
|
|
1406
|
+
* The activity's data contract, as a Standard Schema whose output is the
|
|
1407
|
+
* data. Its validation must be synchronous: every entry point that reads it
|
|
1408
|
+
* is.
|
|
1409
|
+
*/
|
|
1410
|
+
readonly schema: StandardSchemaV1<unknown, TData>;
|
|
1411
|
+
/**
|
|
1412
|
+
* The contract as JSON Schema, for `jsonSchemaFor`. Leave it out when
|
|
1413
|
+
* `schema` can produce one itself through the Standard JSON Schema converter
|
|
1414
|
+
* (`'~standard'.jsonSchema`), as a zod 4.6 schema can; give it to override
|
|
1415
|
+
* that, or for a library that cannot.
|
|
1416
|
+
*/
|
|
1417
|
+
readonly jsonSchema?: Readonly<Record<string, unknown>>;
|
|
1263
1418
|
/** How responses are graded. */
|
|
1264
1419
|
readonly scoring: ActivityTypeScoring<TData, TResponse>;
|
|
1265
1420
|
/** Whether a response counts as an answer (vs. blank/untouched). */
|
|
@@ -1268,10 +1423,11 @@ interface ActivityTypeDescriptor<TData extends {
|
|
|
1268
1423
|
readonly fieldPolicy?: FieldPolicy;
|
|
1269
1424
|
/**
|
|
1270
1425
|
* Schema the output of `redact(data)` (with default `reveal: 'none'`) must
|
|
1271
|
-
* satisfy. Strict by design: it proves the ABSENCE of
|
|
1272
|
-
* so `assertRedacted` can guarantee a payload is safe to
|
|
1426
|
+
* satisfy, as a Standard Schema. Strict by design: it proves the ABSENCE of
|
|
1427
|
+
* answer-key fields, so `assertRedacted` can guarantee a payload is safe to
|
|
1428
|
+
* send to a learner.
|
|
1273
1429
|
*/
|
|
1274
|
-
readonly redactedSchema?:
|
|
1430
|
+
readonly redactedSchema?: StandardSchemaV1;
|
|
1275
1431
|
/** Interop facts for xAPI (and later QTI) statement building. */
|
|
1276
1432
|
readonly interop?: ActivityTypeInterop<TData>;
|
|
1277
1433
|
/** The interaction-event kinds components for this type emit. */
|
|
@@ -1285,7 +1441,8 @@ interface ActivityTypeDescriptor<TData extends {
|
|
|
1285
1441
|
*/
|
|
1286
1442
|
interface RegisteredActivityTypeDescriptor {
|
|
1287
1443
|
readonly type: string;
|
|
1288
|
-
readonly schema:
|
|
1444
|
+
readonly schema: StandardSchemaV1;
|
|
1445
|
+
readonly jsonSchema?: Readonly<Record<string, unknown>>;
|
|
1289
1446
|
readonly scoring: {
|
|
1290
1447
|
readonly kind: 'sync';
|
|
1291
1448
|
readonly score: (data: unknown, response: unknown) => PartialScoringResult;
|
|
@@ -1296,7 +1453,7 @@ interface RegisteredActivityTypeDescriptor {
|
|
|
1296
1453
|
};
|
|
1297
1454
|
readonly isAnswered?: (response: unknown) => boolean;
|
|
1298
1455
|
readonly fieldPolicy?: FieldPolicy;
|
|
1299
|
-
readonly redactedSchema?:
|
|
1456
|
+
readonly redactedSchema?: StandardSchemaV1;
|
|
1300
1457
|
readonly interop?: ActivityTypeInterop<unknown>;
|
|
1301
1458
|
readonly interactions?: readonly string[];
|
|
1302
1459
|
readonly authoring?: ActivityTypeAuthoring<unknown>;
|
|
@@ -1638,4 +1795,4 @@ interface ThemeTokens {
|
|
|
1638
1795
|
'--lk-transition-base': string;
|
|
1639
1796
|
}
|
|
1640
1797
|
|
|
1641
|
-
export { AI_EXPLANATION_TYPES, AI_HINT_TYPES, AI_TEXT_MAX_LENGTH, ActivityData, ActivityDataMap, ActivityMedia, ActivitySchemaError, ActivityType, type ActivityTypeAuthoring, type ActivityTypeDescriptor, type ActivityTypeInterop, type ActivityTypeScoring, AiActivityInput, AiExplanationRequest, AiFeature, AiGrade, AiHintRequest, AiItemFacts, AiRefusal, AiSupportedActivityType, AiTextResult, AssessmentScore, type AttemptPlan, type AttemptPlanDrift, type AttemptPlanSlot, type AttemptProgress, type AttemptState, CompositionPolicy, CriterionScore, DeferredScoringError, DeferredScoringPartial, type DeliveryPolicy, type DeliveryPolicyIssue, DictationData, DictationLearnerResponse, type DraftComplete, type DraftContext, type DraftIssue, type DraftNotComplete, type DraftSeverity, type DraftValidationResult, type FieldPolicy, FillInTheBlanksData, FillInTheBlanksLearnerResponse, type FlattenSequenceOptions, GapSelectData, GapSelectLearnerResponse, type GradeFromRubricOptions, GradeRecord, INTERACTIVE_VIDEO_ITEM_TYPES, type InteractiveVideoItemType, ItemGroup, ItemOutcome, ItemScoringPolicy, LearnerResponse, type MediaBudgetRef, type MediaPlayClaim, type MediaPlayGrant, type MediaPlayLedger, type MediaPlayLedgerEntry, MediaProgress, type MissingOutcomePolicy, MultipleChoiceData, MultipleChoiceLearnerResponse, NativeControlHint, OPEN_DELIVERY_POLICY, type PartialScoringResult, type PlanAttemptOptions, type PlannableEntry, ReadAloudData, ReadAloudLearnerResponse, type RedactOptions, type RedactedActivityData, type RedactedItemGroup, RedactedScoringError, type RegisteredActivityTypeDescriptor, type ResolvedDeliveryPolicy, ResolvedItemScoringPolicy, type ResolvedPlaybackPolicy, type ResponseDiffEntry, RoundingPolicy, ScoredItem, ScoringDetail, ScoringResult, type SeededShuffleOptions, type Sensitivity, SequenceEntry, SequenceSlot, type ShuffleVersion, TIMELINE_MAX_CHAPTERS, TIMELINE_MAX_ITEMS, TIMELINE_MAX_QUIZZES, TIMELINE_MAX_TITLE_LENGTH, type ThemeTokens, UnknownActivityTypeError, ValidationError, WrittenResponseData, WrittenResponseLearnerResponse, type XAPIInteractionType, aiAllowedByContent, aiExplanationRequest, aiGradeOf, aiHintRequest, aiSupports, assertRedacted, assertRedactedItemGroup, buildAiFacts, canonicalJson, checkAiExplanation, checkAiHint, combineDeliveryPolicies, composeTimelineScore, contentHash, countWords, createDraft, createInteractiveVideoDraft, createItemGroupDraft, defineActivityType, dictationType, diffResponses, entryKeyOf, fillInTheBlanksType, fingerprint, flattenSequence, gapSelectType, getActivityTypeDescriptor, gradeFromRubric, hasGrade, hashSeed, hintRevealsAnswer, isInteractiveVideoItemType, isItemGroup, multipleChoiceType, outcomeFromGrade, planAttempt, planMediaBudgets, readAiTextResult, readAloudType, readMediaProgress, redact, redactItemGroup, registerActivityType, registeredActivityTypes, resolveDeliveryPolicy, resolvePlaybackPolicy, restoreAttemptState, restoreMediaPlayLedger, scoredItemsFromPlan, seededShuffle, serializeAttemptState, serializeMediaPlayLedger, slotMediaKey, stimulusMediaKey, validateDeliveryPolicy, validateDraft, validateItemGroupDraft, verifyAttemptPlan, writtenResponseType };
|
|
1798
|
+
export { AI_EXPLANATION_TYPES, AI_HINT_TYPES, AI_TEXT_MAX_LENGTH, AI_WRITING_MAX_CORRECTIONS, AI_WRITING_MAX_FIELD_LENGTH, ActivityData, ActivityDataMap, ActivityMedia, ActivitySchemaError, ActivityType, type ActivityTypeAuthoring, type ActivityTypeDescriptor, type ActivityTypeInterop, type ActivityTypeScoring, AiActivityInput, AiExplanationRequest, AiFeature, AiGrade, AiHintRequest, AiItemFacts, AiRefusal, AiSupportedActivityType, AiTextResult, AiWritingFeedback, AiWritingFeedbackRequest, AssessmentScore, type AttemptPlan, type AttemptPlanDrift, type AttemptPlanSlot, type AttemptProgress, type AttemptState, CompositionPolicy, CriterionScore, DeferredScoringError, DeferredScoringPartial, type DeliveryPolicy, type DeliveryPolicyIssue, DictationData, DictationLearnerResponse, type DraftComplete, type DraftContext, type DraftIssue, type DraftNotComplete, type DraftSeverity, type DraftValidationResult, type FieldPolicy, FillInTheBlanksData, FillInTheBlanksLearnerResponse, type FlattenSequenceOptions, GapSelectData, GapSelectLearnerResponse, type GradeFromRubricOptions, GradeRecord, INTERACTIVE_VIDEO_ITEM_TYPES, type InteractiveVideoItemType, ItemGroup, ItemOutcome, ItemScoringPolicy, LearnerResponse, type MediaBudgetRef, type MediaPlayClaim, type MediaPlayGrant, type MediaPlayLedger, type MediaPlayLedgerEntry, MediaProgress, type MissingOutcomePolicy, MultipleChoiceData, MultipleChoiceLearnerResponse, NativeControlHint, OPEN_DELIVERY_POLICY, type PartialScoringResult, type PlanAttemptOptions, type PlannableEntry, ReadAloudData, ReadAloudLearnerResponse, type RedactOptions, type RedactedActivityData, type RedactedItemGroup, RedactedScoringError, type RegisteredActivityTypeDescriptor, type ResolvedDeliveryPolicy, ResolvedItemScoringPolicy, type ResolvedPlaybackPolicy, type ResponseDiffEntry, RoundingPolicy, ScoredItem, ScoringDetail, ScoringResult, type SeededShuffleOptions, type Sensitivity, SequenceEntry, SequenceSlot, type ShuffleVersion, StandardSchemaV1, TIMELINE_MAX_CHAPTERS, TIMELINE_MAX_ITEMS, TIMELINE_MAX_QUIZZES, TIMELINE_MAX_TITLE_LENGTH, type ThemeTokens, UnknownActivityTypeError, ValidationError, WrittenResponseData, WrittenResponseLearnerResponse, type XAPIInteractionType, aiAllowedByContent, aiExplanationRequest, aiGradeOf, aiHintRequest, aiSupports, aiWritingFeedbackRequest, assertRedacted, assertRedactedItemGroup, buildAiFacts, canonicalJson, checkAiExplanation, checkAiHint, checkAiWritingFeedback, combineDeliveryPolicies, composeTimelineScore, contentHash, countWords, createDraft, createInteractiveVideoDraft, createItemGroupDraft, defineActivityType, dictationType, diffResponses, entryKeyOf, fillInTheBlanksType, fingerprint, flattenSequence, gapSelectType, getActivityTypeDescriptor, gradeFromRubric, hasGrade, hashSeed, hintRevealsAnswer, isInteractiveVideoItemType, isItemGroup, multipleChoiceType, outcomeFromGrade, planAttempt, planMediaBudgets, readAiTextResult, readAloudType, readMediaProgress, redact, redactItemGroup, registerActivityType, registeredActivityTypes, resolveDeliveryPolicy, resolvePlaybackPolicy, restoreAttemptState, restoreMediaPlayLedger, scoredItemsFromPlan, seededShuffle, serializeAttemptState, serializeMediaPlayLedger, slotMediaKey, stimulusMediaKey, validateDeliveryPolicy, validateDraft, validateItemGroupDraft, verifyAttemptPlan, writtenResponseType };
|
package/dist/index.d.ts
CHANGED
|
@@ -1,10 +1,9 @@
|
|
|
1
|
-
import {
|
|
2
|
-
export { A as ActivityAiPermissions, c as ActivityFeedback, e as ActivityResult, h as AiBlankFact, i as AiDictationFacts,
|
|
1
|
+
import { x as AiSupportedActivityType, g as AiActivityInput, l as AiFeature, a4 as LearnerResponse, a3 as ItemOutcome, k as AiExplanationRequest, p as AiGrade, q as AiHintRequest, ak as ScoringDetail, r as AiItemFacts, y as AiTextResult, v as AiRefusal, F as AiWritingFeedbackRequest, E as AiWritingFeedback, a as ActivityData, ap as ValidationError, f as ActivityType, b as ActivityDataMap, I as CriterionScore, X as GradeRecord, ac as NativeControlHint, d as ActivityMedia, am as ScoringResult, K as DeferredScoringPartial, L as DictationData, N as DictationLearnerResponse, Q as FillInTheBlanksData, R as FillInTheBlanksLearnerResponse, U as GapSelectData, W as GapSelectLearnerResponse, a8 as MultipleChoiceData, a9 as MultipleChoiceLearnerResponse, ad as ReadAloudData, ag as ReadAloudLearnerResponse, ar as WrittenResponseData, as as WrittenResponseLearnerResponse } from './activity-DgpBJeBc.js';
|
|
2
|
+
export { A as ActivityAiPermissions, c as ActivityFeedback, e as ActivityResult, h as AiBlankFact, i as AiCriterionJudgement, j as AiDictationFacts, m as AiFillInTheBlanksFacts, n as AiGapFact, o as AiGapSelectFacts, s as AiMultipleChoiceFacts, t as AiOptionFact, u as AiProvenance, w as AiRubricCriterionFact, z as AiVerdict, B as AiWordFact, C as AiWritingCorrection, D as AiWritingFacts, G as AiWritingFeedbackResult, H as BlankConfig, J as DeferredReason, M as DictationEquivalence, O as DictationSlowMedia, P as DictationTolerance, S as GapSelectBank, T as GapSelectChoice, V as GapSelectGap, Y as Grader, Z as GraderKind, _ as GraderUsage, $ as GradingState, a0 as InlineCorrection, a1 as InteractionEvent, a2 as InteractionKind, a5 as LearnerResponseMap, a6 as MediaPlaybackPolicy, a7 as MediaTrack, aa as MultipleChoiceOption, ab as MultipleChoiceOptionMedia, ae as ReadAloudDimension, af as ReadAloudDimensionWeight, ah as ReadAloudSlowMedia, ai as RecordingBounds, aj as RecordingRef, al as ScoringOutcome, an as TextMatchPolicy, ao as TextMatchResult, aq as ValidationResult, at as WrittenResponseRubric, au as WrittenResponseRubricCriterion, av as XAPIActor, aw as XAPIConfig, ax as XAPIContext, ay as XAPIContextActivities, az as XAPIError, aA as XAPIObject, aB as XAPIResult, aC as XAPIScore, aD as XAPIStatement, aE as XAPIVerbObject, aF as levenshteinDistance, aG as matchText } from './activity-DgpBJeBc.js';
|
|
3
3
|
import { ResolvedItemScoringPolicy, ItemScoringPolicy, ScoredItem, RoundingPolicy, CompositionPolicy, AssessmentScore } from './scoring.js';
|
|
4
4
|
export { AssessmentSectionInput, Band, DEFAULT_ITEM_SCORING_POLICY, DEFAULT_PASS_THRESHOLD, DICTATION_MAX_ACCEPTED_TRANSCRIPTS, DICTATION_MAX_EQUIVALENCES, DICTATION_MAX_EQUIVALENCE_LENGTH, DICTATION_MAX_TEXT_LENGTH, DICTATION_MAX_TRANSCRIPT_LENGTH, DictationAlignment, DictationCharOp, DictationReference, DictationWordAlignment, EvaluateOptions, GradeReadAloudOptions, ITEM_SCORING_MAX_RETRIES, ItemScoringCount, ItemScoringPolicyIssue, ItemTriesOutcome, ItemTriesScore, ItemTry, ItemTryScore, PassFailureReason, READ_ALOUD_MAX_DIMENSION_WEIGHT, READ_ALOUD_MAX_REFERENCE_LENGTH, READ_ALOUD_MAX_SECONDS, READ_ALOUD_MAX_TAKES, ReadAloudWordAlignment, ReadAloudWordState, RoundingMode, SPEECH_ASSESSMENT_MAX_WORDS, ScoringOptions, SectionScore, SpeechAssessment, SpeechMeasurement, SpeechPhoneme, SpeechPhonemeCandidate, SpeechPlausibilityPolicy, SpeechSyllable, SpeechUnscorable, SpeechUnscorableCode, SpeechWord, SpeechWordError, WavInspection, WavInspectionPolicy, alignDictation, alignReadAloud, classifyBand, composeAssessmentScore, computePassThreshold, dictationReferenceWords, diffDictationChars, evaluate, evaluateTries, gradeReadAloud, gte, inspectWav, outcomeFromUnscorable, resolveItemScoringPolicy, roundGrade, score, scoreTries, validateItemScoringPolicy, validateSpeechAssessment } from './scoring.js';
|
|
5
|
-
import {
|
|
6
|
-
export {
|
|
7
|
-
import { z } from 'zod/v4';
|
|
5
|
+
import { p as SequenceSlot, S as SequenceEntry, I as ItemGroup, M as MediaProgress } from './index-BVNeSCWC.js';
|
|
6
|
+
export { a as MediaTimeline, R as RedactedActivity, b as RedactedBlankConfig, c as RedactedDictationData, d as RedactedDictationSlowMedia, e as RedactedFillInTheBlanksData, f as RedactedGapSelectBank, g as RedactedGapSelectChoice, h as RedactedGapSelectData, i as RedactedGapSelectGap, j as RedactedMultipleChoiceData, k as RedactedMultipleChoiceOption, l as RedactedMultipleChoiceOptionMedia, m as RedactedReadAloudData, n as RedactedStimulus, o as RedactedWrittenResponseData, q as SequenceSlotGroup, r as Stimulus, s as StimulusKind, T as TimelineChapter, t as TimelineCue, u as dictationJsonSchema, v as fillInTheBlanksJsonSchema, w as gapSelectJsonSchema, x as itemGroupJsonSchema, y as jsonSchemaFor, z as multipleChoiceJsonSchema, A as readAloudJsonSchema, B as stimulusJsonSchema, C as validateActivity, D as validateItemGroup, E as validateMedia, F as validateOptionMedia, G as writtenResponseJsonSchema } from './index-BVNeSCWC.js';
|
|
8
7
|
export { AnsweredStatementParams, CompletedStatementParams, SubmittedStatementParams, XAPIObjectParams, XAPIStatementParams, XAPIVerb, XAPIVerbKey, XAPI_VERB_DISPLAY, validateXAPIStatement, xAPIBuilder, xapiDefinitionFor } from './xapi.js';
|
|
9
8
|
|
|
10
9
|
/**
|
|
@@ -17,14 +16,18 @@ declare const AI_HINT_TYPES: readonly AiSupportedActivityType[];
|
|
|
17
16
|
/** The longest AI text shown, in code points. Longer is refused, not cut. */
|
|
18
17
|
declare const AI_TEXT_MAX_LENGTH = 2000;
|
|
19
18
|
/**
|
|
20
|
-
* Whether the SDK supports `feature` for this activity type
|
|
21
|
-
*
|
|
22
|
-
*
|
|
19
|
+
* Whether the SDK supports `feature` for this activity type: explanations and
|
|
20
|
+
* hints for the types it builds facts for, and writing feedback for a written
|
|
21
|
+
* response. A read-aloud, or a consumer's own type, has none.
|
|
23
22
|
*/
|
|
24
23
|
declare function aiSupports(activityType: string, feature: AiFeature): boolean;
|
|
25
24
|
/**
|
|
26
25
|
* Whether the item's author allows `feature`. Only an explicit `false`
|
|
27
26
|
* switches it off: an author can refuse a feature, never force one on.
|
|
27
|
+
*
|
|
28
|
+
* Writing feedback reads `explanations`: both are a model's words about the
|
|
29
|
+
* learner's own answer, and an author who switched one off has switched off
|
|
30
|
+
* the other.
|
|
28
31
|
*/
|
|
29
32
|
declare function aiAllowedByContent(data: AiActivityInput, feature: AiFeature): boolean;
|
|
30
33
|
/** A grade as an explanation must speak to it: all marks, some, or none. */
|
|
@@ -128,6 +131,59 @@ declare function checkAiHint(raw: unknown, request: AiHintRequest): {
|
|
|
128
131
|
*/
|
|
129
132
|
declare function hintRevealsAnswer(facts: AiItemFacts, hint: string): boolean;
|
|
130
133
|
|
|
134
|
+
/** The most corrections one piece of writing feedback may carry. More is refused, not cut. */
|
|
135
|
+
declare const AI_WRITING_MAX_CORRECTIONS = 20;
|
|
136
|
+
/** The longest quote, correction, explanation or criterion comment, in code points. */
|
|
137
|
+
declare const AI_WRITING_MAX_FIELD_LENGTH = 500;
|
|
138
|
+
/**
|
|
139
|
+
* The request for feedback on a draft, or `null` when there is none to give:
|
|
140
|
+
* not a written response, an author who switched explanations off (writing
|
|
141
|
+
* feedback reads `ai.explanations`), a redacted item — feedback is for
|
|
142
|
+
* practice, where the item is whole — or a draft with nothing in it.
|
|
143
|
+
*
|
|
144
|
+
* The facts are the task as the learner saw it, the draft verbatim with its
|
|
145
|
+
* word count recomputed as the grader will count it, and the rubric the answer
|
|
146
|
+
* will be graded on. `previousFeedback` is the text of the feedback already
|
|
147
|
+
* shown on earlier drafts, so a model can speak to what changed.
|
|
148
|
+
*/
|
|
149
|
+
declare function aiWritingFeedbackRequest(input: {
|
|
150
|
+
data: AiActivityInput;
|
|
151
|
+
response: LearnerResponse | null;
|
|
152
|
+
previousFeedback?: readonly string[];
|
|
153
|
+
learnerLocale?: string;
|
|
154
|
+
}): AiWritingFeedbackRequest | null;
|
|
155
|
+
/**
|
|
156
|
+
* Checks writing feedback a port returned for `request`, and turns it into what
|
|
157
|
+
* a learner is shown. The SDK shows a model's feedback whole or not at all: it
|
|
158
|
+
* never drops the part it doubts and shows the rest.
|
|
159
|
+
*
|
|
160
|
+
* - **The text** is read as every AI text is (`readAiTextResult`): plain text,
|
|
161
|
+
* not empty, at most {@link AI_TEXT_MAX_LENGTH} code points.
|
|
162
|
+
* - **Every correction must quote the draft** — the check only this SDK can run.
|
|
163
|
+
* The SDK finds each quote in the draft itself, typographic quotes and runs of
|
|
164
|
+
* whitespace aside, and anchors it there; a range the model claims must hold
|
|
165
|
+
* the quote. A correction of words the learner did not write refuses the
|
|
166
|
+
* whole reply as `misquotes-answer`, as a hint that gives the answer away
|
|
167
|
+
* refuses the hint. The `original` shown is the draft's own text at the range.
|
|
168
|
+
* At most {@link AI_WRITING_MAX_CORRECTIONS}; a correction that changes
|
|
169
|
+
* nothing is `malformed`.
|
|
170
|
+
* - **Criteria are judgements; the arithmetic is the SDK's.** Each names a
|
|
171
|
+
* criterion of the item's rubric, once; its score, when it has one, is a
|
|
172
|
+
* score out of its `maxScore`. The rubric's weights are attached, whatever
|
|
173
|
+
* the model sent. Anything else is `malformed`, as is any criterion on an
|
|
174
|
+
* item with no rubric.
|
|
175
|
+
* - **`indicativeScore`** is the rubric's weighted total, computed as
|
|
176
|
+
* `gradeFromRubric` computes a grade, when every criterion of the rubric was
|
|
177
|
+
* judged; `null` otherwise. An indication, never a grade.
|
|
178
|
+
*/
|
|
179
|
+
declare function checkAiWritingFeedback(raw: unknown, request: AiWritingFeedbackRequest): {
|
|
180
|
+
ok: true;
|
|
181
|
+
feedback: AiWritingFeedback;
|
|
182
|
+
} | {
|
|
183
|
+
ok: false;
|
|
184
|
+
refusal: AiRefusal;
|
|
185
|
+
};
|
|
186
|
+
|
|
131
187
|
/**
|
|
132
188
|
* How a paper is delivered: what a learner is shown around the questions, as
|
|
133
189
|
* the school running it decides — separately from the content, so that one
|
|
@@ -1160,6 +1216,80 @@ declare function serializeMediaPlayLedger(plan: AttemptPlan, entries: Readonly<R
|
|
|
1160
1216
|
*/
|
|
1161
1217
|
declare function restoreMediaPlayLedger(plan: AttemptPlan, stored: MediaPlayLedger): MediaPlayLedger;
|
|
1162
1218
|
|
|
1219
|
+
/**
|
|
1220
|
+
* Standard Schema v1 (https://standardschema.dev): the interface zod, valibot,
|
|
1221
|
+
* ArkType and other validators implement, so a library can accept a schema from
|
|
1222
|
+
* any of them without depending on one. Copied here, as the specification asks
|
|
1223
|
+
* a library to do, so lk-core depends on no validator's types.
|
|
1224
|
+
*
|
|
1225
|
+
* A registered activity type's `schema` and `redactedSchema` are Standard
|
|
1226
|
+
* Schemas. A zod 4 schema is one as written: `schema: z.object({ … })` needs no
|
|
1227
|
+
* adapter.
|
|
1228
|
+
*/
|
|
1229
|
+
/** A schema that validates unknown input and produces `Output`. */
|
|
1230
|
+
interface StandardSchemaV1<Input = unknown, Output = Input> {
|
|
1231
|
+
/** The Standard Schema properties. */
|
|
1232
|
+
readonly '~standard': StandardSchemaV1.Props<Input, Output>;
|
|
1233
|
+
}
|
|
1234
|
+
declare namespace StandardSchemaV1 {
|
|
1235
|
+
/** The Standard Schema properties interface. */
|
|
1236
|
+
interface Props<Input = unknown, Output = Input> {
|
|
1237
|
+
/** The version number of the standard. */
|
|
1238
|
+
readonly version: 1;
|
|
1239
|
+
/** The vendor name of the schema library. */
|
|
1240
|
+
readonly vendor: string;
|
|
1241
|
+
/**
|
|
1242
|
+
* Validates unknown input values. lk-core validates synchronously, so a
|
|
1243
|
+
* schema whose validation returns a Promise is refused when it is read.
|
|
1244
|
+
*/
|
|
1245
|
+
readonly validate: (value: unknown, options?: StandardSchemaV1.Options | undefined) => Result<Output> | Promise<Result<Output>>;
|
|
1246
|
+
/** Inferred types associated with the schema. */
|
|
1247
|
+
readonly types?: Types<Input, Output> | undefined;
|
|
1248
|
+
}
|
|
1249
|
+
/** The result interface of the validate function. */
|
|
1250
|
+
type Result<Output> = SuccessResult<Output> | FailureResult;
|
|
1251
|
+
/** The result interface if validation succeeds. */
|
|
1252
|
+
interface SuccessResult<Output> {
|
|
1253
|
+
/** The typed output value. */
|
|
1254
|
+
readonly value: Output;
|
|
1255
|
+
/** The absence of issues indicates success. */
|
|
1256
|
+
readonly issues?: undefined;
|
|
1257
|
+
}
|
|
1258
|
+
/** Options for the validate function. */
|
|
1259
|
+
interface Options {
|
|
1260
|
+
/** Implicit support for additional vendor-specific parameters, if needed. */
|
|
1261
|
+
readonly libraryOptions?: Record<string, unknown> | undefined;
|
|
1262
|
+
}
|
|
1263
|
+
/** The result interface if validation fails. */
|
|
1264
|
+
interface FailureResult {
|
|
1265
|
+
/** The issues of failed validation. */
|
|
1266
|
+
readonly issues: ReadonlyArray<Issue>;
|
|
1267
|
+
}
|
|
1268
|
+
/** The issue interface of the failure output. */
|
|
1269
|
+
interface Issue {
|
|
1270
|
+
/** The error message of the issue. */
|
|
1271
|
+
readonly message: string;
|
|
1272
|
+
/** The path of the issue, if any. */
|
|
1273
|
+
readonly path?: ReadonlyArray<PropertyKey | PathSegment> | undefined;
|
|
1274
|
+
}
|
|
1275
|
+
/** The path segment interface of the issue. */
|
|
1276
|
+
interface PathSegment {
|
|
1277
|
+
/** The key representing a path segment. */
|
|
1278
|
+
readonly key: PropertyKey;
|
|
1279
|
+
}
|
|
1280
|
+
/** The Standard Schema types interface. */
|
|
1281
|
+
interface Types<Input = unknown, Output = Input> {
|
|
1282
|
+
/** The input type of the schema. */
|
|
1283
|
+
readonly input: Input;
|
|
1284
|
+
/** The output type of the schema. */
|
|
1285
|
+
readonly output: Output;
|
|
1286
|
+
}
|
|
1287
|
+
/** Infers the input type of a Standard Schema. */
|
|
1288
|
+
type InferInput<Schema extends StandardSchemaV1> = NonNullable<Schema['~standard']['types']>['input'];
|
|
1289
|
+
/** Infers the output type of a Standard Schema. */
|
|
1290
|
+
type InferOutput<Schema extends StandardSchemaV1> = NonNullable<Schema['~standard']['types']>['output'];
|
|
1291
|
+
}
|
|
1292
|
+
|
|
1163
1293
|
/** ScoringResult without `passed` — the public `score()` / `evaluate()` fill that in. */
|
|
1164
1294
|
type PartialScoringResult = Omit<ScoringResult, 'passed'>;
|
|
1165
1295
|
/**
|
|
@@ -1237,8 +1367,9 @@ interface ActivityTypeAuthoring<TData> {
|
|
|
1237
1367
|
* length included, so report a rule about a whole list at the list's own path.
|
|
1238
1368
|
* A failure at the root of the draft is accounted for only by an issue at the
|
|
1239
1369
|
* root. A `null` the schema refuses, where nothing here reports it, comes back
|
|
1240
|
-
* as `null_not_allowed
|
|
1241
|
-
*
|
|
1370
|
+
* as `null_not_allowed`. A zod 4 schema tells a refused `null` from a rule of
|
|
1371
|
+
* yours that merely points at one, which keeps its own code; a schema from
|
|
1372
|
+
* another library cannot, so report such a rule here, at its path.
|
|
1242
1373
|
*
|
|
1243
1374
|
* A code documented in `docs/authoring.md` is reported with its documented
|
|
1244
1375
|
* severity. For a code of your own, a severity other than `'incomplete'` is
|
|
@@ -1252,14 +1383,38 @@ interface ActivityTypeAuthoring<TData> {
|
|
|
1252
1383
|
* descriptor makes `validateActivity`, `validateDraft`, `score`, `evaluate`,
|
|
1253
1384
|
* `redact`, and `jsonSchemaFor` work for the type — an activity type is a value,
|
|
1254
1385
|
* not a hardcoded union member (R1).
|
|
1386
|
+
*
|
|
1387
|
+
* Its schemas are Standard Schemas ({@link StandardSchemaV1}), so they can be
|
|
1388
|
+
* written with any library that implements the standard — a zod 4 schema is
|
|
1389
|
+
* one as it stands:
|
|
1390
|
+
*
|
|
1391
|
+
* ```ts
|
|
1392
|
+
* const pollType = defineActivityType<PollData, PollResponse>({
|
|
1393
|
+
* type: 'poll',
|
|
1394
|
+
* schema: z.looseObject({ type: z.literal('poll'), id: z.string(), … }),
|
|
1395
|
+
* scoring: { kind: 'sync', score: scorePoll },
|
|
1396
|
+
* });
|
|
1397
|
+
* registerActivityType(pollType);
|
|
1398
|
+
* ```
|
|
1255
1399
|
*/
|
|
1256
1400
|
interface ActivityTypeDescriptor<TData extends {
|
|
1257
1401
|
type: string;
|
|
1258
1402
|
}, TResponse> {
|
|
1259
1403
|
/** The `type` discriminator string (kebab-case by convention). */
|
|
1260
1404
|
readonly type: TData['type'];
|
|
1261
|
-
/**
|
|
1262
|
-
|
|
1405
|
+
/**
|
|
1406
|
+
* The activity's data contract, as a Standard Schema whose output is the
|
|
1407
|
+
* data. Its validation must be synchronous: every entry point that reads it
|
|
1408
|
+
* is.
|
|
1409
|
+
*/
|
|
1410
|
+
readonly schema: StandardSchemaV1<unknown, TData>;
|
|
1411
|
+
/**
|
|
1412
|
+
* The contract as JSON Schema, for `jsonSchemaFor`. Leave it out when
|
|
1413
|
+
* `schema` can produce one itself through the Standard JSON Schema converter
|
|
1414
|
+
* (`'~standard'.jsonSchema`), as a zod 4.6 schema can; give it to override
|
|
1415
|
+
* that, or for a library that cannot.
|
|
1416
|
+
*/
|
|
1417
|
+
readonly jsonSchema?: Readonly<Record<string, unknown>>;
|
|
1263
1418
|
/** How responses are graded. */
|
|
1264
1419
|
readonly scoring: ActivityTypeScoring<TData, TResponse>;
|
|
1265
1420
|
/** Whether a response counts as an answer (vs. blank/untouched). */
|
|
@@ -1268,10 +1423,11 @@ interface ActivityTypeDescriptor<TData extends {
|
|
|
1268
1423
|
readonly fieldPolicy?: FieldPolicy;
|
|
1269
1424
|
/**
|
|
1270
1425
|
* Schema the output of `redact(data)` (with default `reveal: 'none'`) must
|
|
1271
|
-
* satisfy. Strict by design: it proves the ABSENCE of
|
|
1272
|
-
* so `assertRedacted` can guarantee a payload is safe to
|
|
1426
|
+
* satisfy, as a Standard Schema. Strict by design: it proves the ABSENCE of
|
|
1427
|
+
* answer-key fields, so `assertRedacted` can guarantee a payload is safe to
|
|
1428
|
+
* send to a learner.
|
|
1273
1429
|
*/
|
|
1274
|
-
readonly redactedSchema?:
|
|
1430
|
+
readonly redactedSchema?: StandardSchemaV1;
|
|
1275
1431
|
/** Interop facts for xAPI (and later QTI) statement building. */
|
|
1276
1432
|
readonly interop?: ActivityTypeInterop<TData>;
|
|
1277
1433
|
/** The interaction-event kinds components for this type emit. */
|
|
@@ -1285,7 +1441,8 @@ interface ActivityTypeDescriptor<TData extends {
|
|
|
1285
1441
|
*/
|
|
1286
1442
|
interface RegisteredActivityTypeDescriptor {
|
|
1287
1443
|
readonly type: string;
|
|
1288
|
-
readonly schema:
|
|
1444
|
+
readonly schema: StandardSchemaV1;
|
|
1445
|
+
readonly jsonSchema?: Readonly<Record<string, unknown>>;
|
|
1289
1446
|
readonly scoring: {
|
|
1290
1447
|
readonly kind: 'sync';
|
|
1291
1448
|
readonly score: (data: unknown, response: unknown) => PartialScoringResult;
|
|
@@ -1296,7 +1453,7 @@ interface RegisteredActivityTypeDescriptor {
|
|
|
1296
1453
|
};
|
|
1297
1454
|
readonly isAnswered?: (response: unknown) => boolean;
|
|
1298
1455
|
readonly fieldPolicy?: FieldPolicy;
|
|
1299
|
-
readonly redactedSchema?:
|
|
1456
|
+
readonly redactedSchema?: StandardSchemaV1;
|
|
1300
1457
|
readonly interop?: ActivityTypeInterop<unknown>;
|
|
1301
1458
|
readonly interactions?: readonly string[];
|
|
1302
1459
|
readonly authoring?: ActivityTypeAuthoring<unknown>;
|
|
@@ -1638,4 +1795,4 @@ interface ThemeTokens {
|
|
|
1638
1795
|
'--lk-transition-base': string;
|
|
1639
1796
|
}
|
|
1640
1797
|
|
|
1641
|
-
export { AI_EXPLANATION_TYPES, AI_HINT_TYPES, AI_TEXT_MAX_LENGTH, ActivityData, ActivityDataMap, ActivityMedia, ActivitySchemaError, ActivityType, type ActivityTypeAuthoring, type ActivityTypeDescriptor, type ActivityTypeInterop, type ActivityTypeScoring, AiActivityInput, AiExplanationRequest, AiFeature, AiGrade, AiHintRequest, AiItemFacts, AiRefusal, AiSupportedActivityType, AiTextResult, AssessmentScore, type AttemptPlan, type AttemptPlanDrift, type AttemptPlanSlot, type AttemptProgress, type AttemptState, CompositionPolicy, CriterionScore, DeferredScoringError, DeferredScoringPartial, type DeliveryPolicy, type DeliveryPolicyIssue, DictationData, DictationLearnerResponse, type DraftComplete, type DraftContext, type DraftIssue, type DraftNotComplete, type DraftSeverity, type DraftValidationResult, type FieldPolicy, FillInTheBlanksData, FillInTheBlanksLearnerResponse, type FlattenSequenceOptions, GapSelectData, GapSelectLearnerResponse, type GradeFromRubricOptions, GradeRecord, INTERACTIVE_VIDEO_ITEM_TYPES, type InteractiveVideoItemType, ItemGroup, ItemOutcome, ItemScoringPolicy, LearnerResponse, type MediaBudgetRef, type MediaPlayClaim, type MediaPlayGrant, type MediaPlayLedger, type MediaPlayLedgerEntry, MediaProgress, type MissingOutcomePolicy, MultipleChoiceData, MultipleChoiceLearnerResponse, NativeControlHint, OPEN_DELIVERY_POLICY, type PartialScoringResult, type PlanAttemptOptions, type PlannableEntry, ReadAloudData, ReadAloudLearnerResponse, type RedactOptions, type RedactedActivityData, type RedactedItemGroup, RedactedScoringError, type RegisteredActivityTypeDescriptor, type ResolvedDeliveryPolicy, ResolvedItemScoringPolicy, type ResolvedPlaybackPolicy, type ResponseDiffEntry, RoundingPolicy, ScoredItem, ScoringDetail, ScoringResult, type SeededShuffleOptions, type Sensitivity, SequenceEntry, SequenceSlot, type ShuffleVersion, TIMELINE_MAX_CHAPTERS, TIMELINE_MAX_ITEMS, TIMELINE_MAX_QUIZZES, TIMELINE_MAX_TITLE_LENGTH, type ThemeTokens, UnknownActivityTypeError, ValidationError, WrittenResponseData, WrittenResponseLearnerResponse, type XAPIInteractionType, aiAllowedByContent, aiExplanationRequest, aiGradeOf, aiHintRequest, aiSupports, assertRedacted, assertRedactedItemGroup, buildAiFacts, canonicalJson, checkAiExplanation, checkAiHint, combineDeliveryPolicies, composeTimelineScore, contentHash, countWords, createDraft, createInteractiveVideoDraft, createItemGroupDraft, defineActivityType, dictationType, diffResponses, entryKeyOf, fillInTheBlanksType, fingerprint, flattenSequence, gapSelectType, getActivityTypeDescriptor, gradeFromRubric, hasGrade, hashSeed, hintRevealsAnswer, isInteractiveVideoItemType, isItemGroup, multipleChoiceType, outcomeFromGrade, planAttempt, planMediaBudgets, readAiTextResult, readAloudType, readMediaProgress, redact, redactItemGroup, registerActivityType, registeredActivityTypes, resolveDeliveryPolicy, resolvePlaybackPolicy, restoreAttemptState, restoreMediaPlayLedger, scoredItemsFromPlan, seededShuffle, serializeAttemptState, serializeMediaPlayLedger, slotMediaKey, stimulusMediaKey, validateDeliveryPolicy, validateDraft, validateItemGroupDraft, verifyAttemptPlan, writtenResponseType };
|
|
1798
|
+
export { AI_EXPLANATION_TYPES, AI_HINT_TYPES, AI_TEXT_MAX_LENGTH, AI_WRITING_MAX_CORRECTIONS, AI_WRITING_MAX_FIELD_LENGTH, ActivityData, ActivityDataMap, ActivityMedia, ActivitySchemaError, ActivityType, type ActivityTypeAuthoring, type ActivityTypeDescriptor, type ActivityTypeInterop, type ActivityTypeScoring, AiActivityInput, AiExplanationRequest, AiFeature, AiGrade, AiHintRequest, AiItemFacts, AiRefusal, AiSupportedActivityType, AiTextResult, AiWritingFeedback, AiWritingFeedbackRequest, AssessmentScore, type AttemptPlan, type AttemptPlanDrift, type AttemptPlanSlot, type AttemptProgress, type AttemptState, CompositionPolicy, CriterionScore, DeferredScoringError, DeferredScoringPartial, type DeliveryPolicy, type DeliveryPolicyIssue, DictationData, DictationLearnerResponse, type DraftComplete, type DraftContext, type DraftIssue, type DraftNotComplete, type DraftSeverity, type DraftValidationResult, type FieldPolicy, FillInTheBlanksData, FillInTheBlanksLearnerResponse, type FlattenSequenceOptions, GapSelectData, GapSelectLearnerResponse, type GradeFromRubricOptions, GradeRecord, INTERACTIVE_VIDEO_ITEM_TYPES, type InteractiveVideoItemType, ItemGroup, ItemOutcome, ItemScoringPolicy, LearnerResponse, type MediaBudgetRef, type MediaPlayClaim, type MediaPlayGrant, type MediaPlayLedger, type MediaPlayLedgerEntry, MediaProgress, type MissingOutcomePolicy, MultipleChoiceData, MultipleChoiceLearnerResponse, NativeControlHint, OPEN_DELIVERY_POLICY, type PartialScoringResult, type PlanAttemptOptions, type PlannableEntry, ReadAloudData, ReadAloudLearnerResponse, type RedactOptions, type RedactedActivityData, type RedactedItemGroup, RedactedScoringError, type RegisteredActivityTypeDescriptor, type ResolvedDeliveryPolicy, ResolvedItemScoringPolicy, type ResolvedPlaybackPolicy, type ResponseDiffEntry, RoundingPolicy, ScoredItem, ScoringDetail, ScoringResult, type SeededShuffleOptions, type Sensitivity, SequenceEntry, SequenceSlot, type ShuffleVersion, StandardSchemaV1, TIMELINE_MAX_CHAPTERS, TIMELINE_MAX_ITEMS, TIMELINE_MAX_QUIZZES, TIMELINE_MAX_TITLE_LENGTH, type ThemeTokens, UnknownActivityTypeError, ValidationError, WrittenResponseData, WrittenResponseLearnerResponse, type XAPIInteractionType, aiAllowedByContent, aiExplanationRequest, aiGradeOf, aiHintRequest, aiSupports, aiWritingFeedbackRequest, assertRedacted, assertRedactedItemGroup, buildAiFacts, canonicalJson, checkAiExplanation, checkAiHint, checkAiWritingFeedback, combineDeliveryPolicies, composeTimelineScore, contentHash, countWords, createDraft, createInteractiveVideoDraft, createItemGroupDraft, defineActivityType, dictationType, diffResponses, entryKeyOf, fillInTheBlanksType, fingerprint, flattenSequence, gapSelectType, getActivityTypeDescriptor, gradeFromRubric, hasGrade, hashSeed, hintRevealsAnswer, isInteractiveVideoItemType, isItemGroup, multipleChoiceType, outcomeFromGrade, planAttempt, planMediaBudgets, readAiTextResult, readAloudType, readMediaProgress, redact, redactItemGroup, registerActivityType, registeredActivityTypes, resolveDeliveryPolicy, resolvePlaybackPolicy, restoreAttemptState, restoreMediaPlayLedger, scoredItemsFromPlan, seededShuffle, serializeAttemptState, serializeMediaPlayLedger, slotMediaKey, stimulusMediaKey, validateDeliveryPolicy, validateDraft, validateItemGroupDraft, verifyAttemptPlan, writtenResponseType };
|