@learnosity/lib-qti-converter 0.12.4 → 0.12.6
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 +28 -3
- package/docs/EXAMPLES.md +47 -21
- package/docs/FAQ.md +11 -1
- package/docs/GETTING_STARTED.md +34 -18
- package/package.json +1 -1
- package/packages/cli/dist/{batchProcessors-C55IxXri.js → batchProcessors-C8k2v0o_.js} +3 -2
- package/packages/cli/dist/batchProcessors-C8k2v0o_.js.map +1 -0
- package/packages/cli/dist/batchWorker.js +1 -1
- package/packages/cli/dist/{learnosityToQti-B0PoimXr.js → learnosityToQti-CXDJoJpl.js} +6 -5
- package/packages/cli/dist/learnosityToQti-CXDJoJpl.js.map +1 -0
- package/packages/cli/dist/{learnosityToQtiPackage-Dwgys922.js → learnosityToQtiPackage-7v-s4ybk.js} +10 -6
- package/packages/cli/dist/learnosityToQtiPackage-7v-s4ybk.js.map +1 -0
- package/packages/cli/dist/main.js +4 -4
- package/packages/cli/dist/{pathUtils-CwZnJ55s.js → pathUtils-CgoDQyJk.js} +2 -1
- package/packages/cli/dist/pathUtils-CgoDQyJk.js.map +1 -0
- package/packages/cli/dist/{qtiPackageToLearnosity-HPtU5x5h.js → qtiPackageToLearnosity-hT4QZ7YX.js} +3 -3
- package/packages/cli/dist/{qtiPackageToLearnosity-HPtU5x5h.js.map → qtiPackageToLearnosity-hT4QZ7YX.js.map} +1 -1
- package/packages/cli/dist/{qtiToLearnosity-jiFTBiQU.js → qtiToLearnosity-BU7mHhIu.js} +3 -3
- package/packages/cli/dist/{qtiToLearnosity-jiFTBiQU.js.map → qtiToLearnosity-BU7mHhIu.js.map} +1 -1
- package/packages/cli/dist/{resolveOptions-gH_YAxxc.js → resolveOptions-ehwJSkQy.js} +121 -13
- package/packages/cli/dist/resolveOptions-ehwJSkQy.js.map +1 -0
- package/packages/core/dist/index.d.ts +30 -0
- package/packages/core/dist/index.js +155 -17
- package/packages/core/dist/node.d.ts +35 -0
- package/packages/core/dist/node.js +349 -22
- package/packages/cli/dist/batchProcessors-C55IxXri.js.map +0 -1
- package/packages/cli/dist/learnosityToQti-B0PoimXr.js.map +0 -1
- package/packages/cli/dist/learnosityToQtiPackage-Dwgys922.js.map +0 -1
- package/packages/cli/dist/pathUtils-CwZnJ55s.js.map +0 -1
- package/packages/cli/dist/resolveOptions-gH_YAxxc.js.map +0 -1
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"qtiPackageToLearnosity-HPtU5x5h.js","names":["input"],"sources":["../src/commands/qtiPackageToLearnosity.ts"],"sourcesContent":["/* eslint-disable @typescript-eslint/no-explicit-any */\n\nimport type { Command } from 'commander';\nimport type {\n Diagnostic,\n ItemFilenameSource,\n ItemReferenceSource,\n} from '@learnosity/converter-core';\nimport {\n convertQtiPackageToLearnosityBundle,\n writeLearnosityBundle,\n loadPackageDirectory,\n nodeFileAccess,\n} from '@learnosity/converter-core/node';\nimport { existsSync, statSync, readFileSync } from 'fs';\nimport { input } from '@inquirer/prompts';\nimport { writeDiagnostics, type WriteDiagnosticsOptions } from '../io/writeDiagnostics.js';\nimport { showBanner } from '../ux/banner.js';\nimport { formatDiagnosticsTable } from '../ux/table.js';\nimport type { CliOptions } from '../options/types.js';\nimport { loadConfig } from '../options/loadConfig.js';\nimport { expandTilde } from '../utils/pathUtils.js';\nimport { processBatch, processBatchParallel } from '../utils/batchProcessing.js';\nimport { processQtiPackageToLearnosity } from '../utils/batchProcessors.js';\nimport { displayConfiguration, configField } from '../utils/configOutput.js';\n\n/**\n * Register qti-package-to-learnosity command\n */\nexport function registerQtiPackageToLearnosityCommand(program: Command, version: string): void {\n program\n .command('qti-package-to-learnosity')\n .alias('convert qti-package')\n .description('Convert a QTI Content Package to a Learnosity bundle')\n .option('--in <path>', 'Input package path (.zip or directory)')\n .option('--out <path>', 'Output bundle path (.zip or directory)')\n .option(\n '--format <type>',\n 'Output format: zip or dir (default: auto-detect from --out path)'\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 '--item-filename-source <source>',\n 'How to name output JSON files: sourceFilename or qti (default: same as --item-reference-source)'\n )\n .option(\n '--truncate-tags',\n 'Truncate tag types and names to 255 characters instead of failing (default: false)'\n )\n .option('--recursive', 'Process all subdirectories in the input path (default: false)')\n .option(\n '--concurrency <number>',\n 'Worker threads for --recursive batch conversion (default: 1 = serial)',\n parseInt\n )\n .option('--diagnostics <mode>', 'Diagnostics output (stderr|file|both|none, default: file)')\n .option('--fail-on-warn', 'Exit with error code 1 if warnings exist (default: false)')\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', 'Show INFO level diagnostics in table (default: false)')\n .option('-q, --quiet', 'Suppress non-essential output (default: false)')\n .action(async (opts: CliOptions) => {\n await executeQtiPackageToLearnosity(opts, version);\n });\n}\n\n/**\n * Write diagnostics to file and/or stderr depending on mode\n */\nasync function outputDiagnostics(\n allDiagnostics: Diagnostic[],\n diagnosticsMode: string,\n verbose: boolean,\n diagnosticsPath: string,\n outputPath: string,\n metadata: WriteDiagnosticsOptions\n): Promise<void> {\n if (diagnosticsMode === 'file' || diagnosticsMode === 'both') {\n await writeDiagnostics(\n allDiagnostics,\n 'file',\n diagnosticsPath,\n outputPath,\n false,\n metadata\n );\n }\n\n if (diagnosticsMode === 'stderr' || diagnosticsMode === 'both') {\n const table = formatDiagnosticsTable(allDiagnostics, verbose);\n\n if (table) {\n console.error(table);\n }\n }\n}\n\n/**\n * Resolve an interactive or CLI-provided path option\n * Returns the expanded path or exits with an error.\n */\nasync function resolvePathOption(\n value: string | undefined,\n interactive: boolean,\n promptMessage: string,\n errorMessage: string\n): Promise<string> {\n let resolved = value;\n\n if (!resolved && interactive) {\n resolved = await input({ message: promptMessage });\n }\n\n if (!resolved) {\n console.error(errorMessage);\n process.exit(1);\n }\n\n return expandTilde(resolved);\n}\n\n/**\n * Parse the --diagnostics CLI option into mode and optional custom path\n */\nfunction resolveDiagnosticsConfig(diagnosticsOpt: string | undefined): {\n mode: 'file' | 'stderr' | 'both' | 'none';\n customPath?: string;\n} {\n const validModes = ['stderr', 'file', 'both', 'none'] as const;\n\n if (!diagnosticsOpt || validModes.includes(diagnosticsOpt as any)) {\n return { mode: (diagnosticsOpt as (typeof validModes)[number]) ?? 'file' };\n }\n\n return { mode: 'file', customPath: diagnosticsOpt };\n}\n\n/**\n * Resolve organisation ID from CLI options with optional interactive prompt\n */\nasync function resolveOrganisationId(\n cliOpts: CliOptions,\n interactive: boolean,\n configOrgId?: number\n): Promise<number> {\n let organisationId = (cliOpts as any).organisation_id ?? (cliOpts as any).org_id ?? configOrgId;\n\n if (organisationId === undefined && interactive) {\n const orgIdInput = await input({\n message: 'Organisation ID for Learnosity CDN asset URLs:',\n });\n\n organisationId = orgIdInput ? parseInt(orgIdInput, 10) : undefined;\n }\n\n if (organisationId === undefined || organisationId === null) {\n console.error(\n 'Error: --organisation_id is required. Use -i or --interactive for prompts or specify --organisation_id <number>'\n );\n process.exit(1);\n }\n\n return organisationId;\n}\n\n/**\n * Validate input path exists and determine its type\n */\nfunction validateInputPath(inputPath: string): { isZipInput: boolean } {\n if (!existsSync(inputPath)) {\n console.error(`Error: Input not found: ${inputPath}`);\n process.exit(1);\n }\n\n const isZipInput = inputPath.toLowerCase().endsWith('.zip');\n\n if (!isZipInput && !statSync(inputPath).isDirectory()) {\n console.error(`Error: Input must be a directory or .zip file: ${inputPath}`);\n process.exit(1);\n }\n\n return { isZipInput };\n}\n\n/**\n * Resolve output format (zip or directory) from path and explicit format option\n */\nfunction resolveOutputFormat(\n outputPath: string,\n formatOption?: string\n): { isZipOutput: boolean; finalOutputPath: string } {\n if (formatOption) {\n const fmt = formatOption.toLowerCase();\n\n if (fmt !== 'zip' && fmt !== 'dir') {\n console.error('Error: --format must be \"zip\" or \"dir\"');\n process.exit(1);\n }\n\n const isZipOutput = fmt === 'zip';\n const finalOutputPath =\n isZipOutput && !outputPath.toLowerCase().endsWith('.zip')\n ? `${outputPath}.zip`\n : outputPath;\n\n return { isZipOutput, finalOutputPath };\n }\n\n return {\n isZipOutput: outputPath.toLowerCase().endsWith('.zip'),\n finalOutputPath: outputPath,\n };\n}\n\n/**\n * Display conversion progress for activities and items\n */\nfunction displayConversionProgress(convertResult: any): void {\n const convertedActivityFiles = convertResult.convertedActivityFiles || [];\n\n if (convertedActivityFiles.length > 0) {\n process.stderr.write(' Assessment tests:\\n');\n convertedActivityFiles.forEach((sourceFile: string, index: number) => {\n process.stderr.write(\n ` [${index + 1}/${convertedActivityFiles.length}] ${sourceFile} \\x1b[32m✓\\x1b[0m\\n`\n );\n });\n process.stderr.write('\\n');\n }\n\n const convertedFiles = convertResult.convertedSourceFiles || [];\n const failedFiles = convertResult.failedSourceFiles || [];\n const totalFiles = convertedFiles.length + failedFiles.length;\n\n if (totalFiles > 0) {\n process.stderr.write(' Assessment items:\\n');\n const successSet = new Set(convertedFiles);\n const allFiles = [...convertedFiles, ...failedFiles].sort();\n\n allFiles.forEach((sourceFile: string, index: number) => {\n const isSuccess = successSet.has(sourceFile);\n const status = isSuccess ? '\\x1b[32m✓\\x1b[0m' : '\\x1b[31m✗\\x1b[0m';\n\n process.stderr.write(` [${index + 1}/${totalFiles}] ${sourceFile} ${status}\\n`);\n });\n\n if (failedFiles.length > 0) {\n process.stderr.write(\n `\\nConversion completed with ERRORS (${convertedFiles.length} succeeded, ${failedFiles.length} failed)\\n`\n );\n process.stderr.write(\n `Proceeding with ${convertedFiles.length} successfully converted items...\\n\\n`\n );\n } else {\n process.stderr.write(`\\nConverted ${convertedFiles.length} items ✓\\n\\n`);\n }\n }\n}\n\n/**\n * Build metadata object for diagnostics output\n */\nfunction buildDiagnosticsMetadata(\n inputPath: string,\n outputPath: string,\n convertResult: any,\n failed: boolean\n): WriteDiagnosticsOptions {\n const convertedFiles = convertResult.convertedSourceFiles || [];\n const failedFiles = convertResult.failedSourceFiles || [];\n const convertedActivityFiles = convertResult.convertedActivityFiles || [];\n const itemRefs = convertResult.bundle\n ? (Array.from(convertResult.bundle.items.keys()) as string[])\n : [];\n\n return {\n inputPath,\n outputPath,\n totalItemsFound: failed ? itemRefs.length : convertedFiles.length + failedFiles.length,\n totalActivitiesFound: convertedActivityFiles.length,\n convertedFiles: failed ? [] : convertedFiles,\n failedFiles: failed ? itemRefs.map((ref: string) => `items/${ref}.xml`) : failedFiles,\n convertedActivities: convertedActivityFiles,\n };\n}\n\n/**\n * Execute qti-package-to-learnosity conversion\n */\nasync function executeQtiPackageToLearnosity(cliOpts: CliOptions, version: string): Promise<void> {\n const allDiagnostics: Diagnostic[] = [];\n const startTime = Date.now();\n const quiet = cliOpts.quiet ?? false;\n\n try {\n showBanner('qti-package-to-learnosity', version, quiet);\n\n const interactive = cliOpts.interactive ?? false;\n\n // Load config file (CLI flags take precedence over config values)\n const { config, diagnostics: configDiagnostics } = await loadConfig(\n cliOpts.config,\n cliOpts.noConfig\n );\n\n allDiagnostics.push(...configDiagnostics);\n\n if (configDiagnostics.some((d) => d.level === 'error')) {\n console.log('\\n' + formatDiagnosticsTable(configDiagnostics));\n process.exit(1);\n\n return;\n }\n\n const inputPath = await resolvePathOption(\n cliOpts.in,\n interactive,\n 'Input QTI package path (.zip or directory):',\n 'Error: --in is required. Use -i or --interactive for prompts or specify --in <path>'\n );\n\n const outputPath = await resolvePathOption(\n cliOpts.out,\n interactive,\n 'Output bundle path (.zip or directory):',\n 'Error: --out is required. Use -i or --interactive for prompts or specify --out <path>'\n );\n\n const failOnWarn = cliOpts.failOnWarn ?? false;\n const verbose = cliOpts.verbose ?? config?.verbose ?? false;\n const { mode: diagnosticsMode, customPath: customDiagnosticsPath } =\n resolveDiagnosticsConfig(cliOpts.diagnostics ?? config?.diagnostics);\n const organisationId = await resolveOrganisationId(\n cliOpts,\n interactive,\n config?.organisationId\n );\n const mediaVault = (cliOpts as any).mediavault ?? config?.mediaVault ?? false;\n const customAssetUrl = (cliOpts as any).customAssetUrl ?? config?.customAssetUrl;\n const itemReferenceSource =\n (cliOpts as any).itemReferenceSource ?? config?.itemReferenceSource;\n const itemFilenameSource =\n (cliOpts as any).itemFilenameSource ?? config?.itemFilenameSource;\n const truncateTags = (cliOpts as any).truncateTags ?? config?.truncateTags ?? false;\n\n const { isZipInput } = validateInputPath(inputPath);\n\n // Handle recursive batch processing\n if ((cliOpts as any).recursive) {\n if (isZipInput) {\n console.error(\n 'Error: --recursive flag cannot be used with ZIP input. Please provide a directory containing subdirectories.'\n );\n process.exit(1);\n\n return;\n }\n\n await executeBatchQtiPackageToLearnosity({\n inputPath,\n outputPath,\n organisationId,\n mediaVault,\n customAssetUrl,\n itemReferenceSource,\n itemFilenameSource,\n truncateTags,\n diagnosticsMode,\n failOnWarn,\n verbose,\n quiet,\n version,\n concurrency: cliOpts.concurrency ?? 1,\n });\n\n return;\n }\n\n const { isZipOutput, finalOutputPath } = resolveOutputFormat(outputPath, cliOpts.format);\n\n if (!quiet) {\n displayConfiguration(\n [\n configField('Input:', inputPath),\n configField('Output:', finalOutputPath),\n configField('Format:', isZipOutput ? 'ZIP' : 'directory'),\n configField('Diagnostics:', diagnosticsMode),\n configField('Org ID:', organisationId),\n configField('Media vault:', mediaVault),\n configField('Item ref src:', itemReferenceSource ?? 'sourceFilename (default)'),\n configField('Item filename:', itemFilenameSource ?? 'same as item ref src'),\n configField('Verbose:', verbose),\n configField('Fail on warn:', failOnWarn),\n ],\n { quiet }\n );\n }\n\n // Step 1: Convert package to bundle model\n process.stderr.write('Converting QTI package...\\n');\n\n const convertOpts = {\n organisationId,\n mediaVault,\n customAssetUrl,\n itemReferenceSource,\n itemFilenameSource,\n truncateTags,\n packageVersion: version,\n };\n let convertResult;\n\n if (isZipInput) {\n convertResult = convertQtiPackageToLearnosityBundle(\n { zipBytes: new Uint8Array(readFileSync(inputPath)) },\n convertOpts\n );\n } else {\n const loaded = loadPackageDirectory(inputPath);\n\n convertResult = loaded.entries\n ? convertQtiPackageToLearnosityBundle(\n { entries: loaded.entries },\n { ...convertOpts, sourceDir: inputPath, fileAccess: nodeFileAccess }\n )\n : { diagnostics: loaded.diagnostics };\n }\n\n allDiagnostics.push(...convertResult.diagnostics);\n\n displayConversionProgress(convertResult);\n\n const getDiagPath = () =>\n customDiagnosticsPath ||\n (isZipOutput\n ? finalOutputPath.replace(/\\.zip$/i, '-diagnostics.json')\n : `${finalOutputPath.replace(/\\/$/, '')}/diagnostics.json`);\n\n // Check for critical errors\n const errors = allDiagnostics.filter((d) => d.level === 'error');\n const warnings = allDiagnostics.filter((d) => d.level === 'warning');\n const hasValidBundle = convertResult.bundle && convertResult.bundle.items.size > 0;\n\n if (errors.length > 0 && !hasValidBundle) {\n process.stderr.write('\\nConversion FAILED with errors\\n\\n');\n await outputDiagnostics(\n allDiagnostics,\n diagnosticsMode,\n verbose,\n getDiagPath(),\n finalOutputPath,\n buildDiagnosticsMetadata(inputPath, finalOutputPath, convertResult, true)\n );\n process.exit(1);\n\n return;\n }\n\n if (failOnWarn && warnings.length > 0) {\n process.stderr.write('\\nConversion completed with WARNINGS (fail-on-warn mode)\\n\\n');\n await outputDiagnostics(\n allDiagnostics,\n diagnosticsMode,\n verbose,\n getDiagPath(),\n finalOutputPath,\n buildDiagnosticsMetadata(\n inputPath,\n finalOutputPath,\n convertResult,\n errors.length > 0\n )\n );\n process.exit(1);\n\n return;\n }\n\n if (!convertResult.bundle) {\n process.stderr.write('\\nConversion FAILED: no bundle generated\\n\\n');\n await outputDiagnostics(\n allDiagnostics,\n diagnosticsMode,\n verbose,\n getDiagPath(),\n finalOutputPath,\n {\n inputPath,\n outputPath: finalOutputPath,\n totalItemsFound: 0,\n convertedFiles: [],\n failedFiles: [],\n }\n );\n process.exit(1);\n\n return;\n }\n\n // Step 2: Write bundle to directory or ZIP\n process.stderr.write(`Writing ${isZipOutput ? 'ZIP' : 'directory'} package... `);\n const writeResult = await writeLearnosityBundle(convertResult.bundle, {\n outDir: finalOutputPath,\n isZipOutput,\n });\n\n allDiagnostics.push(...writeResult.diagnostics);\n\n if (writeResult.diagnostics.some((d) => d.level === 'error')) {\n process.stderr.write('FAILED\\n\\n');\n await outputDiagnostics(\n allDiagnostics,\n diagnosticsMode,\n verbose,\n getDiagPath(),\n outputPath,\n buildDiagnosticsMetadata(inputPath, outputPath, convertResult, true)\n );\n process.exit(1);\n\n return;\n }\n\n process.stderr.write('✓\\n');\n\n // Step 3: Write final diagnostics on success\n const successMetadata = buildDiagnosticsMetadata(\n inputPath,\n finalOutputPath,\n convertResult,\n false\n );\n\n if (diagnosticsMode === 'file' || diagnosticsMode === 'both') {\n const diagnosticsPath = getDiagPath();\n\n process.stderr.write(`Writing diagnostics to ${diagnosticsPath}... `);\n await outputDiagnostics(\n allDiagnostics,\n 'file',\n verbose,\n diagnosticsPath,\n finalOutputPath,\n successMetadata\n );\n process.stderr.write('✓\\n');\n }\n\n if (diagnosticsMode === 'stderr' || diagnosticsMode === 'both') {\n await outputDiagnostics(\n allDiagnostics,\n 'stderr',\n verbose,\n getDiagPath(),\n finalOutputPath,\n successMetadata\n );\n }\n\n const elapsedTime = ((Date.now() - startTime) / 1000).toFixed(1);\n\n process.stderr.write(`\\nCompleted in ${elapsedTime}s\\n`);\n\n const failedFiles = convertResult.failedSourceFiles || [];\n\n if (failedFiles.length > 0) {\n process.stderr.write(\n `\\nPackage written with ${failedFiles.length} item(s) skipped due to errors\\n`\n );\n }\n\n process.exit(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\n/**\n * Execute batch QTI package to Learnosity conversion for multiple subdirectories\n */\nasync function executeBatchQtiPackageToLearnosity(opts: {\n inputPath: string;\n outputPath: string;\n organisationId: number;\n mediaVault: boolean;\n customAssetUrl?: string;\n itemReferenceSource?: ItemReferenceSource;\n itemFilenameSource?: ItemFilenameSource;\n truncateTags: boolean;\n diagnosticsMode: string;\n failOnWarn: boolean;\n verbose: boolean;\n quiet: boolean;\n version: string;\n concurrency: number;\n}): Promise<void> {\n const {\n inputPath,\n outputPath,\n organisationId,\n mediaVault,\n customAssetUrl,\n itemReferenceSource,\n itemFilenameSource,\n truncateTags,\n diagnosticsMode,\n failOnWarn,\n verbose,\n quiet,\n version,\n concurrency,\n } = opts;\n\n if (concurrency > 1) {\n await processBatchParallel({\n inputPath,\n outputPath,\n packageType: 'qti',\n direction: 'qti-to-learnosity',\n options: {\n organisationId,\n mediaVault,\n customAssetUrl,\n itemReferenceSource,\n itemFilenameSource,\n truncateTags,\n version,\n },\n concurrency,\n quiet,\n });\n\n return;\n }\n\n // Display configuration\n displayConfiguration(\n [\n configField('Input:', inputPath),\n configField('Output:', outputPath),\n configField('Format:', 'directory'),\n configField('Diagnostics:', diagnosticsMode),\n configField('Org ID:', organisationId),\n configField('Media vault:', mediaVault),\n configField('Item ref src:', itemReferenceSource ?? 'sourceFilename (default)'),\n configField('Item filename:', itemFilenameSource ?? 'same as item ref src'),\n configField('Truncate tags:', truncateTags),\n configField('Recursive:', true),\n configField('Verbose:', verbose),\n configField('Fail on warn:', failOnWarn),\n ],\n { quiet }\n );\n\n if (!quiet) {\n console.log('🔄 Batch Processing Mode');\n console.log(`Scanning: ${inputPath}\\n`);\n }\n\n // Use generic batch processor\n await processBatch({\n inputPath,\n outputPath,\n packageType: 'qti',\n options: opts,\n quiet,\n processPackage: (pkg, packageOutputPath, options) =>\n processQtiPackageToLearnosity(pkg, packageOutputPath, options, quiet),\n });\n}\n"],"mappings":";;;;;;;;;;AA6BA,SAAgB,sCAAsC,SAAkB,SAAu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ACA;GACJ;GACA;GACA;EACJ,CAAC;EAED;CACJ;CAGA,qBACI;EACI,YAAY,UAAU,SAAS;EAC/B,YAAY,WAAW,UAAU;EACjC,YAAY,WAAW,WAAW;EAClC,YAAY,gBAAgB,eAAe;EAC3C,YAAY,WAAW,cAAc;EACrC,YAAY,gBAAgB,UAAU;EACtC,YAAY,iBAAiB,uBAAuB,0BAA0B;EAC9E,YAAY,kBAAkB,sBAAsB,sBAAsB;EAC1E,YAAY,kBAAkB,YAAY;EAC1C,YAAY,cAAc,IAAI;EAC9B,YAAY,YAAY,OAAO;EAC/B,YAAY,iBAAiB,UAAU;CAC3C,GACA,EAAE,MAAM,CACZ;CAEA,IAAI,CAAC,OAAO;EACR,QAAQ,IAAI,0BAA0B;EACtC,QAAQ,IAAI,aAAa,UAAU,GAAG;CAC1C;CAGA,MAAM,aAAa;EACf;EACA;EACA,aAAa;EACb,SAAS;EACT;EACA,iBAAiB,KAAK,mBAAmB,YACrC,8BAA8B,KAAK,mBAAmB,SAAS,KAAK;CAC5E,CAAC;AACL"}
|
|
1
|
+
{"version":3,"file":"qtiPackageToLearnosity-hT4QZ7YX.js","names":["input"],"sources":["../src/commands/qtiPackageToLearnosity.ts"],"sourcesContent":["/* eslint-disable @typescript-eslint/no-explicit-any */\n\nimport type { Command } from 'commander';\nimport type {\n Diagnostic,\n ItemFilenameSource,\n ItemReferenceSource,\n} from '@learnosity/converter-core';\nimport {\n convertQtiPackageToLearnosityBundle,\n writeLearnosityBundle,\n loadPackageDirectory,\n nodeFileAccess,\n} from '@learnosity/converter-core/node';\nimport { existsSync, statSync, readFileSync } from 'fs';\nimport { input } from '@inquirer/prompts';\nimport { writeDiagnostics, type WriteDiagnosticsOptions } from '../io/writeDiagnostics.js';\nimport { showBanner } from '../ux/banner.js';\nimport { formatDiagnosticsTable } from '../ux/table.js';\nimport type { CliOptions } from '../options/types.js';\nimport { loadConfig } from '../options/loadConfig.js';\nimport { expandTilde } from '../utils/pathUtils.js';\nimport { processBatch, processBatchParallel } from '../utils/batchProcessing.js';\nimport { processQtiPackageToLearnosity } from '../utils/batchProcessors.js';\nimport { displayConfiguration, configField } from '../utils/configOutput.js';\n\n/**\n * Register qti-package-to-learnosity command\n */\nexport function registerQtiPackageToLearnosityCommand(program: Command, version: string): void {\n program\n .command('qti-package-to-learnosity')\n .alias('convert qti-package')\n .description('Convert a QTI Content Package to a Learnosity bundle')\n .option('--in <path>', 'Input package path (.zip or directory)')\n .option('--out <path>', 'Output bundle path (.zip or directory)')\n .option(\n '--format <type>',\n 'Output format: zip or dir (default: auto-detect from --out path)'\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 '--item-filename-source <source>',\n 'How to name output JSON files: sourceFilename or qti (default: same as --item-reference-source)'\n )\n .option(\n '--truncate-tags',\n 'Truncate tag types and names to 255 characters instead of failing (default: false)'\n )\n .option('--recursive', 'Process all subdirectories in the input path (default: false)')\n .option(\n '--concurrency <number>',\n 'Worker threads for --recursive batch conversion (default: 1 = serial)',\n parseInt\n )\n .option('--diagnostics <mode>', 'Diagnostics output (stderr|file|both|none, default: file)')\n .option('--fail-on-warn', 'Exit with error code 1 if warnings exist (default: false)')\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', 'Show INFO level diagnostics in table (default: false)')\n .option('-q, --quiet', 'Suppress non-essential output (default: false)')\n .action(async (opts: CliOptions) => {\n await executeQtiPackageToLearnosity(opts, version);\n });\n}\n\n/**\n * Write diagnostics to file and/or stderr depending on mode\n */\nasync function outputDiagnostics(\n allDiagnostics: Diagnostic[],\n diagnosticsMode: string,\n verbose: boolean,\n diagnosticsPath: string,\n outputPath: string,\n metadata: WriteDiagnosticsOptions\n): Promise<void> {\n if (diagnosticsMode === 'file' || diagnosticsMode === 'both') {\n await writeDiagnostics(\n allDiagnostics,\n 'file',\n diagnosticsPath,\n outputPath,\n false,\n metadata\n );\n }\n\n if (diagnosticsMode === 'stderr' || diagnosticsMode === 'both') {\n const table = formatDiagnosticsTable(allDiagnostics, verbose);\n\n if (table) {\n console.error(table);\n }\n }\n}\n\n/**\n * Resolve an interactive or CLI-provided path option\n * Returns the expanded path or exits with an error.\n */\nasync function resolvePathOption(\n value: string | undefined,\n interactive: boolean,\n promptMessage: string,\n errorMessage: string\n): Promise<string> {\n let resolved = value;\n\n if (!resolved && interactive) {\n resolved = await input({ message: promptMessage });\n }\n\n if (!resolved) {\n console.error(errorMessage);\n process.exit(1);\n }\n\n return expandTilde(resolved);\n}\n\n/**\n * Parse the --diagnostics CLI option into mode and optional custom path\n */\nfunction resolveDiagnosticsConfig(diagnosticsOpt: string | undefined): {\n mode: 'file' | 'stderr' | 'both' | 'none';\n customPath?: string;\n} {\n const validModes = ['stderr', 'file', 'both', 'none'] as const;\n\n if (!diagnosticsOpt || validModes.includes(diagnosticsOpt as any)) {\n return { mode: (diagnosticsOpt as (typeof validModes)[number]) ?? 'file' };\n }\n\n return { mode: 'file', customPath: diagnosticsOpt };\n}\n\n/**\n * Resolve organisation ID from CLI options with optional interactive prompt\n */\nasync function resolveOrganisationId(\n cliOpts: CliOptions,\n interactive: boolean,\n configOrgId?: number\n): Promise<number> {\n let organisationId = (cliOpts as any).organisation_id ?? (cliOpts as any).org_id ?? configOrgId;\n\n if (organisationId === undefined && interactive) {\n const orgIdInput = await input({\n message: 'Organisation ID for Learnosity CDN asset URLs:',\n });\n\n organisationId = orgIdInput ? parseInt(orgIdInput, 10) : undefined;\n }\n\n if (organisationId === undefined || organisationId === null) {\n console.error(\n 'Error: --organisation_id is required. Use -i or --interactive for prompts or specify --organisation_id <number>'\n );\n process.exit(1);\n }\n\n return organisationId;\n}\n\n/**\n * Validate input path exists and determine its type\n */\nfunction validateInputPath(inputPath: string): { isZipInput: boolean } {\n if (!existsSync(inputPath)) {\n console.error(`Error: Input not found: ${inputPath}`);\n process.exit(1);\n }\n\n const isZipInput = inputPath.toLowerCase().endsWith('.zip');\n\n if (!isZipInput && !statSync(inputPath).isDirectory()) {\n console.error(`Error: Input must be a directory or .zip file: ${inputPath}`);\n process.exit(1);\n }\n\n return { isZipInput };\n}\n\n/**\n * Resolve output format (zip or directory) from path and explicit format option\n */\nfunction resolveOutputFormat(\n outputPath: string,\n formatOption?: string\n): { isZipOutput: boolean; finalOutputPath: string } {\n if (formatOption) {\n const fmt = formatOption.toLowerCase();\n\n if (fmt !== 'zip' && fmt !== 'dir') {\n console.error('Error: --format must be \"zip\" or \"dir\"');\n process.exit(1);\n }\n\n const isZipOutput = fmt === 'zip';\n const finalOutputPath =\n isZipOutput && !outputPath.toLowerCase().endsWith('.zip')\n ? `${outputPath}.zip`\n : outputPath;\n\n return { isZipOutput, finalOutputPath };\n }\n\n return {\n isZipOutput: outputPath.toLowerCase().endsWith('.zip'),\n finalOutputPath: outputPath,\n };\n}\n\n/**\n * Display conversion progress for activities and items\n */\nfunction displayConversionProgress(convertResult: any): void {\n const convertedActivityFiles = convertResult.convertedActivityFiles || [];\n\n if (convertedActivityFiles.length > 0) {\n process.stderr.write(' Assessment tests:\\n');\n convertedActivityFiles.forEach((sourceFile: string, index: number) => {\n process.stderr.write(\n ` [${index + 1}/${convertedActivityFiles.length}] ${sourceFile} \\x1b[32m✓\\x1b[0m\\n`\n );\n });\n process.stderr.write('\\n');\n }\n\n const convertedFiles = convertResult.convertedSourceFiles || [];\n const failedFiles = convertResult.failedSourceFiles || [];\n const totalFiles = convertedFiles.length + failedFiles.length;\n\n if (totalFiles > 0) {\n process.stderr.write(' Assessment items:\\n');\n const successSet = new Set(convertedFiles);\n const allFiles = [...convertedFiles, ...failedFiles].sort();\n\n allFiles.forEach((sourceFile: string, index: number) => {\n const isSuccess = successSet.has(sourceFile);\n const status = isSuccess ? '\\x1b[32m✓\\x1b[0m' : '\\x1b[31m✗\\x1b[0m';\n\n process.stderr.write(` [${index + 1}/${totalFiles}] ${sourceFile} ${status}\\n`);\n });\n\n if (failedFiles.length > 0) {\n process.stderr.write(\n `\\nConversion completed with ERRORS (${convertedFiles.length} succeeded, ${failedFiles.length} failed)\\n`\n );\n process.stderr.write(\n `Proceeding with ${convertedFiles.length} successfully converted items...\\n\\n`\n );\n } else {\n process.stderr.write(`\\nConverted ${convertedFiles.length} items ✓\\n\\n`);\n }\n }\n}\n\n/**\n * Build metadata object for diagnostics output\n */\nfunction buildDiagnosticsMetadata(\n inputPath: string,\n outputPath: string,\n convertResult: any,\n failed: boolean\n): WriteDiagnosticsOptions {\n const convertedFiles = convertResult.convertedSourceFiles || [];\n const failedFiles = convertResult.failedSourceFiles || [];\n const convertedActivityFiles = convertResult.convertedActivityFiles || [];\n const itemRefs = convertResult.bundle\n ? (Array.from(convertResult.bundle.items.keys()) as string[])\n : [];\n\n return {\n inputPath,\n outputPath,\n totalItemsFound: failed ? itemRefs.length : convertedFiles.length + failedFiles.length,\n totalActivitiesFound: convertedActivityFiles.length,\n convertedFiles: failed ? [] : convertedFiles,\n failedFiles: failed ? itemRefs.map((ref: string) => `items/${ref}.xml`) : failedFiles,\n convertedActivities: convertedActivityFiles,\n };\n}\n\n/**\n * Execute qti-package-to-learnosity conversion\n */\nasync function executeQtiPackageToLearnosity(cliOpts: CliOptions, version: string): Promise<void> {\n const allDiagnostics: Diagnostic[] = [];\n const startTime = Date.now();\n const quiet = cliOpts.quiet ?? false;\n\n try {\n showBanner('qti-package-to-learnosity', version, quiet);\n\n const interactive = cliOpts.interactive ?? false;\n\n // Load config file (CLI flags take precedence over config values)\n const { config, diagnostics: configDiagnostics } = await loadConfig(\n cliOpts.config,\n cliOpts.noConfig\n );\n\n allDiagnostics.push(...configDiagnostics);\n\n if (configDiagnostics.some((d) => d.level === 'error')) {\n console.log('\\n' + formatDiagnosticsTable(configDiagnostics));\n process.exit(1);\n\n return;\n }\n\n const inputPath = await resolvePathOption(\n cliOpts.in,\n interactive,\n 'Input QTI package path (.zip or directory):',\n 'Error: --in is required. Use -i or --interactive for prompts or specify --in <path>'\n );\n\n const outputPath = await resolvePathOption(\n cliOpts.out,\n interactive,\n 'Output bundle path (.zip or directory):',\n 'Error: --out is required. Use -i or --interactive for prompts or specify --out <path>'\n );\n\n const failOnWarn = cliOpts.failOnWarn ?? false;\n const verbose = cliOpts.verbose ?? config?.verbose ?? false;\n const { mode: diagnosticsMode, customPath: customDiagnosticsPath } =\n resolveDiagnosticsConfig(cliOpts.diagnostics ?? config?.diagnostics);\n const organisationId = await resolveOrganisationId(\n cliOpts,\n interactive,\n config?.organisationId\n );\n const mediaVault = (cliOpts as any).mediavault ?? config?.mediaVault ?? false;\n const customAssetUrl = (cliOpts as any).customAssetUrl ?? config?.customAssetUrl;\n const itemReferenceSource =\n (cliOpts as any).itemReferenceSource ?? config?.itemReferenceSource;\n const itemFilenameSource =\n (cliOpts as any).itemFilenameSource ?? config?.itemFilenameSource;\n const truncateTags = (cliOpts as any).truncateTags ?? config?.truncateTags ?? false;\n\n const { isZipInput } = validateInputPath(inputPath);\n\n // Handle recursive batch processing\n if ((cliOpts as any).recursive) {\n if (isZipInput) {\n console.error(\n 'Error: --recursive flag cannot be used with ZIP input. Please provide a directory containing subdirectories.'\n );\n process.exit(1);\n\n return;\n }\n\n await executeBatchQtiPackageToLearnosity({\n inputPath,\n outputPath,\n organisationId,\n mediaVault,\n customAssetUrl,\n itemReferenceSource,\n itemFilenameSource,\n truncateTags,\n diagnosticsMode,\n failOnWarn,\n verbose,\n quiet,\n version,\n concurrency: cliOpts.concurrency ?? 1,\n });\n\n return;\n }\n\n const { isZipOutput, finalOutputPath } = resolveOutputFormat(outputPath, cliOpts.format);\n\n if (!quiet) {\n displayConfiguration(\n [\n configField('Input:', inputPath),\n configField('Output:', finalOutputPath),\n configField('Format:', isZipOutput ? 'ZIP' : 'directory'),\n configField('Diagnostics:', diagnosticsMode),\n configField('Org ID:', organisationId),\n configField('Media vault:', mediaVault),\n configField('Item ref src:', itemReferenceSource ?? 'sourceFilename (default)'),\n configField('Item filename:', itemFilenameSource ?? 'same as item ref src'),\n configField('Verbose:', verbose),\n configField('Fail on warn:', failOnWarn),\n ],\n { quiet }\n );\n }\n\n // Step 1: Convert package to bundle model\n process.stderr.write('Converting QTI package...\\n');\n\n const convertOpts = {\n organisationId,\n mediaVault,\n customAssetUrl,\n itemReferenceSource,\n itemFilenameSource,\n truncateTags,\n packageVersion: version,\n };\n let convertResult;\n\n if (isZipInput) {\n convertResult = convertQtiPackageToLearnosityBundle(\n { zipBytes: new Uint8Array(readFileSync(inputPath)) },\n convertOpts\n );\n } else {\n const loaded = loadPackageDirectory(inputPath);\n\n convertResult = loaded.entries\n ? convertQtiPackageToLearnosityBundle(\n { entries: loaded.entries },\n { ...convertOpts, sourceDir: inputPath, fileAccess: nodeFileAccess }\n )\n : { diagnostics: loaded.diagnostics };\n }\n\n allDiagnostics.push(...convertResult.diagnostics);\n\n displayConversionProgress(convertResult);\n\n const getDiagPath = () =>\n customDiagnosticsPath ||\n (isZipOutput\n ? finalOutputPath.replace(/\\.zip$/i, '-diagnostics.json')\n : `${finalOutputPath.replace(/\\/$/, '')}/diagnostics.json`);\n\n // Check for critical errors\n const errors = allDiagnostics.filter((d) => d.level === 'error');\n const warnings = allDiagnostics.filter((d) => d.level === 'warning');\n const hasValidBundle = convertResult.bundle && convertResult.bundle.items.size > 0;\n\n if (errors.length > 0 && !hasValidBundle) {\n process.stderr.write('\\nConversion FAILED with errors\\n\\n');\n await outputDiagnostics(\n allDiagnostics,\n diagnosticsMode,\n verbose,\n getDiagPath(),\n finalOutputPath,\n buildDiagnosticsMetadata(inputPath, finalOutputPath, convertResult, true)\n );\n process.exit(1);\n\n return;\n }\n\n if (failOnWarn && warnings.length > 0) {\n process.stderr.write('\\nConversion completed with WARNINGS (fail-on-warn mode)\\n\\n');\n await outputDiagnostics(\n allDiagnostics,\n diagnosticsMode,\n verbose,\n getDiagPath(),\n finalOutputPath,\n buildDiagnosticsMetadata(\n inputPath,\n finalOutputPath,\n convertResult,\n errors.length > 0\n )\n );\n process.exit(1);\n\n return;\n }\n\n if (!convertResult.bundle) {\n process.stderr.write('\\nConversion FAILED: no bundle generated\\n\\n');\n await outputDiagnostics(\n allDiagnostics,\n diagnosticsMode,\n verbose,\n getDiagPath(),\n finalOutputPath,\n {\n inputPath,\n outputPath: finalOutputPath,\n totalItemsFound: 0,\n convertedFiles: [],\n failedFiles: [],\n }\n );\n process.exit(1);\n\n return;\n }\n\n // Step 2: Write bundle to directory or ZIP\n process.stderr.write(`Writing ${isZipOutput ? 'ZIP' : 'directory'} package... `);\n const writeResult = await writeLearnosityBundle(convertResult.bundle, {\n outDir: finalOutputPath,\n isZipOutput,\n });\n\n allDiagnostics.push(...writeResult.diagnostics);\n\n if (writeResult.diagnostics.some((d) => d.level === 'error')) {\n process.stderr.write('FAILED\\n\\n');\n await outputDiagnostics(\n allDiagnostics,\n diagnosticsMode,\n verbose,\n getDiagPath(),\n outputPath,\n buildDiagnosticsMetadata(inputPath, outputPath, convertResult, true)\n );\n process.exit(1);\n\n return;\n }\n\n process.stderr.write('✓\\n');\n\n // Step 3: Write final diagnostics on success\n const successMetadata = buildDiagnosticsMetadata(\n inputPath,\n finalOutputPath,\n convertResult,\n false\n );\n\n if (diagnosticsMode === 'file' || diagnosticsMode === 'both') {\n const diagnosticsPath = getDiagPath();\n\n process.stderr.write(`Writing diagnostics to ${diagnosticsPath}... `);\n await outputDiagnostics(\n allDiagnostics,\n 'file',\n verbose,\n diagnosticsPath,\n finalOutputPath,\n successMetadata\n );\n process.stderr.write('✓\\n');\n }\n\n if (diagnosticsMode === 'stderr' || diagnosticsMode === 'both') {\n await outputDiagnostics(\n allDiagnostics,\n 'stderr',\n verbose,\n getDiagPath(),\n finalOutputPath,\n successMetadata\n );\n }\n\n const elapsedTime = ((Date.now() - startTime) / 1000).toFixed(1);\n\n process.stderr.write(`\\nCompleted in ${elapsedTime}s\\n`);\n\n const failedFiles = convertResult.failedSourceFiles || [];\n\n if (failedFiles.length > 0) {\n process.stderr.write(\n `\\nPackage written with ${failedFiles.length} item(s) skipped due to errors\\n`\n );\n }\n\n process.exit(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\n/**\n * Execute batch QTI package to Learnosity conversion for multiple subdirectories\n */\nasync function executeBatchQtiPackageToLearnosity(opts: {\n inputPath: string;\n outputPath: string;\n organisationId: number;\n mediaVault: boolean;\n customAssetUrl?: string;\n itemReferenceSource?: ItemReferenceSource;\n itemFilenameSource?: ItemFilenameSource;\n truncateTags: boolean;\n diagnosticsMode: string;\n failOnWarn: boolean;\n verbose: boolean;\n quiet: boolean;\n version: string;\n concurrency: number;\n}): Promise<void> {\n const {\n inputPath,\n outputPath,\n organisationId,\n mediaVault,\n customAssetUrl,\n itemReferenceSource,\n itemFilenameSource,\n truncateTags,\n diagnosticsMode,\n failOnWarn,\n verbose,\n quiet,\n version,\n concurrency,\n } = opts;\n\n if (concurrency > 1) {\n await processBatchParallel({\n inputPath,\n outputPath,\n packageType: 'qti',\n direction: 'qti-to-learnosity',\n options: {\n organisationId,\n mediaVault,\n customAssetUrl,\n itemReferenceSource,\n itemFilenameSource,\n truncateTags,\n version,\n },\n concurrency,\n quiet,\n });\n\n return;\n }\n\n // Display configuration\n displayConfiguration(\n [\n configField('Input:', inputPath),\n configField('Output:', outputPath),\n configField('Format:', 'directory'),\n configField('Diagnostics:', diagnosticsMode),\n configField('Org ID:', organisationId),\n configField('Media vault:', mediaVault),\n configField('Item ref src:', itemReferenceSource ?? 'sourceFilename (default)'),\n configField('Item filename:', itemFilenameSource ?? 'same as item ref src'),\n configField('Truncate tags:', truncateTags),\n configField('Recursive:', true),\n configField('Verbose:', verbose),\n configField('Fail on warn:', failOnWarn),\n ],\n { quiet }\n );\n\n if (!quiet) {\n console.log('🔄 Batch Processing Mode');\n console.log(`Scanning: ${inputPath}\\n`);\n }\n\n // Use generic batch processor\n await processBatch({\n inputPath,\n outputPath,\n packageType: 'qti',\n options: opts,\n quiet,\n processPackage: (pkg, packageOutputPath, options) =>\n processQtiPackageToLearnosity(pkg, packageOutputPath, options, quiet),\n });\n}\n"],"mappings":";;;;;;;;;;AA6BA,SAAgB,sCAAsC,SAAkB,SAAuB;CAC3F,QACK,QAAQ,2BAA2B,CAAC,CACpC,MAAM,qBAAqB,CAAC,CAC5B,YAAY,sDAAsD,CAAC,CACnE,OAAO,eAAe,wCAAwC,CAAC,CAC/D,OAAO,gBAAgB,wCAAwC,CAAC,CAChE,OACG,mBACA,kEACJ,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,mCACA,iGACJ,CAAC,CACA,OACG,mBACA,oFACJ,CAAC,CACA,OAAO,eAAe,+DAA+D,CAAC,CACtF,OACG,0BACA,yEACA,QACJ,CAAC,CACA,OAAO,wBAAwB,2DAA2D,CAAC,CAC3F,OAAO,kBAAkB,2DAA2D,CAAC,CACrF,OAAO,mBAAmB,qBAAqB,CAAC,CAChD,OAAO,eAAe,6BAA6B,CAAC,CACpD,OAAO,qBAAqB,6CAA6C,CAAC,CAC1E,OAAO,aAAa,uDAAuD,CAAC,CAC5E,OAAO,eAAe,gDAAgD,CAAC,CACvE,OAAO,OAAO,SAAqB;EAChC,MAAM,8BAA8B,MAAM,OAAO;CACrD,CAAC;AACT;;;;AAKA,eAAe,kBACX,gBACA,iBACA,SACA,iBACA,YACA,UACa;CAC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MAAM,SAAS,mBACzC,QAAQ,KAAK,GAAG;EAEpB,QAAQ,MAAM,QAAQ,iBAAiB,QAAQ,MAAM,UAAU,gBAAgB;EAC/E,QAAQ,KAAK,CAAC;CAClB;AACJ;;;;AAKA,eAAe,mCAAmC,MAehC;CACd,MAAM,EACF,WACA,YACA,gBACA,YACA,gBACA,qBACA,oBACA,cACA,iBACA,YACA,SACA,OACA,SACA,gBACA;CAEJ,IAAI,cAAc,GAAG;EACjB,MAAM,qBAAqB;GACvB;GACA;GACA,aAAa;GACb,WAAW;GACX,SAAS;IACL;IACA;IACA;IACA;IACA;IACA;IACA;GACJ;GACA;GACA;EACJ,CAAC;EAED;CACJ;CAGA,qBACI;EACI,YAAY,UAAU,SAAS;EAC/B,YAAY,WAAW,UAAU;EACjC,YAAY,WAAW,WAAW;EAClC,YAAY,gBAAgB,eAAe;EAC3C,YAAY,WAAW,cAAc;EACrC,YAAY,gBAAgB,UAAU;EACtC,YAAY,iBAAiB,uBAAuB,0BAA0B;EAC9E,YAAY,kBAAkB,sBAAsB,sBAAsB;EAC1E,YAAY,kBAAkB,YAAY;EAC1C,YAAY,cAAc,IAAI;EAC9B,YAAY,YAAY,OAAO;EAC/B,YAAY,iBAAiB,UAAU;CAC3C,GACA,EAAE,MAAM,CACZ;CAEA,IAAI,CAAC,OAAO;EACR,QAAQ,IAAI,0BAA0B;EACtC,QAAQ,IAAI,aAAa,UAAU,GAAG;CAC1C;CAGA,MAAM,aAAa;EACf;EACA;EACA,aAAa;EACb,SAAS;EACT;EACA,iBAAiB,KAAK,mBAAmB,YACrC,8BAA8B,KAAK,mBAAmB,SAAS,KAAK;CAC5E,CAAC;AACL"}
|
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
import { n as loadConfig, r as showBanner } from "./pathUtils-
|
|
1
|
+
import { n as loadConfig, r as showBanner } from "./pathUtils-CgoDQyJk.js";
|
|
2
2
|
import { r as formatDiagnosticsTable, s as writeDiagnostics, t as countErrors } from "./table-DYcNeyJ_.js";
|
|
3
|
-
import { c as convertQtiToLearnosity, i as writeOutput, n as ProgressTracker, o as readInput, r as showResolvedOptions, t as resolveOptions } from "./resolveOptions-
|
|
3
|
+
import { c as convertQtiToLearnosity, i as writeOutput, n as ProgressTracker, o as readInput, r as showResolvedOptions, t as resolveOptions } from "./resolveOptions-ehwJSkQy.js";
|
|
4
4
|
import { nodeFileAccess } from "@learnosity/converter-core/node";
|
|
5
5
|
//#region src/commands/qtiToLearnosity.ts
|
|
6
6
|
/**
|
|
@@ -94,4 +94,4 @@ async function executeQtiToLearnosity(cliOpts, version) {
|
|
|
94
94
|
//#endregion
|
|
95
95
|
export { registerQtiToLearnosityCommand };
|
|
96
96
|
|
|
97
|
-
//# sourceMappingURL=qtiToLearnosity-
|
|
97
|
+
//# sourceMappingURL=qtiToLearnosity-BU7mHhIu.js.map
|
package/packages/cli/dist/{qtiToLearnosity-jiFTBiQU.js.map → qtiToLearnosity-BU7mHhIu.js.map}
RENAMED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"qtiToLearnosity-jiFTBiQU.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,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AQ,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
|
+
{"version":3,"file":"qtiToLearnosity-BU7mHhIu.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,K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@
|
|
|
1
1
|
import { i as __toESM, n as __exportAll, r as __require, t as __commonJSMin } from "./rolldown-runtime-B4iAMlE-.js";
|
|
2
2
|
import { r as onExit } from "./create-prompt-DU9wLVhI.js";
|
|
3
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-
|
|
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-CgoDQyJk.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";
|
|
@@ -20122,7 +20122,7 @@ function buildAssessmentItemXml(ast, pretty, version) {
|
|
|
20122
20122
|
itemBody: "",
|
|
20123
20123
|
modalFeedback: []
|
|
20124
20124
|
};
|
|
20125
|
-
sections.stylesheets.push(`${indent}<stylesheet href="assets/css/lrn-normalize.css" type="text/css"/>${nl}`);
|
|
20125
|
+
sections.stylesheets.push(`${indent}<stylesheet href="./assets/css/lrn-normalize.css" type="text/css"/>${nl}`);
|
|
20126
20126
|
if (ast.layout && ast.interactions) buildMultiWidgetItemSections(ast, diagnostics, sections, indent, indent2, indent3, nl);
|
|
20127
20127
|
else if (!ast.layout && ast.interactions && ast.interactions.length > 1) buildSequentialInteractionsSections(ast, diagnostics, sections, indent, indent2, indent3, nl);
|
|
20128
20128
|
else {
|
|
@@ -22809,7 +22809,7 @@ const MEDIA_SRC_PATTERN = /(<(?:img|audio|video|source)\s+[^>]*src=["'])([^"']+)
|
|
|
22809
22809
|
* "images/photo.png" → "photo.png"
|
|
22810
22810
|
* "/assets/video.mp4" → "video.mp4"
|
|
22811
22811
|
*/
|
|
22812
|
-
function extractFilename(url) {
|
|
22812
|
+
function extractFilename$1(url) {
|
|
22813
22813
|
const segments = url.split("?")[0].split("#")[0].split("/");
|
|
22814
22814
|
return segments[segments.length - 1];
|
|
22815
22815
|
}
|
|
@@ -22836,7 +22836,7 @@ function transformUrl(url, organisationId, mediaVault = false, customAssetUrl) {
|
|
|
22836
22836
|
if (url.includes("assets.learnosity.com") || url.includes("media-vault.learnosity.com")) return url;
|
|
22837
22837
|
if (url.match(/^https?:\/\//i)) return url;
|
|
22838
22838
|
if (url.startsWith("data:")) return url;
|
|
22839
|
-
const filename = extractFilename(url);
|
|
22839
|
+
const filename = extractFilename$1(url);
|
|
22840
22840
|
if (!isSupportedAsset(filename)) return url;
|
|
22841
22841
|
return buildLearnosityAssetUrl(filename, organisationId, mediaVault, customAssetUrl);
|
|
22842
22842
|
}
|
|
@@ -24581,13 +24581,28 @@ function buildHotspotValidation(correctResponses, choiceIdToIndex) {
|
|
|
24581
24581
|
/**
|
|
24582
24582
|
* Convert hotspotInteraction to Learnosity hotspot
|
|
24583
24583
|
*/
|
|
24584
|
-
function convertHotspotToLearnosity(inputXml, diagnostics, lomTags, organisationId, sourceFile, mediaVault, customAssetUrl, itemReferenceSource) {
|
|
24584
|
+
function convertHotspotToLearnosity(inputXml, diagnostics, lomTags, organisationId, sourceFile, mediaVault, customAssetUrl, itemReferenceSource, fileAccess, packageRoot) {
|
|
24585
24585
|
const parsed = readAssessmentItemHotspot(inputXml);
|
|
24586
24586
|
const updatedDiagnostics = addFileContextIfProvided(parsed.diagnostics, sourceFile);
|
|
24587
24587
|
diagnostics.push(...updatedDiagnostics);
|
|
24588
24588
|
if (hasErrors(diagnostics)) return { diagnostics };
|
|
24589
|
-
if (!parsed.identifier || !parsed.responseIdentifier || !parsed.imageSource
|
|
24589
|
+
if (!parsed.identifier || !parsed.responseIdentifier || !parsed.imageSource) return { diagnostics };
|
|
24590
24590
|
if (parsed.hotspotChoices.length === 0) return { diagnostics };
|
|
24591
|
+
if (!parsed.imageWidth || !parsed.imageHeight) {
|
|
24592
|
+
const resolved = fileAccess?.resolveImageDimensions?.(parsed.imageSource, sourceFile, packageRoot);
|
|
24593
|
+
if (resolved) {
|
|
24594
|
+
parsed.imageWidth = parsed.imageWidth || resolved.width;
|
|
24595
|
+
parsed.imageHeight = parsed.imageHeight || resolved.height;
|
|
24596
|
+
} else {
|
|
24597
|
+
diagnostics.push({
|
|
24598
|
+
code: DiagnosticCode.LRN_MISSING_REQUIRED_FIELD,
|
|
24599
|
+
level: "error",
|
|
24600
|
+
file: sourceFile ?? "hotspotInteraction",
|
|
24601
|
+
message: `hotspotInteraction image "${parsed.imageSource}" is missing width/height attributes and its dimensions could not be determined from the image file. Hotspot coordinate conversion requires image dimensions.`
|
|
24602
|
+
});
|
|
24603
|
+
return { diagnostics };
|
|
24604
|
+
}
|
|
24605
|
+
}
|
|
24591
24606
|
const itemRef = generateItemReference(parsed.identifier, itemReferenceSource, sourceFile);
|
|
24592
24607
|
const questionRef = md5hex(itemRef);
|
|
24593
24608
|
const stimulus = buildHotspotStimulus(parsed, organisationId, mediaVault, customAssetUrl);
|
|
@@ -27692,6 +27707,7 @@ function computeClosingTags(html) {
|
|
|
27692
27707
|
*/
|
|
27693
27708
|
function getConverterMap() {
|
|
27694
27709
|
const wrapSourceFirst = (fn) => (xml, diag, tags, orgId, sf, mv, cau, irs, stimuli) => fn(xml, diag, tags, sf, orgId, mv, cau, irs, stimuli);
|
|
27710
|
+
const hotspotConverter = (xml, diag, tags, orgId, sf, mv, cau, irs, _stimuli, fileAccess, packageRoot) => convertHotspotToLearnosity(xml, diag, tags, orgId, sf, mv, cau, irs, fileAccess, packageRoot);
|
|
27695
27711
|
return {
|
|
27696
27712
|
choiceInteraction: wrapSourceFirst(convertMcqToLearnosity),
|
|
27697
27713
|
textEntryInteraction: wrapSourceFirst(convertTextEntryToLearnosity),
|
|
@@ -27700,7 +27716,7 @@ function getConverterMap() {
|
|
|
27700
27716
|
gapMatchInteraction: convertGapMatchToLearnosity,
|
|
27701
27717
|
inlineChoiceInteraction: convertInlineChoiceToLearnosity,
|
|
27702
27718
|
orderInteraction: convertOrderToLearnosity,
|
|
27703
|
-
hotspotInteraction:
|
|
27719
|
+
hotspotInteraction: hotspotConverter,
|
|
27704
27720
|
hottextInteraction: convertHottextToLearnosity,
|
|
27705
27721
|
graphicGapMatchInteraction: convertGraphicGapMatchToLearnosity,
|
|
27706
27722
|
drawingInteraction: convertDrawingToLearnosity,
|
|
@@ -27714,7 +27730,7 @@ const CONVERTER_MAP = getConverterMap();
|
|
|
27714
27730
|
* Strategy: Call each individual converter for its interaction type,
|
|
27715
27731
|
* then combine all questions and widgets into a single composite item
|
|
27716
27732
|
*/
|
|
27717
|
-
function convertMixedInteractionsToLearnosity(inputXml, diagnostics, lomTags, organisationId, sourceFile, mediaVault, customAssetUrl, itemReferenceSource, fileAccess) {
|
|
27733
|
+
function convertMixedInteractionsToLearnosity(inputXml, diagnostics, lomTags, organisationId, sourceFile, mediaVault, customAssetUrl, itemReferenceSource, fileAccess, packageRoot) {
|
|
27718
27734
|
const metadata = extractItemMetadata(inputXml);
|
|
27719
27735
|
const { segments } = segmentItemBodyByInteractions(inputXml);
|
|
27720
27736
|
const stimuliByType = /* @__PURE__ */ new Map();
|
|
@@ -27931,7 +27947,7 @@ function convertMixedInteractionsToLearnosity(inputXml, diagnostics, lomTags, or
|
|
|
27931
27947
|
continue;
|
|
27932
27948
|
}
|
|
27933
27949
|
const converter = CONVERTER_MAP[group.type];
|
|
27934
|
-
if (converter) processResult(converter(inputXml, subDiagnostics, lomTags, organisationId, sourceFile, mediaVault, customAssetUrl, itemReferenceSource, group.stimuli), subDiagnostics);
|
|
27950
|
+
if (converter) processResult(converter(inputXml, subDiagnostics, lomTags, organisationId, sourceFile, mediaVault, customAssetUrl, itemReferenceSource, group.stimuli, fileAccess, packageRoot), subDiagnostics);
|
|
27935
27951
|
}
|
|
27936
27952
|
if (allQuestions.length === 0) {
|
|
27937
27953
|
diagnostics.push({
|
|
@@ -28568,7 +28584,7 @@ const SINGLE_INTERACTION_CONVERTERS = /* @__PURE__ */ new Map([
|
|
|
28568
28584
|
["matchInteraction", (xml, diag, lom, opts) => convertMatchToLearnosity(xml, diag, lom, opts.organisationId, opts.sourceFile, opts.mediaVault, opts.customAssetUrl, opts.itemReferenceSource)],
|
|
28569
28585
|
["gapMatchInteraction", (xml, diag, lom, opts) => convertGapMatchToLearnosity(xml, diag, lom, opts.organisationId, opts.sourceFile, opts.mediaVault, opts.customAssetUrl, opts.itemReferenceSource)],
|
|
28570
28586
|
["orderInteraction", (xml, diag, lom, opts) => convertOrderToLearnosity(xml, diag, lom, opts.organisationId, opts.sourceFile, opts.mediaVault, opts.customAssetUrl, opts.itemReferenceSource)],
|
|
28571
|
-
["hotspotInteraction", (xml, diag, lom, opts) => convertHotspotToLearnosity(xml, diag, lom, opts.organisationId, opts.sourceFile, opts.mediaVault, opts.customAssetUrl, opts.itemReferenceSource)],
|
|
28587
|
+
["hotspotInteraction", (xml, diag, lom, opts) => convertHotspotToLearnosity(xml, diag, lom, opts.organisationId, opts.sourceFile, opts.mediaVault, opts.customAssetUrl, opts.itemReferenceSource, opts.fileAccess, opts.packageRoot)],
|
|
28572
28588
|
["hottextInteraction", (xml, diag, lom, opts) => convertHottextToLearnosity(xml, diag, lom, opts.organisationId, opts.sourceFile, opts.mediaVault, opts.customAssetUrl, opts.itemReferenceSource)],
|
|
28573
28589
|
["graphicGapMatchInteraction", (xml, diag, lom, opts) => convertGraphicGapMatchToLearnosity(xml, diag, lom, opts.organisationId, opts.sourceFile, opts.mediaVault, opts.customAssetUrl, opts.itemReferenceSource)],
|
|
28574
28590
|
["drawingInteraction", (xml, diag, lom, opts) => convertDrawingToLearnosity(xml, diag, lom, opts.organisationId, opts.sourceFile, opts.mediaVault, opts.customAssetUrl, opts.itemReferenceSource)],
|
|
@@ -28696,7 +28712,7 @@ function convertQtiAssessmentItemToLearnosity(inputXml, opts = {}) {
|
|
|
28696
28712
|
const { counts, allInteractions } = countAllInteractions(inputXml);
|
|
28697
28713
|
const presentTypes = INTERACTION_NAMES.filter((name) => counts[name] > 0);
|
|
28698
28714
|
if (presentTypes.reduce((sum, name) => sum + counts[name], 0) === 0) return handleNoInteractions(inputXml, diagnostics, allInteractions, lomTags, opts);
|
|
28699
|
-
if (presentTypes.length > 1) return convertMixedInteractionsToLearnosity(inputXml, diagnostics, lomTags, opts.organisationId, opts.sourceFile, opts.mediaVault, opts.customAssetUrl, opts.itemReferenceSource, opts.fileAccess);
|
|
28715
|
+
if (presentTypes.length > 1) return convertMixedInteractionsToLearnosity(inputXml, diagnostics, lomTags, opts.organisationId, opts.sourceFile, opts.mediaVault, opts.customAssetUrl, opts.itemReferenceSource, opts.fileAccess, opts.packageRoot);
|
|
28700
28716
|
return dispatchSingleInteractionConverter(presentTypes[0], inputXml, counts[presentTypes[0]], diagnostics, lomTags, opts);
|
|
28701
28717
|
} catch (error) {
|
|
28702
28718
|
diagnostics.push({
|
|
@@ -28709,6 +28725,97 @@ function convertQtiAssessmentItemToLearnosity(inputXml, opts = {}) {
|
|
|
28709
28725
|
}
|
|
28710
28726
|
}
|
|
28711
28727
|
//#endregion
|
|
28728
|
+
//#region ../core/src/learnosity-mapper/forwardAssetUrlTransform.ts
|
|
28729
|
+
/**
|
|
28730
|
+
* Forward-direction (Learnosity → QTI) asset URL transformation.
|
|
28731
|
+
*
|
|
28732
|
+
* Learnosity item/stimulus content references assets using Learnosity's own
|
|
28733
|
+
* path convention (for example `/vendor/learnosity/itembank/assets/<hash>_<name>.mp3`).
|
|
28734
|
+
* When converting to a QTI Content Package, those references must point at the
|
|
28735
|
+
* assets that ship inside the package.
|
|
28736
|
+
*
|
|
28737
|
+
* This module rewrites the *prefix* of an asset reference while preserving the
|
|
28738
|
+
* final path segment (the filename), mirroring the reverse-direction helper in
|
|
28739
|
+
* `qti-to-learnosity/utils/assetUrlTransform.ts`.
|
|
28740
|
+
*
|
|
28741
|
+
* Rules:
|
|
28742
|
+
* - Default prefix is `./assets/` so a reference resolves to `./assets/<filename>`.
|
|
28743
|
+
* - A caller-supplied `customAssetUrl` replaces the entire prefix up to the
|
|
28744
|
+
* filename, e.g. `https://cdn.example.com/media` → `https://cdn.example.com/media/<filename>`.
|
|
28745
|
+
* - Remote (`http(s)://`), protocol-relative (`//`) and `data:` URIs are left
|
|
28746
|
+
* untouched.
|
|
28747
|
+
* - References that already point at internal package paths (`assets/`,
|
|
28748
|
+
* `./assets/`, `stimuli/`, `items/`, or a relative `../` path) are left
|
|
28749
|
+
* untouched so we never rewrite converter-generated internal references
|
|
28750
|
+
* (e.g. `assets/gapimgs/...`, `assets/css/lrn-normalize.css`).
|
|
28751
|
+
*/
|
|
28752
|
+
/** Default output prefix applied when no `customAssetUrl` is provided. */
|
|
28753
|
+
const DEFAULT_FORWARD_ASSET_PREFIX = "./assets";
|
|
28754
|
+
/**
|
|
28755
|
+
* Extract the filename (last path segment) from a URL/path, ignoring any query
|
|
28756
|
+
* string or hash fragment.
|
|
28757
|
+
*
|
|
28758
|
+
* Examples:
|
|
28759
|
+
* "/vendor/learnosity/itembank/assets/hash_name.mp3" → "hash_name.mp3"
|
|
28760
|
+
* "images/photo.png?v=2" → "photo.png"
|
|
28761
|
+
*/
|
|
28762
|
+
function extractFilename(url) {
|
|
28763
|
+
const segments = url.split("?")[0].split("#")[0].split("/");
|
|
28764
|
+
return segments[segments.length - 1];
|
|
28765
|
+
}
|
|
28766
|
+
/**
|
|
28767
|
+
* Determine whether a reference is one we should leave untouched (remote/data
|
|
28768
|
+
* URIs and converter-generated internal package paths).
|
|
28769
|
+
*/
|
|
28770
|
+
function isNonRewritableReference(url) {
|
|
28771
|
+
const trimmed = url.trim();
|
|
28772
|
+
if (trimmed === "") return true;
|
|
28773
|
+
if (/^https?:\/\//i.test(trimmed) || trimmed.startsWith("//") || trimmed.startsWith("data:")) return true;
|
|
28774
|
+
if (trimmed.startsWith("assets/") || trimmed.startsWith("./assets/") || trimmed.startsWith("stimuli/") || trimmed.startsWith("items/") || trimmed.startsWith("tests/") || trimmed.startsWith("../")) return true;
|
|
28775
|
+
return false;
|
|
28776
|
+
}
|
|
28777
|
+
/**
|
|
28778
|
+
* Build the output base prefix (without a trailing slash).
|
|
28779
|
+
*/
|
|
28780
|
+
function resolveBasePrefix(customAssetUrl) {
|
|
28781
|
+
const base = customAssetUrl && customAssetUrl.trim() !== "" ? customAssetUrl.trim() : DEFAULT_FORWARD_ASSET_PREFIX;
|
|
28782
|
+
return base.endsWith("/") ? base.slice(0, -1) : base;
|
|
28783
|
+
}
|
|
28784
|
+
/**
|
|
28785
|
+
* Rewrite a single asset reference to the forward-direction package prefix.
|
|
28786
|
+
*
|
|
28787
|
+
* @param url - The incoming Learnosity asset reference.
|
|
28788
|
+
* @param customAssetUrl - Optional base URL/prefix that replaces everything up
|
|
28789
|
+
* to the filename. Defaults to `./assets`.
|
|
28790
|
+
* @returns The rewritten reference, or the original string when it should not
|
|
28791
|
+
* be rewritten.
|
|
28792
|
+
*/
|
|
28793
|
+
function transformForwardAssetUrl(url, customAssetUrl) {
|
|
28794
|
+
if (isNonRewritableReference(url)) return url;
|
|
28795
|
+
const filename = extractFilename(url);
|
|
28796
|
+
if (filename === "") return url;
|
|
28797
|
+
return `${resolveBasePrefix(customAssetUrl)}/${filename}`;
|
|
28798
|
+
}
|
|
28799
|
+
/**
|
|
28800
|
+
* Rewrite every asset reference found in a fragment of QTI XML / XHTML.
|
|
28801
|
+
*
|
|
28802
|
+
* Handles the attributes used by the forward serializers and mappers:
|
|
28803
|
+
* - `src="..."` (img, qh5:source, qh5:track, audio/video source)
|
|
28804
|
+
* - `data="..."` (object elements, e.g. media fallbacks, image backgrounds)
|
|
28805
|
+
* - `href="..."` (download fallback anchors for media)
|
|
28806
|
+
*
|
|
28807
|
+
* Internal references (`stimuli/...`, `assets/...`, the CSS stylesheet, gap
|
|
28808
|
+
* images, etc.) are preserved by {@link transformForwardAssetUrl}.
|
|
28809
|
+
*/
|
|
28810
|
+
function transformForwardAssetUrlsInXml(xml, customAssetUrl) {
|
|
28811
|
+
if (!xml) return xml;
|
|
28812
|
+
return xml.replace(/\b(src|data|href)=("|')([^"']*)\2/gi, (match, attr, quote, value) => {
|
|
28813
|
+
const rewritten = transformForwardAssetUrl(value, customAssetUrl);
|
|
28814
|
+
if (rewritten === value) return match;
|
|
28815
|
+
return `${attr}=${quote}${rewritten}${quote}`;
|
|
28816
|
+
});
|
|
28817
|
+
}
|
|
28818
|
+
//#endregion
|
|
28712
28819
|
//#region ../core/src/conversions.ts
|
|
28713
28820
|
/**
|
|
28714
28821
|
* Convert QTI XML to Learnosity JSON.
|
|
@@ -28775,8 +28882,9 @@ function convertLearnosityToQti(input, opts) {
|
|
|
28775
28882
|
output: "",
|
|
28776
28883
|
diagnostics: allDiagnostics
|
|
28777
28884
|
});
|
|
28885
|
+
const output = transformForwardAssetUrlsInXml(serializeResult.xml, opts.customAssetUrl);
|
|
28778
28886
|
return Promise.resolve({
|
|
28779
|
-
output
|
|
28887
|
+
output,
|
|
28780
28888
|
diagnostics: allDiagnostics
|
|
28781
28889
|
});
|
|
28782
28890
|
}
|
|
@@ -31575,4 +31683,4 @@ async function resolveOptions(cliOpts, config, isPackageCommand, configPath) {
|
|
|
31575
31683
|
//#endregion
|
|
31576
31684
|
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 };
|
|
31577
31685
|
|
|
31578
|
-
//# sourceMappingURL=resolveOptions-
|
|
31686
|
+
//# sourceMappingURL=resolveOptions-ehwJSkQy.js.map
|