@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
|
@@ -615,7 +615,9 @@ function parseClozeformulaData(data, file, diagnostics) {
|
|
|
615
615
|
"showHints",
|
|
616
616
|
"show_hints_button",
|
|
617
617
|
"numberPad",
|
|
618
|
-
"text_blocks"
|
|
618
|
+
"text_blocks",
|
|
619
|
+
"horizontal_layout",
|
|
620
|
+
"horizontalPad"
|
|
619
621
|
]);
|
|
620
622
|
for (const key of Object.keys(data)) if (!knownKeys.has(key)) diagnostics.push({
|
|
621
623
|
level: "warning",
|
|
@@ -14137,8 +14139,8 @@ var require_CSSStyleDeclaration = /* @__PURE__ */ __commonJSMin(((exports) => {
|
|
|
14137
14139
|
return properties.join(" ");
|
|
14138
14140
|
},
|
|
14139
14141
|
set cssText(text) {
|
|
14140
|
-
var i, name;
|
|
14141
|
-
for (
|
|
14142
|
+
var i = this.length, name;
|
|
14143
|
+
for (; i--;) {
|
|
14142
14144
|
name = this[i];
|
|
14143
14145
|
this[name] = "";
|
|
14144
14146
|
}
|
|
@@ -16306,7 +16308,7 @@ function replaceNbspEntity(html, file) {
|
|
|
16306
16308
|
*/
|
|
16307
16309
|
function normalizeXhtmlVoidElements(html, file) {
|
|
16308
16310
|
const allDiagnostics = [];
|
|
16309
|
-
const centerResult = normalizeCenterTags(html, file);
|
|
16311
|
+
const centerResult = normalizeCenterTags(html.replace(/[\u0000-\u0008\u000B\u000C\u000E-\u001F\uFFFE\uFFFF]/g, ""), file);
|
|
16310
16312
|
let content = centerResult.content;
|
|
16311
16313
|
allDiagnostics.push(...centerResult.diagnostics);
|
|
16312
16314
|
const underlineResult = normalizeUnderlineTags(content, file);
|
|
@@ -18501,15 +18503,90 @@ const XML_ESCAPE_MAP = {
|
|
|
18501
18503
|
};
|
|
18502
18504
|
const XML_ESCAPE_PATTERN = /[&<>"']/g;
|
|
18503
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
|
+
/**
|
|
18504
18535
|
* Escape XML special characters.
|
|
18505
18536
|
*
|
|
18506
|
-
*
|
|
18507
|
-
*
|
|
18508
|
-
*
|
|
18509
|
-
*
|
|
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).
|
|
18510
18543
|
*/
|
|
18511
18544
|
function escapeXml$3(text) {
|
|
18512
|
-
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);
|
|
18513
18590
|
}
|
|
18514
18591
|
/**
|
|
18515
18592
|
* Infer MIME type from file extension
|
|
@@ -18958,22 +19035,18 @@ function renderInteractionXml(interaction, diagnostics, indent, nl) {
|
|
|
18958
19035
|
if (interaction.type === "choice") {
|
|
18959
19036
|
const choiceInteraction = interaction;
|
|
18960
19037
|
if (choiceInteraction.prompt) {
|
|
18961
|
-
|
|
18962
|
-
|
|
18963
|
-
|
|
18964
|
-
parts.push(normalized.content);
|
|
18965
|
-
} 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);
|
|
18966
19041
|
}
|
|
18967
19042
|
const minChoicesAttr = choiceInteraction.minChoices !== void 0 ? ` minChoices="${choiceInteraction.minChoices}"` : "";
|
|
18968
19043
|
parts.push(`<choiceInteraction responseIdentifier="${choiceInteraction.responseIdentifier}" shuffle="${choiceInteraction.shuffle}"${minChoicesAttr} maxChoices="${choiceInteraction.maxChoices}">`);
|
|
18969
19044
|
parts.push(nl);
|
|
18970
19045
|
for (const choice of choiceInteraction.choices) {
|
|
18971
19046
|
parts.push(`${indent}<simpleChoice identifier="${escapeXml$3(choice.identifier)}">`);
|
|
18972
|
-
|
|
18973
|
-
|
|
18974
|
-
|
|
18975
|
-
parts.push(normalized.content);
|
|
18976
|
-
} 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);
|
|
18977
19050
|
parts.push("</simpleChoice>");
|
|
18978
19051
|
parts.push(nl);
|
|
18979
19052
|
}
|
|
@@ -18981,11 +19054,9 @@ function renderInteractionXml(interaction, diagnostics, indent, nl) {
|
|
|
18981
19054
|
} else if (interaction.type === "textEntry") {
|
|
18982
19055
|
const textEntryInteraction = interaction;
|
|
18983
19056
|
if (textEntryInteraction.prompt) {
|
|
18984
|
-
|
|
18985
|
-
|
|
18986
|
-
|
|
18987
|
-
parts.push(normalized.content);
|
|
18988
|
-
} 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);
|
|
18989
19060
|
}
|
|
18990
19061
|
let textEntryTag = `<textEntryInteraction responseIdentifier="${textEntryInteraction.responseIdentifier}"`;
|
|
18991
19062
|
if (textEntryInteraction.placeholderText) textEntryTag += ` placeholderText="${escapeXml$3(textEntryInteraction.placeholderText)}"`;
|
|
@@ -19036,10 +19107,7 @@ function renderInteractionXml(interaction, diagnostics, indent, nl) {
|
|
|
19036
19107
|
let inlineChoiceXml = `<inlineChoiceInteraction responseIdentifier="${entry.responseIdentifier}"`;
|
|
19037
19108
|
if (entry.shuffle) inlineChoiceXml += ` shuffle="true"`;
|
|
19038
19109
|
inlineChoiceXml += ">";
|
|
19039
|
-
for (const choice of entry.inlineChoices) {
|
|
19040
|
-
const choiceContent = /<[a-zA-Z][\s\S]*?>/.test(choice.content) ? choice.content : escapeXml$3(choice.content);
|
|
19041
|
-
inlineChoiceXml += `<inlineChoice identifier="${escapeXml$3(choice.identifier)}">${choiceContent}</inlineChoice>`;
|
|
19042
|
-
}
|
|
19110
|
+
for (const choice of entry.inlineChoices) inlineChoiceXml += `<inlineChoice identifier="${escapeXml$3(choice.identifier)}">${choice.content}</inlineChoice>`;
|
|
19043
19111
|
inlineChoiceXml += "</inlineChoiceInteraction>";
|
|
19044
19112
|
templateHtml = templateHtml.replace("{{response}}", inlineChoiceXml);
|
|
19045
19113
|
}
|
|
@@ -19063,7 +19131,9 @@ function renderInteractionXml(interaction, diagnostics, indent, nl) {
|
|
|
19063
19131
|
parts.push(">");
|
|
19064
19132
|
parts.push(nl);
|
|
19065
19133
|
if (gapMatchInteraction.gapTexts) for (const gapText of gapMatchInteraction.gapTexts) {
|
|
19066
|
-
|
|
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>`);
|
|
19067
19137
|
parts.push(nl);
|
|
19068
19138
|
}
|
|
19069
19139
|
if (gapMatchInteraction.template && gapMatchInteraction.gapEntries) {
|
|
@@ -19097,11 +19167,9 @@ function renderInteractionXml(interaction, diagnostics, indent, nl) {
|
|
|
19097
19167
|
parts.push(nl);
|
|
19098
19168
|
for (const choice of orderInteraction.choices) {
|
|
19099
19169
|
parts.push(`${indent}<simpleChoice identifier="${escapeXml$3(choice.identifier)}">`);
|
|
19100
|
-
|
|
19101
|
-
|
|
19102
|
-
|
|
19103
|
-
parts.push(normalized.content);
|
|
19104
|
-
} 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);
|
|
19105
19173
|
parts.push("</simpleChoice>");
|
|
19106
19174
|
parts.push(nl);
|
|
19107
19175
|
}
|
|
@@ -19126,11 +19194,9 @@ function renderInteractionXml(interaction, diagnostics, indent, nl) {
|
|
|
19126
19194
|
parts.push(nl);
|
|
19127
19195
|
for (const choice of matchInteraction.sourceSet) {
|
|
19128
19196
|
parts.push(`${indent}${indent}<simpleAssociableChoice identifier="${escapeXml$3(choice.identifier)}" matchMax="${choice.matchMax}">`);
|
|
19129
|
-
|
|
19130
|
-
|
|
19131
|
-
|
|
19132
|
-
parts.push(normalized.content);
|
|
19133
|
-
} 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);
|
|
19134
19200
|
parts.push("</simpleAssociableChoice>");
|
|
19135
19201
|
parts.push(nl);
|
|
19136
19202
|
}
|
|
@@ -19140,11 +19206,9 @@ function renderInteractionXml(interaction, diagnostics, indent, nl) {
|
|
|
19140
19206
|
parts.push(nl);
|
|
19141
19207
|
for (const choice of matchInteraction.targetSet) {
|
|
19142
19208
|
parts.push(`${indent}${indent}<simpleAssociableChoice identifier="${escapeXml$3(choice.identifier)}" matchMax="${choice.matchMax}">`);
|
|
19143
|
-
|
|
19144
|
-
|
|
19145
|
-
|
|
19146
|
-
parts.push(normalized.content);
|
|
19147
|
-
} 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);
|
|
19148
19212
|
parts.push("</simpleAssociableChoice>");
|
|
19149
19213
|
parts.push(nl);
|
|
19150
19214
|
}
|
|
@@ -19234,11 +19298,9 @@ function renderInteractionXml(interaction, diagnostics, indent, nl) {
|
|
|
19234
19298
|
parts.push(nl);
|
|
19235
19299
|
for (const choice of associateInteraction.choices) {
|
|
19236
19300
|
parts.push(`${indent}<simpleAssociableChoice identifier="${escapeXml$3(choice.identifier)}" matchMax="${choice.matchMax}">`);
|
|
19237
|
-
|
|
19238
|
-
|
|
19239
|
-
|
|
19240
|
-
parts.push(normalized.content);
|
|
19241
|
-
} 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);
|
|
19242
19304
|
parts.push("</simpleAssociableChoice>");
|
|
19243
19305
|
parts.push(nl);
|
|
19244
19306
|
}
|
|
@@ -19337,13 +19399,9 @@ function buildChoiceInteractionXml(interaction, feedbackBlock, diagnostics, part
|
|
|
19337
19399
|
parts.push(nl);
|
|
19338
19400
|
for (let i = 0; i < interaction.choices.length; i++) {
|
|
19339
19401
|
const choice = interaction.choices[i];
|
|
19340
|
-
const
|
|
19341
|
-
|
|
19342
|
-
|
|
19343
|
-
const normalized = normalizeXhtmlVoidElements(choice.content, `choiceInteraction.simpleChoice[${i}]`);
|
|
19344
|
-
diagnostics.push(...normalized.diagnostics);
|
|
19345
|
-
choiceContent = normalized.content;
|
|
19346
|
-
} 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;
|
|
19347
19405
|
const feedbackAttr = choice.feedbackBlockIdentifier ? ` feedbackBlock="${escapeXml$3(choice.feedbackBlockIdentifier)}"` : "";
|
|
19348
19406
|
parts.push(`${indent3}<simpleChoice identifier="${escapeXml$3(choice.identifier)}"${feedbackAttr}>${choiceContent}</simpleChoice>`);
|
|
19349
19407
|
parts.push(nl);
|
|
@@ -19352,13 +19410,9 @@ function buildChoiceInteractionXml(interaction, feedbackBlock, diagnostics, part
|
|
|
19352
19410
|
parts.push(nl);
|
|
19353
19411
|
if (feedbackBlock && feedbackBlock.length > 0) for (let i = 0; i < feedbackBlock.length; i++) {
|
|
19354
19412
|
const feedback = feedbackBlock[i];
|
|
19355
|
-
const
|
|
19356
|
-
|
|
19357
|
-
|
|
19358
|
-
const normalized = normalizeXhtmlVoidElements(feedback.content, `feedbackBlock[${i}]`);
|
|
19359
|
-
diagnostics.push(...normalized.diagnostics);
|
|
19360
|
-
feedbackContent = normalized.content;
|
|
19361
|
-
} else feedbackContent = escapeXml$3(feedback.content);
|
|
19413
|
+
const normalized = normalizeHtmlContentBody(feedback.content, `feedbackBlock[${i}]`);
|
|
19414
|
+
diagnostics.push(...normalized.diagnostics);
|
|
19415
|
+
const feedbackContent = normalized.content;
|
|
19362
19416
|
parts.push(`${indent2}<feedbackBlock identifier="${escapeXml$3(feedback.identifier)}" outcomeIdentifier="FEEDBACK" showHide="${feedback.showHide}">${feedbackContent}</feedbackBlock>`);
|
|
19363
19417
|
parts.push(nl);
|
|
19364
19418
|
}
|
|
@@ -19485,8 +19539,7 @@ function buildTextEntryInteractionXml(interaction, diagnostics, parts, indent, i
|
|
|
19485
19539
|
parts.push(nl);
|
|
19486
19540
|
}
|
|
19487
19541
|
let template = interaction.template;
|
|
19488
|
-
|
|
19489
|
-
if (hasHtmlTags) {
|
|
19542
|
+
{
|
|
19490
19543
|
const normalized = normalizeXhtmlVoidElements(template, "textEntryInteraction.template");
|
|
19491
19544
|
diagnostics.push(...normalized.diagnostics);
|
|
19492
19545
|
template = normalized.content;
|
|
@@ -19499,7 +19552,7 @@ function buildTextEntryInteractionXml(interaction, diagnostics, parts, indent, i
|
|
|
19499
19552
|
while ((match = placeholderRegex.exec(template)) !== null) {
|
|
19500
19553
|
if (match.index > lastIndex) {
|
|
19501
19554
|
const textSegment = template.substring(lastIndex, match.index);
|
|
19502
|
-
segments.push(
|
|
19555
|
+
segments.push(textSegment);
|
|
19503
19556
|
}
|
|
19504
19557
|
if (entryIndex < interaction.textEntries.length) {
|
|
19505
19558
|
const entry = interaction.textEntries[entryIndex];
|
|
@@ -19515,7 +19568,7 @@ function buildTextEntryInteractionXml(interaction, diagnostics, parts, indent, i
|
|
|
19515
19568
|
}
|
|
19516
19569
|
if (lastIndex < template.length) {
|
|
19517
19570
|
const textSegment = template.substring(lastIndex);
|
|
19518
|
-
segments.push(
|
|
19571
|
+
segments.push(textSegment);
|
|
19519
19572
|
}
|
|
19520
19573
|
parts.push(`${indent2}<div>`);
|
|
19521
19574
|
parts.push(segments.join(""));
|
|
@@ -19563,11 +19616,9 @@ function buildExtendedTextInteractionXml(interaction, outcomeDeclaration, diagno
|
|
|
19563
19616
|
parts.push(`${indent}<itemBody>`);
|
|
19564
19617
|
parts.push(nl);
|
|
19565
19618
|
if (interaction.prompt) {
|
|
19566
|
-
|
|
19567
|
-
|
|
19568
|
-
|
|
19569
|
-
parts.push(`${indent2}${normalized.content}`);
|
|
19570
|
-
} 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}`);
|
|
19571
19622
|
parts.push(nl);
|
|
19572
19623
|
}
|
|
19573
19624
|
let interactionTag = `${indent2}<extendedTextInteraction responseIdentifier="${interaction.responseIdentifier}"`;
|
|
@@ -19601,11 +19652,9 @@ function buildUploadInteractionXml(interaction, diagnostics, parts, indent, inde
|
|
|
19601
19652
|
parts.push(`${indent}<itemBody>`);
|
|
19602
19653
|
parts.push(nl);
|
|
19603
19654
|
if (interaction.prompt) {
|
|
19604
|
-
|
|
19605
|
-
|
|
19606
|
-
|
|
19607
|
-
parts.push(`${indent2}${normalized.content}`);
|
|
19608
|
-
} 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}`);
|
|
19609
19658
|
parts.push(nl);
|
|
19610
19659
|
}
|
|
19611
19660
|
let interactionTag = `${indent2}<uploadInteraction responseIdentifier="${interaction.responseIdentifier}"`;
|
|
@@ -19642,14 +19691,15 @@ function buildDrawingInteractionXml(interaction, diagnostics, parts, indent, ind
|
|
|
19642
19691
|
parts.push(nl);
|
|
19643
19692
|
parts.push(`${indent3}<prompt>`);
|
|
19644
19693
|
if (interaction.prompt) {
|
|
19645
|
-
|
|
19646
|
-
|
|
19647
|
-
|
|
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) {
|
|
19648
19698
|
parts.push(nl);
|
|
19649
19699
|
parts.push(`${indent3} ${normalized.content}`);
|
|
19650
19700
|
parts.push(nl);
|
|
19651
19701
|
parts.push(`${indent3}`);
|
|
19652
|
-
} else parts.push(
|
|
19702
|
+
} else parts.push(normalized.content);
|
|
19653
19703
|
}
|
|
19654
19704
|
parts.push(`</prompt>`);
|
|
19655
19705
|
parts.push(nl);
|
|
@@ -19720,11 +19770,9 @@ function buildInlineChoiceInteractionXml(interaction, diagnostics, parts, indent
|
|
|
19720
19770
|
parts.push(`${indent}<itemBody>`);
|
|
19721
19771
|
parts.push(nl);
|
|
19722
19772
|
if (interaction.prompt) {
|
|
19723
|
-
|
|
19724
|
-
|
|
19725
|
-
|
|
19726
|
-
parts.push(`${indent2}${normalized.content}`);
|
|
19727
|
-
} 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}`);
|
|
19728
19776
|
parts.push(nl);
|
|
19729
19777
|
}
|
|
19730
19778
|
if (interaction.template && interaction.inlineChoiceEntries) {
|
|
@@ -19734,10 +19782,7 @@ function buildInlineChoiceInteractionXml(interaction, diagnostics, parts, indent
|
|
|
19734
19782
|
let inlineChoiceXml = `<inlineChoiceInteraction responseIdentifier="${entry.responseIdentifier}"`;
|
|
19735
19783
|
if (entry.shuffle) inlineChoiceXml += ` shuffle="true"`;
|
|
19736
19784
|
inlineChoiceXml += ">";
|
|
19737
|
-
for (const choice of entry.inlineChoices) {
|
|
19738
|
-
const choiceContent = /<[a-zA-Z][\s\S]*?>/.test(choice.content) ? choice.content : escapeXml$3(choice.content);
|
|
19739
|
-
inlineChoiceXml += `<inlineChoice identifier="${escapeXml$3(choice.identifier)}">${choiceContent}</inlineChoice>`;
|
|
19740
|
-
}
|
|
19785
|
+
for (const choice of entry.inlineChoices) inlineChoiceXml += `<inlineChoice identifier="${escapeXml$3(choice.identifier)}">${choice.content}</inlineChoice>`;
|
|
19741
19786
|
inlineChoiceXml += "</inlineChoiceInteraction>";
|
|
19742
19787
|
templateHtml = templateHtml.replace("{{response}}", inlineChoiceXml);
|
|
19743
19788
|
}
|
|
@@ -19793,11 +19838,9 @@ function buildGapMatchInteractionXml(interaction, diagnostics, parts, indent, in
|
|
|
19793
19838
|
parts.push(`${indent}<itemBody>`);
|
|
19794
19839
|
parts.push(nl);
|
|
19795
19840
|
if (interaction.prompt) {
|
|
19796
|
-
|
|
19797
|
-
|
|
19798
|
-
|
|
19799
|
-
parts.push(`${indent2}${normalized.content}`);
|
|
19800
|
-
} 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}`);
|
|
19801
19844
|
parts.push(nl);
|
|
19802
19845
|
}
|
|
19803
19846
|
parts.push(`${indent2}<gapMatchInteraction responseIdentifier="${interaction.responseIdentifier}"`);
|
|
@@ -19805,11 +19848,9 @@ function buildGapMatchInteractionXml(interaction, diagnostics, parts, indent, in
|
|
|
19805
19848
|
parts.push(">");
|
|
19806
19849
|
parts.push(nl);
|
|
19807
19850
|
if (interaction.gapTexts) for (const gapText of interaction.gapTexts) {
|
|
19808
|
-
const
|
|
19809
|
-
|
|
19810
|
-
|
|
19811
|
-
else gapTextContent = escapeXml$3(gapText.content);
|
|
19812
|
-
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>`);
|
|
19813
19854
|
parts.push(nl);
|
|
19814
19855
|
}
|
|
19815
19856
|
if (interaction.template && interaction.gapEntries) {
|
|
@@ -19873,15 +19914,10 @@ function buildOrderInteractionXml(interaction, diagnostics, parts, indent, inden
|
|
|
19873
19914
|
parts.push(`${indent}<itemBody>`);
|
|
19874
19915
|
parts.push(nl);
|
|
19875
19916
|
if (interaction.prompt) {
|
|
19876
|
-
|
|
19877
|
-
|
|
19878
|
-
|
|
19879
|
-
|
|
19880
|
-
parts.push(nl);
|
|
19881
|
-
} else {
|
|
19882
|
-
parts.push(`${indent2}<p>${escapeXml$3(interaction.prompt)}</p>`);
|
|
19883
|
-
parts.push(nl);
|
|
19884
|
-
}
|
|
19917
|
+
const normalized = normalizePromptContent(interaction.prompt, "itemBody.prompt");
|
|
19918
|
+
diagnostics.push(...normalized.diagnostics);
|
|
19919
|
+
parts.push(`${indent2}${normalized.content}`);
|
|
19920
|
+
parts.push(nl);
|
|
19885
19921
|
}
|
|
19886
19922
|
parts.push(`${indent2}<orderInteraction responseIdentifier="${interaction.responseIdentifier}"`);
|
|
19887
19923
|
if (interaction.shuffle) parts.push(` shuffle="true"`);
|
|
@@ -19890,11 +19926,9 @@ function buildOrderInteractionXml(interaction, diagnostics, parts, indent, inden
|
|
|
19890
19926
|
parts.push(nl);
|
|
19891
19927
|
for (const choice of interaction.choices) {
|
|
19892
19928
|
parts.push(`${indent3}<simpleChoice identifier="${escapeXml$3(choice.identifier)}">`);
|
|
19893
|
-
|
|
19894
|
-
|
|
19895
|
-
|
|
19896
|
-
parts.push(normalized.content);
|
|
19897
|
-
} 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);
|
|
19898
19932
|
parts.push("</simpleChoice>");
|
|
19899
19933
|
parts.push(nl);
|
|
19900
19934
|
}
|
|
@@ -20013,15 +20047,10 @@ function buildHottextInteractionXml(interaction, diagnostics, parts, indent, ind
|
|
|
20013
20047
|
parts.push(`${indent}<itemBody>`);
|
|
20014
20048
|
parts.push(nl);
|
|
20015
20049
|
if (interaction.prompt) {
|
|
20016
|
-
|
|
20017
|
-
|
|
20018
|
-
|
|
20019
|
-
|
|
20020
|
-
parts.push(nl);
|
|
20021
|
-
} else {
|
|
20022
|
-
parts.push(`${indent2}<p>${escapeXml$3(interaction.prompt)}</p>`);
|
|
20023
|
-
parts.push(nl);
|
|
20024
|
-
}
|
|
20050
|
+
const normalized = normalizePromptContent(interaction.prompt, "itemBody.prompt");
|
|
20051
|
+
diagnostics.push(...normalized.diagnostics);
|
|
20052
|
+
parts.push(`${indent2}${normalized.content}`);
|
|
20053
|
+
parts.push(nl);
|
|
20025
20054
|
}
|
|
20026
20055
|
parts.push(`${indent2}<hottextInteraction responseIdentifier="${interaction.responseIdentifier}" maxChoices="${interaction.correctResponse?.length || 0}">`);
|
|
20027
20056
|
parts.push(nl);
|
|
@@ -20131,15 +20160,10 @@ function buildGraphicGapMatchInteractionXml(interaction, diagnostics, parts, ind
|
|
|
20131
20160
|
parts.push(`${indent}<itemBody>`);
|
|
20132
20161
|
parts.push(nl);
|
|
20133
20162
|
if (interaction.prompt) {
|
|
20134
|
-
|
|
20135
|
-
|
|
20136
|
-
|
|
20137
|
-
|
|
20138
|
-
parts.push(nl);
|
|
20139
|
-
} else {
|
|
20140
|
-
parts.push(`${indent2}<p>${escapeXml$3(interaction.prompt)}</p>`);
|
|
20141
|
-
parts.push(nl);
|
|
20142
|
-
}
|
|
20163
|
+
const normalized = normalizePromptContent(interaction.prompt, "itemBody.prompt");
|
|
20164
|
+
diagnostics.push(...normalized.diagnostics);
|
|
20165
|
+
parts.push(`${indent2}${normalized.content}`);
|
|
20166
|
+
parts.push(nl);
|
|
20143
20167
|
}
|
|
20144
20168
|
parts.push(`${indent2}<graphicGapMatchInteraction responseIdentifier="${interaction.responseIdentifier}" shuffle="${interaction.shuffle}">`);
|
|
20145
20169
|
parts.push(nl);
|
|
@@ -20217,11 +20241,9 @@ function buildAssociateInteractionXml(interaction, diagnostics, parts, indent, i
|
|
|
20217
20241
|
parts.push(nl);
|
|
20218
20242
|
for (const choice of interaction.choices) {
|
|
20219
20243
|
parts.push(`${indent3}<simpleAssociableChoice identifier="${escapeXml$3(choice.identifier)}" matchMax="${choice.matchMax}">`);
|
|
20220
|
-
|
|
20221
|
-
|
|
20222
|
-
|
|
20223
|
-
parts.push(normalized.content);
|
|
20224
|
-
} 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);
|
|
20225
20247
|
parts.push("</simpleAssociableChoice>");
|
|
20226
20248
|
parts.push(nl);
|
|
20227
20249
|
}
|
|
@@ -20463,13 +20485,9 @@ function buildAssessmentItemXml(ast, pretty, version) {
|
|
|
20463
20485
|
if (ast.modalFeedback && ast.modalFeedback.length > 0) for (let i = 0; i < ast.modalFeedback.length; i++) {
|
|
20464
20486
|
const typedFeedback = ast.modalFeedback[i];
|
|
20465
20487
|
let feedbackXml = `${indent}<modalFeedback identifier="${escapeXml$3(typedFeedback.identifier)}" outcomeIdentifier="${escapeXml$3(typedFeedback.outcomeIdentifier)}" showHide="${typedFeedback.showHide}">${nl}`;
|
|
20466
|
-
const
|
|
20467
|
-
|
|
20468
|
-
|
|
20469
|
-
const normalized = normalizeXhtmlVoidElements(typedFeedback.content, `modalFeedback[${i}]`);
|
|
20470
|
-
diagnostics.push(...normalized.diagnostics);
|
|
20471
|
-
feedbackContent = normalized.content;
|
|
20472
|
-
} else feedbackContent = escapeXml$3(typedFeedback.content);
|
|
20488
|
+
const normalized = normalizeHtmlContentBody(typedFeedback.content, `modalFeedback[${i}]`);
|
|
20489
|
+
diagnostics.push(...normalized.diagnostics);
|
|
20490
|
+
const feedbackContent = normalized.content;
|
|
20473
20491
|
feedbackXml += `${indent2}${feedbackContent}${nl}`;
|
|
20474
20492
|
feedbackXml += `${indent}</modalFeedback>${nl}`;
|
|
20475
20493
|
sections.modalFeedback.push(feedbackXml);
|