@learnosity/lib-qti-converter 0.12.0 → 0.12.2
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 +9 -3
- package/docs/GETTING_STARTED.md +10 -4
- package/docs/TAGS_TO_QTI_METADATA.md +291 -0
- package/docs/_sidebar.md +10 -9
- package/package.json +7 -7
- package/packages/cli/dist/batchProcessors-BfmvnTQ5.js +215 -0
- package/packages/cli/dist/batchProcessors-BfmvnTQ5.js.map +1 -0
- package/packages/cli/dist/batchWorker.js +1 -1
- package/packages/cli/dist/configOutput-FwkFyQmk.js +399 -0
- package/packages/cli/dist/configOutput-FwkFyQmk.js.map +1 -0
- package/packages/cli/dist/create-prompt-COXnAzFl.js +1387 -0
- package/packages/cli/dist/create-prompt-COXnAzFl.js.map +1 -0
- package/packages/cli/dist/dist-CVD-X-DZ.js +278 -0
- package/packages/cli/dist/dist-CVD-X-DZ.js.map +1 -0
- package/packages/cli/dist/learnosityToQti-sKxcj5Hi.js +102 -0
- package/packages/cli/dist/learnosityToQti-sKxcj5Hi.js.map +1 -0
- package/packages/cli/dist/learnosityToQtiPackage-Ij4cM39M.js +632 -0
- package/packages/cli/dist/learnosityToQtiPackage-Ij4cM39M.js.map +1 -0
- package/packages/cli/dist/main.js +32 -37155
- package/packages/cli/dist/main.js.map +1 -1
- package/packages/cli/dist/pathUtils-Cz2GpPEb.js +2386 -0
- package/packages/cli/dist/pathUtils-Cz2GpPEb.js.map +1 -0
- package/packages/cli/dist/qtiPackageToLearnosity-CvXdmwsb.js +354 -0
- package/packages/cli/dist/qtiPackageToLearnosity-CvXdmwsb.js.map +1 -0
- package/packages/cli/dist/qtiToLearnosity-CkD0r1q0.js +97 -0
- package/packages/cli/dist/qtiToLearnosity-CkD0r1q0.js.map +1 -0
- package/packages/cli/dist/resolveOptions-CfXUqGkd.js +31562 -0
- package/packages/cli/dist/resolveOptions-CfXUqGkd.js.map +1 -0
- package/packages/cli/dist/rolldown-runtime-B4iAMlE-.js +35 -0
- package/packages/cli/dist/{batchProcessors-B8EQvMbH.js → table-DYcNeyJ_.js} +906 -1150
- package/packages/cli/dist/table-DYcNeyJ_.js.map +1 -0
- package/packages/core/dist/index.js +389 -411
- package/packages/core/dist/node.js +389 -411
- package/packages/cli/dist/batchProcessors-B8EQvMbH.js.map +0 -1
|
@@ -615,7 +615,9 @@ function parseClozeformulaData(data, file, diagnostics) {
|
|
|
615
615
|
"showHints",
|
|
616
616
|
"show_hints_button",
|
|
617
617
|
"numberPad",
|
|
618
|
-
"text_blocks"
|
|
618
|
+
"text_blocks",
|
|
619
|
+
"horizontal_layout",
|
|
620
|
+
"horizontalPad"
|
|
619
621
|
]);
|
|
620
622
|
for (const key of Object.keys(data)) if (!knownKeys.has(key)) diagnostics.push({
|
|
621
623
|
level: "warning",
|
|
@@ -18528,6 +18530,77 @@ function getMimeTypeFromExtension(src) {
|
|
|
18528
18530
|
if (ext === "webm") return "video/webm";
|
|
18529
18531
|
if (ext === "ogv") return "video/ogg";
|
|
18530
18532
|
}
|
|
18533
|
+
/**
|
|
18534
|
+
* Generic section-extraction wrapper that eliminates boilerplate from individual
|
|
18535
|
+
* interaction builders. Calls the provided `buildXml` function to generate raw XML
|
|
18536
|
+
* fragments, then regex-extracts the standard QTI assessmentItem sections.
|
|
18537
|
+
*
|
|
18538
|
+
* Handles both self-closing (`<responseDeclaration ... />`) and paired
|
|
18539
|
+
* (`<responseDeclaration ...>...</responseDeclaration>`) element forms.
|
|
18540
|
+
*
|
|
18541
|
+
* @example
|
|
18542
|
+
* ```ts
|
|
18543
|
+
* export function buildAssociateInteractionSections(...) {
|
|
18544
|
+
* buildInteractionSections(
|
|
18545
|
+
* buildAssociateInteractionXml,
|
|
18546
|
+
* [interaction, diagnostics],
|
|
18547
|
+
* sections, indent, indent2, indent3, nl
|
|
18548
|
+
* );
|
|
18549
|
+
* }
|
|
18550
|
+
* ```
|
|
18551
|
+
*/
|
|
18552
|
+
function buildInteractionSections(buildXml, buildArgs, _diagnostics, sections, indent, indent2, indent3, nl, opts) {
|
|
18553
|
+
const tempParts = [];
|
|
18554
|
+
buildXml(...buildArgs, tempParts, indent, indent2, indent3, nl);
|
|
18555
|
+
const joined = tempParts.join("");
|
|
18556
|
+
if (opts?.multiResponseDeclarations) {
|
|
18557
|
+
const matches = joined.matchAll(/(<responseDeclaration[\s\S]*?(?:\/>|<\/responseDeclaration>))/g);
|
|
18558
|
+
for (const m of matches) sections.responseDeclarations.push(m[1] + nl);
|
|
18559
|
+
} else if (opts?.selfClosingResponseDecl) {
|
|
18560
|
+
const match = joined.match(/(<responseDeclaration[\s\S]*?(?:\/>|<\/responseDeclaration>))/);
|
|
18561
|
+
if (match) sections.responseDeclarations.push(match[1] + nl);
|
|
18562
|
+
} else {
|
|
18563
|
+
const match = joined.match(/(<responseDeclaration[\s\S]*?<\/responseDeclaration>)/);
|
|
18564
|
+
if (match) sections.responseDeclarations.push(match[1] + nl);
|
|
18565
|
+
}
|
|
18566
|
+
if (opts?.multiOutcomeDeclarations) {
|
|
18567
|
+
const matches = joined.matchAll(/(<outcomeDeclaration[\s\S]*?<\/outcomeDeclaration>)/g);
|
|
18568
|
+
for (const m of matches) sections.outcomeDeclarations.push(m[1] + nl);
|
|
18569
|
+
} else {
|
|
18570
|
+
const match = joined.match(/(<outcomeDeclaration[\s\S]*?<\/outcomeDeclaration>)/);
|
|
18571
|
+
if (match) sections.outcomeDeclarations.push(match[1] + nl);
|
|
18572
|
+
}
|
|
18573
|
+
const itemBodyMatch = joined.match(/(<itemBody>[\s\S]*?<\/itemBody>)/);
|
|
18574
|
+
if (itemBodyMatch) sections.itemBody = itemBodyMatch[1] + nl;
|
|
18575
|
+
const responseProcMatch = joined.match(/(<responseProcessing[\s\S]*?(?:\/>|<\/responseProcessing>))/);
|
|
18576
|
+
if (responseProcMatch) sections.responseProcessing = responseProcMatch[1] + nl;
|
|
18577
|
+
}
|
|
18578
|
+
/**
|
|
18579
|
+
* Emit the standard SCORE outcomeDeclaration block.
|
|
18580
|
+
*
|
|
18581
|
+
* Used by: associate, choice, gapMatch, inlineChoice, match, order, textEntry (×2)
|
|
18582
|
+
*/
|
|
18583
|
+
function pushScoreOutcomeDeclaration(parts, indent, indent2, indent3, nl) {
|
|
18584
|
+
parts.push(`${indent}<outcomeDeclaration identifier="SCORE" cardinality="single" baseType="float">`);
|
|
18585
|
+
parts.push(nl);
|
|
18586
|
+
parts.push(`${indent2}<defaultValue>`);
|
|
18587
|
+
parts.push(nl);
|
|
18588
|
+
parts.push(`${indent3}<value>0</value>`);
|
|
18589
|
+
parts.push(nl);
|
|
18590
|
+
parts.push(`${indent2}</defaultValue>`);
|
|
18591
|
+
parts.push(nl);
|
|
18592
|
+
parts.push(`${indent}</outcomeDeclaration>`);
|
|
18593
|
+
parts.push(nl);
|
|
18594
|
+
}
|
|
18595
|
+
/**
|
|
18596
|
+
* Emit the standard responseProcessing match_correct template reference.
|
|
18597
|
+
*
|
|
18598
|
+
* Used by: associate, choice, gapMatch, hotspot, hottext, match, order, textEntry (×2)
|
|
18599
|
+
*/
|
|
18600
|
+
function pushMatchCorrectResponseProcessing(parts, indent, nl) {
|
|
18601
|
+
parts.push(`${indent}<responseProcessing template="http://www.imsglobal.org/question/qti_v2p2/rptemplates/match_correct"/>`);
|
|
18602
|
+
parts.push(nl);
|
|
18603
|
+
}
|
|
18531
18604
|
//#endregion
|
|
18532
18605
|
//#region src/qti-serializer/multiWidgetSerializer.ts
|
|
18533
18606
|
/**
|
|
@@ -18828,16 +18901,7 @@ function buildMultiWidgetItemXml(ast, diagnostics, parts, indent, indent2, inden
|
|
|
18828
18901
|
parts.push(nl);
|
|
18829
18902
|
}
|
|
18830
18903
|
}
|
|
18831
|
-
parts
|
|
18832
|
-
parts.push(nl);
|
|
18833
|
-
parts.push(`${indent2}<defaultValue>`);
|
|
18834
|
-
parts.push(nl);
|
|
18835
|
-
parts.push(`${indent3}<value>0</value>`);
|
|
18836
|
-
parts.push(nl);
|
|
18837
|
-
parts.push(`${indent2}</defaultValue>`);
|
|
18838
|
-
parts.push(nl);
|
|
18839
|
-
parts.push(`${indent}</outcomeDeclaration>`);
|
|
18840
|
-
parts.push(nl);
|
|
18904
|
+
pushScoreOutcomeDeclaration(parts, indent, indent2, indent3, nl);
|
|
18841
18905
|
parts.push(`${indent}<itemBody>`);
|
|
18842
18906
|
parts.push(nl);
|
|
18843
18907
|
let contentHtml = layout.contentHtml;
|
|
@@ -18886,10 +18950,7 @@ function buildMultiWidgetItemXml(ast, diagnostics, parts, indent, indent2, inden
|
|
|
18886
18950
|
else if (int.type === "textEntry") return (int.correctResponses?.length ?? 0) > 0;
|
|
18887
18951
|
else if (int.type === "order") return (int.correctResponse?.length ?? 0) > 0;
|
|
18888
18952
|
return false;
|
|
18889
|
-
}))
|
|
18890
|
-
parts.push(`${indent}<responseProcessing template="http://www.imsglobal.org/question/qti_v2p2/rptemplates/match_correct"/>`);
|
|
18891
|
-
parts.push(nl);
|
|
18892
|
-
}
|
|
18953
|
+
})) pushMatchCorrectResponseProcessing(parts, indent, nl);
|
|
18893
18954
|
}
|
|
18894
18955
|
/**
|
|
18895
18956
|
* Render an interaction as XML string (for multi-widget layouts)
|
|
@@ -19218,17 +19279,11 @@ function convertVideoplayerToQh5(data) {
|
|
|
19218
19279
|
* Section-based wrapper for buildChoiceInteractionXml
|
|
19219
19280
|
*/
|
|
19220
19281
|
function buildChoiceInteractionSections(interaction, feedbackBlock, diagnostics, sections, indent, indent2, indent3, nl) {
|
|
19221
|
-
|
|
19222
|
-
|
|
19223
|
-
|
|
19224
|
-
|
|
19225
|
-
|
|
19226
|
-
const itemBodyMatch = joined.match(/(<itemBody>[\s\S]*?<\/itemBody>)/);
|
|
19227
|
-
const responseProcMatch = joined.match(/(<responseProcessing[^>]*\/>)/);
|
|
19228
|
-
if (responseDeclMatch) sections.responseDeclarations.push(responseDeclMatch[1] + nl);
|
|
19229
|
-
for (const match of outcomeDeclMatches) sections.outcomeDeclarations.push(match[1] + nl);
|
|
19230
|
-
if (itemBodyMatch) sections.itemBody = itemBodyMatch[1] + nl;
|
|
19231
|
-
if (responseProcMatch) sections.responseProcessing = responseProcMatch[1] + nl;
|
|
19282
|
+
buildInteractionSections(buildChoiceInteractionXml, [
|
|
19283
|
+
interaction,
|
|
19284
|
+
feedbackBlock,
|
|
19285
|
+
diagnostics
|
|
19286
|
+
], diagnostics, sections, indent, indent2, indent3, nl, { multiOutcomeDeclarations: true });
|
|
19232
19287
|
}
|
|
19233
19288
|
/**
|
|
19234
19289
|
* Build choice interaction XML (MCQ)
|
|
@@ -19258,16 +19313,7 @@ function buildChoiceInteractionXml(interaction, feedbackBlock, diagnostics, part
|
|
|
19258
19313
|
parts.push(`${indent}</responseDeclaration>`);
|
|
19259
19314
|
parts.push(nl);
|
|
19260
19315
|
}
|
|
19261
|
-
parts
|
|
19262
|
-
parts.push(nl);
|
|
19263
|
-
parts.push(`${indent2}<defaultValue>`);
|
|
19264
|
-
parts.push(nl);
|
|
19265
|
-
parts.push(`${indent3}<value>0</value>`);
|
|
19266
|
-
parts.push(nl);
|
|
19267
|
-
parts.push(`${indent2}</defaultValue>`);
|
|
19268
|
-
parts.push(nl);
|
|
19269
|
-
parts.push(`${indent}</outcomeDeclaration>`);
|
|
19270
|
-
parts.push(nl);
|
|
19316
|
+
pushScoreOutcomeDeclaration(parts, indent, indent2, indent3, nl);
|
|
19271
19317
|
if (feedbackBlock && feedbackBlock.length > 0) {
|
|
19272
19318
|
parts.push(`${indent}<outcomeDeclaration identifier="FEEDBACK" cardinality="single" baseType="identifier">`);
|
|
19273
19319
|
parts.push(nl);
|
|
@@ -19320,10 +19366,7 @@ function buildChoiceInteractionXml(interaction, feedbackBlock, diagnostics, part
|
|
|
19320
19366
|
}
|
|
19321
19367
|
parts.push(`${indent}</itemBody>`);
|
|
19322
19368
|
parts.push(nl);
|
|
19323
|
-
if (interaction.correctResponse)
|
|
19324
|
-
parts.push(`${indent}<responseProcessing template="http://www.imsglobal.org/question/qti_v2p2/rptemplates/match_correct"/>`);
|
|
19325
|
-
parts.push(nl);
|
|
19326
|
-
}
|
|
19369
|
+
if (interaction.correctResponse) pushMatchCorrectResponseProcessing(parts, indent, nl);
|
|
19327
19370
|
}
|
|
19328
19371
|
//#endregion
|
|
19329
19372
|
//#region src/qti-serializer/interaction-builders/buildTextEntryInteraction.ts
|
|
@@ -19331,17 +19374,7 @@ function buildChoiceInteractionXml(interaction, feedbackBlock, diagnostics, part
|
|
|
19331
19374
|
* Section-based wrapper for buildTextEntryInteractionXml
|
|
19332
19375
|
*/
|
|
19333
19376
|
function buildTextEntryInteractionSections(interaction, diagnostics, sections, indent, indent2, indent3, nl) {
|
|
19334
|
-
|
|
19335
|
-
buildTextEntryInteractionXml(interaction, diagnostics, tempParts, indent, indent2, indent3, nl);
|
|
19336
|
-
const joined = tempParts.join("");
|
|
19337
|
-
const responseDeclMatches = joined.matchAll(/(<responseDeclaration[\s\S]*?(?:\/>|<\/responseDeclaration>))/g);
|
|
19338
|
-
for (const match of responseDeclMatches) sections.responseDeclarations.push(match[1] + nl);
|
|
19339
|
-
const outcomeDeclMatch = joined.match(/(<outcomeDeclaration[\s\S]*?<\/outcomeDeclaration>)/);
|
|
19340
|
-
const itemBodyMatch = joined.match(/(<itemBody>[\s\S]*?<\/itemBody>)/);
|
|
19341
|
-
const responseProcMatch = joined.match(/(<responseProcessing[^>]*\/>)/);
|
|
19342
|
-
if (outcomeDeclMatch) sections.outcomeDeclarations.push(outcomeDeclMatch[1] + nl);
|
|
19343
|
-
if (itemBodyMatch) sections.itemBody = itemBodyMatch[1] + nl;
|
|
19344
|
-
if (responseProcMatch) sections.responseProcessing = responseProcMatch[1] + nl;
|
|
19377
|
+
buildInteractionSections(buildTextEntryInteractionXml, [interaction, diagnostics], diagnostics, sections, indent, indent2, indent3, nl, { multiResponseDeclarations: true });
|
|
19345
19378
|
}
|
|
19346
19379
|
/**
|
|
19347
19380
|
* Build text entry interaction XML (clozetext)
|
|
@@ -19375,16 +19408,7 @@ function buildTextEntryInteractionXml(interaction, diagnostics, parts, indent, i
|
|
|
19375
19408
|
parts.push(`${indent}<responseDeclaration identifier="${interaction.responseIdentifier}" cardinality="single" baseType="string"/>`);
|
|
19376
19409
|
parts.push(nl);
|
|
19377
19410
|
}
|
|
19378
|
-
parts
|
|
19379
|
-
parts.push(nl);
|
|
19380
|
-
parts.push(`${indent2}<defaultValue>`);
|
|
19381
|
-
parts.push(nl);
|
|
19382
|
-
parts.push(`${indent3}<value>0</value>`);
|
|
19383
|
-
parts.push(nl);
|
|
19384
|
-
parts.push(`${indent2}</defaultValue>`);
|
|
19385
|
-
parts.push(nl);
|
|
19386
|
-
parts.push(`${indent}</outcomeDeclaration>`);
|
|
19387
|
-
parts.push(nl);
|
|
19411
|
+
pushScoreOutcomeDeclaration(parts, indent, indent2, indent3, nl);
|
|
19388
19412
|
parts.push(`${indent}<itemBody>`);
|
|
19389
19413
|
parts.push(nl);
|
|
19390
19414
|
diagnostics.push({
|
|
@@ -19414,10 +19438,7 @@ function buildTextEntryInteractionXml(interaction, diagnostics, parts, indent, i
|
|
|
19414
19438
|
parts.push(nl);
|
|
19415
19439
|
parts.push(`${indent}</itemBody>`);
|
|
19416
19440
|
parts.push(nl);
|
|
19417
|
-
if (interaction.correctResponses && interaction.correctResponses.length > 0)
|
|
19418
|
-
parts.push(`${indent}<responseProcessing template="http://www.imsglobal.org/question/qti_v2p2/rptemplates/match_correct"/>`);
|
|
19419
|
-
parts.push(nl);
|
|
19420
|
-
}
|
|
19441
|
+
if (interaction.correctResponses && interaction.correctResponses.length > 0) pushMatchCorrectResponseProcessing(parts, indent, nl);
|
|
19421
19442
|
return;
|
|
19422
19443
|
}
|
|
19423
19444
|
if (!Array.isArray(interaction.textEntries) || interaction.textEntries.length === 0) {
|
|
@@ -19454,16 +19475,7 @@ function buildTextEntryInteractionXml(interaction, diagnostics, parts, indent, i
|
|
|
19454
19475
|
parts.push(`${indent}<responseDeclaration identifier="${entry.responseIdentifier}" cardinality="single" baseType="string"/>`);
|
|
19455
19476
|
parts.push(nl);
|
|
19456
19477
|
}
|
|
19457
|
-
parts
|
|
19458
|
-
parts.push(nl);
|
|
19459
|
-
parts.push(`${indent2}<defaultValue>`);
|
|
19460
|
-
parts.push(nl);
|
|
19461
|
-
parts.push(`${indent3}<value>0</value>`);
|
|
19462
|
-
parts.push(nl);
|
|
19463
|
-
parts.push(`${indent2}</defaultValue>`);
|
|
19464
|
-
parts.push(nl);
|
|
19465
|
-
parts.push(`${indent}</outcomeDeclaration>`);
|
|
19466
|
-
parts.push(nl);
|
|
19478
|
+
pushScoreOutcomeDeclaration(parts, indent, indent2, indent3, nl);
|
|
19467
19479
|
parts.push(`${indent}<itemBody>`);
|
|
19468
19480
|
parts.push(nl);
|
|
19469
19481
|
if (interaction.prompt) {
|
|
@@ -19513,10 +19525,7 @@ function buildTextEntryInteractionXml(interaction, diagnostics, parts, indent, i
|
|
|
19513
19525
|
parts.push(nl);
|
|
19514
19526
|
parts.push(`${indent}</itemBody>`);
|
|
19515
19527
|
parts.push(nl);
|
|
19516
|
-
if (interaction.textEntries.some((e) => e.correctResponse))
|
|
19517
|
-
parts.push(`${indent}<responseProcessing template="http://www.imsglobal.org/question/qti_v2p2/rptemplates/match_correct"/>`);
|
|
19518
|
-
parts.push(nl);
|
|
19519
|
-
}
|
|
19528
|
+
if (interaction.textEntries.some((e) => e.correctResponse)) pushMatchCorrectResponseProcessing(parts, indent, nl);
|
|
19520
19529
|
}
|
|
19521
19530
|
//#endregion
|
|
19522
19531
|
//#region src/qti-serializer/interaction-builders/buildExtendedTextInteraction.ts
|
|
@@ -19524,15 +19533,14 @@ function buildTextEntryInteractionXml(interaction, diagnostics, parts, indent, i
|
|
|
19524
19533
|
* Section-based wrapper for buildExtendedTextInteractionXml
|
|
19525
19534
|
*/
|
|
19526
19535
|
function buildExtendedTextInteractionSections(interaction, outcomeDeclaration, diagnostics, sections, indent, indent2, indent3, nl) {
|
|
19527
|
-
|
|
19528
|
-
|
|
19529
|
-
|
|
19530
|
-
|
|
19531
|
-
|
|
19532
|
-
|
|
19533
|
-
|
|
19534
|
-
|
|
19535
|
-
if (itemBodyMatch) sections.itemBody = itemBodyMatch[1] + nl;
|
|
19536
|
+
buildInteractionSections(buildExtendedTextInteractionXml, [
|
|
19537
|
+
interaction,
|
|
19538
|
+
outcomeDeclaration,
|
|
19539
|
+
diagnostics
|
|
19540
|
+
], diagnostics, sections, indent, indent2, indent3, nl, {
|
|
19541
|
+
multiOutcomeDeclarations: true,
|
|
19542
|
+
selfClosingResponseDecl: true
|
|
19543
|
+
});
|
|
19536
19544
|
}
|
|
19537
19545
|
/**
|
|
19538
19546
|
* Build extended text interaction XML (essay/long answer)
|
|
@@ -19580,15 +19588,10 @@ function buildExtendedTextInteractionXml(interaction, outcomeDeclaration, diagno
|
|
|
19580
19588
|
* Section-based wrapper for buildUploadInteractionXml
|
|
19581
19589
|
*/
|
|
19582
19590
|
function buildUploadInteractionSections(interaction, diagnostics, sections, indent, indent2, nl) {
|
|
19583
|
-
const
|
|
19584
|
-
|
|
19585
|
-
|
|
19586
|
-
|
|
19587
|
-
const itemBodyMatch = joined.match(/(<itemBody>[\s\S]*?<\/itemBody>)/);
|
|
19588
|
-
const responseProcessingMatch = joined.match(/(<responseProcessing[\s\S]*?(?:\/>|<\/responseProcessing>))/);
|
|
19589
|
-
if (responseDeclMatch) sections.responseDeclarations.push(responseDeclMatch[1] + nl);
|
|
19590
|
-
if (itemBodyMatch) sections.itemBody = itemBodyMatch[1] + nl;
|
|
19591
|
-
if (responseProcessingMatch) sections.responseProcessing = responseProcessingMatch[1] + nl;
|
|
19591
|
+
const buildXmlAdapter = (interaction, diagnostics, parts, indent, indent2, _indent3, nl) => {
|
|
19592
|
+
buildUploadInteractionXml(interaction, diagnostics, parts, indent, indent2, nl);
|
|
19593
|
+
};
|
|
19594
|
+
buildInteractionSections(buildXmlAdapter, [interaction, diagnostics], diagnostics, sections, indent, indent2, "", nl, { selfClosingResponseDecl: true });
|
|
19592
19595
|
}
|
|
19593
19596
|
/**
|
|
19594
19597
|
* Build upload interaction XML (file upload)
|
|
@@ -19627,15 +19630,7 @@ function buildUploadInteractionXml(interaction, diagnostics, parts, indent, inde
|
|
|
19627
19630
|
* Build drawingInteraction sections
|
|
19628
19631
|
*/
|
|
19629
19632
|
function buildDrawingInteractionSections(interaction, diagnostics, sections, indent, indent2, indent3, nl) {
|
|
19630
|
-
|
|
19631
|
-
buildDrawingInteractionXml(interaction, diagnostics, tempParts, indent, indent2, indent3, nl);
|
|
19632
|
-
const joined = tempParts.join("");
|
|
19633
|
-
const responseDeclMatch = joined.match(/(<responseDeclaration[\s\S]*?(?:\/>|<\/responseDeclaration>))/);
|
|
19634
|
-
const itemBodyMatch = joined.match(/(<itemBody>[\s\S]*?<\/itemBody>)/);
|
|
19635
|
-
const responseProcessingMatch = joined.match(/(<responseProcessing[\s\S]*?(?:\/>|<\/responseProcessing>))/);
|
|
19636
|
-
if (responseDeclMatch) sections.responseDeclarations.push(responseDeclMatch[1] + nl);
|
|
19637
|
-
if (itemBodyMatch) sections.itemBody = itemBodyMatch[1] + nl;
|
|
19638
|
-
if (responseProcessingMatch) sections.responseProcessing = responseProcessingMatch[1] + nl;
|
|
19633
|
+
buildInteractionSections(buildDrawingInteractionXml, [interaction, diagnostics], diagnostics, sections, indent, indent2, indent3, nl, { selfClosingResponseDecl: true });
|
|
19639
19634
|
}
|
|
19640
19635
|
/**
|
|
19641
19636
|
* Build drawingInteraction XML
|
|
@@ -19693,17 +19688,7 @@ function buildDrawingInteractionXml(interaction, diagnostics, parts, indent, ind
|
|
|
19693
19688
|
* Section-based wrapper for buildInlineChoiceInteractionXml
|
|
19694
19689
|
*/
|
|
19695
19690
|
function buildInlineChoiceInteractionSections(interaction, diagnostics, sections, indent, indent2, indent3, nl) {
|
|
19696
|
-
|
|
19697
|
-
buildInlineChoiceInteractionXml(interaction, diagnostics, tempParts, indent, indent2, indent3, nl);
|
|
19698
|
-
const joined = tempParts.join("");
|
|
19699
|
-
const responseDeclMatches = joined.matchAll(/(<responseDeclaration[\s\S]*?(?:\/>|<\/responseDeclaration>))/g);
|
|
19700
|
-
for (const match of responseDeclMatches) sections.responseDeclarations.push(match[1] + nl);
|
|
19701
|
-
const outcomeDeclMatch = joined.match(/(<outcomeDeclaration[\s\S]*?<\/outcomeDeclaration>)/);
|
|
19702
|
-
const itemBodyMatch = joined.match(/(<itemBody>[\s\S]*?<\/itemBody>)/);
|
|
19703
|
-
const responseProcMatch = joined.match(/(<responseProcessing[^>]*\/>)/);
|
|
19704
|
-
if (outcomeDeclMatch) sections.outcomeDeclarations.push(outcomeDeclMatch[1] + nl);
|
|
19705
|
-
if (itemBodyMatch) sections.itemBody = itemBodyMatch[1] + nl;
|
|
19706
|
-
if (responseProcMatch) sections.responseProcessing = responseProcMatch[1] + nl;
|
|
19691
|
+
buildInteractionSections(buildInlineChoiceInteractionXml, [interaction, diagnostics], diagnostics, sections, indent, indent2, indent3, nl, { multiResponseDeclarations: true });
|
|
19707
19692
|
}
|
|
19708
19693
|
/**
|
|
19709
19694
|
* Build inline choice interaction XML (clozedropdown)
|
|
@@ -19733,16 +19718,7 @@ function buildInlineChoiceInteractionXml(interaction, diagnostics, parts, indent
|
|
|
19733
19718
|
parts.push(nl);
|
|
19734
19719
|
}
|
|
19735
19720
|
}
|
|
19736
|
-
parts
|
|
19737
|
-
parts.push(nl);
|
|
19738
|
-
parts.push(`${indent2}<defaultValue>`);
|
|
19739
|
-
parts.push(nl);
|
|
19740
|
-
parts.push(`${indent3}<value>0</value>`);
|
|
19741
|
-
parts.push(nl);
|
|
19742
|
-
parts.push(`${indent2}</defaultValue>`);
|
|
19743
|
-
parts.push(nl);
|
|
19744
|
-
parts.push(`${indent}</outcomeDeclaration>`);
|
|
19745
|
-
parts.push(nl);
|
|
19721
|
+
pushScoreOutcomeDeclaration(parts, indent, indent2, indent3, nl);
|
|
19746
19722
|
parts.push(`${indent}<itemBody>`);
|
|
19747
19723
|
parts.push(nl);
|
|
19748
19724
|
if (interaction.prompt) {
|
|
@@ -19781,17 +19757,7 @@ function buildInlineChoiceInteractionXml(interaction, diagnostics, parts, indent
|
|
|
19781
19757
|
* Section-based wrapper for buildGapMatchInteractionXml
|
|
19782
19758
|
*/
|
|
19783
19759
|
function buildGapMatchInteractionSections(interaction, diagnostics, sections, indent, indent2, indent3, nl) {
|
|
19784
|
-
|
|
19785
|
-
buildGapMatchInteractionXml(interaction, diagnostics, tempParts, indent, indent2, indent3, nl);
|
|
19786
|
-
const joined = tempParts.join("");
|
|
19787
|
-
const responseDeclMatch = joined.match(/(<responseDeclaration[\s\S]*?<\/responseDeclaration>)/);
|
|
19788
|
-
const outcomeDeclMatch = joined.match(/(<outcomeDeclaration[\s\S]*?<\/outcomeDeclaration>)/);
|
|
19789
|
-
const itemBodyMatch = joined.match(/(<itemBody>[\s\S]*?<\/itemBody>)/);
|
|
19790
|
-
const responseProcMatch = joined.match(/(<responseProcessing[^>]*\/>)/);
|
|
19791
|
-
if (responseDeclMatch) sections.responseDeclarations.push(responseDeclMatch[1] + nl);
|
|
19792
|
-
if (outcomeDeclMatch) sections.outcomeDeclarations.push(outcomeDeclMatch[1] + nl);
|
|
19793
|
-
if (itemBodyMatch) sections.itemBody = itemBodyMatch[1] + nl;
|
|
19794
|
-
if (responseProcMatch) sections.responseProcessing = responseProcMatch[1] + nl;
|
|
19760
|
+
buildInteractionSections(buildGapMatchInteractionXml, [interaction, diagnostics], diagnostics, sections, indent, indent2, indent3, nl);
|
|
19795
19761
|
}
|
|
19796
19762
|
/**
|
|
19797
19763
|
* Build gapMatch interaction XML for clozeassociation
|
|
@@ -19825,16 +19791,7 @@ function buildGapMatchInteractionXml(interaction, diagnostics, parts, indent, in
|
|
|
19825
19791
|
parts.push(nl);
|
|
19826
19792
|
}
|
|
19827
19793
|
}
|
|
19828
|
-
parts
|
|
19829
|
-
parts.push(nl);
|
|
19830
|
-
parts.push(`${indent2}<defaultValue>`);
|
|
19831
|
-
parts.push(nl);
|
|
19832
|
-
parts.push(`${indent3}<value>0</value>`);
|
|
19833
|
-
parts.push(nl);
|
|
19834
|
-
parts.push(`${indent2}</defaultValue>`);
|
|
19835
|
-
parts.push(nl);
|
|
19836
|
-
parts.push(`${indent}</outcomeDeclaration>`);
|
|
19837
|
-
parts.push(nl);
|
|
19794
|
+
pushScoreOutcomeDeclaration(parts, indent, indent2, indent3, nl);
|
|
19838
19795
|
parts.push(`${indent}<itemBody>`);
|
|
19839
19796
|
parts.push(nl);
|
|
19840
19797
|
if (interaction.prompt) {
|
|
@@ -19881,17 +19838,7 @@ function buildGapMatchInteractionXml(interaction, diagnostics, parts, indent, in
|
|
|
19881
19838
|
* Section-based wrapper for buildOrderInteractionXml
|
|
19882
19839
|
*/
|
|
19883
19840
|
function buildOrderInteractionSections(interaction, diagnostics, sections, indent, indent2, indent3, nl) {
|
|
19884
|
-
|
|
19885
|
-
buildOrderInteractionXml(interaction, diagnostics, tempParts, indent, indent2, indent3, nl);
|
|
19886
|
-
const joined = tempParts.join("");
|
|
19887
|
-
const responseDeclMatch = joined.match(/(<responseDeclaration[\s\S]*?<\/responseDeclaration>)/);
|
|
19888
|
-
const outcomeDeclMatch = joined.match(/(<outcomeDeclaration[\s\S]*?<\/outcomeDeclaration>)/);
|
|
19889
|
-
const itemBodyMatch = joined.match(/(<itemBody>[\s\S]*?<\/itemBody>)/);
|
|
19890
|
-
const responseProcMatch = joined.match(/(<responseProcessing[^>]*\/>)/);
|
|
19891
|
-
if (responseDeclMatch) sections.responseDeclarations.push(responseDeclMatch[1] + nl);
|
|
19892
|
-
if (outcomeDeclMatch) sections.outcomeDeclarations.push(outcomeDeclMatch[1] + nl);
|
|
19893
|
-
if (itemBodyMatch) sections.itemBody = itemBodyMatch[1] + nl;
|
|
19894
|
-
if (responseProcMatch) sections.responseProcessing = responseProcMatch[1] + nl;
|
|
19841
|
+
buildInteractionSections(buildOrderInteractionXml, [interaction, diagnostics], diagnostics, sections, indent, indent2, indent3, nl);
|
|
19895
19842
|
}
|
|
19896
19843
|
/**
|
|
19897
19844
|
* Build orderInteraction XML (for single-widget items)
|
|
@@ -19924,16 +19871,7 @@ function buildOrderInteractionXml(interaction, diagnostics, parts, indent, inden
|
|
|
19924
19871
|
parts.push(`${indent}<responseDeclaration identifier="${interaction.responseIdentifier}" cardinality="ordered" baseType="identifier"/>`);
|
|
19925
19872
|
parts.push(nl);
|
|
19926
19873
|
}
|
|
19927
|
-
parts
|
|
19928
|
-
parts.push(nl);
|
|
19929
|
-
parts.push(`${indent2}<defaultValue>`);
|
|
19930
|
-
parts.push(nl);
|
|
19931
|
-
parts.push(`${indent3}<value>0</value>`);
|
|
19932
|
-
parts.push(nl);
|
|
19933
|
-
parts.push(`${indent2}</defaultValue>`);
|
|
19934
|
-
parts.push(nl);
|
|
19935
|
-
parts.push(`${indent}</outcomeDeclaration>`);
|
|
19936
|
-
parts.push(nl);
|
|
19874
|
+
pushScoreOutcomeDeclaration(parts, indent, indent2, indent3, nl);
|
|
19937
19875
|
parts.push(`${indent}<itemBody>`);
|
|
19938
19876
|
parts.push(nl);
|
|
19939
19877
|
if (interaction.prompt) {
|
|
@@ -19966,10 +19904,7 @@ function buildOrderInteractionXml(interaction, diagnostics, parts, indent, inden
|
|
|
19966
19904
|
parts.push(nl);
|
|
19967
19905
|
parts.push(`${indent}</itemBody>`);
|
|
19968
19906
|
parts.push(nl);
|
|
19969
|
-
if (interaction.correctResponse && interaction.correctResponse.length > 0)
|
|
19970
|
-
parts.push(`${indent}<responseProcessing template="http://www.imsglobal.org/question/qti_v2p2/rptemplates/match_correct"/>`);
|
|
19971
|
-
parts.push(nl);
|
|
19972
|
-
}
|
|
19907
|
+
if (interaction.correctResponse && interaction.correctResponse.length > 0) pushMatchCorrectResponseProcessing(parts, indent, nl);
|
|
19973
19908
|
}
|
|
19974
19909
|
//#endregion
|
|
19975
19910
|
//#region src/qti-serializer/interaction-builders/buildMatchInteraction.ts
|
|
@@ -19977,17 +19912,7 @@ function buildOrderInteractionXml(interaction, diagnostics, parts, indent, inden
|
|
|
19977
19912
|
* Section-based wrapper for buildMatchInteractionXml
|
|
19978
19913
|
*/
|
|
19979
19914
|
function buildMatchInteractionSections(interaction, diagnostics, sections, indent, indent2, indent3, nl) {
|
|
19980
|
-
|
|
19981
|
-
buildMatchInteractionXml(interaction, diagnostics, tempParts, indent, indent2, indent3, nl);
|
|
19982
|
-
const joined = tempParts.join("");
|
|
19983
|
-
const responseDeclMatch = joined.match(/(<responseDeclaration[\s\S]*?<\/responseDeclaration>)/);
|
|
19984
|
-
const outcomeDeclMatch = joined.match(/(<outcomeDeclaration[\s\S]*?<\/outcomeDeclaration>)/);
|
|
19985
|
-
const itemBodyMatch = joined.match(/(<itemBody>[\s\S]*?<\/itemBody>)/);
|
|
19986
|
-
const responseProcMatch = joined.match(/(<responseProcessing[^>]*\/>)/);
|
|
19987
|
-
if (responseDeclMatch) sections.responseDeclarations.push(responseDeclMatch[1] + nl);
|
|
19988
|
-
if (outcomeDeclMatch) sections.outcomeDeclarations.push(outcomeDeclMatch[1] + nl);
|
|
19989
|
-
if (itemBodyMatch) sections.itemBody = itemBodyMatch[1] + nl;
|
|
19990
|
-
if (responseProcMatch) sections.responseProcessing = responseProcMatch[1] + nl;
|
|
19915
|
+
buildInteractionSections(buildMatchInteractionXml, [interaction, diagnostics], diagnostics, sections, indent, indent2, indent3, nl);
|
|
19991
19916
|
}
|
|
19992
19917
|
/**
|
|
19993
19918
|
* Build matchInteraction XML (choicematrix)
|
|
@@ -20010,16 +19935,7 @@ function buildMatchInteractionXml(interaction, diagnostics, parts, indent, inden
|
|
|
20010
19935
|
parts.push(`${indent}<responseDeclaration identifier="${interaction.responseIdentifier}" cardinality="multiple" baseType="directedPair"/>`);
|
|
20011
19936
|
parts.push(nl);
|
|
20012
19937
|
}
|
|
20013
|
-
parts
|
|
20014
|
-
parts.push(nl);
|
|
20015
|
-
parts.push(`${indent2}<defaultValue>`);
|
|
20016
|
-
parts.push(nl);
|
|
20017
|
-
parts.push(`${indent3}<value>0</value>`);
|
|
20018
|
-
parts.push(nl);
|
|
20019
|
-
parts.push(`${indent2}</defaultValue>`);
|
|
20020
|
-
parts.push(nl);
|
|
20021
|
-
parts.push(`${indent}</outcomeDeclaration>`);
|
|
20022
|
-
parts.push(nl);
|
|
19938
|
+
pushScoreOutcomeDeclaration(parts, indent, indent2, indent3, nl);
|
|
20023
19939
|
parts.push(`${indent}<itemBody>`);
|
|
20024
19940
|
parts.push(nl);
|
|
20025
19941
|
if (interaction.prompt) {
|
|
@@ -20058,8 +19974,7 @@ function buildMatchInteractionXml(interaction, diagnostics, parts, indent, inden
|
|
|
20058
19974
|
parts.push(nl);
|
|
20059
19975
|
parts.push(`${indent}</itemBody>`);
|
|
20060
19976
|
parts.push(nl);
|
|
20061
|
-
parts
|
|
20062
|
-
parts.push(nl);
|
|
19977
|
+
pushMatchCorrectResponseProcessing(parts, indent, nl);
|
|
20063
19978
|
}
|
|
20064
19979
|
//#endregion
|
|
20065
19980
|
//#region src/qti-serializer/interaction-builders/buildHottextInteraction.ts
|
|
@@ -20067,15 +19982,7 @@ function buildMatchInteractionXml(interaction, diagnostics, parts, indent, inden
|
|
|
20067
19982
|
* Build hottext interaction sections (tokenhighlight)
|
|
20068
19983
|
*/
|
|
20069
19984
|
function buildHottextInteractionSections(interaction, diagnostics, sections, indent, indent2, indent3, nl) {
|
|
20070
|
-
|
|
20071
|
-
buildHottextInteractionXml(interaction, diagnostics, tempParts, indent, indent2, indent3, nl);
|
|
20072
|
-
const joined = tempParts.join("");
|
|
20073
|
-
const responseDeclMatch = joined.match(/(<responseDeclaration[\s\S]*?<\/responseDeclaration>)/);
|
|
20074
|
-
const itemBodyMatch = joined.match(/(<itemBody>[\s\S]*?<\/itemBody>)/);
|
|
20075
|
-
const responseProcMatch = joined.match(/(<responseProcessing[^>]*\/>)/);
|
|
20076
|
-
if (responseDeclMatch) sections.responseDeclarations.push(responseDeclMatch[1] + nl);
|
|
20077
|
-
if (itemBodyMatch) sections.itemBody = itemBodyMatch[1] + nl;
|
|
20078
|
-
if (responseProcMatch) sections.responseProcessing = responseProcMatch[1] + nl;
|
|
19985
|
+
buildInteractionSections(buildHottextInteractionXml, [interaction, diagnostics], diagnostics, sections, indent, indent2, indent3, nl);
|
|
20079
19986
|
}
|
|
20080
19987
|
/**
|
|
20081
19988
|
* Build hottext interaction XML (tokenhighlight)
|
|
@@ -20130,10 +20037,7 @@ function buildHottextInteractionXml(interaction, diagnostics, parts, indent, ind
|
|
|
20130
20037
|
parts.push(nl);
|
|
20131
20038
|
parts.push(`${indent}</itemBody>`);
|
|
20132
20039
|
parts.push(nl);
|
|
20133
|
-
if (interaction.correctResponse && interaction.correctResponse.length > 0)
|
|
20134
|
-
parts.push(`${indent}<responseProcessing template="http://www.imsglobal.org/question/qti_v2p2/rptemplates/match_correct"/>`);
|
|
20135
|
-
parts.push(nl);
|
|
20136
|
-
}
|
|
20040
|
+
if (interaction.correctResponse && interaction.correctResponse.length > 0) pushMatchCorrectResponseProcessing(parts, indent, nl);
|
|
20137
20041
|
}
|
|
20138
20042
|
//#endregion
|
|
20139
20043
|
//#region src/qti-serializer/interaction-builders/buildHotspotInteraction.ts
|
|
@@ -20141,15 +20045,7 @@ function buildHottextInteractionXml(interaction, diagnostics, parts, indent, ind
|
|
|
20141
20045
|
* Build hotspotInteraction sections
|
|
20142
20046
|
*/
|
|
20143
20047
|
function buildHotspotInteractionSections(interaction, diagnostics, sections, indent, indent2, indent3, nl) {
|
|
20144
|
-
|
|
20145
|
-
buildHotspotInteractionXml(interaction, diagnostics, tempParts, indent, indent2, indent3, nl);
|
|
20146
|
-
const joined = tempParts.join("");
|
|
20147
|
-
const responseDeclMatch = joined.match(/(<responseDeclaration[\s\S]*?<\/responseDeclaration>)/);
|
|
20148
|
-
const itemBodyMatch = joined.match(/(<itemBody>[\s\S]*?<\/itemBody>)/);
|
|
20149
|
-
const responseProcMatch = joined.match(/(<responseProcessing[^>]*\/>)/);
|
|
20150
|
-
if (responseDeclMatch) sections.responseDeclarations.push(responseDeclMatch[1] + nl);
|
|
20151
|
-
if (itemBodyMatch) sections.itemBody = itemBodyMatch[1] + nl;
|
|
20152
|
-
if (responseProcMatch) sections.responseProcessing = responseProcMatch[1] + nl;
|
|
20048
|
+
buildInteractionSections(buildHotspotInteractionXml, [interaction, diagnostics], diagnostics, sections, indent, indent2, indent3, nl, { selfClosingResponseDecl: true });
|
|
20153
20049
|
}
|
|
20154
20050
|
/**
|
|
20155
20051
|
* Build hotspotInteraction XML
|
|
@@ -20196,10 +20092,7 @@ function buildHotspotInteractionXml(interaction, _diagnostics, parts, indent, in
|
|
|
20196
20092
|
parts.push(nl);
|
|
20197
20093
|
parts.push(`${indent}</itemBody>`);
|
|
20198
20094
|
parts.push(nl);
|
|
20199
|
-
if (interaction.correctResponse && interaction.correctResponse.length > 0)
|
|
20200
|
-
parts.push(`${indent}<responseProcessing template="http://www.imsglobal.org/question/qti_v2p2/rptemplates/match_correct"/>`);
|
|
20201
|
-
parts.push(nl);
|
|
20202
|
-
}
|
|
20095
|
+
if (interaction.correctResponse && interaction.correctResponse.length > 0) pushMatchCorrectResponseProcessing(parts, indent, nl);
|
|
20203
20096
|
}
|
|
20204
20097
|
//#endregion
|
|
20205
20098
|
//#region src/qti-serializer/interaction-builders/buildGraphicGapMatchInteraction.ts
|
|
@@ -20207,15 +20100,7 @@ function buildHotspotInteractionXml(interaction, _diagnostics, parts, indent, in
|
|
|
20207
20100
|
* Build graphicGapMatchInteraction sections
|
|
20208
20101
|
*/
|
|
20209
20102
|
function buildGraphicGapMatchInteractionSections(interaction, diagnostics, sections, indent, indent2, indent3, nl) {
|
|
20210
|
-
|
|
20211
|
-
buildGraphicGapMatchInteractionXml(interaction, diagnostics, tempParts, indent, indent2, indent3, nl);
|
|
20212
|
-
const joined = tempParts.join("");
|
|
20213
|
-
const responseDeclMatch = joined.match(/(<responseDeclaration[\s\S]*?<\/responseDeclaration>)/);
|
|
20214
|
-
const itemBodyMatch = joined.match(/(<itemBody>[\s\S]*?<\/itemBody>)/);
|
|
20215
|
-
const responseProcMatch = joined.match(/(<responseProcessing[^>]*\/>)/);
|
|
20216
|
-
if (responseDeclMatch) sections.responseDeclarations.push(responseDeclMatch[1] + nl);
|
|
20217
|
-
if (itemBodyMatch) sections.itemBody = itemBodyMatch[1] + nl;
|
|
20218
|
-
if (responseProcMatch) sections.responseProcessing = responseProcMatch[1] + nl;
|
|
20103
|
+
buildInteractionSections(buildGraphicGapMatchInteractionXml, [interaction, diagnostics], diagnostics, sections, indent, indent2, indent3, nl, { selfClosingResponseDecl: true });
|
|
20219
20104
|
}
|
|
20220
20105
|
/**
|
|
20221
20106
|
* Build graphicGapMatchInteraction XML (imageclozeassociationV2)
|
|
@@ -20294,17 +20179,7 @@ function buildGraphicGapMatchInteractionXml(interaction, diagnostics, parts, ind
|
|
|
20294
20179
|
* Section-based wrapper for buildAssociateInteractionXml
|
|
20295
20180
|
*/
|
|
20296
20181
|
function buildAssociateInteractionSections(interaction, diagnostics, sections, indent, indent2, indent3, nl) {
|
|
20297
|
-
|
|
20298
|
-
buildAssociateInteractionXml(interaction, diagnostics, tempParts, indent, indent2, indent3, nl);
|
|
20299
|
-
const joined = tempParts.join("");
|
|
20300
|
-
const responseDeclMatch = joined.match(/(<responseDeclaration[\s\S]*?<\/responseDeclaration>)/);
|
|
20301
|
-
const outcomeDeclMatch = joined.match(/(<outcomeDeclaration[\s\S]*?<\/outcomeDeclaration>)/);
|
|
20302
|
-
const itemBodyMatch = joined.match(/(<itemBody>[\s\S]*?<\/itemBody>)/);
|
|
20303
|
-
const responseProcMatch = joined.match(/(<responseProcessing[^>]*\/>)/);
|
|
20304
|
-
if (responseDeclMatch) sections.responseDeclarations.push(responseDeclMatch[1] + nl);
|
|
20305
|
-
if (outcomeDeclMatch) sections.outcomeDeclarations.push(outcomeDeclMatch[1] + nl);
|
|
20306
|
-
if (itemBodyMatch) sections.itemBody = itemBodyMatch[1] + nl;
|
|
20307
|
-
if (responseProcMatch) sections.responseProcessing = responseProcMatch[1] + nl;
|
|
20182
|
+
buildInteractionSections(buildAssociateInteractionXml, [interaction, diagnostics], diagnostics, sections, indent, indent2, indent3, nl);
|
|
20308
20183
|
}
|
|
20309
20184
|
/**
|
|
20310
20185
|
* Build associateInteraction XML (for single-widget items, classification)
|
|
@@ -20327,16 +20202,7 @@ function buildAssociateInteractionXml(interaction, diagnostics, parts, indent, i
|
|
|
20327
20202
|
parts.push(`${indent}<responseDeclaration identifier="${interaction.responseIdentifier}" cardinality="multiple" baseType="pair"/>`);
|
|
20328
20203
|
parts.push(nl);
|
|
20329
20204
|
}
|
|
20330
|
-
parts
|
|
20331
|
-
parts.push(nl);
|
|
20332
|
-
parts.push(`${indent2}<defaultValue>`);
|
|
20333
|
-
parts.push(nl);
|
|
20334
|
-
parts.push(`${indent3}<value>0</value>`);
|
|
20335
|
-
parts.push(nl);
|
|
20336
|
-
parts.push(`${indent2}</defaultValue>`);
|
|
20337
|
-
parts.push(nl);
|
|
20338
|
-
parts.push(`${indent}</outcomeDeclaration>`);
|
|
20339
|
-
parts.push(nl);
|
|
20205
|
+
pushScoreOutcomeDeclaration(parts, indent, indent2, indent3, nl);
|
|
20340
20206
|
parts.push(`${indent}<itemBody>`);
|
|
20341
20207
|
parts.push(nl);
|
|
20342
20208
|
if (interaction.prompt) {
|
|
@@ -20365,10 +20231,7 @@ function buildAssociateInteractionXml(interaction, diagnostics, parts, indent, i
|
|
|
20365
20231
|
parts.push(nl);
|
|
20366
20232
|
parts.push(`${indent}</itemBody>`);
|
|
20367
20233
|
parts.push(nl);
|
|
20368
|
-
if (interaction.correctResponse && interaction.correctResponse.length > 0)
|
|
20369
|
-
parts.push(`${indent}<responseProcessing template="http://www.imsglobal.org/question/qti_v2p2/rptemplates/match_correct"/>`);
|
|
20370
|
-
parts.push(nl);
|
|
20371
|
-
}
|
|
20234
|
+
if (interaction.correctResponse && interaction.correctResponse.length > 0) pushMatchCorrectResponseProcessing(parts, indent, nl);
|
|
20372
20235
|
}
|
|
20373
20236
|
//#endregion
|
|
20374
20237
|
//#region src/qti-serializer/serializeAssessmentItem.ts
|
|
@@ -27093,104 +26956,267 @@ function convertGraphicGapMatchToLearnosity(inputXml, diagnostics, _lomTags, org
|
|
|
27093
26956
|
};
|
|
27094
26957
|
}
|
|
27095
26958
|
//#endregion
|
|
27096
|
-
//#region src/qti-parser/
|
|
26959
|
+
//#region src/qti-parser/createAssessmentItemReader.ts
|
|
27097
26960
|
/**
|
|
27098
|
-
*
|
|
26961
|
+
* Shared SAX streaming scaffold for QTI assessmentItem readers.
|
|
26962
|
+
*
|
|
26963
|
+
* Every `readAssessmentItemXxx` parser repeats the same ~40 lines of boilerplate:
|
|
26964
|
+
* - Create a SaxesParser
|
|
26965
|
+
* - Handle assessmentItem opentag (extract identifier, title)
|
|
26966
|
+
* - Handle responseDeclaration + correctResponse + value extraction
|
|
26967
|
+
* - Handle itemBody detection
|
|
26968
|
+
* - text/cdata capture dispatch
|
|
26969
|
+
* - try/catch error handling with diagnostics
|
|
26970
|
+
* - Post-parse validations (foundAssessmentItem, foundItemBody, interaction count)
|
|
26971
|
+
*
|
|
26972
|
+
* This utility extracts the shared envelope, leaving each parser to focus only
|
|
26973
|
+
* on its interaction-specific logic.
|
|
27099
26974
|
*/
|
|
27100
|
-
|
|
27101
|
-
|
|
27102
|
-
|
|
27103
|
-
|
|
27104
|
-
|
|
27105
|
-
|
|
27106
|
-
|
|
27107
|
-
|
|
27108
|
-
|
|
27109
|
-
|
|
27110
|
-
|
|
27111
|
-
|
|
27112
|
-
|
|
27113
|
-
|
|
27114
|
-
|
|
27115
|
-
|
|
27116
|
-
|
|
27117
|
-
|
|
27118
|
-
|
|
27119
|
-
|
|
27120
|
-
|
|
27121
|
-
|
|
27122
|
-
|
|
27123
|
-
|
|
27124
|
-
|
|
27125
|
-
|
|
27126
|
-
|
|
27127
|
-
|
|
26975
|
+
/**
|
|
26976
|
+
* Create an assessmentItem reader with the shared envelope handled automatically.
|
|
26977
|
+
*
|
|
26978
|
+
* The returned function accepts XML input and returns the typed result, with all
|
|
26979
|
+
* the common scaffolding (parser creation, assessmentItem/responseDeclaration/itemBody
|
|
26980
|
+
* handling, error handling, validations) done for you.
|
|
26981
|
+
*
|
|
26982
|
+
* @example
|
|
26983
|
+
* ```ts
|
|
26984
|
+
* export const readAssessmentItemDrawing = createAssessmentItemReader<ReadDrawingResult>({
|
|
26985
|
+
* interactionName: 'drawingInteraction',
|
|
26986
|
+
* createResult: (diagnostics) => ({ diagnostics, ... }),
|
|
26987
|
+
* onInteractionOpen: (tag, result, ctx) => { ... },
|
|
26988
|
+
* });
|
|
26989
|
+
* ```
|
|
26990
|
+
*/
|
|
26991
|
+
function createAssessmentItemReader(hooks) {
|
|
26992
|
+
return (inputXml) => {
|
|
26993
|
+
const diagnostics = [];
|
|
26994
|
+
const result = hooks.createResult(diagnostics);
|
|
26995
|
+
const parser = new import_saxes.SaxesParser(hooks.parserOptions);
|
|
26996
|
+
const buffers = /* @__PURE__ */ new Map();
|
|
26997
|
+
let foundAssessmentItem = false;
|
|
26998
|
+
let foundItemBody = false;
|
|
26999
|
+
let inItemBody = false;
|
|
27000
|
+
let inInteraction = false;
|
|
27001
|
+
let interactionCount = 0;
|
|
27002
|
+
let currentResponseDeclId;
|
|
27003
|
+
let inCorrectResponse = false;
|
|
27004
|
+
const correctResponsesByIdentifier = /* @__PURE__ */ new Map();
|
|
27005
|
+
const correctValueBuf = [];
|
|
27006
|
+
const ctx = {
|
|
27007
|
+
get capture() {
|
|
27008
|
+
return _capture;
|
|
27009
|
+
},
|
|
27010
|
+
set capture(val) {
|
|
27011
|
+
_capture = val;
|
|
27012
|
+
},
|
|
27013
|
+
get inItemBody() {
|
|
27014
|
+
return inItemBody;
|
|
27015
|
+
},
|
|
27016
|
+
diagnostics,
|
|
27017
|
+
correctResponsesByIdentifier,
|
|
27018
|
+
get currentResponseDeclId() {
|
|
27019
|
+
return currentResponseDeclId;
|
|
27020
|
+
},
|
|
27021
|
+
getAttr: getAttr$5,
|
|
27022
|
+
normalizeWhitespace,
|
|
27023
|
+
pushToBuffer(name, text) {
|
|
27024
|
+
if (!buffers.has(name)) buffers.set(name, []);
|
|
27025
|
+
buffers.get(name).push(text);
|
|
27026
|
+
},
|
|
27027
|
+
flushBuffer(name) {
|
|
27028
|
+
const buf = buffers.get(name);
|
|
27029
|
+
if (!buf) return "";
|
|
27030
|
+
const result = normalizeWhitespace(buf.join(""));
|
|
27031
|
+
buf.length = 0;
|
|
27032
|
+
return result;
|
|
27033
|
+
},
|
|
27034
|
+
peekBuffer(name) {
|
|
27035
|
+
const buf = buffers.get(name);
|
|
27036
|
+
return buf ? buf.join("") : "";
|
|
27037
|
+
},
|
|
27038
|
+
clearBuffer(name) {
|
|
27039
|
+
const buf = buffers.get(name);
|
|
27040
|
+
if (buf) buf.length = 0;
|
|
27128
27041
|
}
|
|
27129
|
-
}
|
|
27130
|
-
|
|
27131
|
-
|
|
27132
|
-
|
|
27133
|
-
|
|
27134
|
-
|
|
27135
|
-
|
|
27136
|
-
|
|
27137
|
-
|
|
27138
|
-
|
|
27139
|
-
|
|
27140
|
-
|
|
27141
|
-
|
|
27142
|
-
|
|
27143
|
-
|
|
27144
|
-
|
|
27145
|
-
|
|
27146
|
-
|
|
27042
|
+
};
|
|
27043
|
+
let _capture = null;
|
|
27044
|
+
parser.on("opentag", (tag) => {
|
|
27045
|
+
const localName = tag.local ?? tag.name;
|
|
27046
|
+
if (localName === "assessmentItem") {
|
|
27047
|
+
foundAssessmentItem = true;
|
|
27048
|
+
result.identifier = getAttr$5(tag, "identifier");
|
|
27049
|
+
result.title = getAttr$5(tag, "title") ?? null;
|
|
27050
|
+
return;
|
|
27051
|
+
}
|
|
27052
|
+
if (localName === "itemBody") {
|
|
27053
|
+
foundItemBody = true;
|
|
27054
|
+
inItemBody = true;
|
|
27055
|
+
return;
|
|
27056
|
+
}
|
|
27057
|
+
if (localName === hooks.interactionName) {
|
|
27058
|
+
interactionCount++;
|
|
27059
|
+
inInteraction = true;
|
|
27060
|
+
hooks.onInteractionOpen(tag, result, ctx);
|
|
27061
|
+
return;
|
|
27062
|
+
}
|
|
27063
|
+
if (localName === "responseDeclaration") {
|
|
27064
|
+
const identifier = getAttr$5(tag, "identifier");
|
|
27065
|
+
if (identifier) {
|
|
27066
|
+
currentResponseDeclId = identifier;
|
|
27067
|
+
correctResponsesByIdentifier.set(identifier, []);
|
|
27068
|
+
}
|
|
27069
|
+
return;
|
|
27070
|
+
}
|
|
27071
|
+
if (localName === "correctResponse") {
|
|
27072
|
+
inCorrectResponse = true;
|
|
27073
|
+
correctValueBuf.length = 0;
|
|
27074
|
+
return;
|
|
27075
|
+
}
|
|
27076
|
+
if (localName === "value" && inCorrectResponse) {
|
|
27077
|
+
correctValueBuf.length = 0;
|
|
27078
|
+
return;
|
|
27079
|
+
}
|
|
27080
|
+
const location = inInteraction ? "in-interaction" : inItemBody ? "pre-interaction" : "post-interaction";
|
|
27081
|
+
hooks.onOpenTag?.(localName, tag, result, ctx, location);
|
|
27082
|
+
});
|
|
27083
|
+
parser.on("closetag", (tag) => {
|
|
27084
|
+
const localName = tag.local ?? tag.name;
|
|
27085
|
+
if (localName === "itemBody") {
|
|
27086
|
+
inItemBody = false;
|
|
27087
|
+
return;
|
|
27088
|
+
}
|
|
27089
|
+
if (localName === hooks.interactionName) {
|
|
27090
|
+
inInteraction = false;
|
|
27091
|
+
hooks.onInteractionClose?.(result, ctx);
|
|
27092
|
+
return;
|
|
27093
|
+
}
|
|
27094
|
+
if (localName === "responseDeclaration") {
|
|
27095
|
+
currentResponseDeclId = void 0;
|
|
27096
|
+
return;
|
|
27097
|
+
}
|
|
27098
|
+
if (localName === "correctResponse") {
|
|
27099
|
+
inCorrectResponse = false;
|
|
27100
|
+
return;
|
|
27101
|
+
}
|
|
27102
|
+
if (localName === "value" && inCorrectResponse) {
|
|
27103
|
+
const value = normalizeWhitespace(correctValueBuf.join(""));
|
|
27104
|
+
if (value && currentResponseDeclId) {
|
|
27105
|
+
const values = correctResponsesByIdentifier.get(currentResponseDeclId);
|
|
27106
|
+
if (values) values.push(value);
|
|
27107
|
+
}
|
|
27108
|
+
correctValueBuf.length = 0;
|
|
27109
|
+
return;
|
|
27110
|
+
}
|
|
27111
|
+
const location = inInteraction ? "in-interaction" : inItemBody ? "pre-interaction" : "post-interaction";
|
|
27112
|
+
hooks.onCloseTag?.(localName, tag, result, ctx, location);
|
|
27113
|
+
});
|
|
27114
|
+
parser.on("text", (text) => {
|
|
27115
|
+
if (inCorrectResponse) {
|
|
27116
|
+
correctValueBuf.push(text);
|
|
27117
|
+
return;
|
|
27118
|
+
}
|
|
27119
|
+
if (_capture) ctx.pushToBuffer(_capture, text);
|
|
27120
|
+
});
|
|
27121
|
+
parser.on("cdata", (text) => {
|
|
27122
|
+
if (inCorrectResponse) {
|
|
27123
|
+
correctValueBuf.push(text);
|
|
27124
|
+
return;
|
|
27125
|
+
}
|
|
27126
|
+
if (_capture) ctx.pushToBuffer(_capture, text);
|
|
27127
|
+
});
|
|
27128
|
+
parser.on("error", (error) => {
|
|
27129
|
+
diagnostics.push({
|
|
27130
|
+
code: DiagnosticCode.LRN_SCHEMA_INVALID,
|
|
27131
|
+
level: "error",
|
|
27132
|
+
file: "assessmentItem",
|
|
27133
|
+
message: `Failed to parse QTI XML: ${error.message}`
|
|
27134
|
+
});
|
|
27135
|
+
});
|
|
27136
|
+
try {
|
|
27137
|
+
parser.write(inputXml).close();
|
|
27138
|
+
} catch (error) {
|
|
27139
|
+
diagnostics.push({
|
|
27140
|
+
code: DiagnosticCode.LRN_SCHEMA_INVALID,
|
|
27141
|
+
level: "error",
|
|
27142
|
+
file: "assessmentItem",
|
|
27143
|
+
message: `Failed to parse QTI XML: ${error instanceof Error ? error.message : String(error)}`
|
|
27144
|
+
});
|
|
27145
|
+
return result;
|
|
27147
27146
|
}
|
|
27148
|
-
|
|
27149
|
-
|
|
27150
|
-
if (capture === "stimulus") stimulusBuf.push(text);
|
|
27151
|
-
else if (capture === "prompt") promptBuf.push(text);
|
|
27152
|
-
});
|
|
27153
|
-
parser.on("cdata", (text) => {
|
|
27154
|
-
if (capture === "stimulus") stimulusBuf.push(text);
|
|
27155
|
-
else if (capture === "prompt") promptBuf.push(text);
|
|
27156
|
-
});
|
|
27157
|
-
try {
|
|
27158
|
-
parser.write(inputXml).close();
|
|
27159
|
-
} catch (error) {
|
|
27160
|
-
diagnostics.push({
|
|
27147
|
+
hooks.onParseComplete?.(result, ctx);
|
|
27148
|
+
if (!foundAssessmentItem) diagnostics.push({
|
|
27161
27149
|
code: DiagnosticCode.LRN_SCHEMA_INVALID,
|
|
27162
27150
|
level: "error",
|
|
27163
27151
|
file: "assessmentItem",
|
|
27164
|
-
message:
|
|
27152
|
+
message: "No assessmentItem element found"
|
|
27165
27153
|
});
|
|
27166
|
-
|
|
27167
|
-
|
|
27168
|
-
|
|
27169
|
-
|
|
27170
|
-
|
|
27171
|
-
|
|
27172
|
-
|
|
27173
|
-
|
|
27174
|
-
|
|
27175
|
-
|
|
27176
|
-
|
|
27177
|
-
|
|
27178
|
-
|
|
27179
|
-
|
|
27180
|
-
|
|
27181
|
-
|
|
27182
|
-
|
|
27183
|
-
|
|
27184
|
-
|
|
27185
|
-
|
|
27186
|
-
|
|
27187
|
-
level: "error",
|
|
27188
|
-
file: "assessmentItem.itemBody",
|
|
27189
|
-
message: `Multiple drawingInteraction elements found (${drawingInteractionCount}), only single interaction supported`
|
|
27190
|
-
});
|
|
27191
|
-
return result;
|
|
27154
|
+
if (!foundItemBody) diagnostics.push({
|
|
27155
|
+
code: DiagnosticCode.LRN_SCHEMA_INVALID,
|
|
27156
|
+
level: "error",
|
|
27157
|
+
file: "assessmentItem",
|
|
27158
|
+
message: "No itemBody element found"
|
|
27159
|
+
});
|
|
27160
|
+
if (foundItemBody && interactionCount === 0) diagnostics.push({
|
|
27161
|
+
code: DiagnosticCode.QTI_UNSUPPORTED_INTERACTION,
|
|
27162
|
+
level: "error",
|
|
27163
|
+
file: "assessmentItem.itemBody",
|
|
27164
|
+
message: `No ${hooks.interactionName} found in itemBody`
|
|
27165
|
+
});
|
|
27166
|
+
if (interactionCount > 1) diagnostics.push({
|
|
27167
|
+
code: DiagnosticCode.QTI_MULTIPLE_INTERACTIONS,
|
|
27168
|
+
level: "error",
|
|
27169
|
+
file: "assessmentItem.itemBody",
|
|
27170
|
+
message: `Multiple ${hooks.interactionName} elements found (${interactionCount}), only single interaction supported`
|
|
27171
|
+
});
|
|
27172
|
+
hooks.validate?.(result, ctx, interactionCount);
|
|
27173
|
+
return result;
|
|
27174
|
+
};
|
|
27192
27175
|
}
|
|
27193
27176
|
//#endregion
|
|
27177
|
+
//#region src/qti-parser/readAssessmentItemDrawing.ts
|
|
27178
|
+
const readAssessmentItemDrawing = createAssessmentItemReader({
|
|
27179
|
+
interactionName: "drawingInteraction",
|
|
27180
|
+
createResult: (diagnostics) => ({ diagnostics }),
|
|
27181
|
+
onInteractionOpen: (tag, result, ctx) => {
|
|
27182
|
+
result.responseIdentifier = ctx.getAttr(tag, "responseIdentifier");
|
|
27183
|
+
if (ctx.capture === "stimulus") {
|
|
27184
|
+
result.stimulusText = ctx.flushBuffer("stimulus");
|
|
27185
|
+
ctx.capture = null;
|
|
27186
|
+
}
|
|
27187
|
+
},
|
|
27188
|
+
onOpenTag: (localName, tag, result, ctx, location) => {
|
|
27189
|
+
if (location === "pre-interaction") {
|
|
27190
|
+
if (!ctx.capture) {
|
|
27191
|
+
ctx.capture = "stimulus";
|
|
27192
|
+
ctx.clearBuffer("stimulus");
|
|
27193
|
+
}
|
|
27194
|
+
} else if (location === "in-interaction") {
|
|
27195
|
+
if (localName === "prompt") {
|
|
27196
|
+
ctx.capture = "prompt";
|
|
27197
|
+
ctx.clearBuffer("prompt");
|
|
27198
|
+
return true;
|
|
27199
|
+
}
|
|
27200
|
+
if (localName === "img") {
|
|
27201
|
+
result.imageSource = ctx.getAttr(tag, "src");
|
|
27202
|
+
result.imageAlt = ctx.getAttr(tag, "alt");
|
|
27203
|
+
const widthAttr = ctx.getAttr(tag, "width");
|
|
27204
|
+
const heightAttr = ctx.getAttr(tag, "height");
|
|
27205
|
+
if (widthAttr) result.imageWidth = parseInt(widthAttr, 10);
|
|
27206
|
+
if (heightAttr) result.imageHeight = parseInt(heightAttr, 10);
|
|
27207
|
+
return true;
|
|
27208
|
+
}
|
|
27209
|
+
}
|
|
27210
|
+
},
|
|
27211
|
+
onCloseTag: (localName, _tag, result, ctx, location) => {
|
|
27212
|
+
if (location === "in-interaction" && localName === "prompt" && ctx.capture === "prompt") {
|
|
27213
|
+
result.promptText = ctx.flushBuffer("prompt");
|
|
27214
|
+
ctx.capture = null;
|
|
27215
|
+
return true;
|
|
27216
|
+
}
|
|
27217
|
+
}
|
|
27218
|
+
});
|
|
27219
|
+
//#endregion
|
|
27194
27220
|
//#region src/qti-to-learnosity/convertDrawingToLearnosity.ts
|
|
27195
27221
|
/**
|
|
27196
27222
|
* Build drawing stimulus from parsed QTI data
|
|
@@ -28665,14 +28691,6 @@ function parseMetadataTags(metadataXml, options = {}) {
|
|
|
28665
28691
|
}
|
|
28666
28692
|
//#endregion
|
|
28667
28693
|
//#region src/qti-parser/readAssessmentItemUpload.ts
|
|
28668
|
-
/**
|
|
28669
|
-
* Read QTI uploadInteraction using a streaming parser.
|
|
28670
|
-
*
|
|
28671
|
-
* The Learnosity -> QTI serializer carries the fileupload allow-list on the
|
|
28672
|
-
* interaction's `class` attribute as `lrn-allow-<suffix>` tokens and the file
|
|
28673
|
-
* limit as `maxChoices` (QTI has no standard field for either). This reader
|
|
28674
|
-
* recovers both, plus the stimulus HTML, so a fileupload item round-trips.
|
|
28675
|
-
*/
|
|
28676
28694
|
/** Parse `lrn-allow-<suffix>` tokens from a class attribute into allow_* suffixes. */
|
|
28677
28695
|
function parseAllowedFileTypes(classAttr) {
|
|
28678
28696
|
if (!classAttr) return [];
|
|
@@ -28690,69 +28708,29 @@ function extractStimulus(inputXml) {
|
|
|
28690
28708
|
const stimulus = itemBodyMatch[1].replace(/<uploadInteraction[\s\S]*?(?:\/>|<\/uploadInteraction>)/gi, "").trim();
|
|
28691
28709
|
return stimulus.length > 0 ? stimulus : void 0;
|
|
28692
28710
|
}
|
|
28693
|
-
|
|
28694
|
-
|
|
28695
|
-
|
|
28711
|
+
const _baseReader = createAssessmentItemReader({
|
|
28712
|
+
interactionName: "uploadInteraction",
|
|
28713
|
+
createResult: (diagnostics) => ({
|
|
28696
28714
|
allowedFileTypes: [],
|
|
28697
28715
|
diagnostics
|
|
28698
|
-
}
|
|
28699
|
-
|
|
28700
|
-
|
|
28701
|
-
|
|
28702
|
-
|
|
28703
|
-
|
|
28704
|
-
|
|
28705
|
-
|
|
28706
|
-
foundAssessmentItem = true;
|
|
28707
|
-
result.identifier = getAttr$5(tag, "identifier");
|
|
28708
|
-
result.title = getAttr$5(tag, "title") ?? null;
|
|
28709
|
-
} else if (localName === "itemBody") foundItemBody = true;
|
|
28710
|
-
else if (localName === "uploadInteraction") {
|
|
28711
|
-
uploadInteractionCount++;
|
|
28712
|
-
result.responseIdentifier = getAttr$5(tag, "responseIdentifier");
|
|
28713
|
-
result.allowedFileTypes = parseAllowedFileTypes(getAttr$5(tag, "class"));
|
|
28714
|
-
const maxChoices = getAttr$5(tag, "maxChoices");
|
|
28715
|
-
if (maxChoices) {
|
|
28716
|
-
const parsed = parseInt(maxChoices, 10);
|
|
28717
|
-
if (!Number.isNaN(parsed)) result.maxFiles = parsed;
|
|
28718
|
-
}
|
|
28716
|
+
}),
|
|
28717
|
+
onInteractionOpen: (tag, result, ctx) => {
|
|
28718
|
+
result.responseIdentifier = ctx.getAttr(tag, "responseIdentifier");
|
|
28719
|
+
result.allowedFileTypes = parseAllowedFileTypes(getAttr$5(tag, "class"));
|
|
28720
|
+
const maxChoices = ctx.getAttr(tag, "maxChoices");
|
|
28721
|
+
if (maxChoices) {
|
|
28722
|
+
const parsed = parseInt(maxChoices, 10);
|
|
28723
|
+
if (!Number.isNaN(parsed)) result.maxFiles = parsed;
|
|
28719
28724
|
}
|
|
28720
|
-
});
|
|
28721
|
-
try {
|
|
28722
|
-
parser.write(inputXml).close();
|
|
28723
|
-
} catch (error) {
|
|
28724
|
-
diagnostics.push({
|
|
28725
|
-
code: DiagnosticCode.LRN_SCHEMA_INVALID,
|
|
28726
|
-
level: "error",
|
|
28727
|
-
file: "assessmentItem",
|
|
28728
|
-
message: `Failed to parse QTI XML: ${error instanceof Error ? error.message : String(error)}`
|
|
28729
|
-
});
|
|
28730
28725
|
}
|
|
28731
|
-
|
|
28732
|
-
|
|
28733
|
-
|
|
28734
|
-
|
|
28735
|
-
|
|
28736
|
-
|
|
28737
|
-
|
|
28738
|
-
|
|
28739
|
-
level: "error",
|
|
28740
|
-
file: "assessmentItem",
|
|
28741
|
-
message: "No itemBody element found"
|
|
28742
|
-
});
|
|
28743
|
-
if (foundItemBody && uploadInteractionCount === 0) diagnostics.push({
|
|
28744
|
-
code: DiagnosticCode.QTI_UNSUPPORTED_INTERACTION,
|
|
28745
|
-
level: "error",
|
|
28746
|
-
file: "assessmentItem.itemBody",
|
|
28747
|
-
message: "No uploadInteraction found in itemBody"
|
|
28748
|
-
});
|
|
28749
|
-
if (uploadInteractionCount > 1) diagnostics.push({
|
|
28750
|
-
code: DiagnosticCode.QTI_MULTIPLE_INTERACTIONS,
|
|
28751
|
-
level: "error",
|
|
28752
|
-
file: "assessmentItem.itemBody",
|
|
28753
|
-
message: `Multiple uploadInteraction elements found (${uploadInteractionCount}), only single interaction supported`
|
|
28754
|
-
});
|
|
28755
|
-
if (diagnostics.every((d) => d.level !== "error")) result.stimulus = extractStimulus(inputXml);
|
|
28726
|
+
});
|
|
28727
|
+
/**
|
|
28728
|
+
* Read uploadInteraction data from QTI assessmentItem XML.
|
|
28729
|
+
* Wraps the base reader to add post-parse stimulus extraction from raw XML.
|
|
28730
|
+
*/
|
|
28731
|
+
function readAssessmentItemUpload(inputXml) {
|
|
28732
|
+
const result = _baseReader(inputXml);
|
|
28733
|
+
if (result.diagnostics.every((d) => d.level !== "error")) result.stimulus = extractStimulus(inputXml);
|
|
28756
28734
|
return result;
|
|
28757
28735
|
}
|
|
28758
28736
|
//#endregion
|