@superbuilders/incept-renderer 0.1.0 → 0.1.3
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 +632 -88
- package/dist/actions/index.d.ts +1 -1
- package/dist/actions/index.js +362 -552
- package/dist/actions/index.js.map +1 -1
- package/dist/components/index.d.ts +4 -40
- package/dist/components/index.js +71 -115
- package/dist/components/index.js.map +1 -1
- package/dist/index.d.ts +8 -8
- package/dist/index.js +415 -461
- package/dist/index.js.map +1 -1
- package/dist/{schema-DxNEXGoq.d.ts → schema-C3cRJWrK.d.ts} +74 -5
- package/dist/{types-MOyn9ktl.d.ts → types-BqqQtPL8.d.ts} +1 -1
- package/dist/types.d.ts +14 -0
- package/dist/types.js +3 -0
- package/dist/types.js.map +1 -0
- package/package.json +20 -3
|
@@ -1,8 +1,9 @@
|
|
|
1
|
-
import {
|
|
2
|
-
export {
|
|
1
|
+
import { f as ChoiceInteraction, A as AssessmentItem } from '../schema-C3cRJWrK.js';
|
|
2
|
+
export { C as ChoiceCorrectness, c as ContentBlockRenderer, a as ContentBlockRendererProps, d as QTIRenderer, Q as QTIRendererProps, b as QTITheme, R as ResponseFeedback } from '../schema-C3cRJWrK.js';
|
|
3
3
|
import * as react_jsx_runtime from 'react/jsx-runtime';
|
|
4
|
+
import { EvaluationResult } from '../types.js';
|
|
4
5
|
import * as React from 'react';
|
|
5
|
-
import { d as DisplayInlineEmbed, e as DisplayTextEmbed, f as DisplayGap } from '../types-
|
|
6
|
+
import { d as DisplayInlineEmbed, e as DisplayTextEmbed, f as DisplayGap } from '../types-BqqQtPL8.js';
|
|
6
7
|
import 'zod';
|
|
7
8
|
|
|
8
9
|
interface ChoiceInteractionRendererProps {
|
|
@@ -40,43 +41,6 @@ declare function FeedbackMessage({ responseId, showFeedback, perResponseFeedback
|
|
|
40
41
|
}>;
|
|
41
42
|
}): react_jsx_runtime.JSX.Element | null;
|
|
42
43
|
|
|
43
|
-
/**
|
|
44
|
-
* This file contains application-level types for managing the state of QTI interactions,
|
|
45
|
-
* user responses, and evaluation results.
|
|
46
|
-
*
|
|
47
|
-
* Unlike `schema.ts`, which defines the static data structure of a parsed QTI item,
|
|
48
|
-
* the types in this file represent the dynamic data that changes as a user
|
|
49
|
-
* interacts with an assessment item.
|
|
50
|
-
*/
|
|
51
|
-
/**
|
|
52
|
-
* Represents the evaluation status of a user's response to an interaction.
|
|
53
|
-
* - `unanswered`: No response has been submitted yet.
|
|
54
|
-
* - `correct`: The submitted response is fully correct.
|
|
55
|
-
* - `incorrect`: The submitted response is incorrect.
|
|
56
|
-
* - `partially-correct`: For multi-response questions, the answer is partially correct.
|
|
57
|
-
*/
|
|
58
|
-
type EvaluationStatus = "unanswered" | "correct" | "incorrect" | "partially-correct";
|
|
59
|
-
/**
|
|
60
|
-
* Represents the outcome of evaluating a user's response against the correct answer.
|
|
61
|
-
* This object would be generated by an "evaluation engine" function that you will build later.
|
|
62
|
-
*/
|
|
63
|
-
interface EvaluationResult {
|
|
64
|
-
/**
|
|
65
|
-
* The overall status of the user's answer.
|
|
66
|
-
*/
|
|
67
|
-
status: EvaluationStatus;
|
|
68
|
-
/**
|
|
69
|
-
* The numerical score awarded for the response, derived from the `responseProcessing` rules.
|
|
70
|
-
*/
|
|
71
|
-
score: number;
|
|
72
|
-
/**
|
|
73
|
-
* The identifier of the specific feedback block to display to the user,
|
|
74
|
-
* e.g., "FB__RESPONSE_A". This is determined by the `feedbackMap` in your parsed item.
|
|
75
|
-
* Can be undefined if no specific feedback is applicable.
|
|
76
|
-
*/
|
|
77
|
-
feedbackIdentifier?: string;
|
|
78
|
-
}
|
|
79
|
-
|
|
80
44
|
interface QtiFeedbackBlockProps {
|
|
81
45
|
/** The evaluation result containing feedback info */
|
|
82
46
|
result: EvaluationResult;
|
package/dist/components/index.js
CHANGED
|
@@ -3,8 +3,8 @@ import { clsx } from 'clsx';
|
|
|
3
3
|
import { twMerge } from 'tailwind-merge';
|
|
4
4
|
import { createPortal } from 'react-dom';
|
|
5
5
|
import { jsxs, Fragment, jsx } from 'react/jsx-runtime';
|
|
6
|
-
import * as RadioGroupPrimitive from '@radix-ui/react-radio-group';
|
|
7
6
|
import * as CheckboxPrimitive from '@radix-ui/react-checkbox';
|
|
7
|
+
import * as RadioGroupPrimitive from '@radix-ui/react-radio-group';
|
|
8
8
|
import { cva } from 'class-variance-authority';
|
|
9
9
|
import * as LabelPrimitive from '@radix-ui/react-label';
|
|
10
10
|
import '@radix-ui/react-separator';
|
|
@@ -356,26 +356,11 @@ var choiceIndicatorVariants = cva(
|
|
|
356
356
|
"[--choice-foreground:var(--color-foreground)]",
|
|
357
357
|
"[--choice-complement:var(--color-muted-foreground)]"
|
|
358
358
|
],
|
|
359
|
-
betta: [
|
|
360
|
-
|
|
361
|
-
|
|
362
|
-
],
|
|
363
|
-
|
|
364
|
-
"[--choice-foreground:var(--color-cardinal)]",
|
|
365
|
-
"[--choice-complement:var(--color-fire-ant)]"
|
|
366
|
-
],
|
|
367
|
-
bee: [
|
|
368
|
-
"[--choice-foreground:var(--color-bee)]",
|
|
369
|
-
"[--choice-complement:var(--color-lion)]"
|
|
370
|
-
],
|
|
371
|
-
owl: [
|
|
372
|
-
"[--choice-foreground:var(--color-owl)]",
|
|
373
|
-
"[--choice-complement:var(--color-tree-frog)]"
|
|
374
|
-
],
|
|
375
|
-
macaw: [
|
|
376
|
-
"[--choice-foreground:var(--color-macaw)]",
|
|
377
|
-
"[--choice-complement:var(--color-whale)]"
|
|
378
|
-
]
|
|
359
|
+
betta: ["[--choice-foreground:var(--color-betta)]", "[--choice-complement:var(--color-butterfly)]"],
|
|
360
|
+
cardinal: ["[--choice-foreground:var(--color-cardinal)]", "[--choice-complement:var(--color-fire-ant)]"],
|
|
361
|
+
bee: ["[--choice-foreground:var(--color-bee)]", "[--choice-complement:var(--color-lion)]"],
|
|
362
|
+
owl: ["[--choice-foreground:var(--color-owl)]", "[--choice-complement:var(--color-tree-frog)]"],
|
|
363
|
+
macaw: ["[--choice-foreground:var(--color-macaw)]", "[--choice-complement:var(--color-whale)]"]
|
|
379
364
|
}
|
|
380
365
|
},
|
|
381
366
|
defaultVariants: {
|
|
@@ -418,10 +403,7 @@ function ChoiceIndicator({
|
|
|
418
403
|
}
|
|
419
404
|
);
|
|
420
405
|
}
|
|
421
|
-
function Label({
|
|
422
|
-
className,
|
|
423
|
-
...props
|
|
424
|
-
}) {
|
|
406
|
+
function Label({ className, ...props }) {
|
|
425
407
|
return /* @__PURE__ */ jsx(
|
|
426
408
|
LabelPrimitive.Root,
|
|
427
409
|
{
|
|
@@ -461,29 +443,26 @@ function FieldGroup({ className, ...props }) {
|
|
|
461
443
|
}
|
|
462
444
|
);
|
|
463
445
|
}
|
|
464
|
-
var fieldVariants = cva(
|
|
465
|
-
|
|
466
|
-
|
|
467
|
-
|
|
468
|
-
|
|
469
|
-
|
|
470
|
-
|
|
471
|
-
|
|
472
|
-
|
|
473
|
-
|
|
474
|
-
],
|
|
475
|
-
|
|
476
|
-
|
|
477
|
-
|
|
478
|
-
"@md/field-group:has-[>[data-slot=field-content]]:items-start @md/field-group:has-[>[data-slot=field-content]]:[&>[role=checkbox],[role=radio]]:mt-px"
|
|
479
|
-
]
|
|
480
|
-
}
|
|
481
|
-
},
|
|
482
|
-
defaultVariants: {
|
|
483
|
-
orientation: "vertical"
|
|
446
|
+
var fieldVariants = cva("group/field flex w-full gap-3 data-[invalid=true]:text-destructive", {
|
|
447
|
+
variants: {
|
|
448
|
+
orientation: {
|
|
449
|
+
vertical: ["flex-col [&>*]:w-full [&>.sr-only]:w-auto"],
|
|
450
|
+
horizontal: [
|
|
451
|
+
"flex-row items-center",
|
|
452
|
+
"[&>[data-slot=field-label]]:flex-auto",
|
|
453
|
+
"has-[>[data-slot=field-content]]:items-start has-[>[data-slot=field-content]]:[&>[role=checkbox],[role=radio]]:mt-px"
|
|
454
|
+
],
|
|
455
|
+
responsive: [
|
|
456
|
+
"flex-col [&>*]:w-full [&>.sr-only]:w-auto @md/field-group:flex-row @md/field-group:items-center @md/field-group:[&>*]:w-auto",
|
|
457
|
+
"@md/field-group:[&>[data-slot=field-label]]:flex-auto",
|
|
458
|
+
"@md/field-group:has-[>[data-slot=field-content]]:items-start @md/field-group:has-[>[data-slot=field-content]]:[&>[role=checkbox],[role=radio]]:mt-px"
|
|
459
|
+
]
|
|
484
460
|
}
|
|
461
|
+
},
|
|
462
|
+
defaultVariants: {
|
|
463
|
+
orientation: "vertical"
|
|
485
464
|
}
|
|
486
|
-
);
|
|
465
|
+
});
|
|
487
466
|
function Field({
|
|
488
467
|
className,
|
|
489
468
|
orientation = "vertical",
|
|
@@ -505,10 +484,7 @@ function FieldContent({ className, ...props }) {
|
|
|
505
484
|
"div",
|
|
506
485
|
{
|
|
507
486
|
"data-slot": "field-content",
|
|
508
|
-
className: cn(
|
|
509
|
-
"group/field-content flex flex-1 flex-col gap-1.5 leading-snug",
|
|
510
|
-
className
|
|
511
|
-
),
|
|
487
|
+
className: cn("group/field-content flex flex-1 flex-col gap-1.5 leading-snug", className),
|
|
512
488
|
...props
|
|
513
489
|
}
|
|
514
490
|
);
|
|
@@ -611,18 +587,8 @@ cva(
|
|
|
611
587
|
}
|
|
612
588
|
}
|
|
613
589
|
);
|
|
614
|
-
function RadioGroup({
|
|
615
|
-
className,
|
|
616
|
-
...props
|
|
617
|
-
}) {
|
|
618
|
-
return /* @__PURE__ */ jsx(
|
|
619
|
-
RadioGroupPrimitive.Root,
|
|
620
|
-
{
|
|
621
|
-
"data-slot": "radio-group",
|
|
622
|
-
className: cn("grid gap-3", className),
|
|
623
|
-
...props
|
|
624
|
-
}
|
|
625
|
-
);
|
|
590
|
+
function RadioGroup({ className, ...props }) {
|
|
591
|
+
return /* @__PURE__ */ jsx(RadioGroupPrimitive.Root, { "data-slot": "radio-group", className: cn("grid gap-3", className), ...props });
|
|
626
592
|
}
|
|
627
593
|
function ChoiceInteractionRenderer({
|
|
628
594
|
interaction,
|
|
@@ -1099,6 +1065,46 @@ function GapMatchInteraction({
|
|
|
1099
1065
|
}
|
|
1100
1066
|
);
|
|
1101
1067
|
}
|
|
1068
|
+
|
|
1069
|
+
// src/shared/shuffle.ts
|
|
1070
|
+
function xmur3(str) {
|
|
1071
|
+
let h = 1779033703 ^ str.length;
|
|
1072
|
+
for (let i = 0; i < str.length; i++) {
|
|
1073
|
+
h = Math.imul(h ^ str.charCodeAt(i), 3432918353);
|
|
1074
|
+
h = h << 13 | h >>> 19;
|
|
1075
|
+
}
|
|
1076
|
+
return () => {
|
|
1077
|
+
h = Math.imul(h ^ h >>> 16, 2246822507);
|
|
1078
|
+
h = Math.imul(h ^ h >>> 13, 3266489909);
|
|
1079
|
+
const shifted = h >>> 16;
|
|
1080
|
+
h = h ^ shifted;
|
|
1081
|
+
return h >>> 0;
|
|
1082
|
+
};
|
|
1083
|
+
}
|
|
1084
|
+
function mulberry32(seed) {
|
|
1085
|
+
let state = seed;
|
|
1086
|
+
return () => {
|
|
1087
|
+
state = state + 1831565813;
|
|
1088
|
+
let t = state;
|
|
1089
|
+
t = Math.imul(t ^ t >>> 15, t | 1);
|
|
1090
|
+
t = t ^ t + Math.imul(t ^ t >>> 7, t | 61);
|
|
1091
|
+
return ((t ^ t >>> 14) >>> 0) / 4294967296;
|
|
1092
|
+
};
|
|
1093
|
+
}
|
|
1094
|
+
function shuffleWithSeed(items, seed) {
|
|
1095
|
+
const out = items.slice();
|
|
1096
|
+
const seedFn = xmur3(seed);
|
|
1097
|
+
const rng = mulberry32(seedFn());
|
|
1098
|
+
for (let i = out.length - 1; i > 0; i--) {
|
|
1099
|
+
const j = Math.floor(rng() * (i + 1));
|
|
1100
|
+
const vi = out[i];
|
|
1101
|
+
const vj = out[j];
|
|
1102
|
+
if (vi === void 0 || vj === void 0) continue;
|
|
1103
|
+
out[i] = vj;
|
|
1104
|
+
out[j] = vi;
|
|
1105
|
+
}
|
|
1106
|
+
return out;
|
|
1107
|
+
}
|
|
1102
1108
|
var selectTriggerVariants = cva(
|
|
1103
1109
|
[
|
|
1104
1110
|
"cursor-pointer",
|
|
@@ -1157,10 +1163,7 @@ var selectTriggerVariants = cva(
|
|
|
1157
1163
|
function Select({ ...props }) {
|
|
1158
1164
|
return /* @__PURE__ */ jsx(SelectPrimitive.Root, { "data-slot": "select", ...props });
|
|
1159
1165
|
}
|
|
1160
|
-
function SelectValue({
|
|
1161
|
-
className,
|
|
1162
|
-
...props
|
|
1163
|
-
}) {
|
|
1166
|
+
function SelectValue({ className, ...props }) {
|
|
1164
1167
|
return /* @__PURE__ */ jsx(
|
|
1165
1168
|
SelectPrimitive.Value,
|
|
1166
1169
|
{
|
|
@@ -1231,11 +1234,7 @@ function SelectContent({
|
|
|
1231
1234
|
}
|
|
1232
1235
|
) });
|
|
1233
1236
|
}
|
|
1234
|
-
function SelectItem({
|
|
1235
|
-
className,
|
|
1236
|
-
children,
|
|
1237
|
-
...props
|
|
1238
|
-
}) {
|
|
1237
|
+
function SelectItem({ className, children, ...props }) {
|
|
1239
1238
|
return /* @__PURE__ */ jsxs(
|
|
1240
1239
|
SelectPrimitive.Item,
|
|
1241
1240
|
{
|
|
@@ -1252,10 +1251,7 @@ function SelectItem({
|
|
|
1252
1251
|
}
|
|
1253
1252
|
);
|
|
1254
1253
|
}
|
|
1255
|
-
function SelectScrollUpButton({
|
|
1256
|
-
className,
|
|
1257
|
-
...props
|
|
1258
|
-
}) {
|
|
1254
|
+
function SelectScrollUpButton({ className, ...props }) {
|
|
1259
1255
|
return /* @__PURE__ */ jsx(
|
|
1260
1256
|
SelectPrimitive.ScrollUpButton,
|
|
1261
1257
|
{
|
|
@@ -1280,46 +1276,6 @@ function SelectScrollDownButton({
|
|
|
1280
1276
|
}
|
|
1281
1277
|
);
|
|
1282
1278
|
}
|
|
1283
|
-
|
|
1284
|
-
// src/shared/shuffle.ts
|
|
1285
|
-
function xmur3(str) {
|
|
1286
|
-
let h = 1779033703 ^ str.length;
|
|
1287
|
-
for (let i = 0; i < str.length; i++) {
|
|
1288
|
-
h = Math.imul(h ^ str.charCodeAt(i), 3432918353);
|
|
1289
|
-
h = h << 13 | h >>> 19;
|
|
1290
|
-
}
|
|
1291
|
-
return () => {
|
|
1292
|
-
h = Math.imul(h ^ h >>> 16, 2246822507);
|
|
1293
|
-
h = Math.imul(h ^ h >>> 13, 3266489909);
|
|
1294
|
-
const shifted = h >>> 16;
|
|
1295
|
-
h = h ^ shifted;
|
|
1296
|
-
return h >>> 0;
|
|
1297
|
-
};
|
|
1298
|
-
}
|
|
1299
|
-
function mulberry32(seed) {
|
|
1300
|
-
let state = seed;
|
|
1301
|
-
return () => {
|
|
1302
|
-
state = state + 1831565813;
|
|
1303
|
-
let t = state;
|
|
1304
|
-
t = Math.imul(t ^ t >>> 15, t | 1);
|
|
1305
|
-
t = t ^ t + Math.imul(t ^ t >>> 7, t | 61);
|
|
1306
|
-
return ((t ^ t >>> 14) >>> 0) / 4294967296;
|
|
1307
|
-
};
|
|
1308
|
-
}
|
|
1309
|
-
function shuffleWithSeed(items, seed) {
|
|
1310
|
-
const out = items.slice();
|
|
1311
|
-
const seedFn = xmur3(seed);
|
|
1312
|
-
const rng = mulberry32(seedFn());
|
|
1313
|
-
for (let i = out.length - 1; i > 0; i--) {
|
|
1314
|
-
const j = Math.floor(rng() * (i + 1));
|
|
1315
|
-
const vi = out[i];
|
|
1316
|
-
const vj = out[j];
|
|
1317
|
-
if (vi === void 0 || vj === void 0) continue;
|
|
1318
|
-
out[i] = vj;
|
|
1319
|
-
out[j] = vi;
|
|
1320
|
-
}
|
|
1321
|
-
return out;
|
|
1322
|
-
}
|
|
1323
1279
|
function SafeInlineHTML2({ html, className, style }) {
|
|
1324
1280
|
const ref = React3.useRef(null);
|
|
1325
1281
|
React3.useEffect(() => {
|