@mathscan/math-exercise-engine 1.0.7 → 1.0.8
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/index.d.ts +146 -2
- package/dist/index.js +158 -31996
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +153 -31991
- package/dist/index.mjs.map +1 -1
- package/dist/style.css +41 -0
- package/package.json +1 -1
package/dist/index.d.ts
CHANGED
|
@@ -37,6 +37,8 @@ export declare const AST_TYPES: {
|
|
|
37
37
|
readonly TABLE_CELL: "TableCell";
|
|
38
38
|
/** Drag-and-drop options tool */
|
|
39
39
|
readonly DRAG_OPTIONS: "DragOptions";
|
|
40
|
+
/** Radio button options tool */
|
|
41
|
+
readonly RADIO_OPTIONS: "RadioOptions";
|
|
40
42
|
/** Numeric keypad input tool */
|
|
41
43
|
readonly NUMERIC_KEYPAD: "NumericKeypad";
|
|
42
44
|
/** Simple answer matching validation */
|
|
@@ -266,6 +268,11 @@ export declare function compileWithAST(dsl: string): {
|
|
|
266
268
|
colspan?: number | undefined;
|
|
267
269
|
}[];
|
|
268
270
|
}[];
|
|
271
|
+
} | {
|
|
272
|
+
type: "RadioOptions";
|
|
273
|
+
options: string[];
|
|
274
|
+
name: string;
|
|
275
|
+
answer: string;
|
|
269
276
|
})[];
|
|
270
277
|
question?: {
|
|
271
278
|
value: string;
|
|
@@ -300,6 +307,9 @@ export declare function compileWithAST(dsl: string): {
|
|
|
300
307
|
} | {
|
|
301
308
|
type: "drag-options";
|
|
302
309
|
options: string[];
|
|
310
|
+
} | {
|
|
311
|
+
type: "radio-options";
|
|
312
|
+
options: string[];
|
|
303
313
|
} | {
|
|
304
314
|
type: "numeric-keypad";
|
|
305
315
|
includeOperators?: boolean | undefined;
|
|
@@ -801,6 +811,21 @@ export declare const ContentBlockSchema: z.ZodUnion<[z.ZodObject<{
|
|
|
801
811
|
colspan?: number | undefined;
|
|
802
812
|
}[];
|
|
803
813
|
}[];
|
|
814
|
+
}>, z.ZodObject<{
|
|
815
|
+
type: z.ZodLiteral<"RadioOptions">;
|
|
816
|
+
name: z.ZodString;
|
|
817
|
+
options: z.ZodArray<z.ZodString, "many">;
|
|
818
|
+
answer: z.ZodString;
|
|
819
|
+
}, "strip", z.ZodTypeAny, {
|
|
820
|
+
type: "RadioOptions";
|
|
821
|
+
options: string[];
|
|
822
|
+
name: string;
|
|
823
|
+
answer: string;
|
|
824
|
+
}, {
|
|
825
|
+
type: "RadioOptions";
|
|
826
|
+
options: string[];
|
|
827
|
+
name: string;
|
|
828
|
+
answer: string;
|
|
804
829
|
}>]>;
|
|
805
830
|
|
|
806
831
|
/**
|
|
@@ -1462,6 +1487,21 @@ export declare const ExerciseDocumentSchema: z.ZodObject<{
|
|
|
1462
1487
|
colspan?: number | undefined;
|
|
1463
1488
|
}[];
|
|
1464
1489
|
}[];
|
|
1490
|
+
}>, z.ZodObject<{
|
|
1491
|
+
type: z.ZodLiteral<"RadioOptions">;
|
|
1492
|
+
name: z.ZodString;
|
|
1493
|
+
options: z.ZodArray<z.ZodString, "many">;
|
|
1494
|
+
answer: z.ZodString;
|
|
1495
|
+
}, "strip", z.ZodTypeAny, {
|
|
1496
|
+
type: "RadioOptions";
|
|
1497
|
+
options: string[];
|
|
1498
|
+
name: string;
|
|
1499
|
+
answer: string;
|
|
1500
|
+
}, {
|
|
1501
|
+
type: "RadioOptions";
|
|
1502
|
+
options: string[];
|
|
1503
|
+
name: string;
|
|
1504
|
+
answer: string;
|
|
1465
1505
|
}>]>, "many">;
|
|
1466
1506
|
tools: z.ZodOptional<z.ZodArray<z.ZodDiscriminatedUnion<"type", [z.ZodObject<{
|
|
1467
1507
|
type: z.ZodLiteral<"DragOptions">;
|
|
@@ -1583,6 +1623,11 @@ export declare const ExerciseDocumentSchema: z.ZodObject<{
|
|
|
1583
1623
|
colspan?: number | undefined;
|
|
1584
1624
|
}[];
|
|
1585
1625
|
}[];
|
|
1626
|
+
} | {
|
|
1627
|
+
type: "RadioOptions";
|
|
1628
|
+
options: string[];
|
|
1629
|
+
name: string;
|
|
1630
|
+
answer: string;
|
|
1586
1631
|
})[];
|
|
1587
1632
|
question?: {
|
|
1588
1633
|
value: string;
|
|
@@ -1678,6 +1723,11 @@ export declare const ExerciseDocumentSchema: z.ZodObject<{
|
|
|
1678
1723
|
colspan?: number | undefined;
|
|
1679
1724
|
}[];
|
|
1680
1725
|
}[];
|
|
1726
|
+
} | {
|
|
1727
|
+
type: "RadioOptions";
|
|
1728
|
+
options: string[];
|
|
1729
|
+
name: string;
|
|
1730
|
+
answer: string;
|
|
1681
1731
|
})[];
|
|
1682
1732
|
question?: {
|
|
1683
1733
|
value: string;
|
|
@@ -1732,6 +1782,15 @@ export declare const ExerciseJSONSchema: z.ZodObject<{
|
|
|
1732
1782
|
}, {
|
|
1733
1783
|
type: "drag-options";
|
|
1734
1784
|
options: string[];
|
|
1785
|
+
}>, z.ZodObject<{
|
|
1786
|
+
type: z.ZodLiteral<"radio-options">;
|
|
1787
|
+
options: z.ZodArray<z.ZodString, "many">;
|
|
1788
|
+
}, "strip", z.ZodTypeAny, {
|
|
1789
|
+
type: "radio-options";
|
|
1790
|
+
options: string[];
|
|
1791
|
+
}, {
|
|
1792
|
+
type: "radio-options";
|
|
1793
|
+
options: string[];
|
|
1735
1794
|
}>, z.ZodObject<{
|
|
1736
1795
|
type: z.ZodLiteral<"numeric-keypad">;
|
|
1737
1796
|
includeOperators: z.ZodOptional<z.ZodBoolean>;
|
|
@@ -1797,6 +1856,9 @@ export declare const ExerciseJSONSchema: z.ZodObject<{
|
|
|
1797
1856
|
} | {
|
|
1798
1857
|
type: "drag-options";
|
|
1799
1858
|
options: string[];
|
|
1859
|
+
} | {
|
|
1860
|
+
type: "radio-options";
|
|
1861
|
+
options: string[];
|
|
1800
1862
|
} | {
|
|
1801
1863
|
type: "numeric-keypad";
|
|
1802
1864
|
includeOperators?: boolean | undefined;
|
|
@@ -1829,6 +1891,9 @@ export declare const ExerciseJSONSchema: z.ZodObject<{
|
|
|
1829
1891
|
} | {
|
|
1830
1892
|
type: "drag-options";
|
|
1831
1893
|
options: string[];
|
|
1894
|
+
} | {
|
|
1895
|
+
type: "radio-options";
|
|
1896
|
+
options: string[];
|
|
1832
1897
|
} | {
|
|
1833
1898
|
type: "numeric-keypad";
|
|
1834
1899
|
includeOperators?: boolean | undefined;
|
|
@@ -2302,6 +2367,13 @@ export declare function isQuestionText(item: LayoutItem): item is Extract<Layout
|
|
|
2302
2367
|
type: 'question-text';
|
|
2303
2368
|
}>;
|
|
2304
2369
|
|
|
2370
|
+
/**
|
|
2371
|
+
* Type guard for RadioOptionsJSON
|
|
2372
|
+
*/
|
|
2373
|
+
export declare function isRadioOptionsJSON(widget: WidgetJSON): widget is Extract<WidgetJSON, {
|
|
2374
|
+
type: 'radio-options';
|
|
2375
|
+
}>;
|
|
2376
|
+
|
|
2305
2377
|
export declare function isSimpleValidation(value: unknown): value is SimpleValidation;
|
|
2306
2378
|
|
|
2307
2379
|
export declare function isSpace(value: unknown): value is SpaceInline;
|
|
@@ -2398,6 +2470,8 @@ export declare const JSON_TYPES: {
|
|
|
2398
2470
|
readonly INLINE_INPUT: "inline-input";
|
|
2399
2471
|
/** Drag-and-drop options widget */
|
|
2400
2472
|
readonly DRAG_OPTIONS: "drag-options";
|
|
2473
|
+
/** Radio button options widget */
|
|
2474
|
+
readonly RADIO_OPTIONS: "radio-options";
|
|
2401
2475
|
/** Numeric keypad widget */
|
|
2402
2476
|
readonly NUMERIC_KEYPAD: "numeric-keypad";
|
|
2403
2477
|
};
|
|
@@ -2421,7 +2495,7 @@ export declare interface LayoutRendererProps {
|
|
|
2421
2495
|
widgets: Record<string, WidgetJSON>;
|
|
2422
2496
|
values: Record<string, string>;
|
|
2423
2497
|
droppedInputs: Set<string>;
|
|
2424
|
-
onChange: (widgetId: string, value: string, fromDrop?: boolean) => void;
|
|
2498
|
+
onChange: (widgetId: string, value: string, fromDrop?: boolean, sourceOptionId?: string) => void;
|
|
2425
2499
|
onInputFocus?: (widgetId: string) => void;
|
|
2426
2500
|
}
|
|
2427
2501
|
|
|
@@ -2733,6 +2807,49 @@ export declare const QuestionTextSchema: z.ZodObject<{
|
|
|
2733
2807
|
id: string;
|
|
2734
2808
|
}>;
|
|
2735
2809
|
|
|
2810
|
+
export declare type RadioOptionsBlock = z.infer<typeof RadioOptionsBlockSchema>;
|
|
2811
|
+
|
|
2812
|
+
/**
|
|
2813
|
+
* Radio options block schema - single-choice radio buttons
|
|
2814
|
+
*
|
|
2815
|
+
* @example
|
|
2816
|
+
* {
|
|
2817
|
+
* type: "RadioOptions",
|
|
2818
|
+
* name: "q1",
|
|
2819
|
+
* options: ["apple", "orange", "banana"],
|
|
2820
|
+
* answer: "apple"
|
|
2821
|
+
* }
|
|
2822
|
+
*/
|
|
2823
|
+
declare const RadioOptionsBlockSchema: z.ZodObject<{
|
|
2824
|
+
type: z.ZodLiteral<"RadioOptions">;
|
|
2825
|
+
name: z.ZodString;
|
|
2826
|
+
options: z.ZodArray<z.ZodString, "many">;
|
|
2827
|
+
answer: z.ZodString;
|
|
2828
|
+
}, "strip", z.ZodTypeAny, {
|
|
2829
|
+
type: "RadioOptions";
|
|
2830
|
+
options: string[];
|
|
2831
|
+
name: string;
|
|
2832
|
+
answer: string;
|
|
2833
|
+
}, {
|
|
2834
|
+
type: "RadioOptions";
|
|
2835
|
+
options: string[];
|
|
2836
|
+
name: string;
|
|
2837
|
+
answer: string;
|
|
2838
|
+
}>;
|
|
2839
|
+
|
|
2840
|
+
export declare type RadioOptionsJSON = z.infer<typeof RadioOptionsJSONSchema>;
|
|
2841
|
+
|
|
2842
|
+
export declare const RadioOptionsJSONSchema: z.ZodObject<{
|
|
2843
|
+
type: z.ZodLiteral<"radio-options">;
|
|
2844
|
+
options: z.ZodArray<z.ZodString, "many">;
|
|
2845
|
+
}, "strip", z.ZodTypeAny, {
|
|
2846
|
+
type: "radio-options";
|
|
2847
|
+
options: string[];
|
|
2848
|
+
}, {
|
|
2849
|
+
type: "radio-options";
|
|
2850
|
+
options: string[];
|
|
2851
|
+
}>;
|
|
2852
|
+
|
|
2736
2853
|
/**
|
|
2737
2854
|
* DOM helper for quick usage / demos.
|
|
2738
2855
|
*
|
|
@@ -3881,6 +3998,9 @@ export declare function validateExerciseJSON(data: unknown): {
|
|
|
3881
3998
|
} | {
|
|
3882
3999
|
type: "drag-options";
|
|
3883
4000
|
options: string[];
|
|
4001
|
+
} | {
|
|
4002
|
+
type: "radio-options";
|
|
4003
|
+
options: string[];
|
|
3884
4004
|
} | {
|
|
3885
4005
|
type: "numeric-keypad";
|
|
3886
4006
|
includeOperators?: boolean | undefined;
|
|
@@ -3931,6 +4051,9 @@ export declare function validateExerciseJSONSafe(data: unknown): z.SafeParseRetu
|
|
|
3931
4051
|
} | {
|
|
3932
4052
|
type: "drag-options";
|
|
3933
4053
|
options: string[];
|
|
4054
|
+
} | {
|
|
4055
|
+
type: "radio-options";
|
|
4056
|
+
options: string[];
|
|
3934
4057
|
} | {
|
|
3935
4058
|
type: "numeric-keypad";
|
|
3936
4059
|
includeOperators?: boolean | undefined;
|
|
@@ -3963,6 +4086,9 @@ export declare function validateExerciseJSONSafe(data: unknown): z.SafeParseRetu
|
|
|
3963
4086
|
} | {
|
|
3964
4087
|
type: "drag-options";
|
|
3965
4088
|
options: string[];
|
|
4089
|
+
} | {
|
|
4090
|
+
type: "radio-options";
|
|
4091
|
+
options: string[];
|
|
3966
4092
|
} | {
|
|
3967
4093
|
type: "numeric-keypad";
|
|
3968
4094
|
includeOperators?: boolean | undefined;
|
|
@@ -4023,6 +4149,9 @@ export declare function validateWidgetJSON(data: unknown): {
|
|
|
4023
4149
|
} | {
|
|
4024
4150
|
type: "drag-options";
|
|
4025
4151
|
options: string[];
|
|
4152
|
+
} | {
|
|
4153
|
+
type: "radio-options";
|
|
4154
|
+
options: string[];
|
|
4026
4155
|
} | {
|
|
4027
4156
|
type: "numeric-keypad";
|
|
4028
4157
|
includeOperators?: boolean | undefined;
|
|
@@ -4046,6 +4175,9 @@ export declare function validateWidgetJSONSafe(data: unknown): z.SafeParseReturn
|
|
|
4046
4175
|
} | {
|
|
4047
4176
|
type: "drag-options";
|
|
4048
4177
|
options: string[];
|
|
4178
|
+
} | {
|
|
4179
|
+
type: "radio-options";
|
|
4180
|
+
options: string[];
|
|
4049
4181
|
} | {
|
|
4050
4182
|
type: "numeric-keypad";
|
|
4051
4183
|
includeOperators?: boolean | undefined;
|
|
@@ -4061,6 +4193,9 @@ export declare function validateWidgetJSONSafe(data: unknown): z.SafeParseReturn
|
|
|
4061
4193
|
} | {
|
|
4062
4194
|
type: "drag-options";
|
|
4063
4195
|
options: string[];
|
|
4196
|
+
} | {
|
|
4197
|
+
type: "radio-options";
|
|
4198
|
+
options: string[];
|
|
4064
4199
|
} | {
|
|
4065
4200
|
type: "numeric-keypad";
|
|
4066
4201
|
includeOperators?: boolean | undefined;
|
|
@@ -4169,6 +4304,15 @@ export declare const WidgetJSONSchema: z.ZodUnion<[z.ZodDiscriminatedUnion<"inpu
|
|
|
4169
4304
|
}, {
|
|
4170
4305
|
type: "drag-options";
|
|
4171
4306
|
options: string[];
|
|
4307
|
+
}>, z.ZodObject<{
|
|
4308
|
+
type: z.ZodLiteral<"radio-options">;
|
|
4309
|
+
options: z.ZodArray<z.ZodString, "many">;
|
|
4310
|
+
}, "strip", z.ZodTypeAny, {
|
|
4311
|
+
type: "radio-options";
|
|
4312
|
+
options: string[];
|
|
4313
|
+
}, {
|
|
4314
|
+
type: "radio-options";
|
|
4315
|
+
options: string[];
|
|
4172
4316
|
}>, z.ZodObject<{
|
|
4173
4317
|
type: z.ZodLiteral<"numeric-keypad">;
|
|
4174
4318
|
includeOperators: z.ZodOptional<z.ZodBoolean>;
|
|
@@ -4211,7 +4355,7 @@ export declare interface WidgetRendererProps {
|
|
|
4211
4355
|
widgetId: string;
|
|
4212
4356
|
value: string;
|
|
4213
4357
|
isDropped?: boolean;
|
|
4214
|
-
onChange: (widgetId: string, value: string, fromDrop?: boolean) => void;
|
|
4358
|
+
onChange: (widgetId: string, value: string, fromDrop?: boolean, sourceOptionId?: string) => void;
|
|
4215
4359
|
onInputFocus?: (widgetId: string) => void;
|
|
4216
4360
|
onKeypadChange?: (value: string) => void;
|
|
4217
4361
|
}
|