@learnosity/lib-qti-converter 0.12.0 → 0.12.1
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/package.json +7 -7
- package/packages/cli/dist/main.js +406 -430
- package/packages/cli/dist/main.js.map +1 -1
- package/packages/core/dist/index.js +386 -410
- package/packages/core/dist/node.js +386 -410
|
@@ -2973,7 +2973,7 @@ function useColor() {
|
|
|
2973
2973
|
}
|
|
2974
2974
|
new Command();
|
|
2975
2975
|
//#endregion
|
|
2976
|
-
//#region ../../node_modules/.pnpm/@inquirer+core@11.2.1_@types+node@26.
|
|
2976
|
+
//#region ../../node_modules/.pnpm/@inquirer+core@11.2.1_@types+node@26.2.0/node_modules/@inquirer/core/dist/lib/key.js
|
|
2977
2977
|
const keybindingLookup = /* @__PURE__ */ new Set(["emacs", "vim"]);
|
|
2978
2978
|
function isKeybinding(value) {
|
|
2979
2979
|
return keybindingLookup.has(value);
|
|
@@ -2991,7 +2991,7 @@ const isTabKey = (key) => key.name === "tab";
|
|
|
2991
2991
|
const isNumberKey = (key) => "1234567890".includes(key.name);
|
|
2992
2992
|
const isEnterKey = (key) => key.name === "enter" || key.name === "return";
|
|
2993
2993
|
//#endregion
|
|
2994
|
-
//#region ../../node_modules/.pnpm/@inquirer+core@11.2.1_@types+node@26.
|
|
2994
|
+
//#region ../../node_modules/.pnpm/@inquirer+core@11.2.1_@types+node@26.2.0/node_modules/@inquirer/core/dist/lib/errors.js
|
|
2995
2995
|
var AbortPromptError = class extends Error {
|
|
2996
2996
|
name = "AbortPromptError";
|
|
2997
2997
|
message = "Prompt was aborted";
|
|
@@ -3014,7 +3014,7 @@ var ValidationError = class extends Error {
|
|
|
3014
3014
|
name = "ValidationError";
|
|
3015
3015
|
};
|
|
3016
3016
|
//#endregion
|
|
3017
|
-
//#region ../../node_modules/.pnpm/@inquirer+core@11.2.1_@types+node@26.
|
|
3017
|
+
//#region ../../node_modules/.pnpm/@inquirer+core@11.2.1_@types+node@26.2.0/node_modules/@inquirer/core/dist/lib/hook-engine.js
|
|
3018
3018
|
const hookStorage = new AsyncLocalStorage();
|
|
3019
3019
|
function createStore(rl) {
|
|
3020
3020
|
return {
|
|
@@ -3110,7 +3110,7 @@ const effectScheduler = {
|
|
|
3110
3110
|
}
|
|
3111
3111
|
};
|
|
3112
3112
|
//#endregion
|
|
3113
|
-
//#region ../../node_modules/.pnpm/@inquirer+core@11.2.1_@types+node@26.
|
|
3113
|
+
//#region ../../node_modules/.pnpm/@inquirer+core@11.2.1_@types+node@26.2.0/node_modules/@inquirer/core/dist/lib/use-state.js
|
|
3114
3114
|
function isFactory(value) {
|
|
3115
3115
|
return typeof value === "function";
|
|
3116
3116
|
}
|
|
@@ -3129,7 +3129,7 @@ function useState(defaultValue) {
|
|
|
3129
3129
|
});
|
|
3130
3130
|
}
|
|
3131
3131
|
//#endregion
|
|
3132
|
-
//#region ../../node_modules/.pnpm/@inquirer+core@11.2.1_@types+node@26.
|
|
3132
|
+
//#region ../../node_modules/.pnpm/@inquirer+core@11.2.1_@types+node@26.2.0/node_modules/@inquirer/core/dist/lib/use-effect.js
|
|
3133
3133
|
function useEffect(cb, depArray) {
|
|
3134
3134
|
withPointer((pointer) => {
|
|
3135
3135
|
const oldDeps = pointer.get();
|
|
@@ -3422,7 +3422,7 @@ const fallbackSymbols = {
|
|
|
3422
3422
|
const figures = isUnicodeSupported$1() ? mainSymbols : fallbackSymbols;
|
|
3423
3423
|
Object.entries(specialMainSymbols);
|
|
3424
3424
|
//#endregion
|
|
3425
|
-
//#region ../../node_modules/.pnpm/@inquirer+core@11.2.1_@types+node@26.
|
|
3425
|
+
//#region ../../node_modules/.pnpm/@inquirer+core@11.2.1_@types+node@26.2.0/node_modules/@inquirer/core/dist/lib/theme.js
|
|
3426
3426
|
const defaultTheme = {
|
|
3427
3427
|
prefix: {
|
|
3428
3428
|
idle: styleText("blue", "?"),
|
|
@@ -3461,7 +3461,7 @@ function getDefaultTheme() {
|
|
|
3461
3461
|
};
|
|
3462
3462
|
}
|
|
3463
3463
|
//#endregion
|
|
3464
|
-
//#region ../../node_modules/.pnpm/@inquirer+core@11.2.1_@types+node@26.
|
|
3464
|
+
//#region ../../node_modules/.pnpm/@inquirer+core@11.2.1_@types+node@26.2.0/node_modules/@inquirer/core/dist/lib/make-theme.js
|
|
3465
3465
|
function isPlainObject(value) {
|
|
3466
3466
|
if (typeof value !== "object" || value === null) return false;
|
|
3467
3467
|
let proto = value;
|
|
@@ -3480,7 +3480,7 @@ function makeTheme(...themes) {
|
|
|
3480
3480
|
return deepMerge(...[getDefaultTheme(), ...themes.filter((theme) => theme != null)]);
|
|
3481
3481
|
}
|
|
3482
3482
|
//#endregion
|
|
3483
|
-
//#region ../../node_modules/.pnpm/@inquirer+core@11.2.1_@types+node@26.
|
|
3483
|
+
//#region ../../node_modules/.pnpm/@inquirer+core@11.2.1_@types+node@26.2.0/node_modules/@inquirer/core/dist/lib/use-prefix.js
|
|
3484
3484
|
function usePrefix({ status = "idle", theme }) {
|
|
3485
3485
|
const [showLoader, setShowLoader] = useState(false);
|
|
3486
3486
|
const [tick, setTick] = useState(0);
|
|
@@ -3506,7 +3506,7 @@ function usePrefix({ status = "idle", theme }) {
|
|
|
3506
3506
|
return typeof prefix === "string" ? prefix : prefix[status === "loading" ? "idle" : status] ?? prefix["idle"];
|
|
3507
3507
|
}
|
|
3508
3508
|
//#endregion
|
|
3509
|
-
//#region ../../node_modules/.pnpm/@inquirer+core@11.2.1_@types+node@26.
|
|
3509
|
+
//#region ../../node_modules/.pnpm/@inquirer+core@11.2.1_@types+node@26.2.0/node_modules/@inquirer/core/dist/lib/use-memo.js
|
|
3510
3510
|
function useMemo(fn, dependencies) {
|
|
3511
3511
|
return withPointer((pointer) => {
|
|
3512
3512
|
const prev = pointer.get();
|
|
@@ -3522,12 +3522,12 @@ function useMemo(fn, dependencies) {
|
|
|
3522
3522
|
});
|
|
3523
3523
|
}
|
|
3524
3524
|
//#endregion
|
|
3525
|
-
//#region ../../node_modules/.pnpm/@inquirer+core@11.2.1_@types+node@26.
|
|
3525
|
+
//#region ../../node_modules/.pnpm/@inquirer+core@11.2.1_@types+node@26.2.0/node_modules/@inquirer/core/dist/lib/use-ref.js
|
|
3526
3526
|
function useRef(val) {
|
|
3527
3527
|
return useState({ current: val })[0];
|
|
3528
3528
|
}
|
|
3529
3529
|
//#endregion
|
|
3530
|
-
//#region ../../node_modules/.pnpm/@inquirer+core@11.2.1_@types+node@26.
|
|
3530
|
+
//#region ../../node_modules/.pnpm/@inquirer+core@11.2.1_@types+node@26.2.0/node_modules/@inquirer/core/dist/lib/use-keypress.js
|
|
3531
3531
|
function useKeypress(userHandler) {
|
|
3532
3532
|
const signal = useRef(userHandler);
|
|
3533
3533
|
signal.current = userHandler;
|
|
@@ -3855,7 +3855,7 @@ function wrapAnsi$1(string, columns, options) {
|
|
|
3855
3855
|
return String(string).normalize().split(CRLF_OR_LF).map((line) => exec$1(line, columns, options)).join("\n");
|
|
3856
3856
|
}
|
|
3857
3857
|
//#endregion
|
|
3858
|
-
//#region ../../node_modules/.pnpm/@inquirer+core@11.2.1_@types+node@26.
|
|
3858
|
+
//#region ../../node_modules/.pnpm/@inquirer+core@11.2.1_@types+node@26.2.0/node_modules/@inquirer/core/dist/lib/utils.js
|
|
3859
3859
|
var import_cli_width = /* @__PURE__ */ __toESM(require_cli_width(), 1);
|
|
3860
3860
|
/**
|
|
3861
3861
|
* Force line returns at specific width. This function is ANSI code friendly and it'll
|
|
@@ -3881,7 +3881,7 @@ function readlineWidth() {
|
|
|
3881
3881
|
});
|
|
3882
3882
|
}
|
|
3883
3883
|
//#endregion
|
|
3884
|
-
//#region ../../node_modules/.pnpm/@inquirer+core@11.2.1_@types+node@26.
|
|
3884
|
+
//#region ../../node_modules/.pnpm/@inquirer+core@11.2.1_@types+node@26.2.0/node_modules/@inquirer/core/dist/lib/pagination/use-pagination.js
|
|
3885
3885
|
function usePointerPosition({ active, renderedItems, pageSize, loop }) {
|
|
3886
3886
|
const state = useRef({
|
|
3887
3887
|
lastPointer: active,
|
|
@@ -4282,7 +4282,7 @@ const eraseLine = "\x1B[2K";
|
|
|
4282
4282
|
/** Erase the specified number of lines above the cursor */
|
|
4283
4283
|
const eraseLines = (lines) => lines > 0 ? (eraseLine + cursorUp(1)).repeat(lines - 1) + "\x1B[2K\x1B[G" : "";
|
|
4284
4284
|
//#endregion
|
|
4285
|
-
//#region ../../node_modules/.pnpm/@inquirer+core@11.2.1_@types+node@26.
|
|
4285
|
+
//#region ../../node_modules/.pnpm/@inquirer+core@11.2.1_@types+node@26.2.0/node_modules/@inquirer/core/dist/lib/screen-manager.js
|
|
4286
4286
|
const height = (content) => content.split("\n").length;
|
|
4287
4287
|
const lastLine = (content) => content.split("\n").pop() ?? "";
|
|
4288
4288
|
var ScreenManager = class {
|
|
@@ -4339,7 +4339,7 @@ var ScreenManager = class {
|
|
|
4339
4339
|
}
|
|
4340
4340
|
};
|
|
4341
4341
|
//#endregion
|
|
4342
|
-
//#region ../../node_modules/.pnpm/@inquirer+core@11.2.1_@types+node@26.
|
|
4342
|
+
//#region ../../node_modules/.pnpm/@inquirer+core@11.2.1_@types+node@26.2.0/node_modules/@inquirer/core/dist/lib/promise-polyfill.js
|
|
4343
4343
|
var PromisePolyfill = class extends Promise {
|
|
4344
4344
|
static withResolver() {
|
|
4345
4345
|
let resolve;
|
|
@@ -4355,7 +4355,7 @@ var PromisePolyfill = class extends Promise {
|
|
|
4355
4355
|
}
|
|
4356
4356
|
};
|
|
4357
4357
|
//#endregion
|
|
4358
|
-
//#region ../../node_modules/.pnpm/@inquirer+core@11.2.1_@types+node@26.
|
|
4358
|
+
//#region ../../node_modules/.pnpm/@inquirer+core@11.2.1_@types+node@26.2.0/node_modules/@inquirer/core/dist/lib/create-prompt.js
|
|
4359
4359
|
var import_lib$1 = /* @__PURE__ */ __toESM(require_lib$1(), 1);
|
|
4360
4360
|
const nativeSetImmediate = globalThis.setImmediate;
|
|
4361
4361
|
function getCallSites() {
|
|
@@ -4458,7 +4458,7 @@ function createPrompt(view) {
|
|
|
4458
4458
|
return prompt;
|
|
4459
4459
|
}
|
|
4460
4460
|
//#endregion
|
|
4461
|
-
//#region ../../node_modules/.pnpm/@inquirer+core@11.2.1_@types+node@26.
|
|
4461
|
+
//#region ../../node_modules/.pnpm/@inquirer+core@11.2.1_@types+node@26.2.0/node_modules/@inquirer/core/dist/lib/Separator.js
|
|
4462
4462
|
/**
|
|
4463
4463
|
* Separator object
|
|
4464
4464
|
* Used to space/separate choices group
|
|
@@ -4474,7 +4474,7 @@ var Separator = class {
|
|
|
4474
4474
|
}
|
|
4475
4475
|
};
|
|
4476
4476
|
//#endregion
|
|
4477
|
-
//#region ../../node_modules/.pnpm/@inquirer+checkbox@5.2.1_@types+node@26.
|
|
4477
|
+
//#region ../../node_modules/.pnpm/@inquirer+checkbox@5.2.1_@types+node@26.2.0/node_modules/@inquirer/checkbox/dist/index.js
|
|
4478
4478
|
const checkboxTheme = {
|
|
4479
4479
|
icon: {
|
|
4480
4480
|
checked: styleText("green", figures.circleFilled),
|
|
@@ -4658,7 +4658,7 @@ var dist_default$2 = createPrompt((config, done) => {
|
|
|
4658
4658
|
].filter(Boolean).join("\n").trimEnd()}${cursorHide}`;
|
|
4659
4659
|
});
|
|
4660
4660
|
//#endregion
|
|
4661
|
-
//#region ../../node_modules/.pnpm/@inquirer+input@5.1.2_@types+node@26.
|
|
4661
|
+
//#region ../../node_modules/.pnpm/@inquirer+input@5.1.2_@types+node@26.2.0/node_modules/@inquirer/input/dist/index.js
|
|
4662
4662
|
const inputTheme = { validationFailureMode: "keep" };
|
|
4663
4663
|
var dist_default$1 = createPrompt((config, done) => {
|
|
4664
4664
|
const { prefill = "tab" } = config;
|
|
@@ -4727,7 +4727,7 @@ var dist_default$1 = createPrompt((config, done) => {
|
|
|
4727
4727
|
].filter((v) => v !== void 0).join(" "), error];
|
|
4728
4728
|
});
|
|
4729
4729
|
//#endregion
|
|
4730
|
-
//#region ../../node_modules/.pnpm/@inquirer+select@5.2.1_@types+node@26.
|
|
4730
|
+
//#region ../../node_modules/.pnpm/@inquirer+select@5.2.1_@types+node@26.2.0/node_modules/@inquirer/select/dist/index.js
|
|
4731
4731
|
const selectTheme = {
|
|
4732
4732
|
icon: { cursor: figures.pointer },
|
|
4733
4733
|
style: {
|
|
@@ -23226,6 +23226,77 @@ function getMimeTypeFromExtension(src) {
|
|
|
23226
23226
|
if (ext === "webm") return "video/webm";
|
|
23227
23227
|
if (ext === "ogv") return "video/ogg";
|
|
23228
23228
|
}
|
|
23229
|
+
/**
|
|
23230
|
+
* Generic section-extraction wrapper that eliminates boilerplate from individual
|
|
23231
|
+
* interaction builders. Calls the provided `buildXml` function to generate raw XML
|
|
23232
|
+
* fragments, then regex-extracts the standard QTI assessmentItem sections.
|
|
23233
|
+
*
|
|
23234
|
+
* Handles both self-closing (`<responseDeclaration ... />`) and paired
|
|
23235
|
+
* (`<responseDeclaration ...>...</responseDeclaration>`) element forms.
|
|
23236
|
+
*
|
|
23237
|
+
* @example
|
|
23238
|
+
* ```ts
|
|
23239
|
+
* export function buildAssociateInteractionSections(...) {
|
|
23240
|
+
* buildInteractionSections(
|
|
23241
|
+
* buildAssociateInteractionXml,
|
|
23242
|
+
* [interaction, diagnostics],
|
|
23243
|
+
* sections, indent, indent2, indent3, nl
|
|
23244
|
+
* );
|
|
23245
|
+
* }
|
|
23246
|
+
* ```
|
|
23247
|
+
*/
|
|
23248
|
+
function buildInteractionSections(buildXml, buildArgs, _diagnostics, sections, indent, indent2, indent3, nl, opts) {
|
|
23249
|
+
const tempParts = [];
|
|
23250
|
+
buildXml(...buildArgs, tempParts, indent, indent2, indent3, nl);
|
|
23251
|
+
const joined = tempParts.join("");
|
|
23252
|
+
if (opts?.multiResponseDeclarations) {
|
|
23253
|
+
const matches = joined.matchAll(/(<responseDeclaration[\s\S]*?(?:\/>|<\/responseDeclaration>))/g);
|
|
23254
|
+
for (const m of matches) sections.responseDeclarations.push(m[1] + nl);
|
|
23255
|
+
} else if (opts?.selfClosingResponseDecl) {
|
|
23256
|
+
const match = joined.match(/(<responseDeclaration[\s\S]*?(?:\/>|<\/responseDeclaration>))/);
|
|
23257
|
+
if (match) sections.responseDeclarations.push(match[1] + nl);
|
|
23258
|
+
} else {
|
|
23259
|
+
const match = joined.match(/(<responseDeclaration[\s\S]*?<\/responseDeclaration>)/);
|
|
23260
|
+
if (match) sections.responseDeclarations.push(match[1] + nl);
|
|
23261
|
+
}
|
|
23262
|
+
if (opts?.multiOutcomeDeclarations) {
|
|
23263
|
+
const matches = joined.matchAll(/(<outcomeDeclaration[\s\S]*?<\/outcomeDeclaration>)/g);
|
|
23264
|
+
for (const m of matches) sections.outcomeDeclarations.push(m[1] + nl);
|
|
23265
|
+
} else {
|
|
23266
|
+
const match = joined.match(/(<outcomeDeclaration[\s\S]*?<\/outcomeDeclaration>)/);
|
|
23267
|
+
if (match) sections.outcomeDeclarations.push(match[1] + nl);
|
|
23268
|
+
}
|
|
23269
|
+
const itemBodyMatch = joined.match(/(<itemBody>[\s\S]*?<\/itemBody>)/);
|
|
23270
|
+
if (itemBodyMatch) sections.itemBody = itemBodyMatch[1] + nl;
|
|
23271
|
+
const responseProcMatch = joined.match(/(<responseProcessing[\s\S]*?(?:\/>|<\/responseProcessing>))/);
|
|
23272
|
+
if (responseProcMatch) sections.responseProcessing = responseProcMatch[1] + nl;
|
|
23273
|
+
}
|
|
23274
|
+
/**
|
|
23275
|
+
* Emit the standard SCORE outcomeDeclaration block.
|
|
23276
|
+
*
|
|
23277
|
+
* Used by: associate, choice, gapMatch, inlineChoice, match, order, textEntry (×2)
|
|
23278
|
+
*/
|
|
23279
|
+
function pushScoreOutcomeDeclaration(parts, indent, indent2, indent3, nl) {
|
|
23280
|
+
parts.push(`${indent}<outcomeDeclaration identifier="SCORE" cardinality="single" baseType="float">`);
|
|
23281
|
+
parts.push(nl);
|
|
23282
|
+
parts.push(`${indent2}<defaultValue>`);
|
|
23283
|
+
parts.push(nl);
|
|
23284
|
+
parts.push(`${indent3}<value>0</value>`);
|
|
23285
|
+
parts.push(nl);
|
|
23286
|
+
parts.push(`${indent2}</defaultValue>`);
|
|
23287
|
+
parts.push(nl);
|
|
23288
|
+
parts.push(`${indent}</outcomeDeclaration>`);
|
|
23289
|
+
parts.push(nl);
|
|
23290
|
+
}
|
|
23291
|
+
/**
|
|
23292
|
+
* Emit the standard responseProcessing match_correct template reference.
|
|
23293
|
+
*
|
|
23294
|
+
* Used by: associate, choice, gapMatch, hotspot, hottext, match, order, textEntry (×2)
|
|
23295
|
+
*/
|
|
23296
|
+
function pushMatchCorrectResponseProcessing(parts, indent, nl) {
|
|
23297
|
+
parts.push(`${indent}<responseProcessing template="http://www.imsglobal.org/question/qti_v2p2/rptemplates/match_correct"/>`);
|
|
23298
|
+
parts.push(nl);
|
|
23299
|
+
}
|
|
23229
23300
|
//#endregion
|
|
23230
23301
|
//#region ../core/src/qti-serializer/multiWidgetSerializer.ts
|
|
23231
23302
|
/**
|
|
@@ -23526,16 +23597,7 @@ function buildMultiWidgetItemXml(ast, diagnostics, parts, indent, indent2, inden
|
|
|
23526
23597
|
parts.push(nl);
|
|
23527
23598
|
}
|
|
23528
23599
|
}
|
|
23529
|
-
parts
|
|
23530
|
-
parts.push(nl);
|
|
23531
|
-
parts.push(`${indent2}<defaultValue>`);
|
|
23532
|
-
parts.push(nl);
|
|
23533
|
-
parts.push(`${indent3}<value>0</value>`);
|
|
23534
|
-
parts.push(nl);
|
|
23535
|
-
parts.push(`${indent2}</defaultValue>`);
|
|
23536
|
-
parts.push(nl);
|
|
23537
|
-
parts.push(`${indent}</outcomeDeclaration>`);
|
|
23538
|
-
parts.push(nl);
|
|
23600
|
+
pushScoreOutcomeDeclaration(parts, indent, indent2, indent3, nl);
|
|
23539
23601
|
parts.push(`${indent}<itemBody>`);
|
|
23540
23602
|
parts.push(nl);
|
|
23541
23603
|
let contentHtml = layout.contentHtml;
|
|
@@ -23584,10 +23646,7 @@ function buildMultiWidgetItemXml(ast, diagnostics, parts, indent, indent2, inden
|
|
|
23584
23646
|
else if (int.type === "textEntry") return (int.correctResponses?.length ?? 0) > 0;
|
|
23585
23647
|
else if (int.type === "order") return (int.correctResponse?.length ?? 0) > 0;
|
|
23586
23648
|
return false;
|
|
23587
|
-
}))
|
|
23588
|
-
parts.push(`${indent}<responseProcessing template="http://www.imsglobal.org/question/qti_v2p2/rptemplates/match_correct"/>`);
|
|
23589
|
-
parts.push(nl);
|
|
23590
|
-
}
|
|
23649
|
+
})) pushMatchCorrectResponseProcessing(parts, indent, nl);
|
|
23591
23650
|
}
|
|
23592
23651
|
/**
|
|
23593
23652
|
* Render an interaction as XML string (for multi-widget layouts)
|
|
@@ -23916,17 +23975,11 @@ function convertVideoplayerToQh5(data) {
|
|
|
23916
23975
|
* Section-based wrapper for buildChoiceInteractionXml
|
|
23917
23976
|
*/
|
|
23918
23977
|
function buildChoiceInteractionSections(interaction, feedbackBlock, diagnostics, sections, indent, indent2, indent3, nl) {
|
|
23919
|
-
|
|
23920
|
-
|
|
23921
|
-
|
|
23922
|
-
|
|
23923
|
-
|
|
23924
|
-
const itemBodyMatch = joined.match(/(<itemBody>[\s\S]*?<\/itemBody>)/);
|
|
23925
|
-
const responseProcMatch = joined.match(/(<responseProcessing[^>]*\/>)/);
|
|
23926
|
-
if (responseDeclMatch) sections.responseDeclarations.push(responseDeclMatch[1] + nl);
|
|
23927
|
-
for (const match of outcomeDeclMatches) sections.outcomeDeclarations.push(match[1] + nl);
|
|
23928
|
-
if (itemBodyMatch) sections.itemBody = itemBodyMatch[1] + nl;
|
|
23929
|
-
if (responseProcMatch) sections.responseProcessing = responseProcMatch[1] + nl;
|
|
23978
|
+
buildInteractionSections(buildChoiceInteractionXml, [
|
|
23979
|
+
interaction,
|
|
23980
|
+
feedbackBlock,
|
|
23981
|
+
diagnostics
|
|
23982
|
+
], diagnostics, sections, indent, indent2, indent3, nl, { multiOutcomeDeclarations: true });
|
|
23930
23983
|
}
|
|
23931
23984
|
/**
|
|
23932
23985
|
* Build choice interaction XML (MCQ)
|
|
@@ -23956,16 +24009,7 @@ function buildChoiceInteractionXml(interaction, feedbackBlock, diagnostics, part
|
|
|
23956
24009
|
parts.push(`${indent}</responseDeclaration>`);
|
|
23957
24010
|
parts.push(nl);
|
|
23958
24011
|
}
|
|
23959
|
-
parts
|
|
23960
|
-
parts.push(nl);
|
|
23961
|
-
parts.push(`${indent2}<defaultValue>`);
|
|
23962
|
-
parts.push(nl);
|
|
23963
|
-
parts.push(`${indent3}<value>0</value>`);
|
|
23964
|
-
parts.push(nl);
|
|
23965
|
-
parts.push(`${indent2}</defaultValue>`);
|
|
23966
|
-
parts.push(nl);
|
|
23967
|
-
parts.push(`${indent}</outcomeDeclaration>`);
|
|
23968
|
-
parts.push(nl);
|
|
24012
|
+
pushScoreOutcomeDeclaration(parts, indent, indent2, indent3, nl);
|
|
23969
24013
|
if (feedbackBlock && feedbackBlock.length > 0) {
|
|
23970
24014
|
parts.push(`${indent}<outcomeDeclaration identifier="FEEDBACK" cardinality="single" baseType="identifier">`);
|
|
23971
24015
|
parts.push(nl);
|
|
@@ -24018,10 +24062,7 @@ function buildChoiceInteractionXml(interaction, feedbackBlock, diagnostics, part
|
|
|
24018
24062
|
}
|
|
24019
24063
|
parts.push(`${indent}</itemBody>`);
|
|
24020
24064
|
parts.push(nl);
|
|
24021
|
-
if (interaction.correctResponse)
|
|
24022
|
-
parts.push(`${indent}<responseProcessing template="http://www.imsglobal.org/question/qti_v2p2/rptemplates/match_correct"/>`);
|
|
24023
|
-
parts.push(nl);
|
|
24024
|
-
}
|
|
24065
|
+
if (interaction.correctResponse) pushMatchCorrectResponseProcessing(parts, indent, nl);
|
|
24025
24066
|
}
|
|
24026
24067
|
//#endregion
|
|
24027
24068
|
//#region ../core/src/qti-serializer/interaction-builders/buildTextEntryInteraction.ts
|
|
@@ -24029,17 +24070,7 @@ function buildChoiceInteractionXml(interaction, feedbackBlock, diagnostics, part
|
|
|
24029
24070
|
* Section-based wrapper for buildTextEntryInteractionXml
|
|
24030
24071
|
*/
|
|
24031
24072
|
function buildTextEntryInteractionSections(interaction, diagnostics, sections, indent, indent2, indent3, nl) {
|
|
24032
|
-
|
|
24033
|
-
buildTextEntryInteractionXml(interaction, diagnostics, tempParts, indent, indent2, indent3, nl);
|
|
24034
|
-
const joined = tempParts.join("");
|
|
24035
|
-
const responseDeclMatches = joined.matchAll(/(<responseDeclaration[\s\S]*?(?:\/>|<\/responseDeclaration>))/g);
|
|
24036
|
-
for (const match of responseDeclMatches) sections.responseDeclarations.push(match[1] + nl);
|
|
24037
|
-
const outcomeDeclMatch = joined.match(/(<outcomeDeclaration[\s\S]*?<\/outcomeDeclaration>)/);
|
|
24038
|
-
const itemBodyMatch = joined.match(/(<itemBody>[\s\S]*?<\/itemBody>)/);
|
|
24039
|
-
const responseProcMatch = joined.match(/(<responseProcessing[^>]*\/>)/);
|
|
24040
|
-
if (outcomeDeclMatch) sections.outcomeDeclarations.push(outcomeDeclMatch[1] + nl);
|
|
24041
|
-
if (itemBodyMatch) sections.itemBody = itemBodyMatch[1] + nl;
|
|
24042
|
-
if (responseProcMatch) sections.responseProcessing = responseProcMatch[1] + nl;
|
|
24073
|
+
buildInteractionSections(buildTextEntryInteractionXml, [interaction, diagnostics], diagnostics, sections, indent, indent2, indent3, nl, { multiResponseDeclarations: true });
|
|
24043
24074
|
}
|
|
24044
24075
|
/**
|
|
24045
24076
|
* Build text entry interaction XML (clozetext)
|
|
@@ -24073,16 +24104,7 @@ function buildTextEntryInteractionXml(interaction, diagnostics, parts, indent, i
|
|
|
24073
24104
|
parts.push(`${indent}<responseDeclaration identifier="${interaction.responseIdentifier}" cardinality="single" baseType="string"/>`);
|
|
24074
24105
|
parts.push(nl);
|
|
24075
24106
|
}
|
|
24076
|
-
parts
|
|
24077
|
-
parts.push(nl);
|
|
24078
|
-
parts.push(`${indent2}<defaultValue>`);
|
|
24079
|
-
parts.push(nl);
|
|
24080
|
-
parts.push(`${indent3}<value>0</value>`);
|
|
24081
|
-
parts.push(nl);
|
|
24082
|
-
parts.push(`${indent2}</defaultValue>`);
|
|
24083
|
-
parts.push(nl);
|
|
24084
|
-
parts.push(`${indent}</outcomeDeclaration>`);
|
|
24085
|
-
parts.push(nl);
|
|
24107
|
+
pushScoreOutcomeDeclaration(parts, indent, indent2, indent3, nl);
|
|
24086
24108
|
parts.push(`${indent}<itemBody>`);
|
|
24087
24109
|
parts.push(nl);
|
|
24088
24110
|
diagnostics.push({
|
|
@@ -24112,10 +24134,7 @@ function buildTextEntryInteractionXml(interaction, diagnostics, parts, indent, i
|
|
|
24112
24134
|
parts.push(nl);
|
|
24113
24135
|
parts.push(`${indent}</itemBody>`);
|
|
24114
24136
|
parts.push(nl);
|
|
24115
|
-
if (interaction.correctResponses && interaction.correctResponses.length > 0)
|
|
24116
|
-
parts.push(`${indent}<responseProcessing template="http://www.imsglobal.org/question/qti_v2p2/rptemplates/match_correct"/>`);
|
|
24117
|
-
parts.push(nl);
|
|
24118
|
-
}
|
|
24137
|
+
if (interaction.correctResponses && interaction.correctResponses.length > 0) pushMatchCorrectResponseProcessing(parts, indent, nl);
|
|
24119
24138
|
return;
|
|
24120
24139
|
}
|
|
24121
24140
|
if (!Array.isArray(interaction.textEntries) || interaction.textEntries.length === 0) {
|
|
@@ -24152,16 +24171,7 @@ function buildTextEntryInteractionXml(interaction, diagnostics, parts, indent, i
|
|
|
24152
24171
|
parts.push(`${indent}<responseDeclaration identifier="${entry.responseIdentifier}" cardinality="single" baseType="string"/>`);
|
|
24153
24172
|
parts.push(nl);
|
|
24154
24173
|
}
|
|
24155
|
-
parts
|
|
24156
|
-
parts.push(nl);
|
|
24157
|
-
parts.push(`${indent2}<defaultValue>`);
|
|
24158
|
-
parts.push(nl);
|
|
24159
|
-
parts.push(`${indent3}<value>0</value>`);
|
|
24160
|
-
parts.push(nl);
|
|
24161
|
-
parts.push(`${indent2}</defaultValue>`);
|
|
24162
|
-
parts.push(nl);
|
|
24163
|
-
parts.push(`${indent}</outcomeDeclaration>`);
|
|
24164
|
-
parts.push(nl);
|
|
24174
|
+
pushScoreOutcomeDeclaration(parts, indent, indent2, indent3, nl);
|
|
24165
24175
|
parts.push(`${indent}<itemBody>`);
|
|
24166
24176
|
parts.push(nl);
|
|
24167
24177
|
if (interaction.prompt) {
|
|
@@ -24211,10 +24221,7 @@ function buildTextEntryInteractionXml(interaction, diagnostics, parts, indent, i
|
|
|
24211
24221
|
parts.push(nl);
|
|
24212
24222
|
parts.push(`${indent}</itemBody>`);
|
|
24213
24223
|
parts.push(nl);
|
|
24214
|
-
if (interaction.textEntries.some((e) => e.correctResponse))
|
|
24215
|
-
parts.push(`${indent}<responseProcessing template="http://www.imsglobal.org/question/qti_v2p2/rptemplates/match_correct"/>`);
|
|
24216
|
-
parts.push(nl);
|
|
24217
|
-
}
|
|
24224
|
+
if (interaction.textEntries.some((e) => e.correctResponse)) pushMatchCorrectResponseProcessing(parts, indent, nl);
|
|
24218
24225
|
}
|
|
24219
24226
|
//#endregion
|
|
24220
24227
|
//#region ../core/src/qti-serializer/interaction-builders/buildExtendedTextInteraction.ts
|
|
@@ -24222,15 +24229,14 @@ function buildTextEntryInteractionXml(interaction, diagnostics, parts, indent, i
|
|
|
24222
24229
|
* Section-based wrapper for buildExtendedTextInteractionXml
|
|
24223
24230
|
*/
|
|
24224
24231
|
function buildExtendedTextInteractionSections(interaction, outcomeDeclaration, diagnostics, sections, indent, indent2, indent3, nl) {
|
|
24225
|
-
|
|
24226
|
-
|
|
24227
|
-
|
|
24228
|
-
|
|
24229
|
-
|
|
24230
|
-
|
|
24231
|
-
|
|
24232
|
-
|
|
24233
|
-
if (itemBodyMatch) sections.itemBody = itemBodyMatch[1] + nl;
|
|
24232
|
+
buildInteractionSections(buildExtendedTextInteractionXml, [
|
|
24233
|
+
interaction,
|
|
24234
|
+
outcomeDeclaration,
|
|
24235
|
+
diagnostics
|
|
24236
|
+
], diagnostics, sections, indent, indent2, indent3, nl, {
|
|
24237
|
+
multiOutcomeDeclarations: true,
|
|
24238
|
+
selfClosingResponseDecl: true
|
|
24239
|
+
});
|
|
24234
24240
|
}
|
|
24235
24241
|
/**
|
|
24236
24242
|
* Build extended text interaction XML (essay/long answer)
|
|
@@ -24278,15 +24284,10 @@ function buildExtendedTextInteractionXml(interaction, outcomeDeclaration, diagno
|
|
|
24278
24284
|
* Section-based wrapper for buildUploadInteractionXml
|
|
24279
24285
|
*/
|
|
24280
24286
|
function buildUploadInteractionSections(interaction, diagnostics, sections, indent, indent2, nl) {
|
|
24281
|
-
const
|
|
24282
|
-
|
|
24283
|
-
|
|
24284
|
-
|
|
24285
|
-
const itemBodyMatch = joined.match(/(<itemBody>[\s\S]*?<\/itemBody>)/);
|
|
24286
|
-
const responseProcessingMatch = joined.match(/(<responseProcessing[\s\S]*?(?:\/>|<\/responseProcessing>))/);
|
|
24287
|
-
if (responseDeclMatch) sections.responseDeclarations.push(responseDeclMatch[1] + nl);
|
|
24288
|
-
if (itemBodyMatch) sections.itemBody = itemBodyMatch[1] + nl;
|
|
24289
|
-
if (responseProcessingMatch) sections.responseProcessing = responseProcessingMatch[1] + nl;
|
|
24287
|
+
const buildXmlAdapter = (interaction, diagnostics, parts, indent, indent2, _indent3, nl) => {
|
|
24288
|
+
buildUploadInteractionXml(interaction, diagnostics, parts, indent, indent2, nl);
|
|
24289
|
+
};
|
|
24290
|
+
buildInteractionSections(buildXmlAdapter, [interaction, diagnostics], diagnostics, sections, indent, indent2, "", nl, { selfClosingResponseDecl: true });
|
|
24290
24291
|
}
|
|
24291
24292
|
/**
|
|
24292
24293
|
* Build upload interaction XML (file upload)
|
|
@@ -24325,15 +24326,7 @@ function buildUploadInteractionXml(interaction, diagnostics, parts, indent, inde
|
|
|
24325
24326
|
* Build drawingInteraction sections
|
|
24326
24327
|
*/
|
|
24327
24328
|
function buildDrawingInteractionSections(interaction, diagnostics, sections, indent, indent2, indent3, nl) {
|
|
24328
|
-
|
|
24329
|
-
buildDrawingInteractionXml(interaction, diagnostics, tempParts, indent, indent2, indent3, nl);
|
|
24330
|
-
const joined = tempParts.join("");
|
|
24331
|
-
const responseDeclMatch = joined.match(/(<responseDeclaration[\s\S]*?(?:\/>|<\/responseDeclaration>))/);
|
|
24332
|
-
const itemBodyMatch = joined.match(/(<itemBody>[\s\S]*?<\/itemBody>)/);
|
|
24333
|
-
const responseProcessingMatch = joined.match(/(<responseProcessing[\s\S]*?(?:\/>|<\/responseProcessing>))/);
|
|
24334
|
-
if (responseDeclMatch) sections.responseDeclarations.push(responseDeclMatch[1] + nl);
|
|
24335
|
-
if (itemBodyMatch) sections.itemBody = itemBodyMatch[1] + nl;
|
|
24336
|
-
if (responseProcessingMatch) sections.responseProcessing = responseProcessingMatch[1] + nl;
|
|
24329
|
+
buildInteractionSections(buildDrawingInteractionXml, [interaction, diagnostics], diagnostics, sections, indent, indent2, indent3, nl, { selfClosingResponseDecl: true });
|
|
24337
24330
|
}
|
|
24338
24331
|
/**
|
|
24339
24332
|
* Build drawingInteraction XML
|
|
@@ -24391,17 +24384,7 @@ function buildDrawingInteractionXml(interaction, diagnostics, parts, indent, ind
|
|
|
24391
24384
|
* Section-based wrapper for buildInlineChoiceInteractionXml
|
|
24392
24385
|
*/
|
|
24393
24386
|
function buildInlineChoiceInteractionSections(interaction, diagnostics, sections, indent, indent2, indent3, nl) {
|
|
24394
|
-
|
|
24395
|
-
buildInlineChoiceInteractionXml(interaction, diagnostics, tempParts, indent, indent2, indent3, nl);
|
|
24396
|
-
const joined = tempParts.join("");
|
|
24397
|
-
const responseDeclMatches = joined.matchAll(/(<responseDeclaration[\s\S]*?(?:\/>|<\/responseDeclaration>))/g);
|
|
24398
|
-
for (const match of responseDeclMatches) sections.responseDeclarations.push(match[1] + nl);
|
|
24399
|
-
const outcomeDeclMatch = joined.match(/(<outcomeDeclaration[\s\S]*?<\/outcomeDeclaration>)/);
|
|
24400
|
-
const itemBodyMatch = joined.match(/(<itemBody>[\s\S]*?<\/itemBody>)/);
|
|
24401
|
-
const responseProcMatch = joined.match(/(<responseProcessing[^>]*\/>)/);
|
|
24402
|
-
if (outcomeDeclMatch) sections.outcomeDeclarations.push(outcomeDeclMatch[1] + nl);
|
|
24403
|
-
if (itemBodyMatch) sections.itemBody = itemBodyMatch[1] + nl;
|
|
24404
|
-
if (responseProcMatch) sections.responseProcessing = responseProcMatch[1] + nl;
|
|
24387
|
+
buildInteractionSections(buildInlineChoiceInteractionXml, [interaction, diagnostics], diagnostics, sections, indent, indent2, indent3, nl, { multiResponseDeclarations: true });
|
|
24405
24388
|
}
|
|
24406
24389
|
/**
|
|
24407
24390
|
* Build inline choice interaction XML (clozedropdown)
|
|
@@ -24431,16 +24414,7 @@ function buildInlineChoiceInteractionXml(interaction, diagnostics, parts, indent
|
|
|
24431
24414
|
parts.push(nl);
|
|
24432
24415
|
}
|
|
24433
24416
|
}
|
|
24434
|
-
parts
|
|
24435
|
-
parts.push(nl);
|
|
24436
|
-
parts.push(`${indent2}<defaultValue>`);
|
|
24437
|
-
parts.push(nl);
|
|
24438
|
-
parts.push(`${indent3}<value>0</value>`);
|
|
24439
|
-
parts.push(nl);
|
|
24440
|
-
parts.push(`${indent2}</defaultValue>`);
|
|
24441
|
-
parts.push(nl);
|
|
24442
|
-
parts.push(`${indent}</outcomeDeclaration>`);
|
|
24443
|
-
parts.push(nl);
|
|
24417
|
+
pushScoreOutcomeDeclaration(parts, indent, indent2, indent3, nl);
|
|
24444
24418
|
parts.push(`${indent}<itemBody>`);
|
|
24445
24419
|
parts.push(nl);
|
|
24446
24420
|
if (interaction.prompt) {
|
|
@@ -24479,17 +24453,7 @@ function buildInlineChoiceInteractionXml(interaction, diagnostics, parts, indent
|
|
|
24479
24453
|
* Section-based wrapper for buildGapMatchInteractionXml
|
|
24480
24454
|
*/
|
|
24481
24455
|
function buildGapMatchInteractionSections(interaction, diagnostics, sections, indent, indent2, indent3, nl) {
|
|
24482
|
-
|
|
24483
|
-
buildGapMatchInteractionXml(interaction, diagnostics, tempParts, indent, indent2, indent3, nl);
|
|
24484
|
-
const joined = tempParts.join("");
|
|
24485
|
-
const responseDeclMatch = joined.match(/(<responseDeclaration[\s\S]*?<\/responseDeclaration>)/);
|
|
24486
|
-
const outcomeDeclMatch = joined.match(/(<outcomeDeclaration[\s\S]*?<\/outcomeDeclaration>)/);
|
|
24487
|
-
const itemBodyMatch = joined.match(/(<itemBody>[\s\S]*?<\/itemBody>)/);
|
|
24488
|
-
const responseProcMatch = joined.match(/(<responseProcessing[^>]*\/>)/);
|
|
24489
|
-
if (responseDeclMatch) sections.responseDeclarations.push(responseDeclMatch[1] + nl);
|
|
24490
|
-
if (outcomeDeclMatch) sections.outcomeDeclarations.push(outcomeDeclMatch[1] + nl);
|
|
24491
|
-
if (itemBodyMatch) sections.itemBody = itemBodyMatch[1] + nl;
|
|
24492
|
-
if (responseProcMatch) sections.responseProcessing = responseProcMatch[1] + nl;
|
|
24456
|
+
buildInteractionSections(buildGapMatchInteractionXml, [interaction, diagnostics], diagnostics, sections, indent, indent2, indent3, nl);
|
|
24493
24457
|
}
|
|
24494
24458
|
/**
|
|
24495
24459
|
* Build gapMatch interaction XML for clozeassociation
|
|
@@ -24523,16 +24487,7 @@ function buildGapMatchInteractionXml(interaction, diagnostics, parts, indent, in
|
|
|
24523
24487
|
parts.push(nl);
|
|
24524
24488
|
}
|
|
24525
24489
|
}
|
|
24526
|
-
parts
|
|
24527
|
-
parts.push(nl);
|
|
24528
|
-
parts.push(`${indent2}<defaultValue>`);
|
|
24529
|
-
parts.push(nl);
|
|
24530
|
-
parts.push(`${indent3}<value>0</value>`);
|
|
24531
|
-
parts.push(nl);
|
|
24532
|
-
parts.push(`${indent2}</defaultValue>`);
|
|
24533
|
-
parts.push(nl);
|
|
24534
|
-
parts.push(`${indent}</outcomeDeclaration>`);
|
|
24535
|
-
parts.push(nl);
|
|
24490
|
+
pushScoreOutcomeDeclaration(parts, indent, indent2, indent3, nl);
|
|
24536
24491
|
parts.push(`${indent}<itemBody>`);
|
|
24537
24492
|
parts.push(nl);
|
|
24538
24493
|
if (interaction.prompt) {
|
|
@@ -24579,17 +24534,7 @@ function buildGapMatchInteractionXml(interaction, diagnostics, parts, indent, in
|
|
|
24579
24534
|
* Section-based wrapper for buildOrderInteractionXml
|
|
24580
24535
|
*/
|
|
24581
24536
|
function buildOrderInteractionSections(interaction, diagnostics, sections, indent, indent2, indent3, nl) {
|
|
24582
|
-
|
|
24583
|
-
buildOrderInteractionXml(interaction, diagnostics, tempParts, indent, indent2, indent3, nl);
|
|
24584
|
-
const joined = tempParts.join("");
|
|
24585
|
-
const responseDeclMatch = joined.match(/(<responseDeclaration[\s\S]*?<\/responseDeclaration>)/);
|
|
24586
|
-
const outcomeDeclMatch = joined.match(/(<outcomeDeclaration[\s\S]*?<\/outcomeDeclaration>)/);
|
|
24587
|
-
const itemBodyMatch = joined.match(/(<itemBody>[\s\S]*?<\/itemBody>)/);
|
|
24588
|
-
const responseProcMatch = joined.match(/(<responseProcessing[^>]*\/>)/);
|
|
24589
|
-
if (responseDeclMatch) sections.responseDeclarations.push(responseDeclMatch[1] + nl);
|
|
24590
|
-
if (outcomeDeclMatch) sections.outcomeDeclarations.push(outcomeDeclMatch[1] + nl);
|
|
24591
|
-
if (itemBodyMatch) sections.itemBody = itemBodyMatch[1] + nl;
|
|
24592
|
-
if (responseProcMatch) sections.responseProcessing = responseProcMatch[1] + nl;
|
|
24537
|
+
buildInteractionSections(buildOrderInteractionXml, [interaction, diagnostics], diagnostics, sections, indent, indent2, indent3, nl);
|
|
24593
24538
|
}
|
|
24594
24539
|
/**
|
|
24595
24540
|
* Build orderInteraction XML (for single-widget items)
|
|
@@ -24622,16 +24567,7 @@ function buildOrderInteractionXml(interaction, diagnostics, parts, indent, inden
|
|
|
24622
24567
|
parts.push(`${indent}<responseDeclaration identifier="${interaction.responseIdentifier}" cardinality="ordered" baseType="identifier"/>`);
|
|
24623
24568
|
parts.push(nl);
|
|
24624
24569
|
}
|
|
24625
|
-
parts
|
|
24626
|
-
parts.push(nl);
|
|
24627
|
-
parts.push(`${indent2}<defaultValue>`);
|
|
24628
|
-
parts.push(nl);
|
|
24629
|
-
parts.push(`${indent3}<value>0</value>`);
|
|
24630
|
-
parts.push(nl);
|
|
24631
|
-
parts.push(`${indent2}</defaultValue>`);
|
|
24632
|
-
parts.push(nl);
|
|
24633
|
-
parts.push(`${indent}</outcomeDeclaration>`);
|
|
24634
|
-
parts.push(nl);
|
|
24570
|
+
pushScoreOutcomeDeclaration(parts, indent, indent2, indent3, nl);
|
|
24635
24571
|
parts.push(`${indent}<itemBody>`);
|
|
24636
24572
|
parts.push(nl);
|
|
24637
24573
|
if (interaction.prompt) {
|
|
@@ -24664,10 +24600,7 @@ function buildOrderInteractionXml(interaction, diagnostics, parts, indent, inden
|
|
|
24664
24600
|
parts.push(nl);
|
|
24665
24601
|
parts.push(`${indent}</itemBody>`);
|
|
24666
24602
|
parts.push(nl);
|
|
24667
|
-
if (interaction.correctResponse && interaction.correctResponse.length > 0)
|
|
24668
|
-
parts.push(`${indent}<responseProcessing template="http://www.imsglobal.org/question/qti_v2p2/rptemplates/match_correct"/>`);
|
|
24669
|
-
parts.push(nl);
|
|
24670
|
-
}
|
|
24603
|
+
if (interaction.correctResponse && interaction.correctResponse.length > 0) pushMatchCorrectResponseProcessing(parts, indent, nl);
|
|
24671
24604
|
}
|
|
24672
24605
|
//#endregion
|
|
24673
24606
|
//#region ../core/src/qti-serializer/interaction-builders/buildMatchInteraction.ts
|
|
@@ -24675,17 +24608,7 @@ function buildOrderInteractionXml(interaction, diagnostics, parts, indent, inden
|
|
|
24675
24608
|
* Section-based wrapper for buildMatchInteractionXml
|
|
24676
24609
|
*/
|
|
24677
24610
|
function buildMatchInteractionSections(interaction, diagnostics, sections, indent, indent2, indent3, nl) {
|
|
24678
|
-
|
|
24679
|
-
buildMatchInteractionXml(interaction, diagnostics, tempParts, indent, indent2, indent3, nl);
|
|
24680
|
-
const joined = tempParts.join("");
|
|
24681
|
-
const responseDeclMatch = joined.match(/(<responseDeclaration[\s\S]*?<\/responseDeclaration>)/);
|
|
24682
|
-
const outcomeDeclMatch = joined.match(/(<outcomeDeclaration[\s\S]*?<\/outcomeDeclaration>)/);
|
|
24683
|
-
const itemBodyMatch = joined.match(/(<itemBody>[\s\S]*?<\/itemBody>)/);
|
|
24684
|
-
const responseProcMatch = joined.match(/(<responseProcessing[^>]*\/>)/);
|
|
24685
|
-
if (responseDeclMatch) sections.responseDeclarations.push(responseDeclMatch[1] + nl);
|
|
24686
|
-
if (outcomeDeclMatch) sections.outcomeDeclarations.push(outcomeDeclMatch[1] + nl);
|
|
24687
|
-
if (itemBodyMatch) sections.itemBody = itemBodyMatch[1] + nl;
|
|
24688
|
-
if (responseProcMatch) sections.responseProcessing = responseProcMatch[1] + nl;
|
|
24611
|
+
buildInteractionSections(buildMatchInteractionXml, [interaction, diagnostics], diagnostics, sections, indent, indent2, indent3, nl);
|
|
24689
24612
|
}
|
|
24690
24613
|
/**
|
|
24691
24614
|
* Build matchInteraction XML (choicematrix)
|
|
@@ -24708,16 +24631,7 @@ function buildMatchInteractionXml(interaction, diagnostics, parts, indent, inden
|
|
|
24708
24631
|
parts.push(`${indent}<responseDeclaration identifier="${interaction.responseIdentifier}" cardinality="multiple" baseType="directedPair"/>`);
|
|
24709
24632
|
parts.push(nl);
|
|
24710
24633
|
}
|
|
24711
|
-
parts
|
|
24712
|
-
parts.push(nl);
|
|
24713
|
-
parts.push(`${indent2}<defaultValue>`);
|
|
24714
|
-
parts.push(nl);
|
|
24715
|
-
parts.push(`${indent3}<value>0</value>`);
|
|
24716
|
-
parts.push(nl);
|
|
24717
|
-
parts.push(`${indent2}</defaultValue>`);
|
|
24718
|
-
parts.push(nl);
|
|
24719
|
-
parts.push(`${indent}</outcomeDeclaration>`);
|
|
24720
|
-
parts.push(nl);
|
|
24634
|
+
pushScoreOutcomeDeclaration(parts, indent, indent2, indent3, nl);
|
|
24721
24635
|
parts.push(`${indent}<itemBody>`);
|
|
24722
24636
|
parts.push(nl);
|
|
24723
24637
|
if (interaction.prompt) {
|
|
@@ -24756,8 +24670,7 @@ function buildMatchInteractionXml(interaction, diagnostics, parts, indent, inden
|
|
|
24756
24670
|
parts.push(nl);
|
|
24757
24671
|
parts.push(`${indent}</itemBody>`);
|
|
24758
24672
|
parts.push(nl);
|
|
24759
|
-
parts
|
|
24760
|
-
parts.push(nl);
|
|
24673
|
+
pushMatchCorrectResponseProcessing(parts, indent, nl);
|
|
24761
24674
|
}
|
|
24762
24675
|
//#endregion
|
|
24763
24676
|
//#region ../core/src/qti-serializer/interaction-builders/buildHottextInteraction.ts
|
|
@@ -24765,15 +24678,7 @@ function buildMatchInteractionXml(interaction, diagnostics, parts, indent, inden
|
|
|
24765
24678
|
* Build hottext interaction sections (tokenhighlight)
|
|
24766
24679
|
*/
|
|
24767
24680
|
function buildHottextInteractionSections(interaction, diagnostics, sections, indent, indent2, indent3, nl) {
|
|
24768
|
-
|
|
24769
|
-
buildHottextInteractionXml(interaction, diagnostics, tempParts, indent, indent2, indent3, nl);
|
|
24770
|
-
const joined = tempParts.join("");
|
|
24771
|
-
const responseDeclMatch = joined.match(/(<responseDeclaration[\s\S]*?<\/responseDeclaration>)/);
|
|
24772
|
-
const itemBodyMatch = joined.match(/(<itemBody>[\s\S]*?<\/itemBody>)/);
|
|
24773
|
-
const responseProcMatch = joined.match(/(<responseProcessing[^>]*\/>)/);
|
|
24774
|
-
if (responseDeclMatch) sections.responseDeclarations.push(responseDeclMatch[1] + nl);
|
|
24775
|
-
if (itemBodyMatch) sections.itemBody = itemBodyMatch[1] + nl;
|
|
24776
|
-
if (responseProcMatch) sections.responseProcessing = responseProcMatch[1] + nl;
|
|
24681
|
+
buildInteractionSections(buildHottextInteractionXml, [interaction, diagnostics], diagnostics, sections, indent, indent2, indent3, nl);
|
|
24777
24682
|
}
|
|
24778
24683
|
/**
|
|
24779
24684
|
* Build hottext interaction XML (tokenhighlight)
|
|
@@ -24828,10 +24733,7 @@ function buildHottextInteractionXml(interaction, diagnostics, parts, indent, ind
|
|
|
24828
24733
|
parts.push(nl);
|
|
24829
24734
|
parts.push(`${indent}</itemBody>`);
|
|
24830
24735
|
parts.push(nl);
|
|
24831
|
-
if (interaction.correctResponse && interaction.correctResponse.length > 0)
|
|
24832
|
-
parts.push(`${indent}<responseProcessing template="http://www.imsglobal.org/question/qti_v2p2/rptemplates/match_correct"/>`);
|
|
24833
|
-
parts.push(nl);
|
|
24834
|
-
}
|
|
24736
|
+
if (interaction.correctResponse && interaction.correctResponse.length > 0) pushMatchCorrectResponseProcessing(parts, indent, nl);
|
|
24835
24737
|
}
|
|
24836
24738
|
//#endregion
|
|
24837
24739
|
//#region ../core/src/qti-serializer/interaction-builders/buildHotspotInteraction.ts
|
|
@@ -24839,15 +24741,7 @@ function buildHottextInteractionXml(interaction, diagnostics, parts, indent, ind
|
|
|
24839
24741
|
* Build hotspotInteraction sections
|
|
24840
24742
|
*/
|
|
24841
24743
|
function buildHotspotInteractionSections(interaction, diagnostics, sections, indent, indent2, indent3, nl) {
|
|
24842
|
-
|
|
24843
|
-
buildHotspotInteractionXml(interaction, diagnostics, tempParts, indent, indent2, indent3, nl);
|
|
24844
|
-
const joined = tempParts.join("");
|
|
24845
|
-
const responseDeclMatch = joined.match(/(<responseDeclaration[\s\S]*?<\/responseDeclaration>)/);
|
|
24846
|
-
const itemBodyMatch = joined.match(/(<itemBody>[\s\S]*?<\/itemBody>)/);
|
|
24847
|
-
const responseProcMatch = joined.match(/(<responseProcessing[^>]*\/>)/);
|
|
24848
|
-
if (responseDeclMatch) sections.responseDeclarations.push(responseDeclMatch[1] + nl);
|
|
24849
|
-
if (itemBodyMatch) sections.itemBody = itemBodyMatch[1] + nl;
|
|
24850
|
-
if (responseProcMatch) sections.responseProcessing = responseProcMatch[1] + nl;
|
|
24744
|
+
buildInteractionSections(buildHotspotInteractionXml, [interaction, diagnostics], diagnostics, sections, indent, indent2, indent3, nl, { selfClosingResponseDecl: true });
|
|
24851
24745
|
}
|
|
24852
24746
|
/**
|
|
24853
24747
|
* Build hotspotInteraction XML
|
|
@@ -24894,10 +24788,7 @@ function buildHotspotInteractionXml(interaction, _diagnostics, parts, indent, in
|
|
|
24894
24788
|
parts.push(nl);
|
|
24895
24789
|
parts.push(`${indent}</itemBody>`);
|
|
24896
24790
|
parts.push(nl);
|
|
24897
|
-
if (interaction.correctResponse && interaction.correctResponse.length > 0)
|
|
24898
|
-
parts.push(`${indent}<responseProcessing template="http://www.imsglobal.org/question/qti_v2p2/rptemplates/match_correct"/>`);
|
|
24899
|
-
parts.push(nl);
|
|
24900
|
-
}
|
|
24791
|
+
if (interaction.correctResponse && interaction.correctResponse.length > 0) pushMatchCorrectResponseProcessing(parts, indent, nl);
|
|
24901
24792
|
}
|
|
24902
24793
|
//#endregion
|
|
24903
24794
|
//#region ../core/src/qti-serializer/interaction-builders/buildGraphicGapMatchInteraction.ts
|
|
@@ -24905,15 +24796,7 @@ function buildHotspotInteractionXml(interaction, _diagnostics, parts, indent, in
|
|
|
24905
24796
|
* Build graphicGapMatchInteraction sections
|
|
24906
24797
|
*/
|
|
24907
24798
|
function buildGraphicGapMatchInteractionSections(interaction, diagnostics, sections, indent, indent2, indent3, nl) {
|
|
24908
|
-
|
|
24909
|
-
buildGraphicGapMatchInteractionXml(interaction, diagnostics, tempParts, indent, indent2, indent3, nl);
|
|
24910
|
-
const joined = tempParts.join("");
|
|
24911
|
-
const responseDeclMatch = joined.match(/(<responseDeclaration[\s\S]*?<\/responseDeclaration>)/);
|
|
24912
|
-
const itemBodyMatch = joined.match(/(<itemBody>[\s\S]*?<\/itemBody>)/);
|
|
24913
|
-
const responseProcMatch = joined.match(/(<responseProcessing[^>]*\/>)/);
|
|
24914
|
-
if (responseDeclMatch) sections.responseDeclarations.push(responseDeclMatch[1] + nl);
|
|
24915
|
-
if (itemBodyMatch) sections.itemBody = itemBodyMatch[1] + nl;
|
|
24916
|
-
if (responseProcMatch) sections.responseProcessing = responseProcMatch[1] + nl;
|
|
24799
|
+
buildInteractionSections(buildGraphicGapMatchInteractionXml, [interaction, diagnostics], diagnostics, sections, indent, indent2, indent3, nl, { selfClosingResponseDecl: true });
|
|
24917
24800
|
}
|
|
24918
24801
|
/**
|
|
24919
24802
|
* Build graphicGapMatchInteraction XML (imageclozeassociationV2)
|
|
@@ -24992,17 +24875,7 @@ function buildGraphicGapMatchInteractionXml(interaction, diagnostics, parts, ind
|
|
|
24992
24875
|
* Section-based wrapper for buildAssociateInteractionXml
|
|
24993
24876
|
*/
|
|
24994
24877
|
function buildAssociateInteractionSections(interaction, diagnostics, sections, indent, indent2, indent3, nl) {
|
|
24995
|
-
|
|
24996
|
-
buildAssociateInteractionXml(interaction, diagnostics, tempParts, indent, indent2, indent3, nl);
|
|
24997
|
-
const joined = tempParts.join("");
|
|
24998
|
-
const responseDeclMatch = joined.match(/(<responseDeclaration[\s\S]*?<\/responseDeclaration>)/);
|
|
24999
|
-
const outcomeDeclMatch = joined.match(/(<outcomeDeclaration[\s\S]*?<\/outcomeDeclaration>)/);
|
|
25000
|
-
const itemBodyMatch = joined.match(/(<itemBody>[\s\S]*?<\/itemBody>)/);
|
|
25001
|
-
const responseProcMatch = joined.match(/(<responseProcessing[^>]*\/>)/);
|
|
25002
|
-
if (responseDeclMatch) sections.responseDeclarations.push(responseDeclMatch[1] + nl);
|
|
25003
|
-
if (outcomeDeclMatch) sections.outcomeDeclarations.push(outcomeDeclMatch[1] + nl);
|
|
25004
|
-
if (itemBodyMatch) sections.itemBody = itemBodyMatch[1] + nl;
|
|
25005
|
-
if (responseProcMatch) sections.responseProcessing = responseProcMatch[1] + nl;
|
|
24878
|
+
buildInteractionSections(buildAssociateInteractionXml, [interaction, diagnostics], diagnostics, sections, indent, indent2, indent3, nl);
|
|
25006
24879
|
}
|
|
25007
24880
|
/**
|
|
25008
24881
|
* Build associateInteraction XML (for single-widget items, classification)
|
|
@@ -25025,16 +24898,7 @@ function buildAssociateInteractionXml(interaction, diagnostics, parts, indent, i
|
|
|
25025
24898
|
parts.push(`${indent}<responseDeclaration identifier="${interaction.responseIdentifier}" cardinality="multiple" baseType="pair"/>`);
|
|
25026
24899
|
parts.push(nl);
|
|
25027
24900
|
}
|
|
25028
|
-
parts
|
|
25029
|
-
parts.push(nl);
|
|
25030
|
-
parts.push(`${indent2}<defaultValue>`);
|
|
25031
|
-
parts.push(nl);
|
|
25032
|
-
parts.push(`${indent3}<value>0</value>`);
|
|
25033
|
-
parts.push(nl);
|
|
25034
|
-
parts.push(`${indent2}</defaultValue>`);
|
|
25035
|
-
parts.push(nl);
|
|
25036
|
-
parts.push(`${indent}</outcomeDeclaration>`);
|
|
25037
|
-
parts.push(nl);
|
|
24901
|
+
pushScoreOutcomeDeclaration(parts, indent, indent2, indent3, nl);
|
|
25038
24902
|
parts.push(`${indent}<itemBody>`);
|
|
25039
24903
|
parts.push(nl);
|
|
25040
24904
|
if (interaction.prompt) {
|
|
@@ -25063,10 +24927,7 @@ function buildAssociateInteractionXml(interaction, diagnostics, parts, indent, i
|
|
|
25063
24927
|
parts.push(nl);
|
|
25064
24928
|
parts.push(`${indent}</itemBody>`);
|
|
25065
24929
|
parts.push(nl);
|
|
25066
|
-
if (interaction.correctResponse && interaction.correctResponse.length > 0)
|
|
25067
|
-
parts.push(`${indent}<responseProcessing template="http://www.imsglobal.org/question/qti_v2p2/rptemplates/match_correct"/>`);
|
|
25068
|
-
parts.push(nl);
|
|
25069
|
-
}
|
|
24930
|
+
if (interaction.correctResponse && interaction.correctResponse.length > 0) pushMatchCorrectResponseProcessing(parts, indent, nl);
|
|
25070
24931
|
}
|
|
25071
24932
|
//#endregion
|
|
25072
24933
|
//#region ../core/src/qti-serializer/serializeAssessmentItem.ts
|
|
@@ -31794,104 +31655,267 @@ function convertGraphicGapMatchToLearnosity(inputXml, diagnostics, _lomTags, org
|
|
|
31794
31655
|
};
|
|
31795
31656
|
}
|
|
31796
31657
|
//#endregion
|
|
31797
|
-
//#region ../core/src/qti-parser/
|
|
31658
|
+
//#region ../core/src/qti-parser/createAssessmentItemReader.ts
|
|
31798
31659
|
/**
|
|
31799
|
-
*
|
|
31660
|
+
* Shared SAX streaming scaffold for QTI assessmentItem readers.
|
|
31661
|
+
*
|
|
31662
|
+
* Every `readAssessmentItemXxx` parser repeats the same ~40 lines of boilerplate:
|
|
31663
|
+
* - Create a SaxesParser
|
|
31664
|
+
* - Handle assessmentItem opentag (extract identifier, title)
|
|
31665
|
+
* - Handle responseDeclaration + correctResponse + value extraction
|
|
31666
|
+
* - Handle itemBody detection
|
|
31667
|
+
* - text/cdata capture dispatch
|
|
31668
|
+
* - try/catch error handling with diagnostics
|
|
31669
|
+
* - Post-parse validations (foundAssessmentItem, foundItemBody, interaction count)
|
|
31670
|
+
*
|
|
31671
|
+
* This utility extracts the shared envelope, leaving each parser to focus only
|
|
31672
|
+
* on its interaction-specific logic.
|
|
31800
31673
|
*/
|
|
31801
|
-
|
|
31802
|
-
|
|
31803
|
-
|
|
31804
|
-
|
|
31805
|
-
|
|
31806
|
-
|
|
31807
|
-
|
|
31808
|
-
|
|
31809
|
-
|
|
31810
|
-
|
|
31811
|
-
|
|
31812
|
-
|
|
31813
|
-
|
|
31814
|
-
|
|
31815
|
-
|
|
31816
|
-
|
|
31817
|
-
|
|
31818
|
-
|
|
31819
|
-
|
|
31820
|
-
|
|
31821
|
-
|
|
31822
|
-
|
|
31823
|
-
|
|
31824
|
-
|
|
31825
|
-
|
|
31826
|
-
|
|
31827
|
-
|
|
31828
|
-
|
|
31674
|
+
/**
|
|
31675
|
+
* Create an assessmentItem reader with the shared envelope handled automatically.
|
|
31676
|
+
*
|
|
31677
|
+
* The returned function accepts XML input and returns the typed result, with all
|
|
31678
|
+
* the common scaffolding (parser creation, assessmentItem/responseDeclaration/itemBody
|
|
31679
|
+
* handling, error handling, validations) done for you.
|
|
31680
|
+
*
|
|
31681
|
+
* @example
|
|
31682
|
+
* ```ts
|
|
31683
|
+
* export const readAssessmentItemDrawing = createAssessmentItemReader<ReadDrawingResult>({
|
|
31684
|
+
* interactionName: 'drawingInteraction',
|
|
31685
|
+
* createResult: (diagnostics) => ({ diagnostics, ... }),
|
|
31686
|
+
* onInteractionOpen: (tag, result, ctx) => { ... },
|
|
31687
|
+
* });
|
|
31688
|
+
* ```
|
|
31689
|
+
*/
|
|
31690
|
+
function createAssessmentItemReader(hooks) {
|
|
31691
|
+
return (inputXml) => {
|
|
31692
|
+
const diagnostics = [];
|
|
31693
|
+
const result = hooks.createResult(diagnostics);
|
|
31694
|
+
const parser = new import_saxes.SaxesParser(hooks.parserOptions);
|
|
31695
|
+
const buffers = /* @__PURE__ */ new Map();
|
|
31696
|
+
let foundAssessmentItem = false;
|
|
31697
|
+
let foundItemBody = false;
|
|
31698
|
+
let inItemBody = false;
|
|
31699
|
+
let inInteraction = false;
|
|
31700
|
+
let interactionCount = 0;
|
|
31701
|
+
let currentResponseDeclId;
|
|
31702
|
+
let inCorrectResponse = false;
|
|
31703
|
+
const correctResponsesByIdentifier = /* @__PURE__ */ new Map();
|
|
31704
|
+
const correctValueBuf = [];
|
|
31705
|
+
const ctx = {
|
|
31706
|
+
get capture() {
|
|
31707
|
+
return _capture;
|
|
31708
|
+
},
|
|
31709
|
+
set capture(val) {
|
|
31710
|
+
_capture = val;
|
|
31711
|
+
},
|
|
31712
|
+
get inItemBody() {
|
|
31713
|
+
return inItemBody;
|
|
31714
|
+
},
|
|
31715
|
+
diagnostics,
|
|
31716
|
+
correctResponsesByIdentifier,
|
|
31717
|
+
get currentResponseDeclId() {
|
|
31718
|
+
return currentResponseDeclId;
|
|
31719
|
+
},
|
|
31720
|
+
getAttr: getAttr$3,
|
|
31721
|
+
normalizeWhitespace,
|
|
31722
|
+
pushToBuffer(name, text) {
|
|
31723
|
+
if (!buffers.has(name)) buffers.set(name, []);
|
|
31724
|
+
buffers.get(name).push(text);
|
|
31725
|
+
},
|
|
31726
|
+
flushBuffer(name) {
|
|
31727
|
+
const buf = buffers.get(name);
|
|
31728
|
+
if (!buf) return "";
|
|
31729
|
+
const result = normalizeWhitespace(buf.join(""));
|
|
31730
|
+
buf.length = 0;
|
|
31731
|
+
return result;
|
|
31732
|
+
},
|
|
31733
|
+
peekBuffer(name) {
|
|
31734
|
+
const buf = buffers.get(name);
|
|
31735
|
+
return buf ? buf.join("") : "";
|
|
31736
|
+
},
|
|
31737
|
+
clearBuffer(name) {
|
|
31738
|
+
const buf = buffers.get(name);
|
|
31739
|
+
if (buf) buf.length = 0;
|
|
31829
31740
|
}
|
|
31830
|
-
}
|
|
31831
|
-
|
|
31832
|
-
|
|
31833
|
-
|
|
31834
|
-
|
|
31835
|
-
|
|
31836
|
-
|
|
31837
|
-
|
|
31838
|
-
|
|
31839
|
-
|
|
31840
|
-
|
|
31841
|
-
|
|
31842
|
-
|
|
31843
|
-
|
|
31844
|
-
|
|
31845
|
-
|
|
31846
|
-
|
|
31847
|
-
|
|
31741
|
+
};
|
|
31742
|
+
let _capture = null;
|
|
31743
|
+
parser.on("opentag", (tag) => {
|
|
31744
|
+
const localName = tag.local ?? tag.name;
|
|
31745
|
+
if (localName === "assessmentItem") {
|
|
31746
|
+
foundAssessmentItem = true;
|
|
31747
|
+
result.identifier = getAttr$3(tag, "identifier");
|
|
31748
|
+
result.title = getAttr$3(tag, "title") ?? null;
|
|
31749
|
+
return;
|
|
31750
|
+
}
|
|
31751
|
+
if (localName === "itemBody") {
|
|
31752
|
+
foundItemBody = true;
|
|
31753
|
+
inItemBody = true;
|
|
31754
|
+
return;
|
|
31755
|
+
}
|
|
31756
|
+
if (localName === hooks.interactionName) {
|
|
31757
|
+
interactionCount++;
|
|
31758
|
+
inInteraction = true;
|
|
31759
|
+
hooks.onInteractionOpen(tag, result, ctx);
|
|
31760
|
+
return;
|
|
31761
|
+
}
|
|
31762
|
+
if (localName === "responseDeclaration") {
|
|
31763
|
+
const identifier = getAttr$3(tag, "identifier");
|
|
31764
|
+
if (identifier) {
|
|
31765
|
+
currentResponseDeclId = identifier;
|
|
31766
|
+
correctResponsesByIdentifier.set(identifier, []);
|
|
31767
|
+
}
|
|
31768
|
+
return;
|
|
31769
|
+
}
|
|
31770
|
+
if (localName === "correctResponse") {
|
|
31771
|
+
inCorrectResponse = true;
|
|
31772
|
+
correctValueBuf.length = 0;
|
|
31773
|
+
return;
|
|
31774
|
+
}
|
|
31775
|
+
if (localName === "value" && inCorrectResponse) {
|
|
31776
|
+
correctValueBuf.length = 0;
|
|
31777
|
+
return;
|
|
31778
|
+
}
|
|
31779
|
+
const location = inInteraction ? "in-interaction" : inItemBody ? "pre-interaction" : "post-interaction";
|
|
31780
|
+
hooks.onOpenTag?.(localName, tag, result, ctx, location);
|
|
31781
|
+
});
|
|
31782
|
+
parser.on("closetag", (tag) => {
|
|
31783
|
+
const localName = tag.local ?? tag.name;
|
|
31784
|
+
if (localName === "itemBody") {
|
|
31785
|
+
inItemBody = false;
|
|
31786
|
+
return;
|
|
31787
|
+
}
|
|
31788
|
+
if (localName === hooks.interactionName) {
|
|
31789
|
+
inInteraction = false;
|
|
31790
|
+
hooks.onInteractionClose?.(result, ctx);
|
|
31791
|
+
return;
|
|
31792
|
+
}
|
|
31793
|
+
if (localName === "responseDeclaration") {
|
|
31794
|
+
currentResponseDeclId = void 0;
|
|
31795
|
+
return;
|
|
31796
|
+
}
|
|
31797
|
+
if (localName === "correctResponse") {
|
|
31798
|
+
inCorrectResponse = false;
|
|
31799
|
+
return;
|
|
31800
|
+
}
|
|
31801
|
+
if (localName === "value" && inCorrectResponse) {
|
|
31802
|
+
const value = normalizeWhitespace(correctValueBuf.join(""));
|
|
31803
|
+
if (value && currentResponseDeclId) {
|
|
31804
|
+
const values = correctResponsesByIdentifier.get(currentResponseDeclId);
|
|
31805
|
+
if (values) values.push(value);
|
|
31806
|
+
}
|
|
31807
|
+
correctValueBuf.length = 0;
|
|
31808
|
+
return;
|
|
31809
|
+
}
|
|
31810
|
+
const location = inInteraction ? "in-interaction" : inItemBody ? "pre-interaction" : "post-interaction";
|
|
31811
|
+
hooks.onCloseTag?.(localName, tag, result, ctx, location);
|
|
31812
|
+
});
|
|
31813
|
+
parser.on("text", (text) => {
|
|
31814
|
+
if (inCorrectResponse) {
|
|
31815
|
+
correctValueBuf.push(text);
|
|
31816
|
+
return;
|
|
31817
|
+
}
|
|
31818
|
+
if (_capture) ctx.pushToBuffer(_capture, text);
|
|
31819
|
+
});
|
|
31820
|
+
parser.on("cdata", (text) => {
|
|
31821
|
+
if (inCorrectResponse) {
|
|
31822
|
+
correctValueBuf.push(text);
|
|
31823
|
+
return;
|
|
31824
|
+
}
|
|
31825
|
+
if (_capture) ctx.pushToBuffer(_capture, text);
|
|
31826
|
+
});
|
|
31827
|
+
parser.on("error", (error) => {
|
|
31828
|
+
diagnostics.push({
|
|
31829
|
+
code: DiagnosticCode.LRN_SCHEMA_INVALID,
|
|
31830
|
+
level: "error",
|
|
31831
|
+
file: "assessmentItem",
|
|
31832
|
+
message: `Failed to parse QTI XML: ${error.message}`
|
|
31833
|
+
});
|
|
31834
|
+
});
|
|
31835
|
+
try {
|
|
31836
|
+
parser.write(inputXml).close();
|
|
31837
|
+
} catch (error) {
|
|
31838
|
+
diagnostics.push({
|
|
31839
|
+
code: DiagnosticCode.LRN_SCHEMA_INVALID,
|
|
31840
|
+
level: "error",
|
|
31841
|
+
file: "assessmentItem",
|
|
31842
|
+
message: `Failed to parse QTI XML: ${error instanceof Error ? error.message : String(error)}`
|
|
31843
|
+
});
|
|
31844
|
+
return result;
|
|
31848
31845
|
}
|
|
31849
|
-
|
|
31850
|
-
|
|
31851
|
-
if (capture === "stimulus") stimulusBuf.push(text);
|
|
31852
|
-
else if (capture === "prompt") promptBuf.push(text);
|
|
31853
|
-
});
|
|
31854
|
-
parser.on("cdata", (text) => {
|
|
31855
|
-
if (capture === "stimulus") stimulusBuf.push(text);
|
|
31856
|
-
else if (capture === "prompt") promptBuf.push(text);
|
|
31857
|
-
});
|
|
31858
|
-
try {
|
|
31859
|
-
parser.write(inputXml).close();
|
|
31860
|
-
} catch (error) {
|
|
31861
|
-
diagnostics.push({
|
|
31846
|
+
hooks.onParseComplete?.(result, ctx);
|
|
31847
|
+
if (!foundAssessmentItem) diagnostics.push({
|
|
31862
31848
|
code: DiagnosticCode.LRN_SCHEMA_INVALID,
|
|
31863
31849
|
level: "error",
|
|
31864
31850
|
file: "assessmentItem",
|
|
31865
|
-
message:
|
|
31851
|
+
message: "No assessmentItem element found"
|
|
31866
31852
|
});
|
|
31867
|
-
|
|
31868
|
-
|
|
31869
|
-
|
|
31870
|
-
|
|
31871
|
-
|
|
31872
|
-
|
|
31873
|
-
|
|
31874
|
-
|
|
31875
|
-
|
|
31876
|
-
|
|
31877
|
-
|
|
31878
|
-
|
|
31879
|
-
|
|
31880
|
-
|
|
31881
|
-
|
|
31882
|
-
|
|
31883
|
-
|
|
31884
|
-
|
|
31885
|
-
|
|
31886
|
-
|
|
31887
|
-
|
|
31888
|
-
level: "error",
|
|
31889
|
-
file: "assessmentItem.itemBody",
|
|
31890
|
-
message: `Multiple drawingInteraction elements found (${drawingInteractionCount}), only single interaction supported`
|
|
31891
|
-
});
|
|
31892
|
-
return result;
|
|
31853
|
+
if (!foundItemBody) diagnostics.push({
|
|
31854
|
+
code: DiagnosticCode.LRN_SCHEMA_INVALID,
|
|
31855
|
+
level: "error",
|
|
31856
|
+
file: "assessmentItem",
|
|
31857
|
+
message: "No itemBody element found"
|
|
31858
|
+
});
|
|
31859
|
+
if (foundItemBody && interactionCount === 0) diagnostics.push({
|
|
31860
|
+
code: DiagnosticCode.QTI_UNSUPPORTED_INTERACTION,
|
|
31861
|
+
level: "error",
|
|
31862
|
+
file: "assessmentItem.itemBody",
|
|
31863
|
+
message: `No ${hooks.interactionName} found in itemBody`
|
|
31864
|
+
});
|
|
31865
|
+
if (interactionCount > 1) diagnostics.push({
|
|
31866
|
+
code: DiagnosticCode.QTI_MULTIPLE_INTERACTIONS,
|
|
31867
|
+
level: "error",
|
|
31868
|
+
file: "assessmentItem.itemBody",
|
|
31869
|
+
message: `Multiple ${hooks.interactionName} elements found (${interactionCount}), only single interaction supported`
|
|
31870
|
+
});
|
|
31871
|
+
hooks.validate?.(result, ctx, interactionCount);
|
|
31872
|
+
return result;
|
|
31873
|
+
};
|
|
31893
31874
|
}
|
|
31894
31875
|
//#endregion
|
|
31876
|
+
//#region ../core/src/qti-parser/readAssessmentItemDrawing.ts
|
|
31877
|
+
const readAssessmentItemDrawing = createAssessmentItemReader({
|
|
31878
|
+
interactionName: "drawingInteraction",
|
|
31879
|
+
createResult: (diagnostics) => ({ diagnostics }),
|
|
31880
|
+
onInteractionOpen: (tag, result, ctx) => {
|
|
31881
|
+
result.responseIdentifier = ctx.getAttr(tag, "responseIdentifier");
|
|
31882
|
+
if (ctx.capture === "stimulus") {
|
|
31883
|
+
result.stimulusText = ctx.flushBuffer("stimulus");
|
|
31884
|
+
ctx.capture = null;
|
|
31885
|
+
}
|
|
31886
|
+
},
|
|
31887
|
+
onOpenTag: (localName, tag, result, ctx, location) => {
|
|
31888
|
+
if (location === "pre-interaction") {
|
|
31889
|
+
if (!ctx.capture) {
|
|
31890
|
+
ctx.capture = "stimulus";
|
|
31891
|
+
ctx.clearBuffer("stimulus");
|
|
31892
|
+
}
|
|
31893
|
+
} else if (location === "in-interaction") {
|
|
31894
|
+
if (localName === "prompt") {
|
|
31895
|
+
ctx.capture = "prompt";
|
|
31896
|
+
ctx.clearBuffer("prompt");
|
|
31897
|
+
return true;
|
|
31898
|
+
}
|
|
31899
|
+
if (localName === "img") {
|
|
31900
|
+
result.imageSource = ctx.getAttr(tag, "src");
|
|
31901
|
+
result.imageAlt = ctx.getAttr(tag, "alt");
|
|
31902
|
+
const widthAttr = ctx.getAttr(tag, "width");
|
|
31903
|
+
const heightAttr = ctx.getAttr(tag, "height");
|
|
31904
|
+
if (widthAttr) result.imageWidth = parseInt(widthAttr, 10);
|
|
31905
|
+
if (heightAttr) result.imageHeight = parseInt(heightAttr, 10);
|
|
31906
|
+
return true;
|
|
31907
|
+
}
|
|
31908
|
+
}
|
|
31909
|
+
},
|
|
31910
|
+
onCloseTag: (localName, _tag, result, ctx, location) => {
|
|
31911
|
+
if (location === "in-interaction" && localName === "prompt" && ctx.capture === "prompt") {
|
|
31912
|
+
result.promptText = ctx.flushBuffer("prompt");
|
|
31913
|
+
ctx.capture = null;
|
|
31914
|
+
return true;
|
|
31915
|
+
}
|
|
31916
|
+
}
|
|
31917
|
+
});
|
|
31918
|
+
//#endregion
|
|
31895
31919
|
//#region ../core/src/qti-to-learnosity/convertDrawingToLearnosity.ts
|
|
31896
31920
|
/**
|
|
31897
31921
|
* Build drawing stimulus from parsed QTI data
|
|
@@ -33366,14 +33390,6 @@ function parseMetadataTags(metadataXml, options = {}) {
|
|
|
33366
33390
|
}
|
|
33367
33391
|
//#endregion
|
|
33368
33392
|
//#region ../core/src/qti-parser/readAssessmentItemUpload.ts
|
|
33369
|
-
/**
|
|
33370
|
-
* Read QTI uploadInteraction using a streaming parser.
|
|
33371
|
-
*
|
|
33372
|
-
* The Learnosity -> QTI serializer carries the fileupload allow-list on the
|
|
33373
|
-
* interaction's `class` attribute as `lrn-allow-<suffix>` tokens and the file
|
|
33374
|
-
* limit as `maxChoices` (QTI has no standard field for either). This reader
|
|
33375
|
-
* recovers both, plus the stimulus HTML, so a fileupload item round-trips.
|
|
33376
|
-
*/
|
|
33377
33393
|
/** Parse `lrn-allow-<suffix>` tokens from a class attribute into allow_* suffixes. */
|
|
33378
33394
|
function parseAllowedFileTypes(classAttr) {
|
|
33379
33395
|
if (!classAttr) return [];
|
|
@@ -33391,69 +33407,29 @@ function extractStimulus(inputXml) {
|
|
|
33391
33407
|
const stimulus = itemBodyMatch[1].replace(/<uploadInteraction[\s\S]*?(?:\/>|<\/uploadInteraction>)/gi, "").trim();
|
|
33392
33408
|
return stimulus.length > 0 ? stimulus : void 0;
|
|
33393
33409
|
}
|
|
33394
|
-
|
|
33395
|
-
|
|
33396
|
-
|
|
33410
|
+
const _baseReader = createAssessmentItemReader({
|
|
33411
|
+
interactionName: "uploadInteraction",
|
|
33412
|
+
createResult: (diagnostics) => ({
|
|
33397
33413
|
allowedFileTypes: [],
|
|
33398
33414
|
diagnostics
|
|
33399
|
-
}
|
|
33400
|
-
|
|
33401
|
-
|
|
33402
|
-
|
|
33403
|
-
|
|
33404
|
-
|
|
33405
|
-
|
|
33406
|
-
|
|
33407
|
-
foundAssessmentItem = true;
|
|
33408
|
-
result.identifier = getAttr$3(tag, "identifier");
|
|
33409
|
-
result.title = getAttr$3(tag, "title") ?? null;
|
|
33410
|
-
} else if (localName === "itemBody") foundItemBody = true;
|
|
33411
|
-
else if (localName === "uploadInteraction") {
|
|
33412
|
-
uploadInteractionCount++;
|
|
33413
|
-
result.responseIdentifier = getAttr$3(tag, "responseIdentifier");
|
|
33414
|
-
result.allowedFileTypes = parseAllowedFileTypes(getAttr$3(tag, "class"));
|
|
33415
|
-
const maxChoices = getAttr$3(tag, "maxChoices");
|
|
33416
|
-
if (maxChoices) {
|
|
33417
|
-
const parsed = parseInt(maxChoices, 10);
|
|
33418
|
-
if (!Number.isNaN(parsed)) result.maxFiles = parsed;
|
|
33419
|
-
}
|
|
33415
|
+
}),
|
|
33416
|
+
onInteractionOpen: (tag, result, ctx) => {
|
|
33417
|
+
result.responseIdentifier = ctx.getAttr(tag, "responseIdentifier");
|
|
33418
|
+
result.allowedFileTypes = parseAllowedFileTypes(getAttr$3(tag, "class"));
|
|
33419
|
+
const maxChoices = ctx.getAttr(tag, "maxChoices");
|
|
33420
|
+
if (maxChoices) {
|
|
33421
|
+
const parsed = parseInt(maxChoices, 10);
|
|
33422
|
+
if (!Number.isNaN(parsed)) result.maxFiles = parsed;
|
|
33420
33423
|
}
|
|
33421
|
-
});
|
|
33422
|
-
try {
|
|
33423
|
-
parser.write(inputXml).close();
|
|
33424
|
-
} catch (error) {
|
|
33425
|
-
diagnostics.push({
|
|
33426
|
-
code: DiagnosticCode.LRN_SCHEMA_INVALID,
|
|
33427
|
-
level: "error",
|
|
33428
|
-
file: "assessmentItem",
|
|
33429
|
-
message: `Failed to parse QTI XML: ${error instanceof Error ? error.message : String(error)}`
|
|
33430
|
-
});
|
|
33431
33424
|
}
|
|
33432
|
-
|
|
33433
|
-
|
|
33434
|
-
|
|
33435
|
-
|
|
33436
|
-
|
|
33437
|
-
|
|
33438
|
-
|
|
33439
|
-
|
|
33440
|
-
level: "error",
|
|
33441
|
-
file: "assessmentItem",
|
|
33442
|
-
message: "No itemBody element found"
|
|
33443
|
-
});
|
|
33444
|
-
if (foundItemBody && uploadInteractionCount === 0) diagnostics.push({
|
|
33445
|
-
code: DiagnosticCode.QTI_UNSUPPORTED_INTERACTION,
|
|
33446
|
-
level: "error",
|
|
33447
|
-
file: "assessmentItem.itemBody",
|
|
33448
|
-
message: "No uploadInteraction found in itemBody"
|
|
33449
|
-
});
|
|
33450
|
-
if (uploadInteractionCount > 1) diagnostics.push({
|
|
33451
|
-
code: DiagnosticCode.QTI_MULTIPLE_INTERACTIONS,
|
|
33452
|
-
level: "error",
|
|
33453
|
-
file: "assessmentItem.itemBody",
|
|
33454
|
-
message: `Multiple uploadInteraction elements found (${uploadInteractionCount}), only single interaction supported`
|
|
33455
|
-
});
|
|
33456
|
-
if (diagnostics.every((d) => d.level !== "error")) result.stimulus = extractStimulus(inputXml);
|
|
33425
|
+
});
|
|
33426
|
+
/**
|
|
33427
|
+
* Read uploadInteraction data from QTI assessmentItem XML.
|
|
33428
|
+
* Wraps the base reader to add post-parse stimulus extraction from raw XML.
|
|
33429
|
+
*/
|
|
33430
|
+
function readAssessmentItemUpload(inputXml) {
|
|
33431
|
+
const result = _baseReader(inputXml);
|
|
33432
|
+
if (result.diagnostics.every((d) => d.level !== "error")) result.stimulus = extractStimulus(inputXml);
|
|
33457
33433
|
return result;
|
|
33458
33434
|
}
|
|
33459
33435
|
//#endregion
|