@learnosity/lib-qti-converter 0.12.2 → 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/package.json +9 -9
- package/packages/cli/dist/{create-prompt-COXnAzFl.js → create-prompt-DU9wLVhI.js} +23 -18
- package/packages/cli/dist/create-prompt-DU9wLVhI.js.map +1 -0
- package/packages/cli/dist/{dist-CVD-X-DZ.js → dist-DjpU2mIj.js} +7 -7
- package/packages/cli/dist/dist-DjpU2mIj.js.map +1 -0
- package/packages/cli/dist/{learnosityToQti-sKxcj5Hi.js → learnosityToQti-B0PoimXr.js} +3 -3
- package/packages/cli/dist/{learnosityToQti-sKxcj5Hi.js.map → learnosityToQti-B0PoimXr.js.map} +1 -1
- package/packages/cli/dist/{learnosityToQtiPackage-Ij4cM39M.js → learnosityToQtiPackage-RyClxvZj.js} +5 -5
- package/packages/cli/dist/{learnosityToQtiPackage-Ij4cM39M.js.map → learnosityToQtiPackage-RyClxvZj.js.map} +1 -1
- package/packages/cli/dist/main.js +5 -5
- package/packages/cli/dist/{pathUtils-Cz2GpPEb.js → pathUtils-CwZnJ55s.js} +5 -5
- package/packages/cli/dist/pathUtils-CwZnJ55s.js.map +1 -0
- package/packages/cli/dist/{qtiPackageToLearnosity-CvXdmwsb.js → qtiPackageToLearnosity-0rkZKKOK.js} +2 -2
- package/packages/cli/dist/{qtiPackageToLearnosity-CvXdmwsb.js.map → qtiPackageToLearnosity-0rkZKKOK.js.map} +1 -1
- package/packages/cli/dist/{qtiToLearnosity-CkD0r1q0.js → qtiToLearnosity-jiFTBiQU.js} +3 -3
- package/packages/cli/dist/{qtiToLearnosity-CkD0r1q0.js.map → qtiToLearnosity-jiFTBiQU.js.map} +1 -1
- package/packages/cli/dist/{resolveOptions-CfXUqGkd.js → resolveOptions-gH_YAxxc.js} +163 -147
- package/packages/cli/dist/resolveOptions-gH_YAxxc.js.map +1 -0
- package/packages/core/dist/index.js +159 -143
- package/packages/core/dist/node.js +159 -143
- package/packages/cli/dist/create-prompt-COXnAzFl.js.map +0 -1
- package/packages/cli/dist/dist-CVD-X-DZ.js.map +0 -1
- package/packages/cli/dist/pathUtils-Cz2GpPEb.js.map +0 -1
- package/packages/cli/dist/resolveOptions-CfXUqGkd.js.map +0 -1
|
@@ -14146,8 +14146,8 @@ var require_CSSStyleDeclaration = /* @__PURE__ */ __commonJSMin(((exports) => {
|
|
|
14146
14146
|
return properties.join(" ");
|
|
14147
14147
|
},
|
|
14148
14148
|
set cssText(text) {
|
|
14149
|
-
var i, name;
|
|
14150
|
-
for (
|
|
14149
|
+
var i = this.length, name;
|
|
14150
|
+
for (; i--;) {
|
|
14151
14151
|
name = this[i];
|
|
14152
14152
|
this[name] = "";
|
|
14153
14153
|
}
|
|
@@ -16315,7 +16315,7 @@ function replaceNbspEntity(html, file) {
|
|
|
16315
16315
|
*/
|
|
16316
16316
|
function normalizeXhtmlVoidElements(html, file) {
|
|
16317
16317
|
const allDiagnostics = [];
|
|
16318
|
-
const centerResult = normalizeCenterTags(html, file);
|
|
16318
|
+
const centerResult = normalizeCenterTags(html.replace(/[\u0000-\u0008\u000B\u000C\u000E-\u001F\uFFFE\uFFFF]/g, ""), file);
|
|
16319
16319
|
let content = centerResult.content;
|
|
16320
16320
|
allDiagnostics.push(...centerResult.diagnostics);
|
|
16321
16321
|
const underlineResult = normalizeUnderlineTags(content, file);
|
|
@@ -18510,15 +18510,90 @@ const XML_ESCAPE_MAP = {
|
|
|
18510
18510
|
};
|
|
18511
18511
|
const XML_ESCAPE_PATTERN = /[&<>"']/g;
|
|
18512
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
|
+
/**
|
|
18513
18542
|
* Escape XML special characters.
|
|
18514
18543
|
*
|
|
18515
|
-
*
|
|
18516
|
-
*
|
|
18517
|
-
*
|
|
18518
|
-
*
|
|
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).
|
|
18519
18550
|
*/
|
|
18520
18551
|
function escapeXml$3(text) {
|
|
18521
|
-
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);
|
|
18522
18597
|
}
|
|
18523
18598
|
/**
|
|
18524
18599
|
* Infer MIME type from file extension
|
|
@@ -18967,22 +19042,18 @@ function renderInteractionXml(interaction, diagnostics, indent, nl) {
|
|
|
18967
19042
|
if (interaction.type === "choice") {
|
|
18968
19043
|
const choiceInteraction = interaction;
|
|
18969
19044
|
if (choiceInteraction.prompt) {
|
|
18970
|
-
|
|
18971
|
-
|
|
18972
|
-
|
|
18973
|
-
parts.push(normalized.content);
|
|
18974
|
-
} 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);
|
|
18975
19048
|
}
|
|
18976
19049
|
const minChoicesAttr = choiceInteraction.minChoices !== void 0 ? ` minChoices="${choiceInteraction.minChoices}"` : "";
|
|
18977
19050
|
parts.push(`<choiceInteraction responseIdentifier="${choiceInteraction.responseIdentifier}" shuffle="${choiceInteraction.shuffle}"${minChoicesAttr} maxChoices="${choiceInteraction.maxChoices}">`);
|
|
18978
19051
|
parts.push(nl);
|
|
18979
19052
|
for (const choice of choiceInteraction.choices) {
|
|
18980
19053
|
parts.push(`${indent}<simpleChoice identifier="${escapeXml$3(choice.identifier)}">`);
|
|
18981
|
-
|
|
18982
|
-
|
|
18983
|
-
|
|
18984
|
-
parts.push(normalized.content);
|
|
18985
|
-
} 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);
|
|
18986
19057
|
parts.push("</simpleChoice>");
|
|
18987
19058
|
parts.push(nl);
|
|
18988
19059
|
}
|
|
@@ -18990,11 +19061,9 @@ function renderInteractionXml(interaction, diagnostics, indent, nl) {
|
|
|
18990
19061
|
} else if (interaction.type === "textEntry") {
|
|
18991
19062
|
const textEntryInteraction = interaction;
|
|
18992
19063
|
if (textEntryInteraction.prompt) {
|
|
18993
|
-
|
|
18994
|
-
|
|
18995
|
-
|
|
18996
|
-
parts.push(normalized.content);
|
|
18997
|
-
} 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);
|
|
18998
19067
|
}
|
|
18999
19068
|
let textEntryTag = `<textEntryInteraction responseIdentifier="${textEntryInteraction.responseIdentifier}"`;
|
|
19000
19069
|
if (textEntryInteraction.placeholderText) textEntryTag += ` placeholderText="${escapeXml$3(textEntryInteraction.placeholderText)}"`;
|
|
@@ -19045,10 +19114,7 @@ function renderInteractionXml(interaction, diagnostics, indent, nl) {
|
|
|
19045
19114
|
let inlineChoiceXml = `<inlineChoiceInteraction responseIdentifier="${entry.responseIdentifier}"`;
|
|
19046
19115
|
if (entry.shuffle) inlineChoiceXml += ` shuffle="true"`;
|
|
19047
19116
|
inlineChoiceXml += ">";
|
|
19048
|
-
for (const choice of entry.inlineChoices) {
|
|
19049
|
-
const choiceContent = /<[a-zA-Z][\s\S]*?>/.test(choice.content) ? choice.content : escapeXml$3(choice.content);
|
|
19050
|
-
inlineChoiceXml += `<inlineChoice identifier="${escapeXml$3(choice.identifier)}">${choiceContent}</inlineChoice>`;
|
|
19051
|
-
}
|
|
19117
|
+
for (const choice of entry.inlineChoices) inlineChoiceXml += `<inlineChoice identifier="${escapeXml$3(choice.identifier)}">${choice.content}</inlineChoice>`;
|
|
19052
19118
|
inlineChoiceXml += "</inlineChoiceInteraction>";
|
|
19053
19119
|
templateHtml = templateHtml.replace("{{response}}", inlineChoiceXml);
|
|
19054
19120
|
}
|
|
@@ -19072,7 +19138,9 @@ function renderInteractionXml(interaction, diagnostics, indent, nl) {
|
|
|
19072
19138
|
parts.push(">");
|
|
19073
19139
|
parts.push(nl);
|
|
19074
19140
|
if (gapMatchInteraction.gapTexts) for (const gapText of gapMatchInteraction.gapTexts) {
|
|
19075
|
-
|
|
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>`);
|
|
19076
19144
|
parts.push(nl);
|
|
19077
19145
|
}
|
|
19078
19146
|
if (gapMatchInteraction.template && gapMatchInteraction.gapEntries) {
|
|
@@ -19106,11 +19174,9 @@ function renderInteractionXml(interaction, diagnostics, indent, nl) {
|
|
|
19106
19174
|
parts.push(nl);
|
|
19107
19175
|
for (const choice of orderInteraction.choices) {
|
|
19108
19176
|
parts.push(`${indent}<simpleChoice identifier="${escapeXml$3(choice.identifier)}">`);
|
|
19109
|
-
|
|
19110
|
-
|
|
19111
|
-
|
|
19112
|
-
parts.push(normalized.content);
|
|
19113
|
-
} 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);
|
|
19114
19180
|
parts.push("</simpleChoice>");
|
|
19115
19181
|
parts.push(nl);
|
|
19116
19182
|
}
|
|
@@ -19135,11 +19201,9 @@ function renderInteractionXml(interaction, diagnostics, indent, nl) {
|
|
|
19135
19201
|
parts.push(nl);
|
|
19136
19202
|
for (const choice of matchInteraction.sourceSet) {
|
|
19137
19203
|
parts.push(`${indent}${indent}<simpleAssociableChoice identifier="${escapeXml$3(choice.identifier)}" matchMax="${choice.matchMax}">`);
|
|
19138
|
-
|
|
19139
|
-
|
|
19140
|
-
|
|
19141
|
-
parts.push(normalized.content);
|
|
19142
|
-
} 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);
|
|
19143
19207
|
parts.push("</simpleAssociableChoice>");
|
|
19144
19208
|
parts.push(nl);
|
|
19145
19209
|
}
|
|
@@ -19149,11 +19213,9 @@ function renderInteractionXml(interaction, diagnostics, indent, nl) {
|
|
|
19149
19213
|
parts.push(nl);
|
|
19150
19214
|
for (const choice of matchInteraction.targetSet) {
|
|
19151
19215
|
parts.push(`${indent}${indent}<simpleAssociableChoice identifier="${escapeXml$3(choice.identifier)}" matchMax="${choice.matchMax}">`);
|
|
19152
|
-
|
|
19153
|
-
|
|
19154
|
-
|
|
19155
|
-
parts.push(normalized.content);
|
|
19156
|
-
} 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);
|
|
19157
19219
|
parts.push("</simpleAssociableChoice>");
|
|
19158
19220
|
parts.push(nl);
|
|
19159
19221
|
}
|
|
@@ -19243,11 +19305,9 @@ function renderInteractionXml(interaction, diagnostics, indent, nl) {
|
|
|
19243
19305
|
parts.push(nl);
|
|
19244
19306
|
for (const choice of associateInteraction.choices) {
|
|
19245
19307
|
parts.push(`${indent}<simpleAssociableChoice identifier="${escapeXml$3(choice.identifier)}" matchMax="${choice.matchMax}">`);
|
|
19246
|
-
|
|
19247
|
-
|
|
19248
|
-
|
|
19249
|
-
parts.push(normalized.content);
|
|
19250
|
-
} 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);
|
|
19251
19311
|
parts.push("</simpleAssociableChoice>");
|
|
19252
19312
|
parts.push(nl);
|
|
19253
19313
|
}
|
|
@@ -19346,13 +19406,9 @@ function buildChoiceInteractionXml(interaction, feedbackBlock, diagnostics, part
|
|
|
19346
19406
|
parts.push(nl);
|
|
19347
19407
|
for (let i = 0; i < interaction.choices.length; i++) {
|
|
19348
19408
|
const choice = interaction.choices[i];
|
|
19349
|
-
const
|
|
19350
|
-
|
|
19351
|
-
|
|
19352
|
-
const normalized = normalizeXhtmlVoidElements(choice.content, `choiceInteraction.simpleChoice[${i}]`);
|
|
19353
|
-
diagnostics.push(...normalized.diagnostics);
|
|
19354
|
-
choiceContent = normalized.content;
|
|
19355
|
-
} 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;
|
|
19356
19412
|
const feedbackAttr = choice.feedbackBlockIdentifier ? ` feedbackBlock="${escapeXml$3(choice.feedbackBlockIdentifier)}"` : "";
|
|
19357
19413
|
parts.push(`${indent3}<simpleChoice identifier="${escapeXml$3(choice.identifier)}"${feedbackAttr}>${choiceContent}</simpleChoice>`);
|
|
19358
19414
|
parts.push(nl);
|
|
@@ -19361,13 +19417,9 @@ function buildChoiceInteractionXml(interaction, feedbackBlock, diagnostics, part
|
|
|
19361
19417
|
parts.push(nl);
|
|
19362
19418
|
if (feedbackBlock && feedbackBlock.length > 0) for (let i = 0; i < feedbackBlock.length; i++) {
|
|
19363
19419
|
const feedback = feedbackBlock[i];
|
|
19364
|
-
const
|
|
19365
|
-
|
|
19366
|
-
|
|
19367
|
-
const normalized = normalizeXhtmlVoidElements(feedback.content, `feedbackBlock[${i}]`);
|
|
19368
|
-
diagnostics.push(...normalized.diagnostics);
|
|
19369
|
-
feedbackContent = normalized.content;
|
|
19370
|
-
} else feedbackContent = escapeXml$3(feedback.content);
|
|
19420
|
+
const normalized = normalizeHtmlContentBody(feedback.content, `feedbackBlock[${i}]`);
|
|
19421
|
+
diagnostics.push(...normalized.diagnostics);
|
|
19422
|
+
const feedbackContent = normalized.content;
|
|
19371
19423
|
parts.push(`${indent2}<feedbackBlock identifier="${escapeXml$3(feedback.identifier)}" outcomeIdentifier="FEEDBACK" showHide="${feedback.showHide}">${feedbackContent}</feedbackBlock>`);
|
|
19372
19424
|
parts.push(nl);
|
|
19373
19425
|
}
|
|
@@ -19494,8 +19546,7 @@ function buildTextEntryInteractionXml(interaction, diagnostics, parts, indent, i
|
|
|
19494
19546
|
parts.push(nl);
|
|
19495
19547
|
}
|
|
19496
19548
|
let template = interaction.template;
|
|
19497
|
-
|
|
19498
|
-
if (hasHtmlTags) {
|
|
19549
|
+
{
|
|
19499
19550
|
const normalized = normalizeXhtmlVoidElements(template, "textEntryInteraction.template");
|
|
19500
19551
|
diagnostics.push(...normalized.diagnostics);
|
|
19501
19552
|
template = normalized.content;
|
|
@@ -19508,7 +19559,7 @@ function buildTextEntryInteractionXml(interaction, diagnostics, parts, indent, i
|
|
|
19508
19559
|
while ((match = placeholderRegex.exec(template)) !== null) {
|
|
19509
19560
|
if (match.index > lastIndex) {
|
|
19510
19561
|
const textSegment = template.substring(lastIndex, match.index);
|
|
19511
|
-
segments.push(
|
|
19562
|
+
segments.push(textSegment);
|
|
19512
19563
|
}
|
|
19513
19564
|
if (entryIndex < interaction.textEntries.length) {
|
|
19514
19565
|
const entry = interaction.textEntries[entryIndex];
|
|
@@ -19524,7 +19575,7 @@ function buildTextEntryInteractionXml(interaction, diagnostics, parts, indent, i
|
|
|
19524
19575
|
}
|
|
19525
19576
|
if (lastIndex < template.length) {
|
|
19526
19577
|
const textSegment = template.substring(lastIndex);
|
|
19527
|
-
segments.push(
|
|
19578
|
+
segments.push(textSegment);
|
|
19528
19579
|
}
|
|
19529
19580
|
parts.push(`${indent2}<div>`);
|
|
19530
19581
|
parts.push(segments.join(""));
|
|
@@ -19572,11 +19623,9 @@ function buildExtendedTextInteractionXml(interaction, outcomeDeclaration, diagno
|
|
|
19572
19623
|
parts.push(`${indent}<itemBody>`);
|
|
19573
19624
|
parts.push(nl);
|
|
19574
19625
|
if (interaction.prompt) {
|
|
19575
|
-
|
|
19576
|
-
|
|
19577
|
-
|
|
19578
|
-
parts.push(`${indent2}${normalized.content}`);
|
|
19579
|
-
} 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}`);
|
|
19580
19629
|
parts.push(nl);
|
|
19581
19630
|
}
|
|
19582
19631
|
let interactionTag = `${indent2}<extendedTextInteraction responseIdentifier="${interaction.responseIdentifier}"`;
|
|
@@ -19610,11 +19659,9 @@ function buildUploadInteractionXml(interaction, diagnostics, parts, indent, inde
|
|
|
19610
19659
|
parts.push(`${indent}<itemBody>`);
|
|
19611
19660
|
parts.push(nl);
|
|
19612
19661
|
if (interaction.prompt) {
|
|
19613
|
-
|
|
19614
|
-
|
|
19615
|
-
|
|
19616
|
-
parts.push(`${indent2}${normalized.content}`);
|
|
19617
|
-
} 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}`);
|
|
19618
19665
|
parts.push(nl);
|
|
19619
19666
|
}
|
|
19620
19667
|
let interactionTag = `${indent2}<uploadInteraction responseIdentifier="${interaction.responseIdentifier}"`;
|
|
@@ -19651,14 +19698,15 @@ function buildDrawingInteractionXml(interaction, diagnostics, parts, indent, ind
|
|
|
19651
19698
|
parts.push(nl);
|
|
19652
19699
|
parts.push(`${indent3}<prompt>`);
|
|
19653
19700
|
if (interaction.prompt) {
|
|
19654
|
-
|
|
19655
|
-
|
|
19656
|
-
|
|
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) {
|
|
19657
19705
|
parts.push(nl);
|
|
19658
19706
|
parts.push(`${indent3} ${normalized.content}`);
|
|
19659
19707
|
parts.push(nl);
|
|
19660
19708
|
parts.push(`${indent3}`);
|
|
19661
|
-
} else parts.push(
|
|
19709
|
+
} else parts.push(normalized.content);
|
|
19662
19710
|
}
|
|
19663
19711
|
parts.push(`</prompt>`);
|
|
19664
19712
|
parts.push(nl);
|
|
@@ -19729,11 +19777,9 @@ function buildInlineChoiceInteractionXml(interaction, diagnostics, parts, indent
|
|
|
19729
19777
|
parts.push(`${indent}<itemBody>`);
|
|
19730
19778
|
parts.push(nl);
|
|
19731
19779
|
if (interaction.prompt) {
|
|
19732
|
-
|
|
19733
|
-
|
|
19734
|
-
|
|
19735
|
-
parts.push(`${indent2}${normalized.content}`);
|
|
19736
|
-
} 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}`);
|
|
19737
19783
|
parts.push(nl);
|
|
19738
19784
|
}
|
|
19739
19785
|
if (interaction.template && interaction.inlineChoiceEntries) {
|
|
@@ -19743,10 +19789,7 @@ function buildInlineChoiceInteractionXml(interaction, diagnostics, parts, indent
|
|
|
19743
19789
|
let inlineChoiceXml = `<inlineChoiceInteraction responseIdentifier="${entry.responseIdentifier}"`;
|
|
19744
19790
|
if (entry.shuffle) inlineChoiceXml += ` shuffle="true"`;
|
|
19745
19791
|
inlineChoiceXml += ">";
|
|
19746
|
-
for (const choice of entry.inlineChoices) {
|
|
19747
|
-
const choiceContent = /<[a-zA-Z][\s\S]*?>/.test(choice.content) ? choice.content : escapeXml$3(choice.content);
|
|
19748
|
-
inlineChoiceXml += `<inlineChoice identifier="${escapeXml$3(choice.identifier)}">${choiceContent}</inlineChoice>`;
|
|
19749
|
-
}
|
|
19792
|
+
for (const choice of entry.inlineChoices) inlineChoiceXml += `<inlineChoice identifier="${escapeXml$3(choice.identifier)}">${choice.content}</inlineChoice>`;
|
|
19750
19793
|
inlineChoiceXml += "</inlineChoiceInteraction>";
|
|
19751
19794
|
templateHtml = templateHtml.replace("{{response}}", inlineChoiceXml);
|
|
19752
19795
|
}
|
|
@@ -19802,11 +19845,9 @@ function buildGapMatchInteractionXml(interaction, diagnostics, parts, indent, in
|
|
|
19802
19845
|
parts.push(`${indent}<itemBody>`);
|
|
19803
19846
|
parts.push(nl);
|
|
19804
19847
|
if (interaction.prompt) {
|
|
19805
|
-
|
|
19806
|
-
|
|
19807
|
-
|
|
19808
|
-
parts.push(`${indent2}${normalized.content}`);
|
|
19809
|
-
} 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}`);
|
|
19810
19851
|
parts.push(nl);
|
|
19811
19852
|
}
|
|
19812
19853
|
parts.push(`${indent2}<gapMatchInteraction responseIdentifier="${interaction.responseIdentifier}"`);
|
|
@@ -19814,11 +19855,9 @@ function buildGapMatchInteractionXml(interaction, diagnostics, parts, indent, in
|
|
|
19814
19855
|
parts.push(">");
|
|
19815
19856
|
parts.push(nl);
|
|
19816
19857
|
if (interaction.gapTexts) for (const gapText of interaction.gapTexts) {
|
|
19817
|
-
const
|
|
19818
|
-
|
|
19819
|
-
|
|
19820
|
-
else gapTextContent = escapeXml$3(gapText.content);
|
|
19821
|
-
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>`);
|
|
19822
19861
|
parts.push(nl);
|
|
19823
19862
|
}
|
|
19824
19863
|
if (interaction.template && interaction.gapEntries) {
|
|
@@ -19882,15 +19921,10 @@ function buildOrderInteractionXml(interaction, diagnostics, parts, indent, inden
|
|
|
19882
19921
|
parts.push(`${indent}<itemBody>`);
|
|
19883
19922
|
parts.push(nl);
|
|
19884
19923
|
if (interaction.prompt) {
|
|
19885
|
-
|
|
19886
|
-
|
|
19887
|
-
|
|
19888
|
-
|
|
19889
|
-
parts.push(nl);
|
|
19890
|
-
} else {
|
|
19891
|
-
parts.push(`${indent2}<p>${escapeXml$3(interaction.prompt)}</p>`);
|
|
19892
|
-
parts.push(nl);
|
|
19893
|
-
}
|
|
19924
|
+
const normalized = normalizePromptContent(interaction.prompt, "itemBody.prompt");
|
|
19925
|
+
diagnostics.push(...normalized.diagnostics);
|
|
19926
|
+
parts.push(`${indent2}${normalized.content}`);
|
|
19927
|
+
parts.push(nl);
|
|
19894
19928
|
}
|
|
19895
19929
|
parts.push(`${indent2}<orderInteraction responseIdentifier="${interaction.responseIdentifier}"`);
|
|
19896
19930
|
if (interaction.shuffle) parts.push(` shuffle="true"`);
|
|
@@ -19899,11 +19933,9 @@ function buildOrderInteractionXml(interaction, diagnostics, parts, indent, inden
|
|
|
19899
19933
|
parts.push(nl);
|
|
19900
19934
|
for (const choice of interaction.choices) {
|
|
19901
19935
|
parts.push(`${indent3}<simpleChoice identifier="${escapeXml$3(choice.identifier)}">`);
|
|
19902
|
-
|
|
19903
|
-
|
|
19904
|
-
|
|
19905
|
-
parts.push(normalized.content);
|
|
19906
|
-
} 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);
|
|
19907
19939
|
parts.push("</simpleChoice>");
|
|
19908
19940
|
parts.push(nl);
|
|
19909
19941
|
}
|
|
@@ -20022,15 +20054,10 @@ function buildHottextInteractionXml(interaction, diagnostics, parts, indent, ind
|
|
|
20022
20054
|
parts.push(`${indent}<itemBody>`);
|
|
20023
20055
|
parts.push(nl);
|
|
20024
20056
|
if (interaction.prompt) {
|
|
20025
|
-
|
|
20026
|
-
|
|
20027
|
-
|
|
20028
|
-
|
|
20029
|
-
parts.push(nl);
|
|
20030
|
-
} else {
|
|
20031
|
-
parts.push(`${indent2}<p>${escapeXml$3(interaction.prompt)}</p>`);
|
|
20032
|
-
parts.push(nl);
|
|
20033
|
-
}
|
|
20057
|
+
const normalized = normalizePromptContent(interaction.prompt, "itemBody.prompt");
|
|
20058
|
+
diagnostics.push(...normalized.diagnostics);
|
|
20059
|
+
parts.push(`${indent2}${normalized.content}`);
|
|
20060
|
+
parts.push(nl);
|
|
20034
20061
|
}
|
|
20035
20062
|
parts.push(`${indent2}<hottextInteraction responseIdentifier="${interaction.responseIdentifier}" maxChoices="${interaction.correctResponse?.length || 0}">`);
|
|
20036
20063
|
parts.push(nl);
|
|
@@ -20140,15 +20167,10 @@ function buildGraphicGapMatchInteractionXml(interaction, diagnostics, parts, ind
|
|
|
20140
20167
|
parts.push(`${indent}<itemBody>`);
|
|
20141
20168
|
parts.push(nl);
|
|
20142
20169
|
if (interaction.prompt) {
|
|
20143
|
-
|
|
20144
|
-
|
|
20145
|
-
|
|
20146
|
-
|
|
20147
|
-
parts.push(nl);
|
|
20148
|
-
} else {
|
|
20149
|
-
parts.push(`${indent2}<p>${escapeXml$3(interaction.prompt)}</p>`);
|
|
20150
|
-
parts.push(nl);
|
|
20151
|
-
}
|
|
20170
|
+
const normalized = normalizePromptContent(interaction.prompt, "itemBody.prompt");
|
|
20171
|
+
diagnostics.push(...normalized.diagnostics);
|
|
20172
|
+
parts.push(`${indent2}${normalized.content}`);
|
|
20173
|
+
parts.push(nl);
|
|
20152
20174
|
}
|
|
20153
20175
|
parts.push(`${indent2}<graphicGapMatchInteraction responseIdentifier="${interaction.responseIdentifier}" shuffle="${interaction.shuffle}">`);
|
|
20154
20176
|
parts.push(nl);
|
|
@@ -20226,11 +20248,9 @@ function buildAssociateInteractionXml(interaction, diagnostics, parts, indent, i
|
|
|
20226
20248
|
parts.push(nl);
|
|
20227
20249
|
for (const choice of interaction.choices) {
|
|
20228
20250
|
parts.push(`${indent3}<simpleAssociableChoice identifier="${escapeXml$3(choice.identifier)}" matchMax="${choice.matchMax}">`);
|
|
20229
|
-
|
|
20230
|
-
|
|
20231
|
-
|
|
20232
|
-
parts.push(normalized.content);
|
|
20233
|
-
} 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);
|
|
20234
20254
|
parts.push("</simpleAssociableChoice>");
|
|
20235
20255
|
parts.push(nl);
|
|
20236
20256
|
}
|
|
@@ -20472,13 +20492,9 @@ function buildAssessmentItemXml(ast, pretty, version) {
|
|
|
20472
20492
|
if (ast.modalFeedback && ast.modalFeedback.length > 0) for (let i = 0; i < ast.modalFeedback.length; i++) {
|
|
20473
20493
|
const typedFeedback = ast.modalFeedback[i];
|
|
20474
20494
|
let feedbackXml = `${indent}<modalFeedback identifier="${escapeXml$3(typedFeedback.identifier)}" outcomeIdentifier="${escapeXml$3(typedFeedback.outcomeIdentifier)}" showHide="${typedFeedback.showHide}">${nl}`;
|
|
20475
|
-
const
|
|
20476
|
-
|
|
20477
|
-
|
|
20478
|
-
const normalized = normalizeXhtmlVoidElements(typedFeedback.content, `modalFeedback[${i}]`);
|
|
20479
|
-
diagnostics.push(...normalized.diagnostics);
|
|
20480
|
-
feedbackContent = normalized.content;
|
|
20481
|
-
} else feedbackContent = escapeXml$3(typedFeedback.content);
|
|
20495
|
+
const normalized = normalizeHtmlContentBody(typedFeedback.content, `modalFeedback[${i}]`);
|
|
20496
|
+
diagnostics.push(...normalized.diagnostics);
|
|
20497
|
+
const feedbackContent = normalized.content;
|
|
20482
20498
|
feedbackXml += `${indent2}${feedbackContent}${nl}`;
|
|
20483
20499
|
feedbackXml += `${indent}</modalFeedback>${nl}`;
|
|
20484
20500
|
sections.modalFeedback.push(feedbackXml);
|