@conform-ed/qti-react 0.0.13 → 0.0.15
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/dist/capability.d.ts +17 -0
- package/dist/content-model.d.ts +42 -0
- package/dist/graphic.d.ts +23 -0
- package/dist/index.d.ts +14 -0
- package/dist/index.js +155 -162
- package/dist/interactions/associate.d.ts +2 -0
- package/dist/interactions/choice.d.ts +2 -0
- package/dist/interactions/drawing.d.ts +2 -0
- package/dist/interactions/end-attempt.d.ts +2 -0
- package/dist/interactions/extended-text.d.ts +2 -0
- package/dist/interactions/gap-match.d.ts +2 -0
- package/dist/interactions/graphic.d.ts +13 -0
- package/dist/interactions/hottext.d.ts +2 -0
- package/dist/interactions/index.d.ts +18 -0
- package/dist/interactions/inline-choice.d.ts +2 -0
- package/dist/interactions/match.d.ts +2 -0
- package/dist/interactions/media.d.ts +2 -0
- package/dist/interactions/order.d.ts +2 -0
- package/dist/interactions/slider.d.ts +2 -0
- package/dist/interactions/text-entry.d.ts +2 -0
- package/dist/interactions/upload.d.ts +2 -0
- package/dist/normalized-item.d.ts +30 -0
- package/dist/pci/index.d.ts +6 -0
- package/dist/pci/interaction.d.ts +8 -0
- package/dist/pci/markup.d.ts +10 -0
- package/dist/pci/mount.d.ts +50 -0
- package/dist/pci/registry.d.ts +53 -0
- package/dist/pci/response.d.ts +11 -0
- package/dist/pci/skin.d.ts +12 -0
- package/dist/reference-skin/associate.d.ts +8 -0
- package/dist/reference-skin/choice.d.ts +8 -0
- package/dist/reference-skin/content.d.ts +6 -0
- package/dist/reference-skin/drawing.d.ts +9 -0
- package/dist/reference-skin/end-attempt.d.ts +7 -0
- package/dist/reference-skin/extended-text.d.ts +6 -0
- package/dist/reference-skin/gap-match.d.ts +8 -0
- package/dist/reference-skin/graphic-associate.d.ts +8 -0
- package/dist/reference-skin/graphic-base.d.ts +39 -0
- package/dist/reference-skin/graphic-gap-match.d.ts +8 -0
- package/dist/reference-skin/graphic-order.d.ts +8 -0
- package/dist/reference-skin/hotspot.d.ts +8 -0
- package/dist/reference-skin/hottext.d.ts +8 -0
- package/dist/reference-skin/index.d.ts +30 -0
- package/dist/reference-skin/inline-choice.d.ts +7 -0
- package/dist/reference-skin/match.d.ts +8 -0
- package/dist/reference-skin/media.d.ts +9 -0
- package/dist/reference-skin/order.d.ts +8 -0
- package/dist/reference-skin/position-object.d.ts +9 -0
- package/dist/reference-skin/select-point.d.ts +8 -0
- package/dist/reference-skin/slider.d.ts +8 -0
- package/dist/reference-skin/text-entry.d.ts +6 -0
- package/dist/reference-skin/upload.d.ts +8 -0
- package/dist/response-processing.d.ts +48 -0
- package/dist/rp/evaluate.d.ts +35 -0
- package/dist/rp/index.d.ts +4 -0
- package/dist/rp/interpreter.d.ts +15 -0
- package/dist/rp/template-processing.d.ts +49 -0
- package/dist/rp/templates.d.ts +8 -0
- package/dist/rp/types.d.ts +158 -0
- package/dist/rp/values.d.ts +27 -0
- package/dist/runtime.d.ts +164 -0
- package/dist/store.d.ts +61 -0
- package/dist/test/controller.d.ts +11 -0
- package/dist/test/index.d.ts +3 -0
- package/dist/test/session-store.d.ts +46 -0
- package/dist/test/types.d.ts +194 -0
- package/dist/types.d.ts +58 -0
- package/package.json +6 -6
- package/src/interactions/associate.ts +2 -2
- package/src/interactions/choice.ts +2 -2
- package/src/interactions/drawing.ts +2 -2
- package/src/interactions/end-attempt.ts +2 -2
- package/src/interactions/extended-text.ts +2 -2
- package/src/interactions/gap-match.ts +2 -2
- package/src/interactions/graphic.ts +7 -7
- package/src/interactions/hottext.ts +2 -2
- package/src/interactions/index.ts +0 -1
- package/src/interactions/inline-choice.ts +2 -2
- package/src/interactions/match.ts +2 -2
- package/src/interactions/media.ts +2 -2
- package/src/interactions/order.ts +2 -2
- package/src/interactions/slider.ts +2 -2
- package/src/interactions/text-entry.ts +2 -2
- package/src/interactions/upload.ts +2 -2
- package/src/normalized-item.ts +6 -4
- package/src/pci/interaction.ts +2 -2
- package/src/pci/mount.ts +12 -5
- package/src/pci/skin.ts +0 -1
- package/src/reference-skin/drawing.ts +25 -15
- package/src/reference-skin/index.ts +2 -3
- package/src/rp/evaluate.ts +22 -23
- package/src/rp/interpreter.ts +9 -6
- package/src/rp/template-processing.ts +8 -13
- package/src/rp/types.ts +12 -6
- package/src/rp/values.ts +19 -6
- package/src/runtime.ts +9 -7
- package/src/store.ts +14 -8
- package/src/test/controller.ts +10 -7
- package/src/test/session-store.ts +0 -1
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Capability Report types (ADR-0003): the runtime's answer to "can this content be
|
|
3
|
+
* delivered, and if not, why". In their own module so the RP interpreter can report
|
|
4
|
+
* issues without importing the React runtime.
|
|
5
|
+
*/
|
|
6
|
+
export type CapabilityIssueType = "unsupported-interaction" | "invalid-interaction" | "unsupported-element" | "unsupported-rp";
|
|
7
|
+
export interface CapabilityIssue {
|
|
8
|
+
readonly type: CapabilityIssueType;
|
|
9
|
+
/** The interaction kind, element name, or RP rule/operator/template at issue. */
|
|
10
|
+
readonly name: string;
|
|
11
|
+
readonly responseIdentifier?: string;
|
|
12
|
+
readonly detail?: string;
|
|
13
|
+
}
|
|
14
|
+
export interface CapabilityReport {
|
|
15
|
+
readonly deliverable: boolean;
|
|
16
|
+
readonly issues: readonly CapabilityIssue[];
|
|
17
|
+
}
|
|
@@ -0,0 +1,42 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* The single source of truth for what may appear inside an item/stimulus body.
|
|
3
|
+
*
|
|
4
|
+
* Both the renderer's allowlist tree-walk and (later) the authoring editor schema
|
|
5
|
+
* derive from this definition. QTI 3 bodies are validated for *structure* by
|
|
6
|
+
* `@conform-ed/contracts`, but their embedded HTML flow content is modelled as a
|
|
7
|
+
* generic node tree — so validation does not sanitize. This allowlist is the
|
|
8
|
+
* sanitizer: the renderer emits React only for elements/attributes named here and
|
|
9
|
+
* drops everything else. It never injects HTML strings.
|
|
10
|
+
*
|
|
11
|
+
* v0 scope: the minimal flow/inline vocabulary plus the language-critical bits
|
|
12
|
+
* (ruby/furigana, MathML). It grows incrementally with the renderer — never "all of
|
|
13
|
+
* HTML5 at once".
|
|
14
|
+
*/
|
|
15
|
+
/** Interaction node kinds conform-ed ships descriptors and Reference Skins for. */
|
|
16
|
+
export declare const v0InteractionKinds: readonly ["associateInteraction", "choiceInteraction", "drawingInteraction", "endAttemptInteraction", "extendedTextInteraction", "gapMatchInteraction", "graphicAssociateInteraction", "graphicGapMatchInteraction", "graphicOrderInteraction", "hotspotInteraction", "hottextInteraction", "inlineChoiceInteraction", "matchInteraction", "mediaInteraction", "orderInteraction", "positionObjectStage", "selectPointInteraction", "sliderInteraction", "textEntryInteraction", "uploadInteraction"];
|
|
17
|
+
export type V0InteractionKind = (typeof v0InteractionKinds)[number];
|
|
18
|
+
export interface ContentModel {
|
|
19
|
+
readonly interactionKinds: ReadonlySet<string>;
|
|
20
|
+
readonly flowElements: ReadonlySet<string>;
|
|
21
|
+
readonly mathRoot: string;
|
|
22
|
+
readonly globalAttributes: ReadonlySet<string>;
|
|
23
|
+
/** Per-element attribute allowlists, additive to `globalAttributes`. */
|
|
24
|
+
readonly elementAttributes: ReadonlyMap<string, ReadonlySet<string>>;
|
|
25
|
+
/** Attributes whose values are asset references, routed through the Asset Resolver. */
|
|
26
|
+
readonly urlAttributes: ReadonlySet<string>;
|
|
27
|
+
}
|
|
28
|
+
export declare const v0ContentModel: ContentModel;
|
|
29
|
+
export declare function isAllowedFlowElement(model: ContentModel, name: string): boolean;
|
|
30
|
+
export declare function isInteractionKind(model: ContentModel, kind: string): boolean;
|
|
31
|
+
/**
|
|
32
|
+
* Reduce a raw attribute bag to the safe, allowlisted subset for one element. Used by
|
|
33
|
+
* the body walk so a node that validates against QTI structure still cannot carry
|
|
34
|
+
* script or handlers. The allowlist is the global set plus the element's own entries.
|
|
35
|
+
*/
|
|
36
|
+
export declare function sanitizeAttributes(model: ContentModel, elementName: string, attributes: Record<string, unknown> | undefined): Record<string, string>;
|
|
37
|
+
/**
|
|
38
|
+
* Attribute hardening for MathML subtrees: presentation attributes (mathvariant,
|
|
39
|
+
* linethickness, …) are not individually allowlisted — MathML has no scripting surface
|
|
40
|
+
* once event handlers and javascript: URLs are stripped.
|
|
41
|
+
*/
|
|
42
|
+
export declare function sanitizeMathAttributes(attributes: Record<string, unknown> | undefined): Record<string, string>;
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Graphic primitives shared by the graphic interaction family and areaMapping scoring:
|
|
3
|
+
* QTI shape/coords parsing and point-in-shape hit testing. Pure logic, no React.
|
|
4
|
+
*
|
|
5
|
+
* Shapes follow the QTI (HTML image-map) conventions:
|
|
6
|
+
* - `circle`: center-x, center-y, radius
|
|
7
|
+
* - `rect`: left-x, top-y, right-x, bottom-y
|
|
8
|
+
* - `poly`: x1, y1, ..., xn, yn
|
|
9
|
+
* - `ellipse`: center-x, center-y, radius-x, radius-y
|
|
10
|
+
* - `default`: the entire image
|
|
11
|
+
*/
|
|
12
|
+
export type QtiShape = "circle" | "rect" | "poly" | "ellipse" | "default";
|
|
13
|
+
export interface Point {
|
|
14
|
+
readonly x: number;
|
|
15
|
+
readonly y: number;
|
|
16
|
+
}
|
|
17
|
+
/** Parse a QTI coords attribute ("10,20,30") into numbers. */
|
|
18
|
+
export declare function parseCoords(coords: string): number[];
|
|
19
|
+
/** Parse a QTI point value ("x y") or null when malformed. */
|
|
20
|
+
export declare function parsePoint(value: string): Point | null;
|
|
21
|
+
export declare function formatPoint(point: Point): string;
|
|
22
|
+
/** QTI hit test: is `point` inside the area described by (shape, coords)? */
|
|
23
|
+
export declare function pointInShape(shape: string, coords: readonly number[], point: Point): boolean;
|
package/dist/index.d.ts
ADDED
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
export declare const qtiReactPackageName = "@conform-ed/qti-react";
|
|
2
|
+
export { v0ContentModel, v0InteractionKinds, isAllowedFlowElement, isInteractionKind, sanitizeAttributes, type ContentModel, type V0InteractionKind, } from "./content-model";
|
|
3
|
+
export { foldString, mapResponse, matchCorrect, mapResponsePoint, scoreResponse } from "./response-processing";
|
|
4
|
+
export { assessmentItemViewFromNormalized, assessmentTestViewFromNormalized } from "./normalized-item";
|
|
5
|
+
export { formatPoint, parseCoords, parsePoint, pointInShape, type Point, type QtiShape } from "./graphic";
|
|
6
|
+
export { applyCorrectResponseOverrides, collectRpIssues, collectTemplateIssues, executeResponseProcessing, executeTemplateProcessing, mulberry32, resolveTemplate, } from "./rp";
|
|
7
|
+
export type { CustomOperatorImplementation, MaybeRpValue, OutcomeDeclarationView, OutcomeValue, ResponseNormalization, ResponseProcessingContext, ResponseProcessingResult, ResponseProcessingView, RpConditionBranch, RpExpressionView, RpRecordField, RpRuleView, RpScalar, RpValue, TemplateConditionBranch, TemplateDeclarationView, TemplateProcessingContext, TemplateProcessingResult, TemplateProcessingView, TemplateRuleView, } from "./rp";
|
|
8
|
+
export { createAttemptStore, type AttemptSnapshot, type AttemptStore, type AttemptStoreOptions } from "./store";
|
|
9
|
+
export { createTestController, createTestSessionStore, type TestSessionSnapshot, type TestSessionStore, type TestSessionStoreOptions, type AssessmentItemRefView, type AssessmentSectionView, type AssessmentTestView, type BranchRuleView, type ItemSessionControlView, type OutcomeConditionBranch, type OutcomeRuleView, type TestController, type TestFeedbackView, type TestItemResult, type TestPartView, type TestPlan, type TestPlanItem, type TestPlanPart, type TestSessionState, type TimeLimitsView, } from "./test";
|
|
10
|
+
export { createQtiRuntime, defineInteraction, type AssessmentItemView, type AttemptController, type BodyNode, type CapabilityIssue, type CapabilityIssueType, type CapabilityReport, type ContentRendererProps, type FeedbackView, type InteractionDescriptor, type InteractionNode, type InteractionRenderProps, type InteractionSkin, type InteractionStatus, type ItemRendererProps, type NodeOverrides, type OptionProps, type OptionStatus, type QtiRuntime, type QtiRuntimeConfig, type SkinRegistry, type XmlContentNode, } from "./runtime";
|
|
11
|
+
export { createPciModuleRegistry, createPciSkin, mountPci, pciResponseToValue, portableCustomInteraction, serializePciMarkup, valueToPciResponse, type PciConfiguration, type PciInstance, type PciInteractionNode, type PciModule, type PciModuleRegistry, type PciModuleRegistryOptions, type PciMountHandle, type PciMountOptions, type PciSkinOptions, } from "./pci";
|
|
12
|
+
export { associateInteraction, choiceInteraction, drawingInteraction, endAttemptInteraction, extendedTextInteraction, gapMatchInteraction, graphicAssociateInteraction, graphicGapMatchInteraction, graphicOrderInteraction, hotspotInteraction, hottextInteraction, inlineChoiceInteraction, matchInteraction, mediaInteraction, orderInteraction, positionObjectStage, qtiCoreInteractions, selectPointInteraction, sliderInteraction, textEntryInteraction, uploadInteraction, } from "./interactions";
|
|
13
|
+
export { AssociateReferenceSkin, ChoiceReferenceSkin, DrawingReferenceSkin, EndAttemptReferenceSkin, ExtendedTextReferenceSkin, GapMatchReferenceSkin, GraphicAssociateReferenceSkin, GraphicGapMatchReferenceSkin, GraphicOrderReferenceSkin, GraphicStage, HotspotReferenceSkin, HottextReferenceSkin, InlineChoiceReferenceSkin, MatchReferenceSkin, MediaReferenceSkin, OrderReferenceSkin, PositionObjectReferenceSkin, SelectPointReferenceSkin, SliderReferenceSkin, TextEntryReferenceSkin, UploadReferenceSkin, referenceSkin, textOf, } from "./reference-skin";
|
|
14
|
+
export type { AreaMapEntryView, AreaMappingView, Cardinality, CorrectResponseView, MapEntryView, MappingView, ResponseDeclarationView, ResponseValue, ScoreResult, } from "./types";
|