@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
|
@@ -14139,8 +14139,8 @@ var require_CSSStyleDeclaration = /* @__PURE__ */ __commonJSMin(((exports) => {
|
|
|
14139
14139
|
return properties.join(" ");
|
|
14140
14140
|
},
|
|
14141
14141
|
set cssText(text) {
|
|
14142
|
-
var i, name;
|
|
14143
|
-
for (
|
|
14142
|
+
var i = this.length, name;
|
|
14143
|
+
for (; i--;) {
|
|
14144
14144
|
name = this[i];
|
|
14145
14145
|
this[name] = "";
|
|
14146
14146
|
}
|
|
@@ -16308,7 +16308,7 @@ function replaceNbspEntity(html, file) {
|
|
|
16308
16308
|
*/
|
|
16309
16309
|
function normalizeXhtmlVoidElements(html, file) {
|
|
16310
16310
|
const allDiagnostics = [];
|
|
16311
|
-
const centerResult = normalizeCenterTags(html, file);
|
|
16311
|
+
const centerResult = normalizeCenterTags(html.replace(/[\u0000-\u0008\u000B\u000C\u000E-\u001F\uFFFE\uFFFF]/g, ""), file);
|
|
16312
16312
|
let content = centerResult.content;
|
|
16313
16313
|
allDiagnostics.push(...centerResult.diagnostics);
|
|
16314
16314
|
const underlineResult = normalizeUnderlineTags(content, file);
|
|
@@ -18503,15 +18503,90 @@ const XML_ESCAPE_MAP = {
|
|
|
18503
18503
|
};
|
|
18504
18504
|
const XML_ESCAPE_PATTERN = /[&<>"']/g;
|
|
18505
18505
|
/**
|
|
18506
|
+
* Characters that are illegal in XML 1.0 document content.
|
|
18507
|
+
*
|
|
18508
|
+
* XML 1.0 only permits the following characters below U+0020: tab (U+0009),
|
|
18509
|
+
* line feed (U+000A) and carriage return (U+000D). Every other C0 control
|
|
18510
|
+
* character (including U+0001, the SOH character) is forbidden and makes the
|
|
18511
|
+
* document non-well-formed. Also disallowed are U+FFFE and U+FFFF.
|
|
18512
|
+
*
|
|
18513
|
+
* Learnosity source JSON occasionally carries stray control characters (e.g.
|
|
18514
|
+
* a literal `\u0001` inside a choice label or attribute value); left in place
|
|
18515
|
+
* they surface as parser errors such as
|
|
18516
|
+
* "An invalid XML character (Unicode: 0x1) was found in the element content".
|
|
18517
|
+
*
|
|
18518
|
+
* @see https://www.w3.org/TR/xml/#charsets
|
|
18519
|
+
*/
|
|
18520
|
+
const INVALID_XML_CHARS_PATTERN = /[\u0000-\u0008\u000B\u000C\u000E-\u001F\uFFFE\uFFFF]/g;
|
|
18521
|
+
/**
|
|
18522
|
+
* Remove characters that are illegal in XML 1.0 content.
|
|
18523
|
+
*
|
|
18524
|
+
* The disallowed characters are stripped (rather than replaced) so that no
|
|
18525
|
+
* visible artifact is introduced into the output. Tab, newline and carriage
|
|
18526
|
+
* return are preserved because they are the only C0 controls XML 1.0 allows.
|
|
18527
|
+
*
|
|
18528
|
+
* @param text - Raw string that may contain invalid XML characters
|
|
18529
|
+
* @returns The string with all XML-illegal characters removed
|
|
18530
|
+
*/
|
|
18531
|
+
function stripInvalidXmlChars(text) {
|
|
18532
|
+
return text.replace(INVALID_XML_CHARS_PATTERN, "");
|
|
18533
|
+
}
|
|
18534
|
+
/**
|
|
18506
18535
|
* Escape XML special characters.
|
|
18507
18536
|
*
|
|
18508
|
-
*
|
|
18509
|
-
*
|
|
18510
|
-
*
|
|
18511
|
-
*
|
|
18537
|
+
* Invalid XML 1.0 characters (e.g. `\u0001`) are stripped first so they never
|
|
18538
|
+
* reach the serialized output, then a single-pass replacement over the
|
|
18539
|
+
* `[&<>"']` character class runs. Each source character is matched exactly once
|
|
18540
|
+
* and mapped independently, so the output is identical to escaping `&` first
|
|
18541
|
+
* and then the angle/quote characters (the replacement text is never
|
|
18542
|
+
* re-scanned).
|
|
18512
18543
|
*/
|
|
18513
18544
|
function escapeXml$3(text) {
|
|
18514
|
-
return text.replace(XML_ESCAPE_PATTERN, (ch) => XML_ESCAPE_MAP[ch]);
|
|
18545
|
+
return stripInvalidXmlChars(text).replace(XML_ESCAPE_PATTERN, (ch) => XML_ESCAPE_MAP[ch]);
|
|
18546
|
+
}
|
|
18547
|
+
/**
|
|
18548
|
+
* Normalize an HTML content body for emission inside a QTI element.
|
|
18549
|
+
*
|
|
18550
|
+
* Learnosity content fields (option/choice labels, feedback, prompts) are HTML,
|
|
18551
|
+
* so numeric/named character references such as `𝒇` or `−` must be
|
|
18552
|
+
* decoded to their literal Unicode characters before serialization — exactly as
|
|
18553
|
+
* stimulus already is via the linkedom round-trip.
|
|
18554
|
+
*
|
|
18555
|
+
* Historically these fields used a `hasHtmlTags ? normalizeXhtmlVoidElements :
|
|
18556
|
+
* escapeXml` gate. The `escapeXml` fallback treated the leading `&` of an entity
|
|
18557
|
+
* as a raw ampersand and produced double-escaped output (e.g. `𝒇`
|
|
18558
|
+
* became `&#119943;`), which players render as the literal text `𝒇`.
|
|
18559
|
+
*
|
|
18560
|
+
* Running every content body through `normalizeXhtmlVoidElements` (which performs
|
|
18561
|
+
* the DOM round-trip that decodes entities to literal chars and re-escapes only
|
|
18562
|
+
* the structural `<`, `>`, `&`) gives consistent, correct output whether or not
|
|
18563
|
+
* the field contains HTML tags.
|
|
18564
|
+
*
|
|
18565
|
+
* NOTE: This is for element CONTENT only. Attribute values, identifiers and
|
|
18566
|
+
* `<value>` payloads must continue to use `escapeXml`, since those are plain
|
|
18567
|
+
* strings where entities must not be decoded.
|
|
18568
|
+
*
|
|
18569
|
+
* @param content - HTML content body (may be plain text or contain markup)
|
|
18570
|
+
* @param file - Diagnostic path indicating where this content originated
|
|
18571
|
+
* @returns Normalized content and any diagnostics generated
|
|
18572
|
+
*/
|
|
18573
|
+
function normalizeHtmlContentBody(content, file) {
|
|
18574
|
+
return normalizeXhtmlVoidElements(content, file);
|
|
18575
|
+
}
|
|
18576
|
+
/**
|
|
18577
|
+
* Normalize a prompt for emission as a direct child of `itemBody`.
|
|
18578
|
+
*
|
|
18579
|
+
* itemBody requires block-level children, so a plain-text prompt (no HTML tags)
|
|
18580
|
+
* is wrapped in `<p>` before normalization. Either way the content is run
|
|
18581
|
+
* through the linkedom round-trip so numeric/named entities decode to literal
|
|
18582
|
+
* characters instead of being double-escaped by `escapeXml`.
|
|
18583
|
+
*
|
|
18584
|
+
* @param prompt - Prompt content (plain text or HTML)
|
|
18585
|
+
* @param file - Diagnostic path indicating where this content originated
|
|
18586
|
+
* @returns Normalized, block-level prompt content and any diagnostics generated
|
|
18587
|
+
*/
|
|
18588
|
+
function normalizePromptContent(prompt, file) {
|
|
18589
|
+
return normalizeXhtmlVoidElements(/<[a-zA-Z][\s\S]*?>/.test(prompt) ? prompt : `<p>${prompt}</p>`, file);
|
|
18515
18590
|
}
|
|
18516
18591
|
/**
|
|
18517
18592
|
* Infer MIME type from file extension
|
|
@@ -18960,22 +19035,18 @@ function renderInteractionXml(interaction, diagnostics, indent, nl) {
|
|
|
18960
19035
|
if (interaction.type === "choice") {
|
|
18961
19036
|
const choiceInteraction = interaction;
|
|
18962
19037
|
if (choiceInteraction.prompt) {
|
|
18963
|
-
|
|
18964
|
-
|
|
18965
|
-
|
|
18966
|
-
parts.push(normalized.content);
|
|
18967
|
-
} else parts.push(`<p>${escapeXml$3(choiceInteraction.prompt)}</p>`);
|
|
19038
|
+
const normalized = normalizePromptContent(choiceInteraction.prompt, "interaction.prompt");
|
|
19039
|
+
diagnostics.push(...normalized.diagnostics);
|
|
19040
|
+
parts.push(normalized.content);
|
|
18968
19041
|
}
|
|
18969
19042
|
const minChoicesAttr = choiceInteraction.minChoices !== void 0 ? ` minChoices="${choiceInteraction.minChoices}"` : "";
|
|
18970
19043
|
parts.push(`<choiceInteraction responseIdentifier="${choiceInteraction.responseIdentifier}" shuffle="${choiceInteraction.shuffle}"${minChoicesAttr} maxChoices="${choiceInteraction.maxChoices}">`);
|
|
18971
19044
|
parts.push(nl);
|
|
18972
19045
|
for (const choice of choiceInteraction.choices) {
|
|
18973
19046
|
parts.push(`${indent}<simpleChoice identifier="${escapeXml$3(choice.identifier)}">`);
|
|
18974
|
-
|
|
18975
|
-
|
|
18976
|
-
|
|
18977
|
-
parts.push(normalized.content);
|
|
18978
|
-
} else parts.push(escapeXml$3(choice.content));
|
|
19047
|
+
const normalized = normalizeHtmlContentBody(choice.content, `choice.${choice.identifier}`);
|
|
19048
|
+
diagnostics.push(...normalized.diagnostics);
|
|
19049
|
+
parts.push(normalized.content);
|
|
18979
19050
|
parts.push("</simpleChoice>");
|
|
18980
19051
|
parts.push(nl);
|
|
18981
19052
|
}
|
|
@@ -18983,11 +19054,9 @@ function renderInteractionXml(interaction, diagnostics, indent, nl) {
|
|
|
18983
19054
|
} else if (interaction.type === "textEntry") {
|
|
18984
19055
|
const textEntryInteraction = interaction;
|
|
18985
19056
|
if (textEntryInteraction.prompt) {
|
|
18986
|
-
|
|
18987
|
-
|
|
18988
|
-
|
|
18989
|
-
parts.push(normalized.content);
|
|
18990
|
-
} else parts.push(`<p>${escapeXml$3(textEntryInteraction.prompt)}</p>`);
|
|
19057
|
+
const normalized = normalizePromptContent(textEntryInteraction.prompt, "interaction.prompt");
|
|
19058
|
+
diagnostics.push(...normalized.diagnostics);
|
|
19059
|
+
parts.push(normalized.content);
|
|
18991
19060
|
}
|
|
18992
19061
|
let textEntryTag = `<textEntryInteraction responseIdentifier="${textEntryInteraction.responseIdentifier}"`;
|
|
18993
19062
|
if (textEntryInteraction.placeholderText) textEntryTag += ` placeholderText="${escapeXml$3(textEntryInteraction.placeholderText)}"`;
|
|
@@ -19038,10 +19107,7 @@ function renderInteractionXml(interaction, diagnostics, indent, nl) {
|
|
|
19038
19107
|
let inlineChoiceXml = `<inlineChoiceInteraction responseIdentifier="${entry.responseIdentifier}"`;
|
|
19039
19108
|
if (entry.shuffle) inlineChoiceXml += ` shuffle="true"`;
|
|
19040
19109
|
inlineChoiceXml += ">";
|
|
19041
|
-
for (const choice of entry.inlineChoices) {
|
|
19042
|
-
const choiceContent = /<[a-zA-Z][\s\S]*?>/.test(choice.content) ? choice.content : escapeXml$3(choice.content);
|
|
19043
|
-
inlineChoiceXml += `<inlineChoice identifier="${escapeXml$3(choice.identifier)}">${choiceContent}</inlineChoice>`;
|
|
19044
|
-
}
|
|
19110
|
+
for (const choice of entry.inlineChoices) inlineChoiceXml += `<inlineChoice identifier="${escapeXml$3(choice.identifier)}">${choice.content}</inlineChoice>`;
|
|
19045
19111
|
inlineChoiceXml += "</inlineChoiceInteraction>";
|
|
19046
19112
|
templateHtml = templateHtml.replace("{{response}}", inlineChoiceXml);
|
|
19047
19113
|
}
|
|
@@ -19065,7 +19131,9 @@ function renderInteractionXml(interaction, diagnostics, indent, nl) {
|
|
|
19065
19131
|
parts.push(">");
|
|
19066
19132
|
parts.push(nl);
|
|
19067
19133
|
if (gapMatchInteraction.gapTexts) for (const gapText of gapMatchInteraction.gapTexts) {
|
|
19068
|
-
|
|
19134
|
+
const normalized = normalizeHtmlContentBody(gapText.content, `gapText.${gapText.identifier}`);
|
|
19135
|
+
diagnostics.push(...normalized.diagnostics);
|
|
19136
|
+
parts.push(`${indent}<gapText identifier="${escapeXml$3(gapText.identifier)}" matchMax="1">${normalized.content}</gapText>`);
|
|
19069
19137
|
parts.push(nl);
|
|
19070
19138
|
}
|
|
19071
19139
|
if (gapMatchInteraction.template && gapMatchInteraction.gapEntries) {
|
|
@@ -19099,11 +19167,9 @@ function renderInteractionXml(interaction, diagnostics, indent, nl) {
|
|
|
19099
19167
|
parts.push(nl);
|
|
19100
19168
|
for (const choice of orderInteraction.choices) {
|
|
19101
19169
|
parts.push(`${indent}<simpleChoice identifier="${escapeXml$3(choice.identifier)}">`);
|
|
19102
|
-
|
|
19103
|
-
|
|
19104
|
-
|
|
19105
|
-
parts.push(normalized.content);
|
|
19106
|
-
} else parts.push(escapeXml$3(choice.content));
|
|
19170
|
+
const normalized = normalizeHtmlContentBody(choice.content, `choice.${choice.identifier}`);
|
|
19171
|
+
diagnostics.push(...normalized.diagnostics);
|
|
19172
|
+
parts.push(normalized.content);
|
|
19107
19173
|
parts.push("</simpleChoice>");
|
|
19108
19174
|
parts.push(nl);
|
|
19109
19175
|
}
|
|
@@ -19128,11 +19194,9 @@ function renderInteractionXml(interaction, diagnostics, indent, nl) {
|
|
|
19128
19194
|
parts.push(nl);
|
|
19129
19195
|
for (const choice of matchInteraction.sourceSet) {
|
|
19130
19196
|
parts.push(`${indent}${indent}<simpleAssociableChoice identifier="${escapeXml$3(choice.identifier)}" matchMax="${choice.matchMax}">`);
|
|
19131
|
-
|
|
19132
|
-
|
|
19133
|
-
|
|
19134
|
-
parts.push(normalized.content);
|
|
19135
|
-
} else parts.push(escapeXml$3(choice.content));
|
|
19197
|
+
const normalized = normalizeHtmlContentBody(choice.content, `sourceChoice.${choice.identifier}`);
|
|
19198
|
+
diagnostics.push(...normalized.diagnostics);
|
|
19199
|
+
parts.push(normalized.content);
|
|
19136
19200
|
parts.push("</simpleAssociableChoice>");
|
|
19137
19201
|
parts.push(nl);
|
|
19138
19202
|
}
|
|
@@ -19142,11 +19206,9 @@ function renderInteractionXml(interaction, diagnostics, indent, nl) {
|
|
|
19142
19206
|
parts.push(nl);
|
|
19143
19207
|
for (const choice of matchInteraction.targetSet) {
|
|
19144
19208
|
parts.push(`${indent}${indent}<simpleAssociableChoice identifier="${escapeXml$3(choice.identifier)}" matchMax="${choice.matchMax}">`);
|
|
19145
|
-
|
|
19146
|
-
|
|
19147
|
-
|
|
19148
|
-
parts.push(normalized.content);
|
|
19149
|
-
} else parts.push(escapeXml$3(choice.content));
|
|
19209
|
+
const normalized = normalizeHtmlContentBody(choice.content, `targetChoice.${choice.identifier}`);
|
|
19210
|
+
diagnostics.push(...normalized.diagnostics);
|
|
19211
|
+
parts.push(normalized.content);
|
|
19150
19212
|
parts.push("</simpleAssociableChoice>");
|
|
19151
19213
|
parts.push(nl);
|
|
19152
19214
|
}
|
|
@@ -19236,11 +19298,9 @@ function renderInteractionXml(interaction, diagnostics, indent, nl) {
|
|
|
19236
19298
|
parts.push(nl);
|
|
19237
19299
|
for (const choice of associateInteraction.choices) {
|
|
19238
19300
|
parts.push(`${indent}<simpleAssociableChoice identifier="${escapeXml$3(choice.identifier)}" matchMax="${choice.matchMax}">`);
|
|
19239
|
-
|
|
19240
|
-
|
|
19241
|
-
|
|
19242
|
-
parts.push(normalized.content);
|
|
19243
|
-
} else parts.push(escapeXml$3(choice.content));
|
|
19301
|
+
const normalized = normalizeHtmlContentBody(choice.content, `choice.${choice.identifier}`);
|
|
19302
|
+
diagnostics.push(...normalized.diagnostics);
|
|
19303
|
+
parts.push(normalized.content);
|
|
19244
19304
|
parts.push("</simpleAssociableChoice>");
|
|
19245
19305
|
parts.push(nl);
|
|
19246
19306
|
}
|
|
@@ -19339,13 +19399,9 @@ function buildChoiceInteractionXml(interaction, feedbackBlock, diagnostics, part
|
|
|
19339
19399
|
parts.push(nl);
|
|
19340
19400
|
for (let i = 0; i < interaction.choices.length; i++) {
|
|
19341
19401
|
const choice = interaction.choices[i];
|
|
19342
|
-
const
|
|
19343
|
-
|
|
19344
|
-
|
|
19345
|
-
const normalized = normalizeXhtmlVoidElements(choice.content, `choiceInteraction.simpleChoice[${i}]`);
|
|
19346
|
-
diagnostics.push(...normalized.diagnostics);
|
|
19347
|
-
choiceContent = normalized.content;
|
|
19348
|
-
} else choiceContent = escapeXml$3(choice.content);
|
|
19402
|
+
const normalized = normalizeHtmlContentBody(choice.content, `choiceInteraction.simpleChoice[${i}]`);
|
|
19403
|
+
diagnostics.push(...normalized.diagnostics);
|
|
19404
|
+
const choiceContent = normalized.content;
|
|
19349
19405
|
const feedbackAttr = choice.feedbackBlockIdentifier ? ` feedbackBlock="${escapeXml$3(choice.feedbackBlockIdentifier)}"` : "";
|
|
19350
19406
|
parts.push(`${indent3}<simpleChoice identifier="${escapeXml$3(choice.identifier)}"${feedbackAttr}>${choiceContent}</simpleChoice>`);
|
|
19351
19407
|
parts.push(nl);
|
|
@@ -19354,13 +19410,9 @@ function buildChoiceInteractionXml(interaction, feedbackBlock, diagnostics, part
|
|
|
19354
19410
|
parts.push(nl);
|
|
19355
19411
|
if (feedbackBlock && feedbackBlock.length > 0) for (let i = 0; i < feedbackBlock.length; i++) {
|
|
19356
19412
|
const feedback = feedbackBlock[i];
|
|
19357
|
-
const
|
|
19358
|
-
|
|
19359
|
-
|
|
19360
|
-
const normalized = normalizeXhtmlVoidElements(feedback.content, `feedbackBlock[${i}]`);
|
|
19361
|
-
diagnostics.push(...normalized.diagnostics);
|
|
19362
|
-
feedbackContent = normalized.content;
|
|
19363
|
-
} else feedbackContent = escapeXml$3(feedback.content);
|
|
19413
|
+
const normalized = normalizeHtmlContentBody(feedback.content, `feedbackBlock[${i}]`);
|
|
19414
|
+
diagnostics.push(...normalized.diagnostics);
|
|
19415
|
+
const feedbackContent = normalized.content;
|
|
19364
19416
|
parts.push(`${indent2}<feedbackBlock identifier="${escapeXml$3(feedback.identifier)}" outcomeIdentifier="FEEDBACK" showHide="${feedback.showHide}">${feedbackContent}</feedbackBlock>`);
|
|
19365
19417
|
parts.push(nl);
|
|
19366
19418
|
}
|
|
@@ -19487,8 +19539,7 @@ function buildTextEntryInteractionXml(interaction, diagnostics, parts, indent, i
|
|
|
19487
19539
|
parts.push(nl);
|
|
19488
19540
|
}
|
|
19489
19541
|
let template = interaction.template;
|
|
19490
|
-
|
|
19491
|
-
if (hasHtmlTags) {
|
|
19542
|
+
{
|
|
19492
19543
|
const normalized = normalizeXhtmlVoidElements(template, "textEntryInteraction.template");
|
|
19493
19544
|
diagnostics.push(...normalized.diagnostics);
|
|
19494
19545
|
template = normalized.content;
|
|
@@ -19501,7 +19552,7 @@ function buildTextEntryInteractionXml(interaction, diagnostics, parts, indent, i
|
|
|
19501
19552
|
while ((match = placeholderRegex.exec(template)) !== null) {
|
|
19502
19553
|
if (match.index > lastIndex) {
|
|
19503
19554
|
const textSegment = template.substring(lastIndex, match.index);
|
|
19504
|
-
segments.push(
|
|
19555
|
+
segments.push(textSegment);
|
|
19505
19556
|
}
|
|
19506
19557
|
if (entryIndex < interaction.textEntries.length) {
|
|
19507
19558
|
const entry = interaction.textEntries[entryIndex];
|
|
@@ -19517,7 +19568,7 @@ function buildTextEntryInteractionXml(interaction, diagnostics, parts, indent, i
|
|
|
19517
19568
|
}
|
|
19518
19569
|
if (lastIndex < template.length) {
|
|
19519
19570
|
const textSegment = template.substring(lastIndex);
|
|
19520
|
-
segments.push(
|
|
19571
|
+
segments.push(textSegment);
|
|
19521
19572
|
}
|
|
19522
19573
|
parts.push(`${indent2}<div>`);
|
|
19523
19574
|
parts.push(segments.join(""));
|
|
@@ -19565,11 +19616,9 @@ function buildExtendedTextInteractionXml(interaction, outcomeDeclaration, diagno
|
|
|
19565
19616
|
parts.push(`${indent}<itemBody>`);
|
|
19566
19617
|
parts.push(nl);
|
|
19567
19618
|
if (interaction.prompt) {
|
|
19568
|
-
|
|
19569
|
-
|
|
19570
|
-
|
|
19571
|
-
parts.push(`${indent2}${normalized.content}`);
|
|
19572
|
-
} else parts.push(`${indent2}<p>${escapeXml$3(interaction.prompt)}</p>`);
|
|
19619
|
+
const normalized = normalizePromptContent(interaction.prompt, "itemBody.prompt");
|
|
19620
|
+
diagnostics.push(...normalized.diagnostics);
|
|
19621
|
+
parts.push(`${indent2}${normalized.content}`);
|
|
19573
19622
|
parts.push(nl);
|
|
19574
19623
|
}
|
|
19575
19624
|
let interactionTag = `${indent2}<extendedTextInteraction responseIdentifier="${interaction.responseIdentifier}"`;
|
|
@@ -19603,11 +19652,9 @@ function buildUploadInteractionXml(interaction, diagnostics, parts, indent, inde
|
|
|
19603
19652
|
parts.push(`${indent}<itemBody>`);
|
|
19604
19653
|
parts.push(nl);
|
|
19605
19654
|
if (interaction.prompt) {
|
|
19606
|
-
|
|
19607
|
-
|
|
19608
|
-
|
|
19609
|
-
parts.push(`${indent2}${normalized.content}`);
|
|
19610
|
-
} else parts.push(`${indent2}<p>${escapeXml$3(interaction.prompt)}</p>`);
|
|
19655
|
+
const normalized = normalizePromptContent(interaction.prompt, "itemBody.prompt");
|
|
19656
|
+
diagnostics.push(...normalized.diagnostics);
|
|
19657
|
+
parts.push(`${indent2}${normalized.content}`);
|
|
19611
19658
|
parts.push(nl);
|
|
19612
19659
|
}
|
|
19613
19660
|
let interactionTag = `${indent2}<uploadInteraction responseIdentifier="${interaction.responseIdentifier}"`;
|
|
@@ -19644,14 +19691,15 @@ function buildDrawingInteractionXml(interaction, diagnostics, parts, indent, ind
|
|
|
19644
19691
|
parts.push(nl);
|
|
19645
19692
|
parts.push(`${indent3}<prompt>`);
|
|
19646
19693
|
if (interaction.prompt) {
|
|
19647
|
-
|
|
19648
|
-
|
|
19649
|
-
|
|
19694
|
+
const hasHtmlTags = /<[a-zA-Z][\s\S]*?>/.test(interaction.prompt);
|
|
19695
|
+
const normalized = normalizeHtmlContentBody(interaction.prompt, "drawingInteraction.prompt");
|
|
19696
|
+
diagnostics.push(...normalized.diagnostics);
|
|
19697
|
+
if (hasHtmlTags) {
|
|
19650
19698
|
parts.push(nl);
|
|
19651
19699
|
parts.push(`${indent3} ${normalized.content}`);
|
|
19652
19700
|
parts.push(nl);
|
|
19653
19701
|
parts.push(`${indent3}`);
|
|
19654
|
-
} else parts.push(
|
|
19702
|
+
} else parts.push(normalized.content);
|
|
19655
19703
|
}
|
|
19656
19704
|
parts.push(`</prompt>`);
|
|
19657
19705
|
parts.push(nl);
|
|
@@ -19722,11 +19770,9 @@ function buildInlineChoiceInteractionXml(interaction, diagnostics, parts, indent
|
|
|
19722
19770
|
parts.push(`${indent}<itemBody>`);
|
|
19723
19771
|
parts.push(nl);
|
|
19724
19772
|
if (interaction.prompt) {
|
|
19725
|
-
|
|
19726
|
-
|
|
19727
|
-
|
|
19728
|
-
parts.push(`${indent2}${normalized.content}`);
|
|
19729
|
-
} else parts.push(`${indent2}<p>${escapeXml$3(interaction.prompt)}</p>`);
|
|
19773
|
+
const normalized = normalizePromptContent(interaction.prompt, "itemBody.prompt");
|
|
19774
|
+
diagnostics.push(...normalized.diagnostics);
|
|
19775
|
+
parts.push(`${indent2}${normalized.content}`);
|
|
19730
19776
|
parts.push(nl);
|
|
19731
19777
|
}
|
|
19732
19778
|
if (interaction.template && interaction.inlineChoiceEntries) {
|
|
@@ -19736,10 +19782,7 @@ function buildInlineChoiceInteractionXml(interaction, diagnostics, parts, indent
|
|
|
19736
19782
|
let inlineChoiceXml = `<inlineChoiceInteraction responseIdentifier="${entry.responseIdentifier}"`;
|
|
19737
19783
|
if (entry.shuffle) inlineChoiceXml += ` shuffle="true"`;
|
|
19738
19784
|
inlineChoiceXml += ">";
|
|
19739
|
-
for (const choice of entry.inlineChoices) {
|
|
19740
|
-
const choiceContent = /<[a-zA-Z][\s\S]*?>/.test(choice.content) ? choice.content : escapeXml$3(choice.content);
|
|
19741
|
-
inlineChoiceXml += `<inlineChoice identifier="${escapeXml$3(choice.identifier)}">${choiceContent}</inlineChoice>`;
|
|
19742
|
-
}
|
|
19785
|
+
for (const choice of entry.inlineChoices) inlineChoiceXml += `<inlineChoice identifier="${escapeXml$3(choice.identifier)}">${choice.content}</inlineChoice>`;
|
|
19743
19786
|
inlineChoiceXml += "</inlineChoiceInteraction>";
|
|
19744
19787
|
templateHtml = templateHtml.replace("{{response}}", inlineChoiceXml);
|
|
19745
19788
|
}
|
|
@@ -19795,11 +19838,9 @@ function buildGapMatchInteractionXml(interaction, diagnostics, parts, indent, in
|
|
|
19795
19838
|
parts.push(`${indent}<itemBody>`);
|
|
19796
19839
|
parts.push(nl);
|
|
19797
19840
|
if (interaction.prompt) {
|
|
19798
|
-
|
|
19799
|
-
|
|
19800
|
-
|
|
19801
|
-
parts.push(`${indent2}${normalized.content}`);
|
|
19802
|
-
} else parts.push(`${indent2}<p>${escapeXml$3(interaction.prompt)}</p>`);
|
|
19841
|
+
const normalized = normalizePromptContent(interaction.prompt, "itemBody.prompt");
|
|
19842
|
+
diagnostics.push(...normalized.diagnostics);
|
|
19843
|
+
parts.push(`${indent2}${normalized.content}`);
|
|
19803
19844
|
parts.push(nl);
|
|
19804
19845
|
}
|
|
19805
19846
|
parts.push(`${indent2}<gapMatchInteraction responseIdentifier="${interaction.responseIdentifier}"`);
|
|
@@ -19807,11 +19848,9 @@ function buildGapMatchInteractionXml(interaction, diagnostics, parts, indent, in
|
|
|
19807
19848
|
parts.push(">");
|
|
19808
19849
|
parts.push(nl);
|
|
19809
19850
|
if (interaction.gapTexts) for (const gapText of interaction.gapTexts) {
|
|
19810
|
-
const
|
|
19811
|
-
|
|
19812
|
-
|
|
19813
|
-
else gapTextContent = escapeXml$3(gapText.content);
|
|
19814
|
-
parts.push(`${indent3}<gapText identifier="${escapeXml$3(gapText.identifier)}" matchMax="1">${gapTextContent}</gapText>`);
|
|
19851
|
+
const normalized = normalizeHtmlContentBody(gapText.content, `itemBody.gapText.${gapText.identifier}`);
|
|
19852
|
+
diagnostics.push(...normalized.diagnostics);
|
|
19853
|
+
parts.push(`${indent3}<gapText identifier="${escapeXml$3(gapText.identifier)}" matchMax="1">${normalized.content}</gapText>`);
|
|
19815
19854
|
parts.push(nl);
|
|
19816
19855
|
}
|
|
19817
19856
|
if (interaction.template && interaction.gapEntries) {
|
|
@@ -19875,15 +19914,10 @@ function buildOrderInteractionXml(interaction, diagnostics, parts, indent, inden
|
|
|
19875
19914
|
parts.push(`${indent}<itemBody>`);
|
|
19876
19915
|
parts.push(nl);
|
|
19877
19916
|
if (interaction.prompt) {
|
|
19878
|
-
|
|
19879
|
-
|
|
19880
|
-
|
|
19881
|
-
|
|
19882
|
-
parts.push(nl);
|
|
19883
|
-
} else {
|
|
19884
|
-
parts.push(`${indent2}<p>${escapeXml$3(interaction.prompt)}</p>`);
|
|
19885
|
-
parts.push(nl);
|
|
19886
|
-
}
|
|
19917
|
+
const normalized = normalizePromptContent(interaction.prompt, "itemBody.prompt");
|
|
19918
|
+
diagnostics.push(...normalized.diagnostics);
|
|
19919
|
+
parts.push(`${indent2}${normalized.content}`);
|
|
19920
|
+
parts.push(nl);
|
|
19887
19921
|
}
|
|
19888
19922
|
parts.push(`${indent2}<orderInteraction responseIdentifier="${interaction.responseIdentifier}"`);
|
|
19889
19923
|
if (interaction.shuffle) parts.push(` shuffle="true"`);
|
|
@@ -19892,11 +19926,9 @@ function buildOrderInteractionXml(interaction, diagnostics, parts, indent, inden
|
|
|
19892
19926
|
parts.push(nl);
|
|
19893
19927
|
for (const choice of interaction.choices) {
|
|
19894
19928
|
parts.push(`${indent3}<simpleChoice identifier="${escapeXml$3(choice.identifier)}">`);
|
|
19895
|
-
|
|
19896
|
-
|
|
19897
|
-
|
|
19898
|
-
parts.push(normalized.content);
|
|
19899
|
-
} else parts.push(escapeXml$3(choice.content));
|
|
19929
|
+
const normalized = normalizeHtmlContentBody(choice.content, `itemBody.choice.${choice.identifier}`);
|
|
19930
|
+
diagnostics.push(...normalized.diagnostics);
|
|
19931
|
+
parts.push(normalized.content);
|
|
19900
19932
|
parts.push("</simpleChoice>");
|
|
19901
19933
|
parts.push(nl);
|
|
19902
19934
|
}
|
|
@@ -20015,15 +20047,10 @@ function buildHottextInteractionXml(interaction, diagnostics, parts, indent, ind
|
|
|
20015
20047
|
parts.push(`${indent}<itemBody>`);
|
|
20016
20048
|
parts.push(nl);
|
|
20017
20049
|
if (interaction.prompt) {
|
|
20018
|
-
|
|
20019
|
-
|
|
20020
|
-
|
|
20021
|
-
|
|
20022
|
-
parts.push(nl);
|
|
20023
|
-
} else {
|
|
20024
|
-
parts.push(`${indent2}<p>${escapeXml$3(interaction.prompt)}</p>`);
|
|
20025
|
-
parts.push(nl);
|
|
20026
|
-
}
|
|
20050
|
+
const normalized = normalizePromptContent(interaction.prompt, "itemBody.prompt");
|
|
20051
|
+
diagnostics.push(...normalized.diagnostics);
|
|
20052
|
+
parts.push(`${indent2}${normalized.content}`);
|
|
20053
|
+
parts.push(nl);
|
|
20027
20054
|
}
|
|
20028
20055
|
parts.push(`${indent2}<hottextInteraction responseIdentifier="${interaction.responseIdentifier}" maxChoices="${interaction.correctResponse?.length || 0}">`);
|
|
20029
20056
|
parts.push(nl);
|
|
@@ -20133,15 +20160,10 @@ function buildGraphicGapMatchInteractionXml(interaction, diagnostics, parts, ind
|
|
|
20133
20160
|
parts.push(`${indent}<itemBody>`);
|
|
20134
20161
|
parts.push(nl);
|
|
20135
20162
|
if (interaction.prompt) {
|
|
20136
|
-
|
|
20137
|
-
|
|
20138
|
-
|
|
20139
|
-
|
|
20140
|
-
parts.push(nl);
|
|
20141
|
-
} else {
|
|
20142
|
-
parts.push(`${indent2}<p>${escapeXml$3(interaction.prompt)}</p>`);
|
|
20143
|
-
parts.push(nl);
|
|
20144
|
-
}
|
|
20163
|
+
const normalized = normalizePromptContent(interaction.prompt, "itemBody.prompt");
|
|
20164
|
+
diagnostics.push(...normalized.diagnostics);
|
|
20165
|
+
parts.push(`${indent2}${normalized.content}`);
|
|
20166
|
+
parts.push(nl);
|
|
20145
20167
|
}
|
|
20146
20168
|
parts.push(`${indent2}<graphicGapMatchInteraction responseIdentifier="${interaction.responseIdentifier}" shuffle="${interaction.shuffle}">`);
|
|
20147
20169
|
parts.push(nl);
|
|
@@ -20219,11 +20241,9 @@ function buildAssociateInteractionXml(interaction, diagnostics, parts, indent, i
|
|
|
20219
20241
|
parts.push(nl);
|
|
20220
20242
|
for (const choice of interaction.choices) {
|
|
20221
20243
|
parts.push(`${indent3}<simpleAssociableChoice identifier="${escapeXml$3(choice.identifier)}" matchMax="${choice.matchMax}">`);
|
|
20222
|
-
|
|
20223
|
-
|
|
20224
|
-
|
|
20225
|
-
parts.push(normalized.content);
|
|
20226
|
-
} else parts.push(escapeXml$3(choice.content));
|
|
20244
|
+
const normalized = normalizeHtmlContentBody(choice.content, `itemBody.choice.${choice.identifier}`);
|
|
20245
|
+
diagnostics.push(...normalized.diagnostics);
|
|
20246
|
+
parts.push(normalized.content);
|
|
20227
20247
|
parts.push("</simpleAssociableChoice>");
|
|
20228
20248
|
parts.push(nl);
|
|
20229
20249
|
}
|
|
@@ -20465,13 +20485,9 @@ function buildAssessmentItemXml(ast, pretty, version) {
|
|
|
20465
20485
|
if (ast.modalFeedback && ast.modalFeedback.length > 0) for (let i = 0; i < ast.modalFeedback.length; i++) {
|
|
20466
20486
|
const typedFeedback = ast.modalFeedback[i];
|
|
20467
20487
|
let feedbackXml = `${indent}<modalFeedback identifier="${escapeXml$3(typedFeedback.identifier)}" outcomeIdentifier="${escapeXml$3(typedFeedback.outcomeIdentifier)}" showHide="${typedFeedback.showHide}">${nl}`;
|
|
20468
|
-
const
|
|
20469
|
-
|
|
20470
|
-
|
|
20471
|
-
const normalized = normalizeXhtmlVoidElements(typedFeedback.content, `modalFeedback[${i}]`);
|
|
20472
|
-
diagnostics.push(...normalized.diagnostics);
|
|
20473
|
-
feedbackContent = normalized.content;
|
|
20474
|
-
} else feedbackContent = escapeXml$3(typedFeedback.content);
|
|
20488
|
+
const normalized = normalizeHtmlContentBody(typedFeedback.content, `modalFeedback[${i}]`);
|
|
20489
|
+
diagnostics.push(...normalized.diagnostics);
|
|
20490
|
+
const feedbackContent = normalized.content;
|
|
20475
20491
|
feedbackXml += `${indent2}${feedbackContent}${nl}`;
|
|
20476
20492
|
feedbackXml += `${indent}</modalFeedback>${nl}`;
|
|
20477
20493
|
sections.modalFeedback.push(feedbackXml);
|