@learnosity/lib-qti-converter 0.12.1 → 0.12.3
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +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 +9 -9
- 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-DU9wLVhI.js +1392 -0
- package/packages/cli/dist/create-prompt-DU9wLVhI.js.map +1 -0
- package/packages/cli/dist/dist-DjpU2mIj.js +278 -0
- package/packages/cli/dist/dist-DjpU2mIj.js.map +1 -0
- package/packages/cli/dist/learnosityToQti-B0PoimXr.js +102 -0
- package/packages/cli/dist/learnosityToQti-B0PoimXr.js.map +1 -0
- package/packages/cli/dist/learnosityToQtiPackage-RyClxvZj.js +632 -0
- package/packages/cli/dist/learnosityToQtiPackage-RyClxvZj.js.map +1 -0
- package/packages/cli/dist/main.js +32 -37131
- package/packages/cli/dist/main.js.map +1 -1
- package/packages/cli/dist/pathUtils-CwZnJ55s.js +2386 -0
- package/packages/cli/dist/pathUtils-CwZnJ55s.js.map +1 -0
- package/packages/cli/dist/qtiPackageToLearnosity-0rkZKKOK.js +354 -0
- package/packages/cli/dist/qtiPackageToLearnosity-0rkZKKOK.js.map +1 -0
- package/packages/cli/dist/qtiToLearnosity-jiFTBiQU.js +97 -0
- package/packages/cli/dist/qtiToLearnosity-jiFTBiQU.js.map +1 -0
- package/packages/cli/dist/resolveOptions-gH_YAxxc.js +31578 -0
- package/packages/cli/dist/resolveOptions-gH_YAxxc.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 +162 -144
- package/packages/core/dist/node.js +162 -144
- package/packages/cli/dist/batchProcessors-B8EQvMbH.js.map +0 -1
|
@@ -622,7 +622,9 @@ function parseClozeformulaData(data, file, diagnostics) {
|
|
|
622
622
|
"showHints",
|
|
623
623
|
"show_hints_button",
|
|
624
624
|
"numberPad",
|
|
625
|
-
"text_blocks"
|
|
625
|
+
"text_blocks",
|
|
626
|
+
"horizontal_layout",
|
|
627
|
+
"horizontalPad"
|
|
626
628
|
]);
|
|
627
629
|
for (const key of Object.keys(data)) if (!knownKeys.has(key)) diagnostics.push({
|
|
628
630
|
level: "warning",
|
|
@@ -14144,8 +14146,8 @@ var require_CSSStyleDeclaration = /* @__PURE__ */ __commonJSMin(((exports) => {
|
|
|
14144
14146
|
return properties.join(" ");
|
|
14145
14147
|
},
|
|
14146
14148
|
set cssText(text) {
|
|
14147
|
-
var i, name;
|
|
14148
|
-
for (
|
|
14149
|
+
var i = this.length, name;
|
|
14150
|
+
for (; i--;) {
|
|
14149
14151
|
name = this[i];
|
|
14150
14152
|
this[name] = "";
|
|
14151
14153
|
}
|
|
@@ -16313,7 +16315,7 @@ function replaceNbspEntity(html, file) {
|
|
|
16313
16315
|
*/
|
|
16314
16316
|
function normalizeXhtmlVoidElements(html, file) {
|
|
16315
16317
|
const allDiagnostics = [];
|
|
16316
|
-
const centerResult = normalizeCenterTags(html, file);
|
|
16318
|
+
const centerResult = normalizeCenterTags(html.replace(/[\u0000-\u0008\u000B\u000C\u000E-\u001F\uFFFE\uFFFF]/g, ""), file);
|
|
16317
16319
|
let content = centerResult.content;
|
|
16318
16320
|
allDiagnostics.push(...centerResult.diagnostics);
|
|
16319
16321
|
const underlineResult = normalizeUnderlineTags(content, file);
|
|
@@ -18508,15 +18510,90 @@ const XML_ESCAPE_MAP = {
|
|
|
18508
18510
|
};
|
|
18509
18511
|
const XML_ESCAPE_PATTERN = /[&<>"']/g;
|
|
18510
18512
|
/**
|
|
18513
|
+
* Characters that are illegal in XML 1.0 document content.
|
|
18514
|
+
*
|
|
18515
|
+
* XML 1.0 only permits the following characters below U+0020: tab (U+0009),
|
|
18516
|
+
* line feed (U+000A) and carriage return (U+000D). Every other C0 control
|
|
18517
|
+
* character (including U+0001, the SOH character) is forbidden and makes the
|
|
18518
|
+
* document non-well-formed. Also disallowed are U+FFFE and U+FFFF.
|
|
18519
|
+
*
|
|
18520
|
+
* Learnosity source JSON occasionally carries stray control characters (e.g.
|
|
18521
|
+
* a literal `\u0001` inside a choice label or attribute value); left in place
|
|
18522
|
+
* they surface as parser errors such as
|
|
18523
|
+
* "An invalid XML character (Unicode: 0x1) was found in the element content".
|
|
18524
|
+
*
|
|
18525
|
+
* @see https://www.w3.org/TR/xml/#charsets
|
|
18526
|
+
*/
|
|
18527
|
+
const INVALID_XML_CHARS_PATTERN = /[\u0000-\u0008\u000B\u000C\u000E-\u001F\uFFFE\uFFFF]/g;
|
|
18528
|
+
/**
|
|
18529
|
+
* Remove characters that are illegal in XML 1.0 content.
|
|
18530
|
+
*
|
|
18531
|
+
* The disallowed characters are stripped (rather than replaced) so that no
|
|
18532
|
+
* visible artifact is introduced into the output. Tab, newline and carriage
|
|
18533
|
+
* return are preserved because they are the only C0 controls XML 1.0 allows.
|
|
18534
|
+
*
|
|
18535
|
+
* @param text - Raw string that may contain invalid XML characters
|
|
18536
|
+
* @returns The string with all XML-illegal characters removed
|
|
18537
|
+
*/
|
|
18538
|
+
function stripInvalidXmlChars(text) {
|
|
18539
|
+
return text.replace(INVALID_XML_CHARS_PATTERN, "");
|
|
18540
|
+
}
|
|
18541
|
+
/**
|
|
18511
18542
|
* Escape XML special characters.
|
|
18512
18543
|
*
|
|
18513
|
-
*
|
|
18514
|
-
*
|
|
18515
|
-
*
|
|
18516
|
-
*
|
|
18544
|
+
* Invalid XML 1.0 characters (e.g. `\u0001`) are stripped first so they never
|
|
18545
|
+
* reach the serialized output, then a single-pass replacement over the
|
|
18546
|
+
* `[&<>"']` character class runs. Each source character is matched exactly once
|
|
18547
|
+
* and mapped independently, so the output is identical to escaping `&` first
|
|
18548
|
+
* and then the angle/quote characters (the replacement text is never
|
|
18549
|
+
* re-scanned).
|
|
18517
18550
|
*/
|
|
18518
18551
|
function escapeXml$3(text) {
|
|
18519
|
-
return text.replace(XML_ESCAPE_PATTERN, (ch) => XML_ESCAPE_MAP[ch]);
|
|
18552
|
+
return stripInvalidXmlChars(text).replace(XML_ESCAPE_PATTERN, (ch) => XML_ESCAPE_MAP[ch]);
|
|
18553
|
+
}
|
|
18554
|
+
/**
|
|
18555
|
+
* Normalize an HTML content body for emission inside a QTI element.
|
|
18556
|
+
*
|
|
18557
|
+
* Learnosity content fields (option/choice labels, feedback, prompts) are HTML,
|
|
18558
|
+
* so numeric/named character references such as `𝒇` or `−` must be
|
|
18559
|
+
* decoded to their literal Unicode characters before serialization — exactly as
|
|
18560
|
+
* stimulus already is via the linkedom round-trip.
|
|
18561
|
+
*
|
|
18562
|
+
* Historically these fields used a `hasHtmlTags ? normalizeXhtmlVoidElements :
|
|
18563
|
+
* escapeXml` gate. The `escapeXml` fallback treated the leading `&` of an entity
|
|
18564
|
+
* as a raw ampersand and produced double-escaped output (e.g. `𝒇`
|
|
18565
|
+
* became `&#119943;`), which players render as the literal text `𝒇`.
|
|
18566
|
+
*
|
|
18567
|
+
* Running every content body through `normalizeXhtmlVoidElements` (which performs
|
|
18568
|
+
* the DOM round-trip that decodes entities to literal chars and re-escapes only
|
|
18569
|
+
* the structural `<`, `>`, `&`) gives consistent, correct output whether or not
|
|
18570
|
+
* the field contains HTML tags.
|
|
18571
|
+
*
|
|
18572
|
+
* NOTE: This is for element CONTENT only. Attribute values, identifiers and
|
|
18573
|
+
* `<value>` payloads must continue to use `escapeXml`, since those are plain
|
|
18574
|
+
* strings where entities must not be decoded.
|
|
18575
|
+
*
|
|
18576
|
+
* @param content - HTML content body (may be plain text or contain markup)
|
|
18577
|
+
* @param file - Diagnostic path indicating where this content originated
|
|
18578
|
+
* @returns Normalized content and any diagnostics generated
|
|
18579
|
+
*/
|
|
18580
|
+
function normalizeHtmlContentBody(content, file) {
|
|
18581
|
+
return normalizeXhtmlVoidElements(content, file);
|
|
18582
|
+
}
|
|
18583
|
+
/**
|
|
18584
|
+
* Normalize a prompt for emission as a direct child of `itemBody`.
|
|
18585
|
+
*
|
|
18586
|
+
* itemBody requires block-level children, so a plain-text prompt (no HTML tags)
|
|
18587
|
+
* is wrapped in `<p>` before normalization. Either way the content is run
|
|
18588
|
+
* through the linkedom round-trip so numeric/named entities decode to literal
|
|
18589
|
+
* characters instead of being double-escaped by `escapeXml`.
|
|
18590
|
+
*
|
|
18591
|
+
* @param prompt - Prompt content (plain text or HTML)
|
|
18592
|
+
* @param file - Diagnostic path indicating where this content originated
|
|
18593
|
+
* @returns Normalized, block-level prompt content and any diagnostics generated
|
|
18594
|
+
*/
|
|
18595
|
+
function normalizePromptContent(prompt, file) {
|
|
18596
|
+
return normalizeXhtmlVoidElements(/<[a-zA-Z][\s\S]*?>/.test(prompt) ? prompt : `<p>${prompt}</p>`, file);
|
|
18520
18597
|
}
|
|
18521
18598
|
/**
|
|
18522
18599
|
* Infer MIME type from file extension
|
|
@@ -18965,22 +19042,18 @@ function renderInteractionXml(interaction, diagnostics, indent, nl) {
|
|
|
18965
19042
|
if (interaction.type === "choice") {
|
|
18966
19043
|
const choiceInteraction = interaction;
|
|
18967
19044
|
if (choiceInteraction.prompt) {
|
|
18968
|
-
|
|
18969
|
-
|
|
18970
|
-
|
|
18971
|
-
parts.push(normalized.content);
|
|
18972
|
-
} else parts.push(`<p>${escapeXml$3(choiceInteraction.prompt)}</p>`);
|
|
19045
|
+
const normalized = normalizePromptContent(choiceInteraction.prompt, "interaction.prompt");
|
|
19046
|
+
diagnostics.push(...normalized.diagnostics);
|
|
19047
|
+
parts.push(normalized.content);
|
|
18973
19048
|
}
|
|
18974
19049
|
const minChoicesAttr = choiceInteraction.minChoices !== void 0 ? ` minChoices="${choiceInteraction.minChoices}"` : "";
|
|
18975
19050
|
parts.push(`<choiceInteraction responseIdentifier="${choiceInteraction.responseIdentifier}" shuffle="${choiceInteraction.shuffle}"${minChoicesAttr} maxChoices="${choiceInteraction.maxChoices}">`);
|
|
18976
19051
|
parts.push(nl);
|
|
18977
19052
|
for (const choice of choiceInteraction.choices) {
|
|
18978
19053
|
parts.push(`${indent}<simpleChoice identifier="${escapeXml$3(choice.identifier)}">`);
|
|
18979
|
-
|
|
18980
|
-
|
|
18981
|
-
|
|
18982
|
-
parts.push(normalized.content);
|
|
18983
|
-
} else parts.push(escapeXml$3(choice.content));
|
|
19054
|
+
const normalized = normalizeHtmlContentBody(choice.content, `choice.${choice.identifier}`);
|
|
19055
|
+
diagnostics.push(...normalized.diagnostics);
|
|
19056
|
+
parts.push(normalized.content);
|
|
18984
19057
|
parts.push("</simpleChoice>");
|
|
18985
19058
|
parts.push(nl);
|
|
18986
19059
|
}
|
|
@@ -18988,11 +19061,9 @@ function renderInteractionXml(interaction, diagnostics, indent, nl) {
|
|
|
18988
19061
|
} else if (interaction.type === "textEntry") {
|
|
18989
19062
|
const textEntryInteraction = interaction;
|
|
18990
19063
|
if (textEntryInteraction.prompt) {
|
|
18991
|
-
|
|
18992
|
-
|
|
18993
|
-
|
|
18994
|
-
parts.push(normalized.content);
|
|
18995
|
-
} else parts.push(`<p>${escapeXml$3(textEntryInteraction.prompt)}</p>`);
|
|
19064
|
+
const normalized = normalizePromptContent(textEntryInteraction.prompt, "interaction.prompt");
|
|
19065
|
+
diagnostics.push(...normalized.diagnostics);
|
|
19066
|
+
parts.push(normalized.content);
|
|
18996
19067
|
}
|
|
18997
19068
|
let textEntryTag = `<textEntryInteraction responseIdentifier="${textEntryInteraction.responseIdentifier}"`;
|
|
18998
19069
|
if (textEntryInteraction.placeholderText) textEntryTag += ` placeholderText="${escapeXml$3(textEntryInteraction.placeholderText)}"`;
|
|
@@ -19043,10 +19114,7 @@ function renderInteractionXml(interaction, diagnostics, indent, nl) {
|
|
|
19043
19114
|
let inlineChoiceXml = `<inlineChoiceInteraction responseIdentifier="${entry.responseIdentifier}"`;
|
|
19044
19115
|
if (entry.shuffle) inlineChoiceXml += ` shuffle="true"`;
|
|
19045
19116
|
inlineChoiceXml += ">";
|
|
19046
|
-
for (const choice of entry.inlineChoices) {
|
|
19047
|
-
const choiceContent = /<[a-zA-Z][\s\S]*?>/.test(choice.content) ? choice.content : escapeXml$3(choice.content);
|
|
19048
|
-
inlineChoiceXml += `<inlineChoice identifier="${escapeXml$3(choice.identifier)}">${choiceContent}</inlineChoice>`;
|
|
19049
|
-
}
|
|
19117
|
+
for (const choice of entry.inlineChoices) inlineChoiceXml += `<inlineChoice identifier="${escapeXml$3(choice.identifier)}">${choice.content}</inlineChoice>`;
|
|
19050
19118
|
inlineChoiceXml += "</inlineChoiceInteraction>";
|
|
19051
19119
|
templateHtml = templateHtml.replace("{{response}}", inlineChoiceXml);
|
|
19052
19120
|
}
|
|
@@ -19070,7 +19138,9 @@ function renderInteractionXml(interaction, diagnostics, indent, nl) {
|
|
|
19070
19138
|
parts.push(">");
|
|
19071
19139
|
parts.push(nl);
|
|
19072
19140
|
if (gapMatchInteraction.gapTexts) for (const gapText of gapMatchInteraction.gapTexts) {
|
|
19073
|
-
|
|
19141
|
+
const normalized = normalizeHtmlContentBody(gapText.content, `gapText.${gapText.identifier}`);
|
|
19142
|
+
diagnostics.push(...normalized.diagnostics);
|
|
19143
|
+
parts.push(`${indent}<gapText identifier="${escapeXml$3(gapText.identifier)}" matchMax="1">${normalized.content}</gapText>`);
|
|
19074
19144
|
parts.push(nl);
|
|
19075
19145
|
}
|
|
19076
19146
|
if (gapMatchInteraction.template && gapMatchInteraction.gapEntries) {
|
|
@@ -19104,11 +19174,9 @@ function renderInteractionXml(interaction, diagnostics, indent, nl) {
|
|
|
19104
19174
|
parts.push(nl);
|
|
19105
19175
|
for (const choice of orderInteraction.choices) {
|
|
19106
19176
|
parts.push(`${indent}<simpleChoice identifier="${escapeXml$3(choice.identifier)}">`);
|
|
19107
|
-
|
|
19108
|
-
|
|
19109
|
-
|
|
19110
|
-
parts.push(normalized.content);
|
|
19111
|
-
} else parts.push(escapeXml$3(choice.content));
|
|
19177
|
+
const normalized = normalizeHtmlContentBody(choice.content, `choice.${choice.identifier}`);
|
|
19178
|
+
diagnostics.push(...normalized.diagnostics);
|
|
19179
|
+
parts.push(normalized.content);
|
|
19112
19180
|
parts.push("</simpleChoice>");
|
|
19113
19181
|
parts.push(nl);
|
|
19114
19182
|
}
|
|
@@ -19133,11 +19201,9 @@ function renderInteractionXml(interaction, diagnostics, indent, nl) {
|
|
|
19133
19201
|
parts.push(nl);
|
|
19134
19202
|
for (const choice of matchInteraction.sourceSet) {
|
|
19135
19203
|
parts.push(`${indent}${indent}<simpleAssociableChoice identifier="${escapeXml$3(choice.identifier)}" matchMax="${choice.matchMax}">`);
|
|
19136
|
-
|
|
19137
|
-
|
|
19138
|
-
|
|
19139
|
-
parts.push(normalized.content);
|
|
19140
|
-
} else parts.push(escapeXml$3(choice.content));
|
|
19204
|
+
const normalized = normalizeHtmlContentBody(choice.content, `sourceChoice.${choice.identifier}`);
|
|
19205
|
+
diagnostics.push(...normalized.diagnostics);
|
|
19206
|
+
parts.push(normalized.content);
|
|
19141
19207
|
parts.push("</simpleAssociableChoice>");
|
|
19142
19208
|
parts.push(nl);
|
|
19143
19209
|
}
|
|
@@ -19147,11 +19213,9 @@ function renderInteractionXml(interaction, diagnostics, indent, nl) {
|
|
|
19147
19213
|
parts.push(nl);
|
|
19148
19214
|
for (const choice of matchInteraction.targetSet) {
|
|
19149
19215
|
parts.push(`${indent}${indent}<simpleAssociableChoice identifier="${escapeXml$3(choice.identifier)}" matchMax="${choice.matchMax}">`);
|
|
19150
|
-
|
|
19151
|
-
|
|
19152
|
-
|
|
19153
|
-
parts.push(normalized.content);
|
|
19154
|
-
} else parts.push(escapeXml$3(choice.content));
|
|
19216
|
+
const normalized = normalizeHtmlContentBody(choice.content, `targetChoice.${choice.identifier}`);
|
|
19217
|
+
diagnostics.push(...normalized.diagnostics);
|
|
19218
|
+
parts.push(normalized.content);
|
|
19155
19219
|
parts.push("</simpleAssociableChoice>");
|
|
19156
19220
|
parts.push(nl);
|
|
19157
19221
|
}
|
|
@@ -19241,11 +19305,9 @@ function renderInteractionXml(interaction, diagnostics, indent, nl) {
|
|
|
19241
19305
|
parts.push(nl);
|
|
19242
19306
|
for (const choice of associateInteraction.choices) {
|
|
19243
19307
|
parts.push(`${indent}<simpleAssociableChoice identifier="${escapeXml$3(choice.identifier)}" matchMax="${choice.matchMax}">`);
|
|
19244
|
-
|
|
19245
|
-
|
|
19246
|
-
|
|
19247
|
-
parts.push(normalized.content);
|
|
19248
|
-
} else parts.push(escapeXml$3(choice.content));
|
|
19308
|
+
const normalized = normalizeHtmlContentBody(choice.content, `choice.${choice.identifier}`);
|
|
19309
|
+
diagnostics.push(...normalized.diagnostics);
|
|
19310
|
+
parts.push(normalized.content);
|
|
19249
19311
|
parts.push("</simpleAssociableChoice>");
|
|
19250
19312
|
parts.push(nl);
|
|
19251
19313
|
}
|
|
@@ -19344,13 +19406,9 @@ function buildChoiceInteractionXml(interaction, feedbackBlock, diagnostics, part
|
|
|
19344
19406
|
parts.push(nl);
|
|
19345
19407
|
for (let i = 0; i < interaction.choices.length; i++) {
|
|
19346
19408
|
const choice = interaction.choices[i];
|
|
19347
|
-
const
|
|
19348
|
-
|
|
19349
|
-
|
|
19350
|
-
const normalized = normalizeXhtmlVoidElements(choice.content, `choiceInteraction.simpleChoice[${i}]`);
|
|
19351
|
-
diagnostics.push(...normalized.diagnostics);
|
|
19352
|
-
choiceContent = normalized.content;
|
|
19353
|
-
} else choiceContent = escapeXml$3(choice.content);
|
|
19409
|
+
const normalized = normalizeHtmlContentBody(choice.content, `choiceInteraction.simpleChoice[${i}]`);
|
|
19410
|
+
diagnostics.push(...normalized.diagnostics);
|
|
19411
|
+
const choiceContent = normalized.content;
|
|
19354
19412
|
const feedbackAttr = choice.feedbackBlockIdentifier ? ` feedbackBlock="${escapeXml$3(choice.feedbackBlockIdentifier)}"` : "";
|
|
19355
19413
|
parts.push(`${indent3}<simpleChoice identifier="${escapeXml$3(choice.identifier)}"${feedbackAttr}>${choiceContent}</simpleChoice>`);
|
|
19356
19414
|
parts.push(nl);
|
|
@@ -19359,13 +19417,9 @@ function buildChoiceInteractionXml(interaction, feedbackBlock, diagnostics, part
|
|
|
19359
19417
|
parts.push(nl);
|
|
19360
19418
|
if (feedbackBlock && feedbackBlock.length > 0) for (let i = 0; i < feedbackBlock.length; i++) {
|
|
19361
19419
|
const feedback = feedbackBlock[i];
|
|
19362
|
-
const
|
|
19363
|
-
|
|
19364
|
-
|
|
19365
|
-
const normalized = normalizeXhtmlVoidElements(feedback.content, `feedbackBlock[${i}]`);
|
|
19366
|
-
diagnostics.push(...normalized.diagnostics);
|
|
19367
|
-
feedbackContent = normalized.content;
|
|
19368
|
-
} else feedbackContent = escapeXml$3(feedback.content);
|
|
19420
|
+
const normalized = normalizeHtmlContentBody(feedback.content, `feedbackBlock[${i}]`);
|
|
19421
|
+
diagnostics.push(...normalized.diagnostics);
|
|
19422
|
+
const feedbackContent = normalized.content;
|
|
19369
19423
|
parts.push(`${indent2}<feedbackBlock identifier="${escapeXml$3(feedback.identifier)}" outcomeIdentifier="FEEDBACK" showHide="${feedback.showHide}">${feedbackContent}</feedbackBlock>`);
|
|
19370
19424
|
parts.push(nl);
|
|
19371
19425
|
}
|
|
@@ -19492,8 +19546,7 @@ function buildTextEntryInteractionXml(interaction, diagnostics, parts, indent, i
|
|
|
19492
19546
|
parts.push(nl);
|
|
19493
19547
|
}
|
|
19494
19548
|
let template = interaction.template;
|
|
19495
|
-
|
|
19496
|
-
if (hasHtmlTags) {
|
|
19549
|
+
{
|
|
19497
19550
|
const normalized = normalizeXhtmlVoidElements(template, "textEntryInteraction.template");
|
|
19498
19551
|
diagnostics.push(...normalized.diagnostics);
|
|
19499
19552
|
template = normalized.content;
|
|
@@ -19506,7 +19559,7 @@ function buildTextEntryInteractionXml(interaction, diagnostics, parts, indent, i
|
|
|
19506
19559
|
while ((match = placeholderRegex.exec(template)) !== null) {
|
|
19507
19560
|
if (match.index > lastIndex) {
|
|
19508
19561
|
const textSegment = template.substring(lastIndex, match.index);
|
|
19509
|
-
segments.push(
|
|
19562
|
+
segments.push(textSegment);
|
|
19510
19563
|
}
|
|
19511
19564
|
if (entryIndex < interaction.textEntries.length) {
|
|
19512
19565
|
const entry = interaction.textEntries[entryIndex];
|
|
@@ -19522,7 +19575,7 @@ function buildTextEntryInteractionXml(interaction, diagnostics, parts, indent, i
|
|
|
19522
19575
|
}
|
|
19523
19576
|
if (lastIndex < template.length) {
|
|
19524
19577
|
const textSegment = template.substring(lastIndex);
|
|
19525
|
-
segments.push(
|
|
19578
|
+
segments.push(textSegment);
|
|
19526
19579
|
}
|
|
19527
19580
|
parts.push(`${indent2}<div>`);
|
|
19528
19581
|
parts.push(segments.join(""));
|
|
@@ -19570,11 +19623,9 @@ function buildExtendedTextInteractionXml(interaction, outcomeDeclaration, diagno
|
|
|
19570
19623
|
parts.push(`${indent}<itemBody>`);
|
|
19571
19624
|
parts.push(nl);
|
|
19572
19625
|
if (interaction.prompt) {
|
|
19573
|
-
|
|
19574
|
-
|
|
19575
|
-
|
|
19576
|
-
parts.push(`${indent2}${normalized.content}`);
|
|
19577
|
-
} else parts.push(`${indent2}<p>${escapeXml$3(interaction.prompt)}</p>`);
|
|
19626
|
+
const normalized = normalizePromptContent(interaction.prompt, "itemBody.prompt");
|
|
19627
|
+
diagnostics.push(...normalized.diagnostics);
|
|
19628
|
+
parts.push(`${indent2}${normalized.content}`);
|
|
19578
19629
|
parts.push(nl);
|
|
19579
19630
|
}
|
|
19580
19631
|
let interactionTag = `${indent2}<extendedTextInteraction responseIdentifier="${interaction.responseIdentifier}"`;
|
|
@@ -19608,11 +19659,9 @@ function buildUploadInteractionXml(interaction, diagnostics, parts, indent, inde
|
|
|
19608
19659
|
parts.push(`${indent}<itemBody>`);
|
|
19609
19660
|
parts.push(nl);
|
|
19610
19661
|
if (interaction.prompt) {
|
|
19611
|
-
|
|
19612
|
-
|
|
19613
|
-
|
|
19614
|
-
parts.push(`${indent2}${normalized.content}`);
|
|
19615
|
-
} else parts.push(`${indent2}<p>${escapeXml$3(interaction.prompt)}</p>`);
|
|
19662
|
+
const normalized = normalizePromptContent(interaction.prompt, "itemBody.prompt");
|
|
19663
|
+
diagnostics.push(...normalized.diagnostics);
|
|
19664
|
+
parts.push(`${indent2}${normalized.content}`);
|
|
19616
19665
|
parts.push(nl);
|
|
19617
19666
|
}
|
|
19618
19667
|
let interactionTag = `${indent2}<uploadInteraction responseIdentifier="${interaction.responseIdentifier}"`;
|
|
@@ -19649,14 +19698,15 @@ function buildDrawingInteractionXml(interaction, diagnostics, parts, indent, ind
|
|
|
19649
19698
|
parts.push(nl);
|
|
19650
19699
|
parts.push(`${indent3}<prompt>`);
|
|
19651
19700
|
if (interaction.prompt) {
|
|
19652
|
-
|
|
19653
|
-
|
|
19654
|
-
|
|
19701
|
+
const hasHtmlTags = /<[a-zA-Z][\s\S]*?>/.test(interaction.prompt);
|
|
19702
|
+
const normalized = normalizeHtmlContentBody(interaction.prompt, "drawingInteraction.prompt");
|
|
19703
|
+
diagnostics.push(...normalized.diagnostics);
|
|
19704
|
+
if (hasHtmlTags) {
|
|
19655
19705
|
parts.push(nl);
|
|
19656
19706
|
parts.push(`${indent3} ${normalized.content}`);
|
|
19657
19707
|
parts.push(nl);
|
|
19658
19708
|
parts.push(`${indent3}`);
|
|
19659
|
-
} else parts.push(
|
|
19709
|
+
} else parts.push(normalized.content);
|
|
19660
19710
|
}
|
|
19661
19711
|
parts.push(`</prompt>`);
|
|
19662
19712
|
parts.push(nl);
|
|
@@ -19727,11 +19777,9 @@ function buildInlineChoiceInteractionXml(interaction, diagnostics, parts, indent
|
|
|
19727
19777
|
parts.push(`${indent}<itemBody>`);
|
|
19728
19778
|
parts.push(nl);
|
|
19729
19779
|
if (interaction.prompt) {
|
|
19730
|
-
|
|
19731
|
-
|
|
19732
|
-
|
|
19733
|
-
parts.push(`${indent2}${normalized.content}`);
|
|
19734
|
-
} else parts.push(`${indent2}<p>${escapeXml$3(interaction.prompt)}</p>`);
|
|
19780
|
+
const normalized = normalizePromptContent(interaction.prompt, "itemBody.prompt");
|
|
19781
|
+
diagnostics.push(...normalized.diagnostics);
|
|
19782
|
+
parts.push(`${indent2}${normalized.content}`);
|
|
19735
19783
|
parts.push(nl);
|
|
19736
19784
|
}
|
|
19737
19785
|
if (interaction.template && interaction.inlineChoiceEntries) {
|
|
@@ -19741,10 +19789,7 @@ function buildInlineChoiceInteractionXml(interaction, diagnostics, parts, indent
|
|
|
19741
19789
|
let inlineChoiceXml = `<inlineChoiceInteraction responseIdentifier="${entry.responseIdentifier}"`;
|
|
19742
19790
|
if (entry.shuffle) inlineChoiceXml += ` shuffle="true"`;
|
|
19743
19791
|
inlineChoiceXml += ">";
|
|
19744
|
-
for (const choice of entry.inlineChoices) {
|
|
19745
|
-
const choiceContent = /<[a-zA-Z][\s\S]*?>/.test(choice.content) ? choice.content : escapeXml$3(choice.content);
|
|
19746
|
-
inlineChoiceXml += `<inlineChoice identifier="${escapeXml$3(choice.identifier)}">${choiceContent}</inlineChoice>`;
|
|
19747
|
-
}
|
|
19792
|
+
for (const choice of entry.inlineChoices) inlineChoiceXml += `<inlineChoice identifier="${escapeXml$3(choice.identifier)}">${choice.content}</inlineChoice>`;
|
|
19748
19793
|
inlineChoiceXml += "</inlineChoiceInteraction>";
|
|
19749
19794
|
templateHtml = templateHtml.replace("{{response}}", inlineChoiceXml);
|
|
19750
19795
|
}
|
|
@@ -19800,11 +19845,9 @@ function buildGapMatchInteractionXml(interaction, diagnostics, parts, indent, in
|
|
|
19800
19845
|
parts.push(`${indent}<itemBody>`);
|
|
19801
19846
|
parts.push(nl);
|
|
19802
19847
|
if (interaction.prompt) {
|
|
19803
|
-
|
|
19804
|
-
|
|
19805
|
-
|
|
19806
|
-
parts.push(`${indent2}${normalized.content}`);
|
|
19807
|
-
} else parts.push(`${indent2}<p>${escapeXml$3(interaction.prompt)}</p>`);
|
|
19848
|
+
const normalized = normalizePromptContent(interaction.prompt, "itemBody.prompt");
|
|
19849
|
+
diagnostics.push(...normalized.diagnostics);
|
|
19850
|
+
parts.push(`${indent2}${normalized.content}`);
|
|
19808
19851
|
parts.push(nl);
|
|
19809
19852
|
}
|
|
19810
19853
|
parts.push(`${indent2}<gapMatchInteraction responseIdentifier="${interaction.responseIdentifier}"`);
|
|
@@ -19812,11 +19855,9 @@ function buildGapMatchInteractionXml(interaction, diagnostics, parts, indent, in
|
|
|
19812
19855
|
parts.push(">");
|
|
19813
19856
|
parts.push(nl);
|
|
19814
19857
|
if (interaction.gapTexts) for (const gapText of interaction.gapTexts) {
|
|
19815
|
-
const
|
|
19816
|
-
|
|
19817
|
-
|
|
19818
|
-
else gapTextContent = escapeXml$3(gapText.content);
|
|
19819
|
-
parts.push(`${indent3}<gapText identifier="${escapeXml$3(gapText.identifier)}" matchMax="1">${gapTextContent}</gapText>`);
|
|
19858
|
+
const normalized = normalizeHtmlContentBody(gapText.content, `itemBody.gapText.${gapText.identifier}`);
|
|
19859
|
+
diagnostics.push(...normalized.diagnostics);
|
|
19860
|
+
parts.push(`${indent3}<gapText identifier="${escapeXml$3(gapText.identifier)}" matchMax="1">${normalized.content}</gapText>`);
|
|
19820
19861
|
parts.push(nl);
|
|
19821
19862
|
}
|
|
19822
19863
|
if (interaction.template && interaction.gapEntries) {
|
|
@@ -19880,15 +19921,10 @@ function buildOrderInteractionXml(interaction, diagnostics, parts, indent, inden
|
|
|
19880
19921
|
parts.push(`${indent}<itemBody>`);
|
|
19881
19922
|
parts.push(nl);
|
|
19882
19923
|
if (interaction.prompt) {
|
|
19883
|
-
|
|
19884
|
-
|
|
19885
|
-
|
|
19886
|
-
|
|
19887
|
-
parts.push(nl);
|
|
19888
|
-
} else {
|
|
19889
|
-
parts.push(`${indent2}<p>${escapeXml$3(interaction.prompt)}</p>`);
|
|
19890
|
-
parts.push(nl);
|
|
19891
|
-
}
|
|
19924
|
+
const normalized = normalizePromptContent(interaction.prompt, "itemBody.prompt");
|
|
19925
|
+
diagnostics.push(...normalized.diagnostics);
|
|
19926
|
+
parts.push(`${indent2}${normalized.content}`);
|
|
19927
|
+
parts.push(nl);
|
|
19892
19928
|
}
|
|
19893
19929
|
parts.push(`${indent2}<orderInteraction responseIdentifier="${interaction.responseIdentifier}"`);
|
|
19894
19930
|
if (interaction.shuffle) parts.push(` shuffle="true"`);
|
|
@@ -19897,11 +19933,9 @@ function buildOrderInteractionXml(interaction, diagnostics, parts, indent, inden
|
|
|
19897
19933
|
parts.push(nl);
|
|
19898
19934
|
for (const choice of interaction.choices) {
|
|
19899
19935
|
parts.push(`${indent3}<simpleChoice identifier="${escapeXml$3(choice.identifier)}">`);
|
|
19900
|
-
|
|
19901
|
-
|
|
19902
|
-
|
|
19903
|
-
parts.push(normalized.content);
|
|
19904
|
-
} else parts.push(escapeXml$3(choice.content));
|
|
19936
|
+
const normalized = normalizeHtmlContentBody(choice.content, `itemBody.choice.${choice.identifier}`);
|
|
19937
|
+
diagnostics.push(...normalized.diagnostics);
|
|
19938
|
+
parts.push(normalized.content);
|
|
19905
19939
|
parts.push("</simpleChoice>");
|
|
19906
19940
|
parts.push(nl);
|
|
19907
19941
|
}
|
|
@@ -20020,15 +20054,10 @@ function buildHottextInteractionXml(interaction, diagnostics, parts, indent, ind
|
|
|
20020
20054
|
parts.push(`${indent}<itemBody>`);
|
|
20021
20055
|
parts.push(nl);
|
|
20022
20056
|
if (interaction.prompt) {
|
|
20023
|
-
|
|
20024
|
-
|
|
20025
|
-
|
|
20026
|
-
|
|
20027
|
-
parts.push(nl);
|
|
20028
|
-
} else {
|
|
20029
|
-
parts.push(`${indent2}<p>${escapeXml$3(interaction.prompt)}</p>`);
|
|
20030
|
-
parts.push(nl);
|
|
20031
|
-
}
|
|
20057
|
+
const normalized = normalizePromptContent(interaction.prompt, "itemBody.prompt");
|
|
20058
|
+
diagnostics.push(...normalized.diagnostics);
|
|
20059
|
+
parts.push(`${indent2}${normalized.content}`);
|
|
20060
|
+
parts.push(nl);
|
|
20032
20061
|
}
|
|
20033
20062
|
parts.push(`${indent2}<hottextInteraction responseIdentifier="${interaction.responseIdentifier}" maxChoices="${interaction.correctResponse?.length || 0}">`);
|
|
20034
20063
|
parts.push(nl);
|
|
@@ -20138,15 +20167,10 @@ function buildGraphicGapMatchInteractionXml(interaction, diagnostics, parts, ind
|
|
|
20138
20167
|
parts.push(`${indent}<itemBody>`);
|
|
20139
20168
|
parts.push(nl);
|
|
20140
20169
|
if (interaction.prompt) {
|
|
20141
|
-
|
|
20142
|
-
|
|
20143
|
-
|
|
20144
|
-
|
|
20145
|
-
parts.push(nl);
|
|
20146
|
-
} else {
|
|
20147
|
-
parts.push(`${indent2}<p>${escapeXml$3(interaction.prompt)}</p>`);
|
|
20148
|
-
parts.push(nl);
|
|
20149
|
-
}
|
|
20170
|
+
const normalized = normalizePromptContent(interaction.prompt, "itemBody.prompt");
|
|
20171
|
+
diagnostics.push(...normalized.diagnostics);
|
|
20172
|
+
parts.push(`${indent2}${normalized.content}`);
|
|
20173
|
+
parts.push(nl);
|
|
20150
20174
|
}
|
|
20151
20175
|
parts.push(`${indent2}<graphicGapMatchInteraction responseIdentifier="${interaction.responseIdentifier}" shuffle="${interaction.shuffle}">`);
|
|
20152
20176
|
parts.push(nl);
|
|
@@ -20224,11 +20248,9 @@ function buildAssociateInteractionXml(interaction, diagnostics, parts, indent, i
|
|
|
20224
20248
|
parts.push(nl);
|
|
20225
20249
|
for (const choice of interaction.choices) {
|
|
20226
20250
|
parts.push(`${indent3}<simpleAssociableChoice identifier="${escapeXml$3(choice.identifier)}" matchMax="${choice.matchMax}">`);
|
|
20227
|
-
|
|
20228
|
-
|
|
20229
|
-
|
|
20230
|
-
parts.push(normalized.content);
|
|
20231
|
-
} else parts.push(escapeXml$3(choice.content));
|
|
20251
|
+
const normalized = normalizeHtmlContentBody(choice.content, `itemBody.choice.${choice.identifier}`);
|
|
20252
|
+
diagnostics.push(...normalized.diagnostics);
|
|
20253
|
+
parts.push(normalized.content);
|
|
20232
20254
|
parts.push("</simpleAssociableChoice>");
|
|
20233
20255
|
parts.push(nl);
|
|
20234
20256
|
}
|
|
@@ -20470,13 +20492,9 @@ function buildAssessmentItemXml(ast, pretty, version) {
|
|
|
20470
20492
|
if (ast.modalFeedback && ast.modalFeedback.length > 0) for (let i = 0; i < ast.modalFeedback.length; i++) {
|
|
20471
20493
|
const typedFeedback = ast.modalFeedback[i];
|
|
20472
20494
|
let feedbackXml = `${indent}<modalFeedback identifier="${escapeXml$3(typedFeedback.identifier)}" outcomeIdentifier="${escapeXml$3(typedFeedback.outcomeIdentifier)}" showHide="${typedFeedback.showHide}">${nl}`;
|
|
20473
|
-
const
|
|
20474
|
-
|
|
20475
|
-
|
|
20476
|
-
const normalized = normalizeXhtmlVoidElements(typedFeedback.content, `modalFeedback[${i}]`);
|
|
20477
|
-
diagnostics.push(...normalized.diagnostics);
|
|
20478
|
-
feedbackContent = normalized.content;
|
|
20479
|
-
} else feedbackContent = escapeXml$3(typedFeedback.content);
|
|
20495
|
+
const normalized = normalizeHtmlContentBody(typedFeedback.content, `modalFeedback[${i}]`);
|
|
20496
|
+
diagnostics.push(...normalized.diagnostics);
|
|
20497
|
+
const feedbackContent = normalized.content;
|
|
20480
20498
|
feedbackXml += `${indent2}${feedbackContent}${nl}`;
|
|
20481
20499
|
feedbackXml += `${indent}</modalFeedback>${nl}`;
|
|
20482
20500
|
sections.modalFeedback.push(feedbackXml);
|