@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
package/packages/cli/dist/{qtiToLearnosity-CkD0r1q0.js.map → qtiToLearnosity-jiFTBiQU.js.map}
RENAMED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"qtiToLearnosity-CkD0r1q0.js","names":[],"sources":["../src/commands/qtiToLearnosity.ts"],"sourcesContent":["/* eslint-disable @typescript-eslint/no-explicit-any */\n\nimport type { Command } from 'commander';\nimport type { ConversionOptions, Diagnostic } from '@learnosity/converter-core';\nimport { convertQtiToLearnosity } from '@learnosity/converter-core';\nimport { nodeFileAccess } from '@learnosity/converter-core/node';\nimport { readInput } from '../io/readInput.js';\nimport { writeOutput } from '../io/writeOutput.js';\nimport { writeDiagnostics } from '../io/writeDiagnostics.js';\nimport { showBanner } from '../ux/banner.js';\nimport { showResolvedOptions } from '../ux/resolvedOptions.js';\nimport { ProgressTracker } from '../ux/progress.js';\nimport { formatDiagnosticsTable, countErrors } from '../ux/table.js';\nimport { loadConfig } from '../options/loadConfig.js';\nimport { resolveOptions } from '../options/resolveOptions.js';\nimport type { CliOptions } from '../options/types.js';\n\n/**\n * Register qti-to-learnosity command\n */\nexport function registerQtiToLearnosityCommand(program: Command, version: string): void {\n program\n .command('qti-to-learnosity')\n .description('Convert a single QTI file to Learnosity JSON')\n .option('--in <path>', 'Input file path or \"-\" for stdin')\n .option('--out <path>', 'Output file path or \"-\" for stdout')\n .option('--qti-version <version>', 'QTI version (2.1 or 2.2, default: 2.2)')\n .option(\n '--output-format <format>',\n 'Output format (dir|zip|stdout, default: auto-detect from output path)'\n )\n .option(\n '--diagnostics <mode>',\n 'Diagnostics output (stderr|file|both|none, default: file for file output, stderr for stdout)'\n )\n .option(\n '--organisation_id <number>',\n 'Organisation ID for Learnosity CDN asset URLs',\n parseInt\n )\n .option('--org_id <number>', 'Alias for --organisation_id', parseInt)\n .option('--mediavault', 'Use media-vault subdomain instead of assets (default: false)')\n .option(\n '--custom-asset-url <url>',\n 'Custom asset URL prefix to override default Learnosity CDN'\n )\n .option(\n '--item-reference-source <source>',\n 'How to generate item references: sourceFilename (default), qti (identifier), or uuid'\n )\n .option(\n '--truncate-tags',\n 'Truncate tag types and names to 255 characters instead of failing (default: false)'\n )\n .option('--config <path>', 'Path to config file')\n .option('--no-config', 'Disable config file loading')\n .option('-i, --interactive', 'Enable interactive prompts (default: false)')\n .option('--verbose', 'Verbose output (default: false)')\n .option('--pretty', 'Pretty-print JSON output (default: false)')\n .option('-q, --quiet', 'Suppress non-essential output (default: false)')\n .action(async (opts: CliOptions) => {\n await executeQtiToLearnosity(opts, version);\n });\n}\n\nasync function resolveOutputFilePath(outputPath: string, itemReference?: string): Promise<string> {\n if (outputPath === '-' || !itemReference) {\n return outputPath;\n }\n\n const fs = await import('fs/promises');\n\n try {\n const stat = await fs.stat(outputPath);\n\n if (stat.isDirectory()) {\n return `${outputPath}/${itemReference}.json`;\n }\n } catch {\n if (outputPath.endsWith('/') || !outputPath.includes('.')) {\n return `${outputPath}${outputPath.endsWith('/') ? '' : '/'}${itemReference}.json`;\n }\n }\n\n return outputPath;\n}\n\n/**\n * Execute qti-to-learnosity conversion\n */\nasync function executeQtiToLearnosity(cliOpts: CliOptions, version: string): Promise<void> {\n const allDiagnostics: Diagnostic[] = [];\n const quiet = cliOpts.quiet ?? false;\n\n try {\n showBanner('qti-to-learnosity', version, quiet);\n\n // Load config\n const {\n config,\n diagnostics: configDiagnostics,\n configPath,\n } = await loadConfig(cliOpts.config, cliOpts.noConfig);\n\n allDiagnostics.push(...configDiagnostics);\n\n // Check for config errors\n const configErrors = configDiagnostics.filter((d) => d.level === 'error');\n\n if (configErrors.length > 0) {\n console.log('\\n' + formatDiagnosticsTable(configDiagnostics));\n process.exit(1);\n }\n\n // Resolve options\n const {\n options: resolved,\n diagnostics: resolveDiagnostics,\n withSources,\n } = await resolveOptions(cliOpts, config, false, configPath);\n\n allDiagnostics.push(...resolveDiagnostics);\n\n // Show resolved options\n showResolvedOptions(resolved, withSources, quiet);\n\n const progress = new ProgressTracker(resolved.verbose);\n\n // Read input\n progress.startStage('Reading input...');\n const input = await readInput(resolved.inputPath);\n\n progress.succeedStage('Input read');\n\n // Convert\n progress.startStage('Converting QTI to Learnosity...');\n const conversionOpts: ConversionOptions = {\n qtiVersion: resolved.qtiVersion,\n outputFormat: resolved.outputFormat,\n diagnostics: resolved.diagnostics,\n verbose: resolved.verbose,\n pretty: resolved.pretty,\n inputPath: resolved.inputPath,\n organisationId: resolved.organisationId, // TASK 030\n mediaVault: resolved.mediaVault,\n customAssetUrl: resolved.customAssetUrl,\n itemReferenceSource: resolved.itemReferenceSource,\n truncateTags: resolved.truncateTags,\n fileAccess: nodeFileAccess,\n };\n const result = await convertQtiToLearnosity(input, conversionOpts);\n\n // Set diagnostics file to input filename only\n const inputFilename = resolved.inputPath.split('/').pop() ?? resolved.inputPath;\n const prefixedDiagnostics = result.diagnostics.map((d) => ({\n ...d,\n file: inputFilename,\n }));\n\n allDiagnostics.push(...prefixedDiagnostics);\n progress.succeedStage('Conversion complete');\n\n // Determine output path - use MD5-based filename if output is a directory\n const itemReference = (result.output as any).reference;\n const finalOutputPath = await resolveOutputFilePath(resolved.outputPath, itemReference);\n\n // Write output\n progress.startStage('Writing output...');\n await writeOutput(finalOutputPath, result.output, resolved.pretty);\n progress.succeedStage('Output written');\n\n // Write diagnostics\n if (resolved.diagnostics !== 'none') {\n progress.startStage('Writing diagnostics...');\n const hasErrors = allDiagnostics.some((d) => d.level === 'error');\n\n await writeDiagnostics(\n allDiagnostics,\n resolved.diagnostics,\n resolved.diagnosticsPath,\n resolved.outputPath,\n resolved.verbose,\n {\n inputPath: resolved.inputPath,\n outputPath: resolved.outputPath,\n totalItemsFound: 1,\n convertedFiles: hasErrors ? [] : [inputFilename],\n failedFiles: hasErrors ? [inputFilename] : [],\n }\n );\n progress.succeedStage('Diagnostics written');\n }\n\n // Display diagnostics table only if mode is stderr or both\n if (resolved.diagnostics === 'stderr' || resolved.diagnostics === 'both') {\n console.log('\\n' + formatDiagnosticsTable(allDiagnostics));\n }\n\n const errorCount = countErrors(allDiagnostics);\n\n process.exit(errorCount > 0 ? 1 : 0);\n } catch (error) {\n if (error instanceof Error && error.name === 'ExitPromptError') {\n process.exit(130);\n }\n console.error('\\n' + (error instanceof Error ? error.message : 'Unknown error'));\n process.exit(1);\n }\n}\n"],"mappings":";;;;;;;;AAoBA,SAAgB,+BAA+B,SAAkB,SAAuB;CACpF,QACK,QAAQ,mBAAmB,CAAC,CAC5B,YAAY,8CAA8C,CAAC,CAC3D,OAAO,eAAe,oCAAkC,CAAC,CACzD,OAAO,gBAAgB,sCAAoC,CAAC,CAC5D,OAAO,2BAA2B,wCAAwC,CAAC,CAC3E,OACG,4BACA,uEACJ,CAAC,CACA,OACG,wBACA,8FACJ,CAAC,CACA,OACG,8BACA,iDACA,QACJ,CAAC,CACA,OAAO,qBAAqB,+BAA+B,QAAQ,CAAC,CACpE,OAAO,gBAAgB,8DAA8D,CAAC,CACtF,OACG,4BACA,4DACJ,CAAC,CACA,OACG,oCACA,sFACJ,CAAC,CACA,OACG,mBACA,oFACJ,CAAC,CACA,OAAO,mBAAmB,qBAAqB,CAAC,CAChD,OAAO,eAAe,6BAA6B,CAAC,CACpD,OAAO,qBAAqB,6CAA6C,CAAC,CAC1E,OAAO,aAAa,iCAAiC,CAAC,CACtD,OAAO,YAAY,2CAA2C,CAAC,CAC/D,OAAO,eAAe,gDAAgD,CAAC,CACvE,OAAO,OAAO,SAAqB;EAChC,MAAM,uBAAuB,MAAM,OAAO;CAC9C,CAAC;AACT;AAEA,eAAe,sBAAsB,YAAoB,eAAyC;CAC9F,IAAI,eAAe,OAAO,CAAC,eACvB,OAAO;CAGX,MAAM,KAAK,MAAM,OAAO;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FTBiQU.js","names":[],"sources":["../src/commands/qtiToLearnosity.ts"],"sourcesContent":["/* eslint-disable @typescript-eslint/no-explicit-any */\n\nimport type { Command } from 'commander';\nimport type { ConversionOptions, Diagnostic } from '@learnosity/converter-core';\nimport { convertQtiToLearnosity } from '@learnosity/converter-core';\nimport { nodeFileAccess } from '@learnosity/converter-core/node';\nimport { readInput } from '../io/readInput.js';\nimport { writeOutput } from '../io/writeOutput.js';\nimport { writeDiagnostics } from '../io/writeDiagnostics.js';\nimport { showBanner } from '../ux/banner.js';\nimport { showResolvedOptions } from '../ux/resolvedOptions.js';\nimport { ProgressTracker } from '../ux/progress.js';\nimport { formatDiagnosticsTable, countErrors } from '../ux/table.js';\nimport { loadConfig } from '../options/loadConfig.js';\nimport { resolveOptions } from '../options/resolveOptions.js';\nimport type { CliOptions } from '../options/types.js';\n\n/**\n * Register qti-to-learnosity command\n */\nexport function registerQtiToLearnosityCommand(program: Command, version: string): void {\n program\n .command('qti-to-learnosity')\n .description('Convert a single QTI file to Learnosity JSON')\n .option('--in <path>', 'Input file path or \"-\" for stdin')\n .option('--out <path>', 'Output file path or \"-\" for stdout')\n .option('--qti-version <version>', 'QTI version (2.1 or 2.2, default: 2.2)')\n .option(\n '--output-format <format>',\n 'Output format (dir|zip|stdout, default: auto-detect from output path)'\n )\n .option(\n '--diagnostics <mode>',\n 'Diagnostics output (stderr|file|both|none, default: file for file output, stderr for stdout)'\n )\n .option(\n '--organisation_id <number>',\n 'Organisation ID for Learnosity CDN asset URLs',\n parseInt\n )\n .option('--org_id <number>', 'Alias for --organisation_id', parseInt)\n .option('--mediavault', 'Use media-vault subdomain instead of assets (default: false)')\n .option(\n '--custom-asset-url <url>',\n 'Custom asset URL prefix to override default Learnosity CDN'\n )\n .option(\n '--item-reference-source <source>',\n 'How to generate item references: sourceFilename (default), qti (identifier), or uuid'\n )\n .option(\n '--truncate-tags',\n 'Truncate tag types and names to 255 characters instead of failing (default: false)'\n )\n .option('--config <path>', 'Path to config file')\n .option('--no-config', 'Disable config file loading')\n .option('-i, --interactive', 'Enable interactive prompts (default: false)')\n .option('--verbose', 'Verbose output (default: false)')\n .option('--pretty', 'Pretty-print JSON output (default: false)')\n .option('-q, --quiet', 'Suppress non-essential output (default: false)')\n .action(async (opts: CliOptions) => {\n await executeQtiToLearnosity(opts, version);\n });\n}\n\nasync function resolveOutputFilePath(outputPath: string, itemReference?: string): Promise<string> {\n if (outputPath === '-' || !itemReference) {\n return outputPath;\n }\n\n const fs = await import('fs/promises');\n\n try {\n const stat = await fs.stat(outputPath);\n\n if (stat.isDirectory()) {\n return `${outputPath}/${itemReference}.json`;\n }\n } catch {\n if (outputPath.endsWith('/') || !outputPath.includes('.')) {\n return `${outputPath}${outputPath.endsWith('/') ? '' : '/'}${itemReference}.json`;\n }\n }\n\n return outputPath;\n}\n\n/**\n * Execute qti-to-learnosity conversion\n */\nasync function executeQtiToLearnosity(cliOpts: CliOptions, version: string): Promise<void> {\n const allDiagnostics: Diagnostic[] = [];\n const quiet = cliOpts.quiet ?? false;\n\n try {\n showBanner('qti-to-learnosity', version, quiet);\n\n // Load config\n const {\n config,\n diagnostics: configDiagnostics,\n configPath,\n } = await loadConfig(cliOpts.config, cliOpts.noConfig);\n\n allDiagnostics.push(...configDiagnostics);\n\n // Check for config errors\n const configErrors = configDiagnostics.filter((d) => d.level === 'error');\n\n if (configErrors.length > 0) {\n console.log('\\n' + formatDiagnosticsTable(configDiagnostics));\n process.exit(1);\n }\n\n // Resolve options\n const {\n options: resolved,\n diagnostics: resolveDiagnostics,\n withSources,\n } = await resolveOptions(cliOpts, config, false, configPath);\n\n allDiagnostics.push(...resolveDiagnostics);\n\n // Show resolved options\n showResolvedOptions(resolved, withSources, quiet);\n\n const progress = new ProgressTracker(resolved.verbose);\n\n // Read input\n progress.startStage('Reading input...');\n const input = await readInput(resolved.inputPath);\n\n progress.succeedStage('Input read');\n\n // Convert\n progress.startStage('Converting QTI to Learnosity...');\n const conversionOpts: ConversionOptions = {\n qtiVersion: resolved.qtiVersion,\n outputFormat: resolved.outputFormat,\n diagnostics: resolved.diagnostics,\n verbose: resolved.verbose,\n pretty: resolved.pretty,\n inputPath: resolved.inputPath,\n organisationId: resolved.organisationId, // TASK 030\n mediaVault: resolved.mediaVault,\n customAssetUrl: resolved.customAssetUrl,\n itemReferenceSource: resolved.itemReferenceSource,\n truncateTags: resolved.truncateTags,\n fileAccess: nodeFileAccess,\n };\n const result = await convertQtiToLearnosity(input, conversionOpts);\n\n // Set diagnostics file to input filename only\n const inputFilename = resolved.inputPath.split('/').pop() ?? resolved.inputPath;\n const prefixedDiagnostics = result.diagnostics.map((d) => ({\n ...d,\n file: inputFilename,\n }));\n\n allDiagnostics.push(...prefixedDiagnostics);\n progress.succeedStage('Conversion complete');\n\n // Determine output path - use MD5-based filename if output is a directory\n const itemReference = (result.output as any).reference;\n const finalOutputPath = await resolveOutputFilePath(resolved.outputPath, itemReference);\n\n // Write output\n progress.startStage('Writing output...');\n await writeOutput(finalOutputPath, result.output, resolved.pretty);\n progress.succeedStage('Output written');\n\n // Write diagnostics\n if (resolved.diagnostics !== 'none') {\n progress.startStage('Writing diagnostics...');\n const hasErrors = allDiagnostics.some((d) => d.level === 'error');\n\n await writeDiagnostics(\n allDiagnostics,\n resolved.diagnostics,\n resolved.diagnosticsPath,\n resolved.outputPath,\n resolved.verbose,\n {\n inputPath: resolved.inputPath,\n outputPath: resolved.outputPath,\n totalItemsFound: 1,\n convertedFiles: hasErrors ? [] : [inputFilename],\n failedFiles: hasErrors ? [inputFilename] : [],\n }\n );\n progress.succeedStage('Diagnostics written');\n }\n\n // Display diagnostics table only if mode is stderr or both\n if (resolved.diagnostics === 'stderr' || resolved.diagnostics === 'both') {\n console.log('\\n' + formatDiagnosticsTable(allDiagnostics));\n }\n\n const errorCount = countErrors(allDiagnostics);\n\n process.exit(errorCount > 0 ? 1 : 0);\n } catch (error) {\n if (error instanceof Error && error.name === 'ExitPromptError') {\n process.exit(130);\n }\n console.error('\\n' + (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BAAkB,MAAM,sBAAsB,SAAS,YAAY,aAAa;EAGtF,SAAS,WAAW,mBAAmB;EACvC,MAAM,YAAY,iBAAiB,OAAO,QAAQ,SAAS,MAAM;EACjE,SAAS,aAAa,gBAAgB;EAGtC,IAAI,SAAS,gBAAgB,QAAQ;GACjC,SAAS,WAAW,wBAAwB;GAC5C,MAAM,YAAY,eAAe,MAAM,MAAM,EAAE,UAAU,OAAO;GAEhE,MAAM,iBACF,gBACA,SAAS,aACT,SAAS,iBACT,SAAS,YACT,SAAS,SACT;IACI,WAAW,SAAS;IACpB,YAAY,SAAS;IACrB,iBAAiB;IACjB,gBAAgB,YAAY,CAAC,IAAI,CAAC,aAAa;IAC/C,aAAa,YAAY,CAAC,aAAa,IAAI,CAAC;GAChD,CACJ;GACA,SAAS,aAAa,qBAAqB;EAC/C;EAGA,IAAI,SAAS,gBAAgB,YAAY,SAAS,gBAAgB,QAC9D,QAAQ,IAAI,OAAO,uBAAuB,cAAc,CAAC;EAG7D,MAAM,aAAa,YAAY,cAAc;EAE7C,QAAQ,KAAK,aAAa,IAAI,IAAI,CAAC;CACvC,SAAS,OAAO;EACZ,IAAI,iBAAiB,SAAS,MAAM,SAAS,mBACzC,QAAQ,KAAK,GAAG;EAEpB,QAAQ,MAAM,QAAQ,iBAAiB,QAAQ,MAAM,UAAU,gBAAgB;EAC/E,QAAQ,KAAK,CAAC;CAClB;AACJ"}
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { i as __toESM, n as __exportAll, r as __require, t as __commonJSMin } from "./rolldown-runtime-B4iAMlE-.js";
|
|
2
|
-
import { r as onExit } from "./create-prompt-
|
|
3
|
-
import { t as dist_default } from "./dist-
|
|
4
|
-
import { a as chalk, c as DiagnosticCode, i as boxen, l as dist_default$1, o as eastAsianWidth, s as stripAnsi, t as expandTilde } from "./pathUtils-
|
|
2
|
+
import { r as onExit } from "./create-prompt-DU9wLVhI.js";
|
|
3
|
+
import { t as dist_default } from "./dist-DjpU2mIj.js";
|
|
4
|
+
import { a as chalk, c as DiagnosticCode, i as boxen, l as dist_default$1, o as eastAsianWidth, s as stripAnsi, t as expandTilde } from "./pathUtils-CwZnJ55s.js";
|
|
5
5
|
import { a as require_cli_table3, i as chalk$1 } from "./table-DYcNeyJ_.js";
|
|
6
6
|
import process$1 from "node:process";
|
|
7
7
|
import { stripVTControlCharacters } from "node:util";
|
|
@@ -13853,8 +13853,8 @@ var require_CSSStyleDeclaration = /* @__PURE__ */ __commonJSMin(((exports) => {
|
|
|
13853
13853
|
return properties.join(" ");
|
|
13854
13854
|
},
|
|
13855
13855
|
set cssText(text) {
|
|
13856
|
-
var i, name;
|
|
13857
|
-
for (
|
|
13856
|
+
var i = this.length, name;
|
|
13857
|
+
for (; i--;) {
|
|
13858
13858
|
name = this[i];
|
|
13859
13859
|
this[name] = "";
|
|
13860
13860
|
}
|
|
@@ -16022,7 +16022,7 @@ function replaceNbspEntity(html, file) {
|
|
|
16022
16022
|
*/
|
|
16023
16023
|
function normalizeXhtmlVoidElements(html, file) {
|
|
16024
16024
|
const allDiagnostics = [];
|
|
16025
|
-
const centerResult = normalizeCenterTags(html, file);
|
|
16025
|
+
const centerResult = normalizeCenterTags(html.replace(/[\u0000-\u0008\u000B\u000C\u000E-\u001F\uFFFE\uFFFF]/g, ""), file);
|
|
16026
16026
|
let content = centerResult.content;
|
|
16027
16027
|
allDiagnostics.push(...centerResult.diagnostics);
|
|
16028
16028
|
const underlineResult = normalizeUnderlineTags(content, file);
|
|
@@ -18182,15 +18182,90 @@ const XML_ESCAPE_MAP = {
|
|
|
18182
18182
|
};
|
|
18183
18183
|
const XML_ESCAPE_PATTERN = /[&<>"']/g;
|
|
18184
18184
|
/**
|
|
18185
|
+
* Characters that are illegal in XML 1.0 document content.
|
|
18186
|
+
*
|
|
18187
|
+
* XML 1.0 only permits the following characters below U+0020: tab (U+0009),
|
|
18188
|
+
* line feed (U+000A) and carriage return (U+000D). Every other C0 control
|
|
18189
|
+
* character (including U+0001, the SOH character) is forbidden and makes the
|
|
18190
|
+
* document non-well-formed. Also disallowed are U+FFFE and U+FFFF.
|
|
18191
|
+
*
|
|
18192
|
+
* Learnosity source JSON occasionally carries stray control characters (e.g.
|
|
18193
|
+
* a literal `\u0001` inside a choice label or attribute value); left in place
|
|
18194
|
+
* they surface as parser errors such as
|
|
18195
|
+
* "An invalid XML character (Unicode: 0x1) was found in the element content".
|
|
18196
|
+
*
|
|
18197
|
+
* @see https://www.w3.org/TR/xml/#charsets
|
|
18198
|
+
*/
|
|
18199
|
+
const INVALID_XML_CHARS_PATTERN = /[\u0000-\u0008\u000B\u000C\u000E-\u001F\uFFFE\uFFFF]/g;
|
|
18200
|
+
/**
|
|
18201
|
+
* Remove characters that are illegal in XML 1.0 content.
|
|
18202
|
+
*
|
|
18203
|
+
* The disallowed characters are stripped (rather than replaced) so that no
|
|
18204
|
+
* visible artifact is introduced into the output. Tab, newline and carriage
|
|
18205
|
+
* return are preserved because they are the only C0 controls XML 1.0 allows.
|
|
18206
|
+
*
|
|
18207
|
+
* @param text - Raw string that may contain invalid XML characters
|
|
18208
|
+
* @returns The string with all XML-illegal characters removed
|
|
18209
|
+
*/
|
|
18210
|
+
function stripInvalidXmlChars(text) {
|
|
18211
|
+
return text.replace(INVALID_XML_CHARS_PATTERN, "");
|
|
18212
|
+
}
|
|
18213
|
+
/**
|
|
18185
18214
|
* Escape XML special characters.
|
|
18186
18215
|
*
|
|
18187
|
-
*
|
|
18188
|
-
*
|
|
18189
|
-
*
|
|
18190
|
-
*
|
|
18216
|
+
* Invalid XML 1.0 characters (e.g. `\u0001`) are stripped first so they never
|
|
18217
|
+
* reach the serialized output, then a single-pass replacement over the
|
|
18218
|
+
* `[&<>"']` character class runs. Each source character is matched exactly once
|
|
18219
|
+
* and mapped independently, so the output is identical to escaping `&` first
|
|
18220
|
+
* and then the angle/quote characters (the replacement text is never
|
|
18221
|
+
* re-scanned).
|
|
18191
18222
|
*/
|
|
18192
18223
|
function escapeXml(text) {
|
|
18193
|
-
return text.replace(XML_ESCAPE_PATTERN, (ch) => XML_ESCAPE_MAP[ch]);
|
|
18224
|
+
return stripInvalidXmlChars(text).replace(XML_ESCAPE_PATTERN, (ch) => XML_ESCAPE_MAP[ch]);
|
|
18225
|
+
}
|
|
18226
|
+
/**
|
|
18227
|
+
* Normalize an HTML content body for emission inside a QTI element.
|
|
18228
|
+
*
|
|
18229
|
+
* Learnosity content fields (option/choice labels, feedback, prompts) are HTML,
|
|
18230
|
+
* so numeric/named character references such as `𝒇` or `−` must be
|
|
18231
|
+
* decoded to their literal Unicode characters before serialization — exactly as
|
|
18232
|
+
* stimulus already is via the linkedom round-trip.
|
|
18233
|
+
*
|
|
18234
|
+
* Historically these fields used a `hasHtmlTags ? normalizeXhtmlVoidElements :
|
|
18235
|
+
* escapeXml` gate. The `escapeXml` fallback treated the leading `&` of an entity
|
|
18236
|
+
* as a raw ampersand and produced double-escaped output (e.g. `𝒇`
|
|
18237
|
+
* became `&#119943;`), which players render as the literal text `𝒇`.
|
|
18238
|
+
*
|
|
18239
|
+
* Running every content body through `normalizeXhtmlVoidElements` (which performs
|
|
18240
|
+
* the DOM round-trip that decodes entities to literal chars and re-escapes only
|
|
18241
|
+
* the structural `<`, `>`, `&`) gives consistent, correct output whether or not
|
|
18242
|
+
* the field contains HTML tags.
|
|
18243
|
+
*
|
|
18244
|
+
* NOTE: This is for element CONTENT only. Attribute values, identifiers and
|
|
18245
|
+
* `<value>` payloads must continue to use `escapeXml`, since those are plain
|
|
18246
|
+
* strings where entities must not be decoded.
|
|
18247
|
+
*
|
|
18248
|
+
* @param content - HTML content body (may be plain text or contain markup)
|
|
18249
|
+
* @param file - Diagnostic path indicating where this content originated
|
|
18250
|
+
* @returns Normalized content and any diagnostics generated
|
|
18251
|
+
*/
|
|
18252
|
+
function normalizeHtmlContentBody(content, file) {
|
|
18253
|
+
return normalizeXhtmlVoidElements(content, file);
|
|
18254
|
+
}
|
|
18255
|
+
/**
|
|
18256
|
+
* Normalize a prompt for emission as a direct child of `itemBody`.
|
|
18257
|
+
*
|
|
18258
|
+
* itemBody requires block-level children, so a plain-text prompt (no HTML tags)
|
|
18259
|
+
* is wrapped in `<p>` before normalization. Either way the content is run
|
|
18260
|
+
* through the linkedom round-trip so numeric/named entities decode to literal
|
|
18261
|
+
* characters instead of being double-escaped by `escapeXml`.
|
|
18262
|
+
*
|
|
18263
|
+
* @param prompt - Prompt content (plain text or HTML)
|
|
18264
|
+
* @param file - Diagnostic path indicating where this content originated
|
|
18265
|
+
* @returns Normalized, block-level prompt content and any diagnostics generated
|
|
18266
|
+
*/
|
|
18267
|
+
function normalizePromptContent(prompt, file) {
|
|
18268
|
+
return normalizeXhtmlVoidElements(/<[a-zA-Z][\s\S]*?>/.test(prompt) ? prompt : `<p>${prompt}</p>`, file);
|
|
18194
18269
|
}
|
|
18195
18270
|
/**
|
|
18196
18271
|
* Infer MIME type from file extension
|
|
@@ -18639,22 +18714,18 @@ function renderInteractionXml(interaction, diagnostics, indent, nl) {
|
|
|
18639
18714
|
if (interaction.type === "choice") {
|
|
18640
18715
|
const choiceInteraction = interaction;
|
|
18641
18716
|
if (choiceInteraction.prompt) {
|
|
18642
|
-
|
|
18643
|
-
|
|
18644
|
-
|
|
18645
|
-
parts.push(normalized.content);
|
|
18646
|
-
} else parts.push(`<p>${escapeXml(choiceInteraction.prompt)}</p>`);
|
|
18717
|
+
const normalized = normalizePromptContent(choiceInteraction.prompt, "interaction.prompt");
|
|
18718
|
+
diagnostics.push(...normalized.diagnostics);
|
|
18719
|
+
parts.push(normalized.content);
|
|
18647
18720
|
}
|
|
18648
18721
|
const minChoicesAttr = choiceInteraction.minChoices !== void 0 ? ` minChoices="${choiceInteraction.minChoices}"` : "";
|
|
18649
18722
|
parts.push(`<choiceInteraction responseIdentifier="${choiceInteraction.responseIdentifier}" shuffle="${choiceInteraction.shuffle}"${minChoicesAttr} maxChoices="${choiceInteraction.maxChoices}">`);
|
|
18650
18723
|
parts.push(nl);
|
|
18651
18724
|
for (const choice of choiceInteraction.choices) {
|
|
18652
18725
|
parts.push(`${indent}<simpleChoice identifier="${escapeXml(choice.identifier)}">`);
|
|
18653
|
-
|
|
18654
|
-
|
|
18655
|
-
|
|
18656
|
-
parts.push(normalized.content);
|
|
18657
|
-
} else parts.push(escapeXml(choice.content));
|
|
18726
|
+
const normalized = normalizeHtmlContentBody(choice.content, `choice.${choice.identifier}`);
|
|
18727
|
+
diagnostics.push(...normalized.diagnostics);
|
|
18728
|
+
parts.push(normalized.content);
|
|
18658
18729
|
parts.push("</simpleChoice>");
|
|
18659
18730
|
parts.push(nl);
|
|
18660
18731
|
}
|
|
@@ -18662,11 +18733,9 @@ function renderInteractionXml(interaction, diagnostics, indent, nl) {
|
|
|
18662
18733
|
} else if (interaction.type === "textEntry") {
|
|
18663
18734
|
const textEntryInteraction = interaction;
|
|
18664
18735
|
if (textEntryInteraction.prompt) {
|
|
18665
|
-
|
|
18666
|
-
|
|
18667
|
-
|
|
18668
|
-
parts.push(normalized.content);
|
|
18669
|
-
} else parts.push(`<p>${escapeXml(textEntryInteraction.prompt)}</p>`);
|
|
18736
|
+
const normalized = normalizePromptContent(textEntryInteraction.prompt, "interaction.prompt");
|
|
18737
|
+
diagnostics.push(...normalized.diagnostics);
|
|
18738
|
+
parts.push(normalized.content);
|
|
18670
18739
|
}
|
|
18671
18740
|
let textEntryTag = `<textEntryInteraction responseIdentifier="${textEntryInteraction.responseIdentifier}"`;
|
|
18672
18741
|
if (textEntryInteraction.placeholderText) textEntryTag += ` placeholderText="${escapeXml(textEntryInteraction.placeholderText)}"`;
|
|
@@ -18717,10 +18786,7 @@ function renderInteractionXml(interaction, diagnostics, indent, nl) {
|
|
|
18717
18786
|
let inlineChoiceXml = `<inlineChoiceInteraction responseIdentifier="${entry.responseIdentifier}"`;
|
|
18718
18787
|
if (entry.shuffle) inlineChoiceXml += ` shuffle="true"`;
|
|
18719
18788
|
inlineChoiceXml += ">";
|
|
18720
|
-
for (const choice of entry.inlineChoices) {
|
|
18721
|
-
const choiceContent = /<[a-zA-Z][\s\S]*?>/.test(choice.content) ? choice.content : escapeXml(choice.content);
|
|
18722
|
-
inlineChoiceXml += `<inlineChoice identifier="${escapeXml(choice.identifier)}">${choiceContent}</inlineChoice>`;
|
|
18723
|
-
}
|
|
18789
|
+
for (const choice of entry.inlineChoices) inlineChoiceXml += `<inlineChoice identifier="${escapeXml(choice.identifier)}">${choice.content}</inlineChoice>`;
|
|
18724
18790
|
inlineChoiceXml += "</inlineChoiceInteraction>";
|
|
18725
18791
|
templateHtml = templateHtml.replace("{{response}}", inlineChoiceXml);
|
|
18726
18792
|
}
|
|
@@ -18744,7 +18810,9 @@ function renderInteractionXml(interaction, diagnostics, indent, nl) {
|
|
|
18744
18810
|
parts.push(">");
|
|
18745
18811
|
parts.push(nl);
|
|
18746
18812
|
if (gapMatchInteraction.gapTexts) for (const gapText of gapMatchInteraction.gapTexts) {
|
|
18747
|
-
|
|
18813
|
+
const normalized = normalizeHtmlContentBody(gapText.content, `gapText.${gapText.identifier}`);
|
|
18814
|
+
diagnostics.push(...normalized.diagnostics);
|
|
18815
|
+
parts.push(`${indent}<gapText identifier="${escapeXml(gapText.identifier)}" matchMax="1">${normalized.content}</gapText>`);
|
|
18748
18816
|
parts.push(nl);
|
|
18749
18817
|
}
|
|
18750
18818
|
if (gapMatchInteraction.template && gapMatchInteraction.gapEntries) {
|
|
@@ -18778,11 +18846,9 @@ function renderInteractionXml(interaction, diagnostics, indent, nl) {
|
|
|
18778
18846
|
parts.push(nl);
|
|
18779
18847
|
for (const choice of orderInteraction.choices) {
|
|
18780
18848
|
parts.push(`${indent}<simpleChoice identifier="${escapeXml(choice.identifier)}">`);
|
|
18781
|
-
|
|
18782
|
-
|
|
18783
|
-
|
|
18784
|
-
parts.push(normalized.content);
|
|
18785
|
-
} else parts.push(escapeXml(choice.content));
|
|
18849
|
+
const normalized = normalizeHtmlContentBody(choice.content, `choice.${choice.identifier}`);
|
|
18850
|
+
diagnostics.push(...normalized.diagnostics);
|
|
18851
|
+
parts.push(normalized.content);
|
|
18786
18852
|
parts.push("</simpleChoice>");
|
|
18787
18853
|
parts.push(nl);
|
|
18788
18854
|
}
|
|
@@ -18807,11 +18873,9 @@ function renderInteractionXml(interaction, diagnostics, indent, nl) {
|
|
|
18807
18873
|
parts.push(nl);
|
|
18808
18874
|
for (const choice of matchInteraction.sourceSet) {
|
|
18809
18875
|
parts.push(`${indent}${indent}<simpleAssociableChoice identifier="${escapeXml(choice.identifier)}" matchMax="${choice.matchMax}">`);
|
|
18810
|
-
|
|
18811
|
-
|
|
18812
|
-
|
|
18813
|
-
parts.push(normalized.content);
|
|
18814
|
-
} else parts.push(escapeXml(choice.content));
|
|
18876
|
+
const normalized = normalizeHtmlContentBody(choice.content, `sourceChoice.${choice.identifier}`);
|
|
18877
|
+
diagnostics.push(...normalized.diagnostics);
|
|
18878
|
+
parts.push(normalized.content);
|
|
18815
18879
|
parts.push("</simpleAssociableChoice>");
|
|
18816
18880
|
parts.push(nl);
|
|
18817
18881
|
}
|
|
@@ -18821,11 +18885,9 @@ function renderInteractionXml(interaction, diagnostics, indent, nl) {
|
|
|
18821
18885
|
parts.push(nl);
|
|
18822
18886
|
for (const choice of matchInteraction.targetSet) {
|
|
18823
18887
|
parts.push(`${indent}${indent}<simpleAssociableChoice identifier="${escapeXml(choice.identifier)}" matchMax="${choice.matchMax}">`);
|
|
18824
|
-
|
|
18825
|
-
|
|
18826
|
-
|
|
18827
|
-
parts.push(normalized.content);
|
|
18828
|
-
} else parts.push(escapeXml(choice.content));
|
|
18888
|
+
const normalized = normalizeHtmlContentBody(choice.content, `targetChoice.${choice.identifier}`);
|
|
18889
|
+
diagnostics.push(...normalized.diagnostics);
|
|
18890
|
+
parts.push(normalized.content);
|
|
18829
18891
|
parts.push("</simpleAssociableChoice>");
|
|
18830
18892
|
parts.push(nl);
|
|
18831
18893
|
}
|
|
@@ -18915,11 +18977,9 @@ function renderInteractionXml(interaction, diagnostics, indent, nl) {
|
|
|
18915
18977
|
parts.push(nl);
|
|
18916
18978
|
for (const choice of associateInteraction.choices) {
|
|
18917
18979
|
parts.push(`${indent}<simpleAssociableChoice identifier="${escapeXml(choice.identifier)}" matchMax="${choice.matchMax}">`);
|
|
18918
|
-
|
|
18919
|
-
|
|
18920
|
-
|
|
18921
|
-
parts.push(normalized.content);
|
|
18922
|
-
} else parts.push(escapeXml(choice.content));
|
|
18980
|
+
const normalized = normalizeHtmlContentBody(choice.content, `choice.${choice.identifier}`);
|
|
18981
|
+
diagnostics.push(...normalized.diagnostics);
|
|
18982
|
+
parts.push(normalized.content);
|
|
18923
18983
|
parts.push("</simpleAssociableChoice>");
|
|
18924
18984
|
parts.push(nl);
|
|
18925
18985
|
}
|
|
@@ -19018,13 +19078,9 @@ function buildChoiceInteractionXml(interaction, feedbackBlock, diagnostics, part
|
|
|
19018
19078
|
parts.push(nl);
|
|
19019
19079
|
for (let i = 0; i < interaction.choices.length; i++) {
|
|
19020
19080
|
const choice = interaction.choices[i];
|
|
19021
|
-
const
|
|
19022
|
-
|
|
19023
|
-
|
|
19024
|
-
const normalized = normalizeXhtmlVoidElements(choice.content, `choiceInteraction.simpleChoice[${i}]`);
|
|
19025
|
-
diagnostics.push(...normalized.diagnostics);
|
|
19026
|
-
choiceContent = normalized.content;
|
|
19027
|
-
} else choiceContent = escapeXml(choice.content);
|
|
19081
|
+
const normalized = normalizeHtmlContentBody(choice.content, `choiceInteraction.simpleChoice[${i}]`);
|
|
19082
|
+
diagnostics.push(...normalized.diagnostics);
|
|
19083
|
+
const choiceContent = normalized.content;
|
|
19028
19084
|
const feedbackAttr = choice.feedbackBlockIdentifier ? ` feedbackBlock="${escapeXml(choice.feedbackBlockIdentifier)}"` : "";
|
|
19029
19085
|
parts.push(`${indent3}<simpleChoice identifier="${escapeXml(choice.identifier)}"${feedbackAttr}>${choiceContent}</simpleChoice>`);
|
|
19030
19086
|
parts.push(nl);
|
|
@@ -19033,13 +19089,9 @@ function buildChoiceInteractionXml(interaction, feedbackBlock, diagnostics, part
|
|
|
19033
19089
|
parts.push(nl);
|
|
19034
19090
|
if (feedbackBlock && feedbackBlock.length > 0) for (let i = 0; i < feedbackBlock.length; i++) {
|
|
19035
19091
|
const feedback = feedbackBlock[i];
|
|
19036
|
-
const
|
|
19037
|
-
|
|
19038
|
-
|
|
19039
|
-
const normalized = normalizeXhtmlVoidElements(feedback.content, `feedbackBlock[${i}]`);
|
|
19040
|
-
diagnostics.push(...normalized.diagnostics);
|
|
19041
|
-
feedbackContent = normalized.content;
|
|
19042
|
-
} else feedbackContent = escapeXml(feedback.content);
|
|
19092
|
+
const normalized = normalizeHtmlContentBody(feedback.content, `feedbackBlock[${i}]`);
|
|
19093
|
+
diagnostics.push(...normalized.diagnostics);
|
|
19094
|
+
const feedbackContent = normalized.content;
|
|
19043
19095
|
parts.push(`${indent2}<feedbackBlock identifier="${escapeXml(feedback.identifier)}" outcomeIdentifier="FEEDBACK" showHide="${feedback.showHide}">${feedbackContent}</feedbackBlock>`);
|
|
19044
19096
|
parts.push(nl);
|
|
19045
19097
|
}
|
|
@@ -19166,8 +19218,7 @@ function buildTextEntryInteractionXml(interaction, diagnostics, parts, indent, i
|
|
|
19166
19218
|
parts.push(nl);
|
|
19167
19219
|
}
|
|
19168
19220
|
let template = interaction.template;
|
|
19169
|
-
|
|
19170
|
-
if (hasHtmlTags) {
|
|
19221
|
+
{
|
|
19171
19222
|
const normalized = normalizeXhtmlVoidElements(template, "textEntryInteraction.template");
|
|
19172
19223
|
diagnostics.push(...normalized.diagnostics);
|
|
19173
19224
|
template = normalized.content;
|
|
@@ -19180,7 +19231,7 @@ function buildTextEntryInteractionXml(interaction, diagnostics, parts, indent, i
|
|
|
19180
19231
|
while ((match = placeholderRegex.exec(template)) !== null) {
|
|
19181
19232
|
if (match.index > lastIndex) {
|
|
19182
19233
|
const textSegment = template.substring(lastIndex, match.index);
|
|
19183
|
-
segments.push(
|
|
19234
|
+
segments.push(textSegment);
|
|
19184
19235
|
}
|
|
19185
19236
|
if (entryIndex < interaction.textEntries.length) {
|
|
19186
19237
|
const entry = interaction.textEntries[entryIndex];
|
|
@@ -19196,7 +19247,7 @@ function buildTextEntryInteractionXml(interaction, diagnostics, parts, indent, i
|
|
|
19196
19247
|
}
|
|
19197
19248
|
if (lastIndex < template.length) {
|
|
19198
19249
|
const textSegment = template.substring(lastIndex);
|
|
19199
|
-
segments.push(
|
|
19250
|
+
segments.push(textSegment);
|
|
19200
19251
|
}
|
|
19201
19252
|
parts.push(`${indent2}<div>`);
|
|
19202
19253
|
parts.push(segments.join(""));
|
|
@@ -19244,11 +19295,9 @@ function buildExtendedTextInteractionXml(interaction, outcomeDeclaration, diagno
|
|
|
19244
19295
|
parts.push(`${indent}<itemBody>`);
|
|
19245
19296
|
parts.push(nl);
|
|
19246
19297
|
if (interaction.prompt) {
|
|
19247
|
-
|
|
19248
|
-
|
|
19249
|
-
|
|
19250
|
-
parts.push(`${indent2}${normalized.content}`);
|
|
19251
|
-
} else parts.push(`${indent2}<p>${escapeXml(interaction.prompt)}</p>`);
|
|
19298
|
+
const normalized = normalizePromptContent(interaction.prompt, "itemBody.prompt");
|
|
19299
|
+
diagnostics.push(...normalized.diagnostics);
|
|
19300
|
+
parts.push(`${indent2}${normalized.content}`);
|
|
19252
19301
|
parts.push(nl);
|
|
19253
19302
|
}
|
|
19254
19303
|
let interactionTag = `${indent2}<extendedTextInteraction responseIdentifier="${interaction.responseIdentifier}"`;
|
|
@@ -19282,11 +19331,9 @@ function buildUploadInteractionXml(interaction, diagnostics, parts, indent, inde
|
|
|
19282
19331
|
parts.push(`${indent}<itemBody>`);
|
|
19283
19332
|
parts.push(nl);
|
|
19284
19333
|
if (interaction.prompt) {
|
|
19285
|
-
|
|
19286
|
-
|
|
19287
|
-
|
|
19288
|
-
parts.push(`${indent2}${normalized.content}`);
|
|
19289
|
-
} else parts.push(`${indent2}<p>${escapeXml(interaction.prompt)}</p>`);
|
|
19334
|
+
const normalized = normalizePromptContent(interaction.prompt, "itemBody.prompt");
|
|
19335
|
+
diagnostics.push(...normalized.diagnostics);
|
|
19336
|
+
parts.push(`${indent2}${normalized.content}`);
|
|
19290
19337
|
parts.push(nl);
|
|
19291
19338
|
}
|
|
19292
19339
|
let interactionTag = `${indent2}<uploadInteraction responseIdentifier="${interaction.responseIdentifier}"`;
|
|
@@ -19323,14 +19370,15 @@ function buildDrawingInteractionXml(interaction, diagnostics, parts, indent, ind
|
|
|
19323
19370
|
parts.push(nl);
|
|
19324
19371
|
parts.push(`${indent3}<prompt>`);
|
|
19325
19372
|
if (interaction.prompt) {
|
|
19326
|
-
|
|
19327
|
-
|
|
19328
|
-
|
|
19373
|
+
const hasHtmlTags = /<[a-zA-Z][\s\S]*?>/.test(interaction.prompt);
|
|
19374
|
+
const normalized = normalizeHtmlContentBody(interaction.prompt, "drawingInteraction.prompt");
|
|
19375
|
+
diagnostics.push(...normalized.diagnostics);
|
|
19376
|
+
if (hasHtmlTags) {
|
|
19329
19377
|
parts.push(nl);
|
|
19330
19378
|
parts.push(`${indent3} ${normalized.content}`);
|
|
19331
19379
|
parts.push(nl);
|
|
19332
19380
|
parts.push(`${indent3}`);
|
|
19333
|
-
} else parts.push(
|
|
19381
|
+
} else parts.push(normalized.content);
|
|
19334
19382
|
}
|
|
19335
19383
|
parts.push(`</prompt>`);
|
|
19336
19384
|
parts.push(nl);
|
|
@@ -19401,11 +19449,9 @@ function buildInlineChoiceInteractionXml(interaction, diagnostics, parts, indent
|
|
|
19401
19449
|
parts.push(`${indent}<itemBody>`);
|
|
19402
19450
|
parts.push(nl);
|
|
19403
19451
|
if (interaction.prompt) {
|
|
19404
|
-
|
|
19405
|
-
|
|
19406
|
-
|
|
19407
|
-
parts.push(`${indent2}${normalized.content}`);
|
|
19408
|
-
} else parts.push(`${indent2}<p>${escapeXml(interaction.prompt)}</p>`);
|
|
19452
|
+
const normalized = normalizePromptContent(interaction.prompt, "itemBody.prompt");
|
|
19453
|
+
diagnostics.push(...normalized.diagnostics);
|
|
19454
|
+
parts.push(`${indent2}${normalized.content}`);
|
|
19409
19455
|
parts.push(nl);
|
|
19410
19456
|
}
|
|
19411
19457
|
if (interaction.template && interaction.inlineChoiceEntries) {
|
|
@@ -19415,10 +19461,7 @@ function buildInlineChoiceInteractionXml(interaction, diagnostics, parts, indent
|
|
|
19415
19461
|
let inlineChoiceXml = `<inlineChoiceInteraction responseIdentifier="${entry.responseIdentifier}"`;
|
|
19416
19462
|
if (entry.shuffle) inlineChoiceXml += ` shuffle="true"`;
|
|
19417
19463
|
inlineChoiceXml += ">";
|
|
19418
|
-
for (const choice of entry.inlineChoices) {
|
|
19419
|
-
const choiceContent = /<[a-zA-Z][\s\S]*?>/.test(choice.content) ? choice.content : escapeXml(choice.content);
|
|
19420
|
-
inlineChoiceXml += `<inlineChoice identifier="${escapeXml(choice.identifier)}">${choiceContent}</inlineChoice>`;
|
|
19421
|
-
}
|
|
19464
|
+
for (const choice of entry.inlineChoices) inlineChoiceXml += `<inlineChoice identifier="${escapeXml(choice.identifier)}">${choice.content}</inlineChoice>`;
|
|
19422
19465
|
inlineChoiceXml += "</inlineChoiceInteraction>";
|
|
19423
19466
|
templateHtml = templateHtml.replace("{{response}}", inlineChoiceXml);
|
|
19424
19467
|
}
|
|
@@ -19474,11 +19517,9 @@ function buildGapMatchInteractionXml(interaction, diagnostics, parts, indent, in
|
|
|
19474
19517
|
parts.push(`${indent}<itemBody>`);
|
|
19475
19518
|
parts.push(nl);
|
|
19476
19519
|
if (interaction.prompt) {
|
|
19477
|
-
|
|
19478
|
-
|
|
19479
|
-
|
|
19480
|
-
parts.push(`${indent2}${normalized.content}`);
|
|
19481
|
-
} else parts.push(`${indent2}<p>${escapeXml(interaction.prompt)}</p>`);
|
|
19520
|
+
const normalized = normalizePromptContent(interaction.prompt, "itemBody.prompt");
|
|
19521
|
+
diagnostics.push(...normalized.diagnostics);
|
|
19522
|
+
parts.push(`${indent2}${normalized.content}`);
|
|
19482
19523
|
parts.push(nl);
|
|
19483
19524
|
}
|
|
19484
19525
|
parts.push(`${indent2}<gapMatchInteraction responseIdentifier="${interaction.responseIdentifier}"`);
|
|
@@ -19486,11 +19527,9 @@ function buildGapMatchInteractionXml(interaction, diagnostics, parts, indent, in
|
|
|
19486
19527
|
parts.push(">");
|
|
19487
19528
|
parts.push(nl);
|
|
19488
19529
|
if (interaction.gapTexts) for (const gapText of interaction.gapTexts) {
|
|
19489
|
-
const
|
|
19490
|
-
|
|
19491
|
-
|
|
19492
|
-
else gapTextContent = escapeXml(gapText.content);
|
|
19493
|
-
parts.push(`${indent3}<gapText identifier="${escapeXml(gapText.identifier)}" matchMax="1">${gapTextContent}</gapText>`);
|
|
19530
|
+
const normalized = normalizeHtmlContentBody(gapText.content, `itemBody.gapText.${gapText.identifier}`);
|
|
19531
|
+
diagnostics.push(...normalized.diagnostics);
|
|
19532
|
+
parts.push(`${indent3}<gapText identifier="${escapeXml(gapText.identifier)}" matchMax="1">${normalized.content}</gapText>`);
|
|
19494
19533
|
parts.push(nl);
|
|
19495
19534
|
}
|
|
19496
19535
|
if (interaction.template && interaction.gapEntries) {
|
|
@@ -19554,15 +19593,10 @@ function buildOrderInteractionXml(interaction, diagnostics, parts, indent, inden
|
|
|
19554
19593
|
parts.push(`${indent}<itemBody>`);
|
|
19555
19594
|
parts.push(nl);
|
|
19556
19595
|
if (interaction.prompt) {
|
|
19557
|
-
|
|
19558
|
-
|
|
19559
|
-
|
|
19560
|
-
|
|
19561
|
-
parts.push(nl);
|
|
19562
|
-
} else {
|
|
19563
|
-
parts.push(`${indent2}<p>${escapeXml(interaction.prompt)}</p>`);
|
|
19564
|
-
parts.push(nl);
|
|
19565
|
-
}
|
|
19596
|
+
const normalized = normalizePromptContent(interaction.prompt, "itemBody.prompt");
|
|
19597
|
+
diagnostics.push(...normalized.diagnostics);
|
|
19598
|
+
parts.push(`${indent2}${normalized.content}`);
|
|
19599
|
+
parts.push(nl);
|
|
19566
19600
|
}
|
|
19567
19601
|
parts.push(`${indent2}<orderInteraction responseIdentifier="${interaction.responseIdentifier}"`);
|
|
19568
19602
|
if (interaction.shuffle) parts.push(` shuffle="true"`);
|
|
@@ -19571,11 +19605,9 @@ function buildOrderInteractionXml(interaction, diagnostics, parts, indent, inden
|
|
|
19571
19605
|
parts.push(nl);
|
|
19572
19606
|
for (const choice of interaction.choices) {
|
|
19573
19607
|
parts.push(`${indent3}<simpleChoice identifier="${escapeXml(choice.identifier)}">`);
|
|
19574
|
-
|
|
19575
|
-
|
|
19576
|
-
|
|
19577
|
-
parts.push(normalized.content);
|
|
19578
|
-
} else parts.push(escapeXml(choice.content));
|
|
19608
|
+
const normalized = normalizeHtmlContentBody(choice.content, `itemBody.choice.${choice.identifier}`);
|
|
19609
|
+
diagnostics.push(...normalized.diagnostics);
|
|
19610
|
+
parts.push(normalized.content);
|
|
19579
19611
|
parts.push("</simpleChoice>");
|
|
19580
19612
|
parts.push(nl);
|
|
19581
19613
|
}
|
|
@@ -19694,15 +19726,10 @@ function buildHottextInteractionXml(interaction, diagnostics, parts, indent, ind
|
|
|
19694
19726
|
parts.push(`${indent}<itemBody>`);
|
|
19695
19727
|
parts.push(nl);
|
|
19696
19728
|
if (interaction.prompt) {
|
|
19697
|
-
|
|
19698
|
-
|
|
19699
|
-
|
|
19700
|
-
|
|
19701
|
-
parts.push(nl);
|
|
19702
|
-
} else {
|
|
19703
|
-
parts.push(`${indent2}<p>${escapeXml(interaction.prompt)}</p>`);
|
|
19704
|
-
parts.push(nl);
|
|
19705
|
-
}
|
|
19729
|
+
const normalized = normalizePromptContent(interaction.prompt, "itemBody.prompt");
|
|
19730
|
+
diagnostics.push(...normalized.diagnostics);
|
|
19731
|
+
parts.push(`${indent2}${normalized.content}`);
|
|
19732
|
+
parts.push(nl);
|
|
19706
19733
|
}
|
|
19707
19734
|
parts.push(`${indent2}<hottextInteraction responseIdentifier="${interaction.responseIdentifier}" maxChoices="${interaction.correctResponse?.length || 0}">`);
|
|
19708
19735
|
parts.push(nl);
|
|
@@ -19812,15 +19839,10 @@ function buildGraphicGapMatchInteractionXml(interaction, diagnostics, parts, ind
|
|
|
19812
19839
|
parts.push(`${indent}<itemBody>`);
|
|
19813
19840
|
parts.push(nl);
|
|
19814
19841
|
if (interaction.prompt) {
|
|
19815
|
-
|
|
19816
|
-
|
|
19817
|
-
|
|
19818
|
-
|
|
19819
|
-
parts.push(nl);
|
|
19820
|
-
} else {
|
|
19821
|
-
parts.push(`${indent2}<p>${escapeXml(interaction.prompt)}</p>`);
|
|
19822
|
-
parts.push(nl);
|
|
19823
|
-
}
|
|
19842
|
+
const normalized = normalizePromptContent(interaction.prompt, "itemBody.prompt");
|
|
19843
|
+
diagnostics.push(...normalized.diagnostics);
|
|
19844
|
+
parts.push(`${indent2}${normalized.content}`);
|
|
19845
|
+
parts.push(nl);
|
|
19824
19846
|
}
|
|
19825
19847
|
parts.push(`${indent2}<graphicGapMatchInteraction responseIdentifier="${interaction.responseIdentifier}" shuffle="${interaction.shuffle}">`);
|
|
19826
19848
|
parts.push(nl);
|
|
@@ -19898,11 +19920,9 @@ function buildAssociateInteractionXml(interaction, diagnostics, parts, indent, i
|
|
|
19898
19920
|
parts.push(nl);
|
|
19899
19921
|
for (const choice of interaction.choices) {
|
|
19900
19922
|
parts.push(`${indent3}<simpleAssociableChoice identifier="${escapeXml(choice.identifier)}" matchMax="${choice.matchMax}">`);
|
|
19901
|
-
|
|
19902
|
-
|
|
19903
|
-
|
|
19904
|
-
parts.push(normalized.content);
|
|
19905
|
-
} else parts.push(escapeXml(choice.content));
|
|
19923
|
+
const normalized = normalizeHtmlContentBody(choice.content, `itemBody.choice.${choice.identifier}`);
|
|
19924
|
+
diagnostics.push(...normalized.diagnostics);
|
|
19925
|
+
parts.push(normalized.content);
|
|
19906
19926
|
parts.push("</simpleAssociableChoice>");
|
|
19907
19927
|
parts.push(nl);
|
|
19908
19928
|
}
|
|
@@ -20144,13 +20164,9 @@ function buildAssessmentItemXml(ast, pretty, version) {
|
|
|
20144
20164
|
if (ast.modalFeedback && ast.modalFeedback.length > 0) for (let i = 0; i < ast.modalFeedback.length; i++) {
|
|
20145
20165
|
const typedFeedback = ast.modalFeedback[i];
|
|
20146
20166
|
let feedbackXml = `${indent}<modalFeedback identifier="${escapeXml(typedFeedback.identifier)}" outcomeIdentifier="${escapeXml(typedFeedback.outcomeIdentifier)}" showHide="${typedFeedback.showHide}">${nl}`;
|
|
20147
|
-
const
|
|
20148
|
-
|
|
20149
|
-
|
|
20150
|
-
const normalized = normalizeXhtmlVoidElements(typedFeedback.content, `modalFeedback[${i}]`);
|
|
20151
|
-
diagnostics.push(...normalized.diagnostics);
|
|
20152
|
-
feedbackContent = normalized.content;
|
|
20153
|
-
} else feedbackContent = escapeXml(typedFeedback.content);
|
|
20167
|
+
const normalized = normalizeHtmlContentBody(typedFeedback.content, `modalFeedback[${i}]`);
|
|
20168
|
+
diagnostics.push(...normalized.diagnostics);
|
|
20169
|
+
const feedbackContent = normalized.content;
|
|
20154
20170
|
feedbackXml += `${indent2}${feedbackContent}${nl}`;
|
|
20155
20171
|
feedbackXml += `${indent}</modalFeedback>${nl}`;
|
|
20156
20172
|
sections.modalFeedback.push(feedbackXml);
|
|
@@ -31559,4 +31575,4 @@ async function resolveOptions(cliOpts, config, isPackageCommand, configPath) {
|
|
|
31559
31575
|
//#endregion
|
|
31560
31576
|
export { parseJsonInput as a, convertQtiToLearnosity as c, writeOutput as i, ProgressTracker as n, readInput as o, showResolvedOptions as r, convertLearnosityToQti as s, resolveOptions as t };
|
|
31561
31577
|
|
|
31562
|
-
//# sourceMappingURL=resolveOptions-
|
|
31578
|
+
//# sourceMappingURL=resolveOptions-gH_YAxxc.js.map
|