@learnosity/lib-qti-converter 0.12.8 → 0.14.0
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/docs/EXAMPLES.md +46 -34
- package/docs/GETTING_STARTED.md +88 -31
- package/docs/LEARNOSITY_BUNDLE_FORMAT.md +24 -8
- package/package.json +1 -1
- package/packages/cli/dist/{batchProcessors-CUJoQD8a.js → batchProcessors-DWG8qk7G.js} +296 -80
- package/packages/cli/dist/batchProcessors-DWG8qk7G.js.map +1 -0
- package/packages/cli/dist/batchWorker.js +1 -1
- package/packages/cli/dist/{learnosityToQti-CvfVQ6Kl.js → learnosityToQti-C7cTRTU2.js} +4 -4
- package/packages/cli/dist/{learnosityToQti-CvfVQ6Kl.js.map → learnosityToQti-C7cTRTU2.js.map} +1 -1
- package/packages/cli/dist/{learnosityToQtiPackage-CXMsJNQD.js → learnosityToQtiPackage-C84dQKKi.js} +4 -4
- package/packages/cli/dist/{learnosityToQtiPackage-CXMsJNQD.js.map → learnosityToQtiPackage-C84dQKKi.js.map} +1 -1
- package/packages/cli/dist/main.js +4 -4
- package/packages/cli/dist/{pathUtils-DmtCfutO.js → pathUtils-Cr9IcK0n.js} +21 -6
- package/packages/cli/dist/{pathUtils-DmtCfutO.js.map → pathUtils-Cr9IcK0n.js.map} +1 -1
- package/packages/cli/dist/{qtiPackageToLearnosity-FhfNr7gf.js → qtiPackageToLearnosity-BBfZgWBh.js} +14 -8
- package/packages/cli/dist/qtiPackageToLearnosity-BBfZgWBh.js.map +1 -0
- package/packages/cli/dist/{qtiToLearnosity-5lQ5f3-t.js → qtiToLearnosity-C9OW_n7Z.js} +6 -5
- package/packages/cli/dist/qtiToLearnosity-C9OW_n7Z.js.map +1 -0
- package/packages/cli/dist/{resolveOptions-lHxSyq9F.js → resolveOptions-D_UECo_9.js} +22 -7
- package/packages/cli/dist/resolveOptions-D_UECo_9.js.map +1 -0
- package/packages/cli/dist/{table-7b-8MN2z.js → table-D1ydwhbX.js} +536 -175
- package/packages/cli/dist/table-D1ydwhbX.js.map +1 -0
- package/packages/core/dist/index.d.ts +20 -4
- package/packages/core/dist/index.js +802 -246
- package/packages/core/dist/node.d.ts +23 -5
- package/packages/core/dist/node.js +828 -251
- package/packages/cli/dist/batchProcessors-CUJoQD8a.js.map +0 -1
- package/packages/cli/dist/qtiPackageToLearnosity-FhfNr7gf.js.map +0 -1
- package/packages/cli/dist/qtiToLearnosity-5lQ5f3-t.js.map +0 -1
- package/packages/cli/dist/resolveOptions-lHxSyq9F.js.map +0 -1
- package/packages/cli/dist/table-7b-8MN2z.js.map +0 -1
|
@@ -144,6 +144,9 @@ const DiagnosticCode = {
|
|
|
144
144
|
QTI_PACKAGE_NO_CONTENT: "QTI_PACKAGE_NO_CONTENT",
|
|
145
145
|
QTI_PACKAGE_DUPLICATE_IDENTIFIER: "QTI_PACKAGE_DUPLICATE_IDENTIFIER",
|
|
146
146
|
QTI_ITEM_CONVERSION_FAILED: "QTI_ITEM_CONVERSION_FAILED",
|
|
147
|
+
QTI_ASSET_HREF_UNSAFE: "QTI_ASSET_HREF_UNSAFE",
|
|
148
|
+
QTI_ASSET_FILENAME_CONFLICT: "QTI_ASSET_FILENAME_CONFLICT",
|
|
149
|
+
QTI_ASSET_IDENTITY_BYTES_CONFLICT: "QTI_ASSET_IDENTITY_BYTES_CONFLICT",
|
|
147
150
|
LRN_BUNDLE_WRITTEN: "LRN_BUNDLE_WRITTEN",
|
|
148
151
|
QTI_DOWNGRADE_NAMESPACE: "QTI_DOWNGRADE_NAMESPACE",
|
|
149
152
|
QTI_DOWNGRADE_SCHEMA_LOCATION: "QTI_DOWNGRADE_SCHEMA_LOCATION",
|
|
@@ -22896,6 +22899,33 @@ function md5hex(input) {
|
|
|
22896
22899
|
return hex;
|
|
22897
22900
|
}
|
|
22898
22901
|
//#endregion
|
|
22902
|
+
//#region ../core/src/qti-to-learnosity/utils/mediaFeature.ts
|
|
22903
|
+
/**
|
|
22904
|
+
* Build a stable UUID-shaped identifier for a media feature.
|
|
22905
|
+
*
|
|
22906
|
+
* Feature output must remain identical for equivalent directory and ZIP
|
|
22907
|
+
* package conversions, so the identifier is derived from the final media URL
|
|
22908
|
+
* rather than generated randomly. The UUID version and variant bits are set
|
|
22909
|
+
* to keep the value compatible with consumers expecting a v4-shaped UUID.
|
|
22910
|
+
*/
|
|
22911
|
+
function buildMediaFeatureId(transformedUrl) {
|
|
22912
|
+
const hash = md5hex(transformedUrl).split("");
|
|
22913
|
+
const variant = [
|
|
22914
|
+
"8",
|
|
22915
|
+
"9",
|
|
22916
|
+
"a",
|
|
22917
|
+
"b"
|
|
22918
|
+
][parseInt(hash[16], 16) & 3];
|
|
22919
|
+
hash[12] = "4";
|
|
22920
|
+
hash[16] = variant;
|
|
22921
|
+
return `${hash.slice(0, 8).join("")}-${hash.slice(8, 12).join("")}-${hash.slice(12, 16).join("")}-${hash.slice(16, 20).join("")}-${hash.slice(20).join("")}`;
|
|
22922
|
+
}
|
|
22923
|
+
/** Build a Learnosity simple-feature span for audio or hosted video. */
|
|
22924
|
+
function buildMediaFeatureSpan(transformedUrl, kind, featureId = buildMediaFeatureId(transformedUrl)) {
|
|
22925
|
+
if (kind === "audio") return `<span class="learnosity-feature" data-player="button" data-simplefeature_id="${featureId}" data-src="${transformedUrl}" data-type="audioplayer"></span>`;
|
|
22926
|
+
return `<span class="learnosity-feature" data-player_type="hosted-video" data-simplefeature_id="${featureId}" data-src="${transformedUrl}" data-text_alternative.caption.src="" data-type="videoplayer"></span>`;
|
|
22927
|
+
}
|
|
22928
|
+
//#endregion
|
|
22899
22929
|
//#region ../core/src/qti-to-learnosity/utils/convertObjectElement.ts
|
|
22900
22930
|
/**
|
|
22901
22931
|
* Convert QTI <object> elements to appropriate Learnosity HTML elements
|
|
@@ -22947,7 +22977,7 @@ function buildDeterministicFeatureId(transformedUrl) {
|
|
|
22947
22977
|
* <object data="video.mp4" type="video/mp4"/>
|
|
22948
22978
|
* → <span class="learnosity-feature" data-player_type="hosted-video" data-simplefeature_id="..." data-src="[cdn-url]" data-text_alternative.caption.src="" data-type="videoplayer"></span>
|
|
22949
22979
|
*/
|
|
22950
|
-
function convertObjectToElement(objectTag, organisationId, mediaVault = false, customAssetUrl) {
|
|
22980
|
+
function convertObjectToElement(objectTag, organisationId, mediaVault = false, customAssetUrl, assetContext = {}) {
|
|
22951
22981
|
const dataMatch = objectTag.match(/data=["']([^"']+)["']/i);
|
|
22952
22982
|
const srcMatch = objectTag.match(/src=["']([^"']+)["']/i);
|
|
22953
22983
|
const typeMatch = objectTag.match(/type=["']([^"']+)["']/i);
|
|
@@ -22957,11 +22987,11 @@ function convertObjectToElement(objectTag, organisationId, mediaVault = false, c
|
|
|
22957
22987
|
if (!urlMatch) return objectTag;
|
|
22958
22988
|
const sourceUrl = urlMatch[1];
|
|
22959
22989
|
const category = getMimeTypeCategory(typeMatch ? typeMatch[1] : "");
|
|
22960
|
-
const transformedUrl = transformUrl(sourceUrl, organisationId, mediaVault, customAssetUrl);
|
|
22990
|
+
const transformedUrl = transformUrl(sourceUrl, organisationId, mediaVault, customAssetUrl, assetContext);
|
|
22961
22991
|
switch (category) {
|
|
22962
22992
|
case "image": return buildImageTag(transformedUrl, heightMatch, widthMatch);
|
|
22963
|
-
case "audio": return
|
|
22964
|
-
case "video": return
|
|
22993
|
+
case "audio": return buildMediaFeatureSpan(transformedUrl, "audio", buildDeterministicFeatureId(transformedUrl));
|
|
22994
|
+
case "video": return buildMediaFeatureSpan(transformedUrl, "video", buildDeterministicFeatureId(transformedUrl));
|
|
22965
22995
|
default: return objectTag.replace(sourceUrl, transformedUrl);
|
|
22966
22996
|
}
|
|
22967
22997
|
}
|
|
@@ -23005,55 +23035,139 @@ function normalizeTableClass(html) {
|
|
|
23005
23035
|
});
|
|
23006
23036
|
}
|
|
23007
23037
|
//#endregion
|
|
23008
|
-
//#region ../core/src/qti-to-learnosity/utils/
|
|
23038
|
+
//#region ../core/src/qti-to-learnosity/utils/assetIdentity.ts
|
|
23009
23039
|
/**
|
|
23010
|
-
*
|
|
23011
|
-
* TASK 030
|
|
23040
|
+
* Browser-safe helpers for identifying package-local QTI assets.
|
|
23012
23041
|
*
|
|
23013
|
-
*
|
|
23042
|
+
* QTI asset references are package-relative paths, not filesystem paths. Keeping
|
|
23043
|
+
* their canonical form here makes directory and ZIP inputs produce the same
|
|
23044
|
+
* identity while rejecting references that could escape the package root.
|
|
23045
|
+
*/
|
|
23046
|
+
/** Asset extensions copied and rewritten by QTI → Learnosity conversion. */
|
|
23047
|
+
const QTI_ASSET_EXTENSIONS = [
|
|
23048
|
+
".png",
|
|
23049
|
+
".jpg",
|
|
23050
|
+
".jpeg",
|
|
23051
|
+
".gif",
|
|
23052
|
+
".svg",
|
|
23053
|
+
".webp",
|
|
23054
|
+
".bmp",
|
|
23055
|
+
".ico",
|
|
23056
|
+
".mp3",
|
|
23057
|
+
".mp4",
|
|
23058
|
+
".wav",
|
|
23059
|
+
".ogg",
|
|
23060
|
+
".webm",
|
|
23061
|
+
".ogv",
|
|
23062
|
+
".m4a",
|
|
23063
|
+
".m4v",
|
|
23064
|
+
".css",
|
|
23065
|
+
".woff",
|
|
23066
|
+
".woff2",
|
|
23067
|
+
".ttf",
|
|
23068
|
+
".eot",
|
|
23069
|
+
".pdf",
|
|
23070
|
+
".json"
|
|
23071
|
+
];
|
|
23072
|
+
function isSupportedQtiAssetPath(path) {
|
|
23073
|
+
const lowerPath = path.toLowerCase();
|
|
23074
|
+
return !lowerPath.endsWith(".html") && !lowerPath.endsWith(".htm") && QTI_ASSET_EXTENSIONS.some((extension) => lowerPath.endsWith(extension));
|
|
23075
|
+
}
|
|
23076
|
+
function isUnsafeQtiAssetHrefError(error) {
|
|
23077
|
+
return error instanceof Error && (error.message.startsWith("Unsafe QTI asset href:") || error.message.startsWith("QTI asset href has no filename:"));
|
|
23078
|
+
}
|
|
23079
|
+
/**
|
|
23080
|
+
* Canonicalize a package-relative QTI asset href.
|
|
23081
|
+
*
|
|
23082
|
+
* Query strings and fragments are URL metadata and do not identify a different
|
|
23083
|
+
* package asset. Path separators are normalized to `/`, dot segments are
|
|
23084
|
+
* resolved, and traversal above the package root is rejected.
|
|
23014
23085
|
*/
|
|
23086
|
+
function stripHrefMetadata(href) {
|
|
23087
|
+
const metadataStart = href.search(/[?#]/);
|
|
23088
|
+
return (metadataStart === -1 ? href : href.slice(0, metadataStart)).replaceAll("\\", "/");
|
|
23089
|
+
}
|
|
23090
|
+
function assertPackageRelativePath(path, href) {
|
|
23091
|
+
const isAbsolute = path.startsWith("/") || /^[A-Za-z]:/.test(path) || /^[A-Za-z][A-Za-z\d+.-]*:/.test(path);
|
|
23092
|
+
if (!path || path.includes("\0") || isAbsolute) throw new Error(`Unsafe QTI asset href: ${href}`);
|
|
23093
|
+
if (path.endsWith("/")) throw new Error(`QTI asset href has no filename: ${href}`);
|
|
23094
|
+
}
|
|
23095
|
+
function normalizePathSegments(path, href) {
|
|
23096
|
+
const segments = [];
|
|
23097
|
+
for (const segment of path.split("/")) {
|
|
23098
|
+
if (!segment || segment === ".") continue;
|
|
23099
|
+
if (segment === "..") {
|
|
23100
|
+
if (segments.length === 0) throw new Error(`Unsafe QTI asset href: ${href}`);
|
|
23101
|
+
segments.pop();
|
|
23102
|
+
continue;
|
|
23103
|
+
}
|
|
23104
|
+
segments.push(segment);
|
|
23105
|
+
}
|
|
23106
|
+
if (segments.length === 0) throw new Error(`QTI asset href has no filename: ${href}`);
|
|
23107
|
+
return segments.join("/");
|
|
23108
|
+
}
|
|
23109
|
+
function canonicalizeQtiAssetHref(href) {
|
|
23110
|
+
if (typeof href !== "string") throw new TypeError("QTI asset href must be a string");
|
|
23111
|
+
const path = stripHrefMetadata(href);
|
|
23112
|
+
assertPackageRelativePath(path, href);
|
|
23113
|
+
return normalizePathSegments(path, href);
|
|
23114
|
+
}
|
|
23115
|
+
/** Return the final filename from a canonicalized package-relative href. */
|
|
23116
|
+
function extractQtiAssetBasename(href) {
|
|
23117
|
+
const canonicalHref = canonicalizeQtiAssetHref(href);
|
|
23118
|
+
return canonicalHref.slice(canonicalHref.lastIndexOf("/") + 1);
|
|
23119
|
+
}
|
|
23015
23120
|
/**
|
|
23016
|
-
*
|
|
23017
|
-
|
|
23018
|
-
|
|
23019
|
-
|
|
23020
|
-
|
|
23021
|
-
"
|
|
23022
|
-
"
|
|
23023
|
-
|
|
23024
|
-
"webp",
|
|
23025
|
-
"mp3",
|
|
23026
|
-
"wav",
|
|
23027
|
-
"ogg",
|
|
23028
|
-
"m4a",
|
|
23029
|
-
"mp4",
|
|
23030
|
-
"webm",
|
|
23031
|
-
"ogv",
|
|
23032
|
-
"m4v"
|
|
23033
|
-
]);
|
|
23121
|
+
* Return the final filename extension, including its leading dot.
|
|
23122
|
+
* Dotfiles and filenames ending in a dot have no extension.
|
|
23123
|
+
*/
|
|
23124
|
+
function extractQtiAssetExtension(href) {
|
|
23125
|
+
const basename = extractQtiAssetBasename(href);
|
|
23126
|
+
const extensionStart = basename.lastIndexOf(".");
|
|
23127
|
+
return extensionStart > 0 && extensionStart < basename.length - 1 ? basename.slice(extensionStart) : "";
|
|
23128
|
+
}
|
|
23034
23129
|
/**
|
|
23035
|
-
*
|
|
23036
|
-
*
|
|
23037
|
-
*
|
|
23130
|
+
* Serialize the item-scoped asset identity using an ordered JSON tuple.
|
|
23131
|
+
*
|
|
23132
|
+
* JSON serialization is intentional: unlike delimiter-based concatenation, it
|
|
23133
|
+
* keeps the item reference and canonical href unambiguous when either value
|
|
23134
|
+
* contains punctuation that could otherwise be mistaken for a separator.
|
|
23038
23135
|
*/
|
|
23039
|
-
|
|
23040
|
-
|
|
23041
|
-
|
|
23042
|
-
|
|
23043
|
-
|
|
23044
|
-
|
|
23045
|
-
|
|
23046
|
-
|
|
23047
|
-
|
|
23136
|
+
function serializeQtiAssetIdentity(finalItemReference, qtiAssetHref) {
|
|
23137
|
+
const canonicalHref = canonicalizeQtiAssetHref(qtiAssetHref);
|
|
23138
|
+
return JSON.stringify([finalItemReference, canonicalHref]);
|
|
23139
|
+
}
|
|
23140
|
+
/** Derive the lowercase MD5 hex hash for a canonical item-scoped identity. */
|
|
23141
|
+
function hashQtiAssetIdentity(finalItemReference, qtiAssetHref) {
|
|
23142
|
+
return md5hex(serializeQtiAssetIdentity(finalItemReference, qtiAssetHref));
|
|
23143
|
+
}
|
|
23144
|
+
/**
|
|
23145
|
+
* Select the output filename for a package-local QTI asset.
|
|
23146
|
+
*
|
|
23147
|
+
* Hashed naming is the default so the full item-scoped identity, rather than a
|
|
23148
|
+
* globally ambiguous source basename, determines the output name. Only the
|
|
23149
|
+
* canonical source extension is retained after the digest. Preserve mode is
|
|
23150
|
+
* an explicit compatibility opt-out and returns the canonical final basename.
|
|
23151
|
+
*/
|
|
23152
|
+
function selectQtiAssetFilename(finalItemReference, qtiAssetHref, preserveAssetFilenames = false) {
|
|
23153
|
+
const canonicalHref = canonicalizeQtiAssetHref(qtiAssetHref);
|
|
23154
|
+
if (preserveAssetFilenames) return extractQtiAssetBasename(canonicalHref);
|
|
23155
|
+
return `${hashQtiAssetIdentity(finalItemReference, canonicalHref)}${extractQtiAssetExtension(canonicalHref)}`;
|
|
23156
|
+
}
|
|
23157
|
+
//#endregion
|
|
23158
|
+
//#region ../core/src/qti-to-learnosity/utils/assetUrlTransform.ts
|
|
23048
23159
|
/**
|
|
23049
|
-
*
|
|
23160
|
+
* Asset URL transformation for Learnosity CDN
|
|
23161
|
+
* TASK 030
|
|
23050
23162
|
*
|
|
23051
|
-
*
|
|
23052
|
-
* be influenced at runtime. Global regex used only with
|
|
23053
|
-
* `String.prototype.replace`, which resets lastIndex on completion, so sharing
|
|
23054
|
-
* a single compiled instance across calls is safe.
|
|
23163
|
+
* Transforms asset URLs in HTML content to use Learnosity CDN URLs.
|
|
23055
23164
|
*/
|
|
23056
|
-
|
|
23165
|
+
/** Matches supported asset-bearing HTML attributes on any element. */
|
|
23166
|
+
const ASSET_ATTRIBUTE_PATTERN = /(<[A-Za-z][^>]*?\b(?:src|data|href)\s*=\s*["'])([^"']+)(["'][^>]*>)/gi;
|
|
23167
|
+
/** Matches <object ...> (optionally with its closing tag) for element conversion. */
|
|
23168
|
+
const OBJECT_TAG_PATTERN = /<object\s+[^>]*>(?:<\/object>)?/gi;
|
|
23169
|
+
/** Matches anchors whose href points to inline audio/video media. */
|
|
23170
|
+
const INLINE_MEDIA_LINK_PATTERN = /<a\b([^>]*?)\bhref\s*=\s*(["'])([^"']+)\2([^>]*)>([\s\S]*?)<\/a\s*>/gi;
|
|
23057
23171
|
/**
|
|
23058
23172
|
* Extract filename from a URL path
|
|
23059
23173
|
* Examples:
|
|
@@ -23065,12 +23179,26 @@ function extractFilename$2(url) {
|
|
|
23065
23179
|
const segments = url.split("?")[0].split("#")[0].split("/");
|
|
23066
23180
|
return segments[segments.length - 1];
|
|
23067
23181
|
}
|
|
23068
|
-
/**
|
|
23069
|
-
* Check if a filename has a supported asset extension
|
|
23070
|
-
*/
|
|
23071
23182
|
function isSupportedAsset(filename) {
|
|
23072
|
-
|
|
23073
|
-
|
|
23183
|
+
return isSupportedQtiAssetPath(filename);
|
|
23184
|
+
}
|
|
23185
|
+
function getInlineMediaKind(url, attributes) {
|
|
23186
|
+
const mimeType = attributes.match(/\btype\s*=\s*(["'])([^"']+)\1/i)?.[2].toLowerCase();
|
|
23187
|
+
if (mimeType?.startsWith("audio/")) return "audio";
|
|
23188
|
+
if (mimeType?.startsWith("video/")) return "video";
|
|
23189
|
+
const filename = extractFilename$2(url).toLowerCase();
|
|
23190
|
+
if ([
|
|
23191
|
+
".mp3",
|
|
23192
|
+
".wav",
|
|
23193
|
+
".ogg",
|
|
23194
|
+
".m4a"
|
|
23195
|
+
].some((extension) => filename.endsWith(extension))) return "audio";
|
|
23196
|
+
if ([
|
|
23197
|
+
".mp4",
|
|
23198
|
+
".webm",
|
|
23199
|
+
".ogv",
|
|
23200
|
+
".m4v"
|
|
23201
|
+
].some((extension) => filename.endsWith(extension))) return "video";
|
|
23074
23202
|
}
|
|
23075
23203
|
/**
|
|
23076
23204
|
* Build Learnosity CDN URL for an asset
|
|
@@ -23080,17 +23208,24 @@ function buildLearnosityAssetUrl(filename, organisationId, mediaVault = false, c
|
|
|
23080
23208
|
if (customAssetUrl) return `${customAssetUrl.endsWith("/") ? customAssetUrl.slice(0, -1) : customAssetUrl}/${filename}`;
|
|
23081
23209
|
return `https://${mediaVault ? "media-vault" : "assets"}.learnosity.com/organisations/${organisationId}/${filename}`;
|
|
23082
23210
|
}
|
|
23211
|
+
function resolveQtiAssetHref(url, sourceHrefBase) {
|
|
23212
|
+
const normalizedUrl = url.split(/[?#]/, 1)[0].replaceAll("\\", "/");
|
|
23213
|
+
const isItemRelative = /^\.\.?\//.test(normalizedUrl) || !normalizedUrl.includes("/");
|
|
23214
|
+
if (!sourceHrefBase || !isItemRelative) return canonicalizeQtiAssetHref(url);
|
|
23215
|
+
const baseHref = canonicalizeQtiAssetHref(sourceHrefBase);
|
|
23216
|
+
return canonicalizeQtiAssetHref(`${baseHref.slice(0, baseHref.lastIndexOf("/") + 1)}${normalizedUrl}`);
|
|
23217
|
+
}
|
|
23083
23218
|
/**
|
|
23084
23219
|
* Transform a single URL to Learnosity CDN format
|
|
23085
23220
|
* Exported for use in image object source fields
|
|
23086
23221
|
*/
|
|
23087
|
-
function transformUrl(url, organisationId, mediaVault = false, customAssetUrl) {
|
|
23222
|
+
function transformUrl(url, organisationId, mediaVault = false, customAssetUrl, context = {}) {
|
|
23088
23223
|
if (url.includes("assets.learnosity.com") || url.includes("media-vault.learnosity.com")) return url;
|
|
23089
|
-
if (
|
|
23224
|
+
if (/^https?:\/\//i.test(url) || url.startsWith("//")) return url;
|
|
23090
23225
|
if (url.startsWith("data:")) return url;
|
|
23091
23226
|
const filename = extractFilename$2(url);
|
|
23092
23227
|
if (!isSupportedAsset(filename)) return url;
|
|
23093
|
-
return buildLearnosityAssetUrl(filename, organisationId, mediaVault, customAssetUrl);
|
|
23228
|
+
return buildLearnosityAssetUrl(context.finalItemReference ? selectQtiAssetFilename(context.finalItemReference, resolveQtiAssetHref(url, context.sourceHrefBase), context.preserveAssetFilenames ?? false) : filename, organisationId, mediaVault, customAssetUrl);
|
|
23094
23229
|
}
|
|
23095
23230
|
/**
|
|
23096
23231
|
* Transform asset URLs in HTML content
|
|
@@ -23108,14 +23243,24 @@ function transformUrl(url, organisationId, mediaVault = false, customAssetUrl) {
|
|
|
23108
23243
|
*/
|
|
23109
23244
|
function transformAssetUrls(html, options) {
|
|
23110
23245
|
if (!html) return html;
|
|
23111
|
-
if (
|
|
23246
|
+
if (Array.from(html.matchAll(ASSET_ATTRIBUTE_PATTERN)).some((match) => isSupportedAsset(extractFilename$2(match[2]))) && !options.organisationId) throw new Error("Asset references found in QTI content but no --organisation_id provided. Please provide --organisation_id to convert assets to Learnosity CDN URLs.");
|
|
23112
23247
|
if (!options.organisationId) return normalizeTableClass(html);
|
|
23113
23248
|
const orgId = options.organisationId;
|
|
23114
23249
|
const mediaVault = options.mediaVault ?? false;
|
|
23115
23250
|
const customAssetUrl = options.customAssetUrl;
|
|
23251
|
+
const assetContext = {
|
|
23252
|
+
finalItemReference: options.finalItemReference,
|
|
23253
|
+
preserveAssetFilenames: options.preserveAssetFilenames,
|
|
23254
|
+
sourceHrefBase: options.sourceHrefBase
|
|
23255
|
+
};
|
|
23116
23256
|
let result = html;
|
|
23117
|
-
result = result.replace(OBJECT_TAG_PATTERN, (match) => convertObjectToElement(match, orgId, mediaVault, customAssetUrl));
|
|
23118
|
-
result = result.replace(
|
|
23257
|
+
result = result.replace(OBJECT_TAG_PATTERN, (match) => convertObjectToElement(match, orgId, mediaVault, customAssetUrl, assetContext));
|
|
23258
|
+
result = result.replace(INLINE_MEDIA_LINK_PATTERN, (match, beforeAttributes, _quote, url, afterAttributes) => {
|
|
23259
|
+
const kind = getInlineMediaKind(url, `${beforeAttributes}${afterAttributes}`);
|
|
23260
|
+
if (!kind) return match;
|
|
23261
|
+
return buildMediaFeatureSpan(transformUrl(url, orgId, mediaVault, customAssetUrl, assetContext), kind);
|
|
23262
|
+
});
|
|
23263
|
+
result = result.replace(ASSET_ATTRIBUTE_PATTERN, (_match, prefix, url, suffix) => prefix + transformUrl(url, orgId, mediaVault, customAssetUrl, assetContext) + suffix);
|
|
23119
23264
|
result = normalizeHtmlWhitespace(result);
|
|
23120
23265
|
result = normalizeTableClass(result);
|
|
23121
23266
|
return result;
|
|
@@ -23123,12 +23268,16 @@ function transformAssetUrls(html, options) {
|
|
|
23123
23268
|
//#endregion
|
|
23124
23269
|
//#region ../core/src/qti-to-learnosity/utils/generateItemReference.ts
|
|
23125
23270
|
/**
|
|
23126
|
-
* Generate item reference based on the configured source
|
|
23271
|
+
* Generate item reference based on the configured source.
|
|
23272
|
+
*
|
|
23273
|
+
* - `'itemIdentifier'` (default) and its deprecated alias `'qti'`, as well as an
|
|
23274
|
+
* omitted source, return the QTI `identifier`.
|
|
23275
|
+
* - `'uuid'` returns an MD5 hash of the QTI `identifier`.
|
|
23276
|
+
* - `'sourceFilename'` derives the reference from the source file name.
|
|
23127
23277
|
*/
|
|
23128
23278
|
function generateItemReference(qtiIdentifier, itemReferenceSource, sourceFile) {
|
|
23129
|
-
if (itemReferenceSource === "qti") return qtiIdentifier;
|
|
23130
23279
|
if (itemReferenceSource === "uuid") return md5hex(qtiIdentifier);
|
|
23131
|
-
if (sourceFile) return (sourceFile.split(/[\\/]/).pop() ?? sourceFile).replace(/\.xml$/i, "");
|
|
23280
|
+
if (itemReferenceSource === "sourceFilename" && sourceFile) return (sourceFile.split(/[\\/]/).pop() ?? sourceFile).replace(/\.xml$/i, "");
|
|
23132
23281
|
return qtiIdentifier;
|
|
23133
23282
|
}
|
|
23134
23283
|
//#endregion
|
|
@@ -23261,23 +23410,30 @@ function mapCorrectPairsToValidation(correctPairs, stemIdToIndex, optionIdToInde
|
|
|
23261
23410
|
/**
|
|
23262
23411
|
* Convert matchInteraction to Learnosity choicematrix
|
|
23263
23412
|
*/
|
|
23264
|
-
function convertMatchToLearnosity(inputXml, diagnostics, lomTags, organisationId, sourceFile, mediaVault, customAssetUrl, itemReferenceSource) {
|
|
23413
|
+
function convertMatchToLearnosity(inputXml, diagnostics, lomTags, organisationId, sourceFile, mediaVault, customAssetUrl, itemReferenceSource, _stimulusOverride, assetTransformContext) {
|
|
23265
23414
|
const parsed = readAssessmentItemMatch(inputXml);
|
|
23266
23415
|
const updatedDiagnostics = addFileContextIfProvided(parsed.diagnostics, sourceFile);
|
|
23267
23416
|
diagnostics.push(...updatedDiagnostics);
|
|
23268
23417
|
if (hasErrors(diagnostics)) return { diagnostics };
|
|
23269
23418
|
if (!parsed.identifier || parsed.stems.length === 0 || parsed.options.length === 0) return { diagnostics };
|
|
23270
|
-
const itemRef = generateItemReference(parsed.identifier, itemReferenceSource, sourceFile);
|
|
23419
|
+
const itemRef = assetTransformContext?.finalItemReference ?? generateItemReference(parsed.identifier, itemReferenceSource, sourceFile);
|
|
23420
|
+
const transformContext = {
|
|
23421
|
+
finalItemReference: itemRef,
|
|
23422
|
+
preserveAssetFilenames: assetTransformContext?.preserveAssetFilenames ?? false,
|
|
23423
|
+
sourceHrefBase: assetTransformContext?.sourceHrefBase
|
|
23424
|
+
};
|
|
23271
23425
|
const questionRef = md5hex(itemRef);
|
|
23272
23426
|
const stems = parsed.stems.map((stem) => transformAssetUrls(stem.text, {
|
|
23273
23427
|
organisationId,
|
|
23274
23428
|
mediaVault,
|
|
23275
|
-
customAssetUrl
|
|
23429
|
+
customAssetUrl,
|
|
23430
|
+
...transformContext
|
|
23276
23431
|
}));
|
|
23277
23432
|
const options = parsed.options.map((option) => transformAssetUrls(option.text, {
|
|
23278
23433
|
organisationId,
|
|
23279
23434
|
mediaVault,
|
|
23280
|
-
customAssetUrl
|
|
23435
|
+
customAssetUrl,
|
|
23436
|
+
...transformContext
|
|
23281
23437
|
}));
|
|
23282
23438
|
const stemIdToIndex = /* @__PURE__ */ new Map();
|
|
23283
23439
|
parsed.stems.forEach((stem, index) => {
|
|
@@ -23295,7 +23451,8 @@ function convertMatchToLearnosity(inputXml, diagnostics, lomTags, organisationId
|
|
|
23295
23451
|
const stimulus = transformAssetUrls(parsed.stimulusText ? `<p>${parsed.stimulusText}</p>` : "", {
|
|
23296
23452
|
organisationId,
|
|
23297
23453
|
mediaVault,
|
|
23298
|
-
customAssetUrl
|
|
23454
|
+
customAssetUrl,
|
|
23455
|
+
...transformContext
|
|
23299
23456
|
});
|
|
23300
23457
|
const item = {
|
|
23301
23458
|
item: {
|
|
@@ -23675,25 +23832,32 @@ function buildGapValidation(gaps, gapIdToGapTextIds, gapTextIdToContent, sourceF
|
|
|
23675
23832
|
/**
|
|
23676
23833
|
* Convert gapMatchInteraction to Learnosity clozeassociation
|
|
23677
23834
|
*/
|
|
23678
|
-
function convertGapMatchToLearnosity(inputXml, diagnostics, lomTags, organisationId, sourceFile, mediaVault, customAssetUrl, itemReferenceSource) {
|
|
23835
|
+
function convertGapMatchToLearnosity(inputXml, diagnostics, lomTags, organisationId, sourceFile, mediaVault, customAssetUrl, itemReferenceSource, _stimulusOverride, assetTransformContext) {
|
|
23679
23836
|
const parsed = readAssessmentItemGapMatch(inputXml);
|
|
23680
23837
|
const updatedDiagnostics = addFileContextIfProvided(parsed.diagnostics, sourceFile);
|
|
23681
23838
|
diagnostics.push(...updatedDiagnostics);
|
|
23682
23839
|
if (hasErrors(diagnostics)) return { diagnostics };
|
|
23683
23840
|
if (!parsed.identifier || parsed.gapTexts.length === 0 || parsed.gaps.length === 0) return { diagnostics };
|
|
23684
|
-
const itemRef = generateItemReference(parsed.identifier, itemReferenceSource, sourceFile);
|
|
23841
|
+
const itemRef = assetTransformContext?.finalItemReference ?? generateItemReference(parsed.identifier, itemReferenceSource, sourceFile);
|
|
23842
|
+
const transformContext = {
|
|
23843
|
+
finalItemReference: itemRef,
|
|
23844
|
+
preserveAssetFilenames: assetTransformContext?.preserveAssetFilenames ?? false,
|
|
23845
|
+
sourceHrefBase: assetTransformContext?.sourceHrefBase
|
|
23846
|
+
};
|
|
23685
23847
|
const questionRef = md5hex(itemRef);
|
|
23686
23848
|
const possibleResponses = parsed.gapTexts.map((gt) => transformAssetUrls(gt.text, {
|
|
23687
23849
|
organisationId,
|
|
23688
23850
|
mediaVault,
|
|
23689
|
-
customAssetUrl
|
|
23851
|
+
customAssetUrl,
|
|
23852
|
+
...transformContext
|
|
23690
23853
|
}));
|
|
23691
23854
|
const gapTextIdToContent = /* @__PURE__ */ new Map();
|
|
23692
23855
|
parsed.gapTexts.forEach((gt) => {
|
|
23693
23856
|
const transformedText = transformAssetUrls(gt.text, {
|
|
23694
23857
|
organisationId,
|
|
23695
23858
|
mediaVault,
|
|
23696
|
-
customAssetUrl
|
|
23859
|
+
customAssetUrl,
|
|
23860
|
+
...transformContext
|
|
23697
23861
|
});
|
|
23698
23862
|
gapTextIdToContent.set(gt.identifier, transformedText);
|
|
23699
23863
|
});
|
|
@@ -23711,7 +23875,8 @@ function convertGapMatchToLearnosity(inputXml, diagnostics, lomTags, organisatio
|
|
|
23711
23875
|
template: transformAssetUrls(parsed.templateHtml ?? "", {
|
|
23712
23876
|
organisationId,
|
|
23713
23877
|
mediaVault,
|
|
23714
|
-
customAssetUrl
|
|
23878
|
+
customAssetUrl,
|
|
23879
|
+
...transformContext
|
|
23715
23880
|
}),
|
|
23716
23881
|
possible_responses: possibleResponses,
|
|
23717
23882
|
shuffle_options: parsed.shuffle ?? false,
|
|
@@ -23726,7 +23891,8 @@ function convertGapMatchToLearnosity(inputXml, diagnostics, lomTags, organisatio
|
|
|
23726
23891
|
if (parsed.promptHtml) questionData.stimulus = transformAssetUrls(parsed.promptHtml, {
|
|
23727
23892
|
organisationId,
|
|
23728
23893
|
mediaVault,
|
|
23729
|
-
customAssetUrl
|
|
23894
|
+
customAssetUrl,
|
|
23895
|
+
...transformContext
|
|
23730
23896
|
});
|
|
23731
23897
|
if (maxResponsesPerZone > 1) questionData.max_response_per_zone = maxResponsesPerZone;
|
|
23732
23898
|
const choiceCounts = /* @__PURE__ */ new Map();
|
|
@@ -24131,19 +24297,22 @@ function buildValidationValues(interactions, responseDeclarations, diagnostics,
|
|
|
24131
24297
|
* Convert inlineChoiceInteraction to Learnosity clozedropdown
|
|
24132
24298
|
* TASK 036: Added stimulusOverride parameter for composite items
|
|
24133
24299
|
*/
|
|
24134
|
-
function convertInlineChoiceToLearnosity(inputXml, diagnostics, lomTags, organisationId, sourceFile, mediaVault, customAssetUrl, itemReferenceSource, stimulusOverride) {
|
|
24300
|
+
function convertInlineChoiceToLearnosity(inputXml, diagnostics, lomTags, organisationId, sourceFile, mediaVault, customAssetUrl, itemReferenceSource, stimulusOverride, assetTransformContext) {
|
|
24135
24301
|
const parsed = readAssessmentItemInlineChoice(inputXml);
|
|
24136
24302
|
const updatedDiagnostics = addFileContextIfProvided(parsed.diagnostics, sourceFile);
|
|
24137
24303
|
diagnostics.push(...updatedDiagnostics);
|
|
24138
24304
|
if (hasErrors(diagnostics)) return { diagnostics };
|
|
24139
24305
|
if (!parsed.identifier || parsed.interactions.length === 0) return { diagnostics };
|
|
24140
|
-
const itemRef = generateItemReference(parsed.identifier, itemReferenceSource, sourceFile);
|
|
24141
|
-
const questionRef = md5hex(itemRef);
|
|
24306
|
+
const itemRef = assetTransformContext?.finalItemReference ?? generateItemReference(parsed.identifier, itemReferenceSource, sourceFile);
|
|
24142
24307
|
const transformOpts = {
|
|
24143
24308
|
organisationId,
|
|
24144
24309
|
mediaVault,
|
|
24145
|
-
customAssetUrl
|
|
24310
|
+
customAssetUrl,
|
|
24311
|
+
finalItemReference: itemRef,
|
|
24312
|
+
preserveAssetFilenames: assetTransformContext?.preserveAssetFilenames ?? false,
|
|
24313
|
+
sourceHrefBase: assetTransformContext?.sourceHrefBase
|
|
24146
24314
|
};
|
|
24315
|
+
const questionRef = md5hex(itemRef);
|
|
24147
24316
|
const possibleResponses = parsed.interactions.map((interaction) => interaction.choices.map((choice) => transformAssetUrls(choice.text, transformOpts)));
|
|
24148
24317
|
const validationValue = buildValidationValues(parsed.interactions, parsed.responseDeclarations, diagnostics, transformOpts, sourceFile);
|
|
24149
24318
|
if (!validationValue) return { diagnostics };
|
|
@@ -24410,23 +24579,30 @@ function readAssessmentItemOrder(inputXml) {
|
|
|
24410
24579
|
/**
|
|
24411
24580
|
* Convert orderInteraction to Learnosity orderlist
|
|
24412
24581
|
*/
|
|
24413
|
-
function convertOrderToLearnosity(inputXml, diagnostics, lomTags, organisationId, sourceFile, mediaVault, customAssetUrl, itemReferenceSource) {
|
|
24582
|
+
function convertOrderToLearnosity(inputXml, diagnostics, lomTags, organisationId, sourceFile, mediaVault, customAssetUrl, itemReferenceSource, _stimulusOverride, assetTransformContext) {
|
|
24414
24583
|
const parsed = readAssessmentItemOrder(inputXml);
|
|
24415
24584
|
const updatedDiagnostics = addFileContextIfProvided(parsed.diagnostics, sourceFile);
|
|
24416
24585
|
diagnostics.push(...updatedDiagnostics);
|
|
24417
24586
|
if (hasErrors(diagnostics)) return { diagnostics };
|
|
24418
24587
|
if (!parsed.identifier || !parsed.responseIdentifier || parsed.choices.length === 0) return { diagnostics };
|
|
24419
|
-
const itemRef = generateItemReference(parsed.identifier, itemReferenceSource, sourceFile);
|
|
24588
|
+
const itemRef = assetTransformContext?.finalItemReference ?? generateItemReference(parsed.identifier, itemReferenceSource, sourceFile);
|
|
24589
|
+
const transformContext = {
|
|
24590
|
+
finalItemReference: itemRef,
|
|
24591
|
+
preserveAssetFilenames: assetTransformContext?.preserveAssetFilenames ?? false,
|
|
24592
|
+
sourceHrefBase: assetTransformContext?.sourceHrefBase
|
|
24593
|
+
};
|
|
24420
24594
|
const questionRef = md5hex(itemRef);
|
|
24421
24595
|
const stimulus = transformAssetUrls(parsed.stimulusText ?? "", {
|
|
24422
24596
|
organisationId,
|
|
24423
24597
|
mediaVault,
|
|
24424
|
-
customAssetUrl
|
|
24598
|
+
customAssetUrl,
|
|
24599
|
+
...transformContext
|
|
24425
24600
|
});
|
|
24426
24601
|
const list = parsed.choices.map((choice) => transformAssetUrls(choice.text, {
|
|
24427
24602
|
organisationId,
|
|
24428
24603
|
mediaVault,
|
|
24429
|
-
customAssetUrl
|
|
24604
|
+
customAssetUrl,
|
|
24605
|
+
...transformContext
|
|
24430
24606
|
}));
|
|
24431
24607
|
let validationValue;
|
|
24432
24608
|
if (parsed.correctOrder && parsed.correctOrder.length > 0) {
|
|
@@ -24801,17 +24977,19 @@ function convertShapeToPolygon(choice, imageWidth, imageHeight, diagnostics, sou
|
|
|
24801
24977
|
/**
|
|
24802
24978
|
* Build the combined stimulus HTML from parsed stimulusText and promptText
|
|
24803
24979
|
*/
|
|
24804
|
-
function buildHotspotStimulus(parsed, organisationId, mediaVault, customAssetUrl) {
|
|
24980
|
+
function buildHotspotStimulus(parsed, organisationId, mediaVault, customAssetUrl, assetTransformContext) {
|
|
24805
24981
|
let stimulus = "";
|
|
24806
24982
|
if (parsed.stimulusText) stimulus += transformAssetUrls(parsed.stimulusText, {
|
|
24807
24983
|
organisationId,
|
|
24808
24984
|
mediaVault,
|
|
24809
|
-
customAssetUrl
|
|
24985
|
+
customAssetUrl,
|
|
24986
|
+
...assetTransformContext
|
|
24810
24987
|
});
|
|
24811
24988
|
if (parsed.promptText) stimulus += `<p>${transformAssetUrls(parsed.promptText, {
|
|
24812
24989
|
organisationId,
|
|
24813
24990
|
mediaVault,
|
|
24814
|
-
customAssetUrl
|
|
24991
|
+
customAssetUrl,
|
|
24992
|
+
...assetTransformContext
|
|
24815
24993
|
})}</p>`;
|
|
24816
24994
|
return stimulus;
|
|
24817
24995
|
}
|
|
@@ -24836,7 +25014,7 @@ function buildHotspotValidation(correctResponses, choiceIdToIndex) {
|
|
|
24836
25014
|
/**
|
|
24837
25015
|
* Convert hotspotInteraction to Learnosity hotspot
|
|
24838
25016
|
*/
|
|
24839
|
-
function convertHotspotToLearnosity(inputXml, diagnostics, lomTags, organisationId, sourceFile, mediaVault, customAssetUrl, itemReferenceSource, fileAccess, packageRoot) {
|
|
25017
|
+
function convertHotspotToLearnosity(inputXml, diagnostics, lomTags, organisationId, sourceFile, mediaVault, customAssetUrl, itemReferenceSource, fileAccess, packageRoot, assetTransformContext) {
|
|
24840
25018
|
const parsed = readAssessmentItemHotspot(inputXml);
|
|
24841
25019
|
const updatedDiagnostics = addFileContextIfProvided(parsed.diagnostics, sourceFile);
|
|
24842
25020
|
diagnostics.push(...updatedDiagnostics);
|
|
@@ -24858,10 +25036,15 @@ function convertHotspotToLearnosity(inputXml, diagnostics, lomTags, organisation
|
|
|
24858
25036
|
return { diagnostics };
|
|
24859
25037
|
}
|
|
24860
25038
|
}
|
|
24861
|
-
const itemRef = generateItemReference(parsed.identifier, itemReferenceSource, sourceFile);
|
|
25039
|
+
const itemRef = assetTransformContext?.finalItemReference ?? generateItemReference(parsed.identifier, itemReferenceSource, sourceFile);
|
|
25040
|
+
const transformContext = {
|
|
25041
|
+
finalItemReference: itemRef,
|
|
25042
|
+
preserveAssetFilenames: assetTransformContext?.preserveAssetFilenames ?? false,
|
|
25043
|
+
sourceHrefBase: assetTransformContext?.sourceHrefBase
|
|
25044
|
+
};
|
|
24862
25045
|
const questionRef = md5hex(itemRef);
|
|
24863
|
-
const stimulus = buildHotspotStimulus(parsed, organisationId, mediaVault, customAssetUrl);
|
|
24864
|
-
const imageSource = organisationId ? transformUrl(parsed.imageSource, organisationId, mediaVault, customAssetUrl) : parsed.imageSource;
|
|
25046
|
+
const stimulus = buildHotspotStimulus(parsed, organisationId, mediaVault, customAssetUrl, transformContext);
|
|
25047
|
+
const imageSource = organisationId ? transformUrl(parsed.imageSource, organisationId, mediaVault, customAssetUrl, transformContext) : parsed.imageSource;
|
|
24865
25048
|
const areas = [];
|
|
24866
25049
|
const choiceIdToIndex = /* @__PURE__ */ new Map();
|
|
24867
25050
|
for (const choice of parsed.hotspotChoices) {
|
|
@@ -25144,14 +25327,19 @@ function readAssessmentItemHottext(inputXml) {
|
|
|
25144
25327
|
/**
|
|
25145
25328
|
* Convert hottextInteraction to Learnosity tokenhighlight
|
|
25146
25329
|
*/
|
|
25147
|
-
function convertHottextToLearnosity(inputXml, diagnostics, lomTags, organisationId, sourceFile, mediaVault, customAssetUrl, itemReferenceSource) {
|
|
25330
|
+
function convertHottextToLearnosity(inputXml, diagnostics, lomTags, organisationId, sourceFile, mediaVault, customAssetUrl, itemReferenceSource, _stimulusOverride, assetTransformContext) {
|
|
25148
25331
|
const parsed = readAssessmentItemHottext(inputXml);
|
|
25149
25332
|
const updatedDiagnostics = addFileContextIfProvided(parsed.diagnostics, sourceFile);
|
|
25150
25333
|
diagnostics.push(...updatedDiagnostics);
|
|
25151
25334
|
if (hasErrors(diagnostics)) return { diagnostics };
|
|
25152
25335
|
if (!parsed.identifier || !parsed.responseIdentifier || !parsed.templateHtml) return { diagnostics };
|
|
25153
25336
|
if (parsed.hottextElements.length === 0) return { diagnostics };
|
|
25154
|
-
const itemRef = generateItemReference(parsed.identifier, itemReferenceSource, sourceFile);
|
|
25337
|
+
const itemRef = assetTransformContext?.finalItemReference ?? generateItemReference(parsed.identifier, itemReferenceSource, sourceFile);
|
|
25338
|
+
const transformContext = {
|
|
25339
|
+
finalItemReference: itemRef,
|
|
25340
|
+
preserveAssetFilenames: assetTransformContext?.preserveAssetFilenames ?? false,
|
|
25341
|
+
sourceHrefBase: assetTransformContext?.sourceHrefBase
|
|
25342
|
+
};
|
|
25155
25343
|
const questionRef = md5hex(itemRef);
|
|
25156
25344
|
if (parsed.shuffle) diagnostics.push({
|
|
25157
25345
|
code: DiagnosticCode.QTI_SHUFFLE_NOT_SUPPORTED,
|
|
@@ -25163,7 +25351,8 @@ function convertHottextToLearnosity(inputXml, diagnostics, lomTags, organisation
|
|
|
25163
25351
|
if (stimulus) stimulus = transformAssetUrls(stimulus, {
|
|
25164
25352
|
organisationId,
|
|
25165
25353
|
mediaVault,
|
|
25166
|
-
customAssetUrl
|
|
25354
|
+
customAssetUrl,
|
|
25355
|
+
...transformContext
|
|
25167
25356
|
});
|
|
25168
25357
|
let template = parsed.templateHtml || "";
|
|
25169
25358
|
const identifierToIndex = /* @__PURE__ */ new Map();
|
|
@@ -25176,7 +25365,8 @@ function convertHottextToLearnosity(inputXml, diagnostics, lomTags, organisation
|
|
|
25176
25365
|
template = transformAssetUrls(template, {
|
|
25177
25366
|
organisationId,
|
|
25178
25367
|
mediaVault,
|
|
25179
|
-
customAssetUrl
|
|
25368
|
+
customAssetUrl,
|
|
25369
|
+
...transformContext
|
|
25180
25370
|
});
|
|
25181
25371
|
let validation = void 0;
|
|
25182
25372
|
if (parsed.correctResponses && parsed.correctResponses.length > 0) {
|
|
@@ -25643,7 +25833,7 @@ function readAssessmentItemMcq(inputXml, stimulusOverride) {
|
|
|
25643
25833
|
* Supports both single and composite (multiple) choiceInteractions
|
|
25644
25834
|
* TASK 036: Added stimulusOverride parameter for composite items
|
|
25645
25835
|
*/
|
|
25646
|
-
function convertMcqToLearnosity(inputXml, diagnostics, lomTags, sourceFile, organisationId, mediaVault, customAssetUrl, itemReferenceSource, stimulusOverride) {
|
|
25836
|
+
function convertMcqToLearnosity(inputXml, diagnostics, lomTags, sourceFile, organisationId, mediaVault, customAssetUrl, itemReferenceSource, stimulusOverride, assetTransformContext) {
|
|
25647
25837
|
const parsed = readAssessmentItemMcq(inputXml, stimulusOverride);
|
|
25648
25838
|
const contextualDiagnostics = sourceFile ? parsed.diagnostics.map((d) => ({
|
|
25649
25839
|
...d,
|
|
@@ -25652,7 +25842,12 @@ function convertMcqToLearnosity(inputXml, diagnostics, lomTags, sourceFile, orga
|
|
|
25652
25842
|
diagnostics.push(...contextualDiagnostics);
|
|
25653
25843
|
if (diagnostics.some((d) => d.level === "error")) return { diagnostics };
|
|
25654
25844
|
if (!parsed.identifier || parsed.interactions.length === 0) return { diagnostics };
|
|
25655
|
-
const itemRef = generateItemReference(parsed.identifier, itemReferenceSource, sourceFile);
|
|
25845
|
+
const itemRef = assetTransformContext?.finalItemReference ?? generateItemReference(parsed.identifier, itemReferenceSource, sourceFile);
|
|
25846
|
+
const transformContext = {
|
|
25847
|
+
finalItemReference: itemRef,
|
|
25848
|
+
preserveAssetFilenames: assetTransformContext?.preserveAssetFilenames ?? false,
|
|
25849
|
+
sourceHrefBase: assetTransformContext?.sourceHrefBase
|
|
25850
|
+
};
|
|
25656
25851
|
const isComposite = parsed.interactions.length > 1;
|
|
25657
25852
|
const questions = [];
|
|
25658
25853
|
const widgets = [];
|
|
@@ -25662,7 +25857,8 @@ function convertMcqToLearnosity(inputXml, diagnostics, lomTags, sourceFile, orga
|
|
|
25662
25857
|
const stimulus = interaction.stimulusText ? transformAssetUrls(interaction.stimulusText, {
|
|
25663
25858
|
organisationId,
|
|
25664
25859
|
mediaVault,
|
|
25665
|
-
customAssetUrl
|
|
25860
|
+
customAssetUrl,
|
|
25861
|
+
...transformContext
|
|
25666
25862
|
}) : void 0;
|
|
25667
25863
|
const choiceMapping = /* @__PURE__ */ new Map();
|
|
25668
25864
|
const options = interaction.choices.map((choice) => {
|
|
@@ -25671,7 +25867,8 @@ function convertMcqToLearnosity(inputXml, diagnostics, lomTags, sourceFile, orga
|
|
|
25671
25867
|
label: transformAssetUrls(choice.text, {
|
|
25672
25868
|
organisationId,
|
|
25673
25869
|
mediaVault,
|
|
25674
|
-
customAssetUrl
|
|
25870
|
+
customAssetUrl,
|
|
25871
|
+
...transformContext
|
|
25675
25872
|
}),
|
|
25676
25873
|
value: choice.identifier
|
|
25677
25874
|
};
|
|
@@ -25708,7 +25905,8 @@ function convertMcqToLearnosity(inputXml, diagnostics, lomTags, sourceFile, orga
|
|
|
25708
25905
|
const instructorStimulus = parsed.instructorStimulus ? transformAssetUrls(parsed.instructorStimulus, {
|
|
25709
25906
|
organisationId,
|
|
25710
25907
|
mediaVault,
|
|
25711
|
-
customAssetUrl
|
|
25908
|
+
customAssetUrl,
|
|
25909
|
+
...transformContext
|
|
25712
25910
|
}) : void 0;
|
|
25713
25911
|
questions.push({
|
|
25714
25912
|
reference: questionRef,
|
|
@@ -26076,7 +26274,7 @@ function stripWrapperDiv(html) {
|
|
|
26076
26274
|
* Convert textEntry (textEntryInteraction) to Learnosity clozetext or shorttext
|
|
26077
26275
|
* TASK 036: Added stimulusOverride parameter for composite items
|
|
26078
26276
|
*/
|
|
26079
|
-
function convertTextEntryToLearnosity(inputXml, diagnostics, lomTags, sourceFile, organisationId, mediaVault, customAssetUrl, itemReferenceSource, stimulusOverride) {
|
|
26277
|
+
function convertTextEntryToLearnosity(inputXml, diagnostics, lomTags, sourceFile, organisationId, mediaVault, customAssetUrl, itemReferenceSource, stimulusOverride, assetTransformContext) {
|
|
26080
26278
|
const parsed = readAssessmentItemTextEntry(inputXml, stimulusOverride);
|
|
26081
26279
|
const contextualDiagnostics = sourceFile ? parsed.diagnostics.map((d) => ({
|
|
26082
26280
|
...d,
|
|
@@ -26086,24 +26284,31 @@ function convertTextEntryToLearnosity(inputXml, diagnostics, lomTags, sourceFile
|
|
|
26086
26284
|
if (diagnostics.some((d) => d.level === "error")) return { diagnostics };
|
|
26087
26285
|
if (!parsed.identifier || parsed.textEntries.length === 0) return { diagnostics };
|
|
26088
26286
|
if (typeof parsed.templateText === "string") parsed.templateText = stripWrapperDiv(parsed.templateText);
|
|
26089
|
-
if (parsed.textEntries.length === 1 && /{{response}}(?:\s*<\/[^>]+>)*\s*$/.test(parsed.templateText.trim())) return convertShorttextToLearnosity(parsed, diagnostics, lomTags, organisationId, mediaVault, customAssetUrl, itemReferenceSource, sourceFile);
|
|
26090
|
-
else return convertClozetextToLearnosity(parsed, diagnostics, lomTags, organisationId, mediaVault, customAssetUrl, itemReferenceSource, sourceFile);
|
|
26287
|
+
if (parsed.textEntries.length === 1 && /{{response}}(?:\s*<\/[^>]+>)*\s*$/.test(parsed.templateText.trim())) return convertShorttextToLearnosity(parsed, diagnostics, lomTags, organisationId, mediaVault, customAssetUrl, itemReferenceSource, sourceFile, assetTransformContext);
|
|
26288
|
+
else return convertClozetextToLearnosity(parsed, diagnostics, lomTags, organisationId, mediaVault, customAssetUrl, itemReferenceSource, sourceFile, assetTransformContext);
|
|
26091
26289
|
}
|
|
26092
26290
|
/**
|
|
26093
26291
|
* Convert single textEntry to Learnosity shorttext
|
|
26094
26292
|
*/
|
|
26095
|
-
function convertShorttextToLearnosity(parsed, diagnostics, lomTags, organisationId, mediaVault, customAssetUrl, itemReferenceSource, sourceFile) {
|
|
26096
|
-
const itemRef = generateItemReference(parsed.identifier, itemReferenceSource, sourceFile);
|
|
26293
|
+
function convertShorttextToLearnosity(parsed, diagnostics, lomTags, organisationId, mediaVault, customAssetUrl, itemReferenceSource, sourceFile, assetTransformContext) {
|
|
26294
|
+
const itemRef = assetTransformContext?.finalItemReference ?? generateItemReference(parsed.identifier, itemReferenceSource, sourceFile);
|
|
26295
|
+
const transformContext = {
|
|
26296
|
+
finalItemReference: itemRef,
|
|
26297
|
+
preserveAssetFilenames: assetTransformContext?.preserveAssetFilenames ?? false,
|
|
26298
|
+
sourceHrefBase: assetTransformContext?.sourceHrefBase
|
|
26299
|
+
};
|
|
26097
26300
|
const questionRef = md5hex(parsed.responseIdentifier ?? parsed.identifier);
|
|
26098
26301
|
const stimulus = normalizeFinalText(transformAssetUrls((parsed.templateText || "").replace(/{{response}}(?:\s*<\/[^>]+>)*\s*$/, "").trim(), {
|
|
26099
26302
|
organisationId,
|
|
26100
26303
|
mediaVault,
|
|
26101
|
-
customAssetUrl
|
|
26304
|
+
customAssetUrl,
|
|
26305
|
+
...transformContext
|
|
26102
26306
|
}));
|
|
26103
26307
|
const instructorStimulus = parsed.instructorStimulus ? transformAssetUrls(parsed.instructorStimulus, {
|
|
26104
26308
|
organisationId,
|
|
26105
26309
|
mediaVault,
|
|
26106
|
-
customAssetUrl
|
|
26310
|
+
customAssetUrl,
|
|
26311
|
+
...transformContext
|
|
26107
26312
|
}) : void 0;
|
|
26108
26313
|
const entry = parsed.textEntries[0];
|
|
26109
26314
|
const correctResponses = entry.correctResponses || (entry.correctResponse ? [entry.correctResponse] : []);
|
|
@@ -26177,25 +26382,33 @@ function convertShorttextToLearnosity(parsed, diagnostics, lomTags, organisation
|
|
|
26177
26382
|
/**
|
|
26178
26383
|
* Convert textEntry with template to Learnosity clozetext
|
|
26179
26384
|
*/
|
|
26180
|
-
function convertClozetextToLearnosity(parsed, diagnostics, lomTags, organisationId, mediaVault, customAssetUrl, itemReferenceSource, sourceFile) {
|
|
26385
|
+
function convertClozetextToLearnosity(parsed, diagnostics, lomTags, organisationId, mediaVault, customAssetUrl, itemReferenceSource, sourceFile, assetTransformContext) {
|
|
26181
26386
|
const correctResponses = [];
|
|
26182
26387
|
for (const entry of parsed.textEntries) if (entry.correctResponse) correctResponses.push(entry.correctResponse);
|
|
26183
|
-
const itemRef = generateItemReference(parsed.identifier, itemReferenceSource, sourceFile);
|
|
26388
|
+
const itemRef = assetTransformContext?.finalItemReference ?? generateItemReference(parsed.identifier, itemReferenceSource, sourceFile);
|
|
26389
|
+
const transformContext = {
|
|
26390
|
+
finalItemReference: itemRef,
|
|
26391
|
+
preserveAssetFilenames: assetTransformContext?.preserveAssetFilenames ?? false,
|
|
26392
|
+
sourceHrefBase: assetTransformContext?.sourceHrefBase
|
|
26393
|
+
};
|
|
26184
26394
|
const questionRef = md5hex(parsed.responseIdentifier ?? parsed.identifier);
|
|
26185
26395
|
const stimulus = parsed.stimulusText ? normalizeFinalText(transformAssetUrls(parsed.stimulusText, {
|
|
26186
26396
|
organisationId,
|
|
26187
26397
|
mediaVault,
|
|
26188
|
-
customAssetUrl
|
|
26398
|
+
customAssetUrl,
|
|
26399
|
+
...transformContext
|
|
26189
26400
|
})) : void 0;
|
|
26190
26401
|
const template = normalizeFinalText(transformAssetUrls(parsed.templateText, {
|
|
26191
26402
|
organisationId,
|
|
26192
26403
|
mediaVault,
|
|
26193
|
-
customAssetUrl
|
|
26404
|
+
customAssetUrl,
|
|
26405
|
+
...transformContext
|
|
26194
26406
|
}));
|
|
26195
26407
|
const instructorStimulus = parsed.instructorStimulus ? transformAssetUrls(parsed.instructorStimulus, {
|
|
26196
26408
|
organisationId,
|
|
26197
26409
|
mediaVault,
|
|
26198
|
-
customAssetUrl
|
|
26410
|
+
customAssetUrl,
|
|
26411
|
+
...transformContext
|
|
26199
26412
|
}) : void 0;
|
|
26200
26413
|
const validation = {
|
|
26201
26414
|
scoring_type: "exactMatch",
|
|
@@ -26428,8 +26641,13 @@ function readAssessmentItemExtendedText(inputXml) {
|
|
|
26428
26641
|
/**
|
|
26429
26642
|
* Build multi-interaction extended text item (multiple longtextV2 questions)
|
|
26430
26643
|
*/
|
|
26431
|
-
function buildMultiExtendedTextItem(parsed, inputXml, stimulusOverride, diagnostics, lomTags, organisationId, mediaVault, customAssetUrl, itemReferenceSource, sourceFile) {
|
|
26432
|
-
const itemRef = generateItemReference(parsed.identifier ?? "unknown", itemReferenceSource, sourceFile);
|
|
26644
|
+
function buildMultiExtendedTextItem(parsed, inputXml, stimulusOverride, diagnostics, lomTags, organisationId, mediaVault, customAssetUrl, itemReferenceSource, sourceFile, assetTransformContext) {
|
|
26645
|
+
const itemRef = assetTransformContext?.finalItemReference ?? generateItemReference(parsed.identifier ?? "unknown", itemReferenceSource, sourceFile);
|
|
26646
|
+
const transformContext = {
|
|
26647
|
+
finalItemReference: itemRef,
|
|
26648
|
+
preserveAssetFilenames: assetTransformContext?.preserveAssetFilenames ?? false,
|
|
26649
|
+
sourceHrefBase: assetTransformContext?.sourceHrefBase
|
|
26650
|
+
};
|
|
26433
26651
|
const questions = [];
|
|
26434
26652
|
const widgets = [];
|
|
26435
26653
|
const questionSpans = [];
|
|
@@ -26439,7 +26657,8 @@ function buildMultiExtendedTextItem(parsed, inputXml, stimulusOverride, diagnost
|
|
|
26439
26657
|
const stimulus = transformAssetUrls(stimulusOverride[i], {
|
|
26440
26658
|
organisationId,
|
|
26441
26659
|
mediaVault,
|
|
26442
|
-
customAssetUrl
|
|
26660
|
+
customAssetUrl,
|
|
26661
|
+
...transformContext
|
|
26443
26662
|
});
|
|
26444
26663
|
widgets.push({
|
|
26445
26664
|
reference: questionRef,
|
|
@@ -26489,19 +26708,25 @@ function extractResponseIdentifiers(inputXml, interactionTag) {
|
|
|
26489
26708
|
* Convert extended text (extendedTextInteraction) to Learnosity longtextV2
|
|
26490
26709
|
* TASK 036: Added stimulusOverride parameter for composite items
|
|
26491
26710
|
*/
|
|
26492
|
-
function convertExtendedTextToLearnosity(inputXml, diagnostics, lomTags, sourceFile, organisationId, mediaVault, customAssetUrl, itemReferenceSource, stimulusOverride) {
|
|
26711
|
+
function convertExtendedTextToLearnosity(inputXml, diagnostics, lomTags, sourceFile, organisationId, mediaVault, customAssetUrl, itemReferenceSource, stimulusOverride, assetTransformContext) {
|
|
26493
26712
|
const parsed = readAssessmentItemExtendedText(inputXml);
|
|
26494
26713
|
const contextualDiagnostics = addFileContextIfProvided(stimulusOverride ? filterOutCodes(parsed.diagnostics, [DiagnosticCode.QTI_EXTENDED_TEXT_MULTIPLE_INTERACTIONS]) : parsed.diagnostics, sourceFile);
|
|
26495
26714
|
diagnostics.push(...contextualDiagnostics);
|
|
26496
26715
|
if (hasErrors(diagnostics)) return { diagnostics };
|
|
26497
|
-
if (stimulusOverride && stimulusOverride.length > 1) return buildMultiExtendedTextItem(parsed, inputXml, stimulusOverride, diagnostics, lomTags, organisationId, mediaVault, customAssetUrl, itemReferenceSource, sourceFile);
|
|
26498
|
-
const itemRef = generateItemReference(parsed.identifier ?? "unknown", itemReferenceSource, sourceFile);
|
|
26716
|
+
if (stimulusOverride && stimulusOverride.length > 1) return buildMultiExtendedTextItem(parsed, inputXml, stimulusOverride, diagnostics, lomTags, organisationId, mediaVault, customAssetUrl, itemReferenceSource, sourceFile, assetTransformContext);
|
|
26717
|
+
const itemRef = assetTransformContext?.finalItemReference ?? generateItemReference(parsed.identifier ?? "unknown", itemReferenceSource, sourceFile);
|
|
26718
|
+
const transformContext = {
|
|
26719
|
+
finalItemReference: itemRef,
|
|
26720
|
+
preserveAssetFilenames: assetTransformContext?.preserveAssetFilenames ?? false,
|
|
26721
|
+
sourceHrefBase: assetTransformContext?.sourceHrefBase
|
|
26722
|
+
};
|
|
26499
26723
|
const questionRef = md5hex(parsed.responseIdentifier ?? parsed.identifier ?? "unknown");
|
|
26500
26724
|
const stimulusRaw = stimulusOverride && stimulusOverride.length === 1 ? stimulusOverride[0] : parsed.stimulusText;
|
|
26501
26725
|
const stimulus = stimulusRaw ? transformAssetUrls(stimulusRaw, {
|
|
26502
26726
|
organisationId,
|
|
26503
26727
|
mediaVault,
|
|
26504
|
-
customAssetUrl
|
|
26728
|
+
customAssetUrl,
|
|
26729
|
+
...transformContext
|
|
26505
26730
|
}) : void 0;
|
|
26506
26731
|
const instructorStimulus = parsed.instructorStimulus ? transformAssetUrls(parsed.instructorStimulus, {
|
|
26507
26732
|
organisationId,
|
|
@@ -26796,7 +27021,7 @@ function buildValidationValue$1(hotspots, correctPairs, gapImgIdToResponse) {
|
|
|
26796
27021
|
/**
|
|
26797
27022
|
* Convert QTI graphicGapMatchInteraction to Learnosity imageclozeassociationV2
|
|
26798
27023
|
*/
|
|
26799
|
-
function convertGraphicGapMatchToLearnosity(inputXml, diagnostics, _lomTags, organisationId, sourceFile, mediaVault, customAssetUrl, itemReferenceSource) {
|
|
27024
|
+
function convertGraphicGapMatchToLearnosity(inputXml, diagnostics, _lomTags, organisationId, sourceFile, mediaVault, customAssetUrl, itemReferenceSource, _stimulusOverride, assetTransformContext) {
|
|
26800
27025
|
const parsed = readAssessmentItemGraphicGapMatch(inputXml);
|
|
26801
27026
|
const contextualDiagnostics = addFileContextIfProvided(parsed.diagnostics, sourceFile);
|
|
26802
27027
|
diagnostics.push(...contextualDiagnostics);
|
|
@@ -26812,6 +27037,12 @@ function convertGraphicGapMatchToLearnosity(inputXml, diagnostics, _lomTags, org
|
|
|
26812
27037
|
}
|
|
26813
27038
|
const bgWidth = parsed.backgroundImage.width;
|
|
26814
27039
|
const bgHeight = parsed.backgroundImage.height;
|
|
27040
|
+
const itemRef = assetTransformContext?.finalItemReference ?? generateItemReference(parsed.identifier ?? "item", itemReferenceSource, sourceFile);
|
|
27041
|
+
const transformContext = {
|
|
27042
|
+
finalItemReference: itemRef,
|
|
27043
|
+
preserveAssetFilenames: assetTransformContext?.preserveAssetFilenames ?? false,
|
|
27044
|
+
sourceHrefBase: assetTransformContext?.sourceHrefBase
|
|
27045
|
+
};
|
|
26815
27046
|
const gapImgIdToResponse = /* @__PURE__ */ new Map();
|
|
26816
27047
|
const possible_responses = parsed.gapImages.map((g) => {
|
|
26817
27048
|
if (g.text !== void 0) {
|
|
@@ -26830,7 +27061,8 @@ function convertGraphicGapMatchToLearnosity(inputXml, diagnostics, _lomTags, org
|
|
|
26830
27061
|
const transformedImgTag = transformAssetUrls(imgTag, {
|
|
26831
27062
|
organisationId,
|
|
26832
27063
|
mediaVault,
|
|
26833
|
-
customAssetUrl
|
|
27064
|
+
customAssetUrl,
|
|
27065
|
+
...transformContext
|
|
26834
27066
|
});
|
|
26835
27067
|
gapImgIdToResponse.set(g.identifier, transformedImgTag);
|
|
26836
27068
|
return transformedImgTag;
|
|
@@ -26868,7 +27100,7 @@ function convertGraphicGapMatchToLearnosity(inputXml, diagnostics, _lomTags, org
|
|
|
26868
27100
|
const question = {
|
|
26869
27101
|
type: "imageclozeassociationV2",
|
|
26870
27102
|
image: {
|
|
26871
|
-
src: organisationId ? transformUrl(parsed.backgroundImage.src, organisationId, mediaVault, customAssetUrl) : parsed.backgroundImage.src,
|
|
27103
|
+
src: organisationId ? transformUrl(parsed.backgroundImage.src, organisationId, mediaVault, customAssetUrl, transformContext) : parsed.backgroundImage.src,
|
|
26872
27104
|
width: bgWidth,
|
|
26873
27105
|
height: bgHeight
|
|
26874
27106
|
},
|
|
@@ -26892,11 +27124,12 @@ function convertGraphicGapMatchToLearnosity(inputXml, diagnostics, _lomTags, org
|
|
|
26892
27124
|
if (parsed.stimulus) question.stimulus = transformAssetUrls(parsed.stimulus, {
|
|
26893
27125
|
organisationId,
|
|
26894
27126
|
mediaVault,
|
|
26895
|
-
customAssetUrl
|
|
27127
|
+
customAssetUrl,
|
|
27128
|
+
...transformContext
|
|
26896
27129
|
});
|
|
26897
27130
|
const item = {
|
|
26898
27131
|
item: {
|
|
26899
|
-
reference:
|
|
27132
|
+
reference: itemRef,
|
|
26900
27133
|
title: parsed.title ?? void 0,
|
|
26901
27134
|
definition: { widgets: [{
|
|
26902
27135
|
reference: questionRef,
|
|
@@ -27186,35 +27419,38 @@ const readAssessmentItemDrawing = createAssessmentItemReader({
|
|
|
27186
27419
|
/**
|
|
27187
27420
|
* Build drawing stimulus from parsed QTI data
|
|
27188
27421
|
*/
|
|
27189
|
-
function buildDrawingStimulus(parsed, organisationId, mediaVault, customAssetUrl) {
|
|
27422
|
+
function buildDrawingStimulus(parsed, organisationId, mediaVault, customAssetUrl, assetTransformContext) {
|
|
27190
27423
|
if (!parsed.stimulusText && !parsed.promptText) return;
|
|
27191
27424
|
const stimulus = parsed.promptText || parsed.stimulusText || "";
|
|
27192
27425
|
try {
|
|
27193
27426
|
return transformAssetUrls(stimulus, {
|
|
27194
27427
|
organisationId,
|
|
27195
27428
|
mediaVault,
|
|
27196
|
-
customAssetUrl
|
|
27429
|
+
customAssetUrl,
|
|
27430
|
+
...assetTransformContext
|
|
27197
27431
|
});
|
|
27198
|
-
} catch {
|
|
27432
|
+
} catch (error) {
|
|
27433
|
+
if (isUnsafeQtiAssetHrefError(error)) throw error;
|
|
27199
27434
|
return stimulus;
|
|
27200
27435
|
}
|
|
27201
27436
|
}
|
|
27202
27437
|
/**
|
|
27203
27438
|
* Transform a single image source URL
|
|
27204
27439
|
*/
|
|
27205
|
-
function transformImageSource(imageSource, organisationId, mediaVault, customAssetUrl) {
|
|
27440
|
+
function transformImageSource(imageSource, organisationId, mediaVault, customAssetUrl, assetTransformContext) {
|
|
27206
27441
|
try {
|
|
27207
|
-
return organisationId ? transformUrl(imageSource, organisationId, mediaVault, customAssetUrl) : imageSource;
|
|
27208
|
-
} catch {
|
|
27442
|
+
return organisationId ? transformUrl(imageSource, organisationId, mediaVault, customAssetUrl, assetTransformContext) : imageSource;
|
|
27443
|
+
} catch (error) {
|
|
27444
|
+
if (isUnsafeQtiAssetHrefError(error)) throw error;
|
|
27209
27445
|
return imageSource;
|
|
27210
27446
|
}
|
|
27211
27447
|
}
|
|
27212
27448
|
/**
|
|
27213
27449
|
* Build drawing image data from parsed QTI data
|
|
27214
27450
|
*/
|
|
27215
|
-
function buildDrawingImage(parsed, organisationId, mediaVault, customAssetUrl) {
|
|
27451
|
+
function buildDrawingImage(parsed, organisationId, mediaVault, customAssetUrl, assetTransformContext) {
|
|
27216
27452
|
if (!parsed.imageSource) return;
|
|
27217
|
-
const image = { source: transformImageSource(parsed.imageSource, organisationId, mediaVault, customAssetUrl) };
|
|
27453
|
+
const image = { source: transformImageSource(parsed.imageSource, organisationId, mediaVault, customAssetUrl, assetTransformContext) };
|
|
27218
27454
|
if (parsed.imageWidth) image.width = parsed.imageWidth;
|
|
27219
27455
|
if (parsed.imageHeight) image.height = parsed.imageHeight;
|
|
27220
27456
|
if (parsed.imageAlt) image.alt = parsed.imageAlt;
|
|
@@ -27223,21 +27459,27 @@ function buildDrawingImage(parsed, organisationId, mediaVault, customAssetUrl) {
|
|
|
27223
27459
|
/**
|
|
27224
27460
|
* Convert QTI drawingInteraction to Learnosity drawing question
|
|
27225
27461
|
*/
|
|
27226
|
-
function convertDrawingToLearnosity(inputXml, diagnostics, lomTags, organisationId, sourceFile, mediaVault, customAssetUrl, itemReferenceSource) {
|
|
27462
|
+
function convertDrawingToLearnosity(inputXml, diagnostics, lomTags, organisationId, sourceFile, mediaVault, customAssetUrl, itemReferenceSource, _stimulusOverride, assetTransformContext) {
|
|
27227
27463
|
const parsed = readAssessmentItemDrawing(inputXml);
|
|
27228
27464
|
diagnostics.push(...parsed.diagnostics);
|
|
27229
27465
|
if (parsed.diagnostics.some((d) => d.level === "error")) return { diagnostics };
|
|
27230
|
-
const
|
|
27466
|
+
const generatedItemRef = generateItemReference(parsed.identifier ?? "item", itemReferenceSource, sourceFile);
|
|
27467
|
+
const itemRef = assetTransformContext?.finalItemReference ?? parsed.identifier ?? generatedItemRef;
|
|
27468
|
+
const transformContext = {
|
|
27469
|
+
finalItemReference: itemRef,
|
|
27470
|
+
preserveAssetFilenames: assetTransformContext?.preserveAssetFilenames ?? false,
|
|
27471
|
+
sourceHrefBase: assetTransformContext?.sourceHrefBase
|
|
27472
|
+
};
|
|
27231
27473
|
const questionRef = md5hex(itemRef + (parsed.responseIdentifier ?? "drawing"));
|
|
27232
27474
|
const questionData = { type: "drawing" };
|
|
27233
|
-
const stimulus = buildDrawingStimulus(parsed, organisationId, mediaVault, customAssetUrl);
|
|
27475
|
+
const stimulus = buildDrawingStimulus(parsed, organisationId, mediaVault, customAssetUrl, transformContext);
|
|
27234
27476
|
if (stimulus !== void 0) questionData.stimulus = stimulus;
|
|
27235
|
-
const image = buildDrawingImage(parsed, organisationId, mediaVault, customAssetUrl);
|
|
27477
|
+
const image = buildDrawingImage(parsed, organisationId, mediaVault, customAssetUrl, transformContext);
|
|
27236
27478
|
if (image) questionData.image = image;
|
|
27237
27479
|
const content = `<span class="learnosity-response question-${questionRef}"></span>`;
|
|
27238
27480
|
const item = {
|
|
27239
27481
|
item: {
|
|
27240
|
-
reference:
|
|
27482
|
+
reference: itemRef,
|
|
27241
27483
|
title: parsed.title ?? void 0,
|
|
27242
27484
|
content,
|
|
27243
27485
|
definition: { widgets: [{
|
|
@@ -27527,7 +27769,7 @@ function buildValidationValue(choices, correctPairs, diagnostics, sourceFile) {
|
|
|
27527
27769
|
* This reflects the undirected-pair nature of associateInteraction: no choice is
|
|
27528
27770
|
* inherently a "category" or a "draggable" — both sides of a pair are equivalent.
|
|
27529
27771
|
*/
|
|
27530
|
-
function convertAssociationToLearnosity(inputXml, diagnostics, lomTags, organisationId, sourceFile, mediaVault, customAssetUrl, itemReferenceSource) {
|
|
27772
|
+
function convertAssociationToLearnosity(inputXml, diagnostics, lomTags, organisationId, sourceFile, mediaVault, customAssetUrl, itemReferenceSource, _stimulusOverride, assetTransformContext) {
|
|
27531
27773
|
const parsed = readAssessmentItemAssociation(inputXml);
|
|
27532
27774
|
const updatedDiagnostics = addFileContextIfProvided(parsed.diagnostics, sourceFile);
|
|
27533
27775
|
diagnostics.push(...updatedDiagnostics);
|
|
@@ -27535,17 +27777,24 @@ function convertAssociationToLearnosity(inputXml, diagnostics, lomTags, organisa
|
|
|
27535
27777
|
if (!parsed.identifier || parsed.choices.length === 0) return { diagnostics };
|
|
27536
27778
|
const validationValue = buildValidationValue(parsed.choices, parsed.correctPairs, diagnostics, sourceFile);
|
|
27537
27779
|
if (hasErrors(diagnostics)) return { diagnostics };
|
|
27538
|
-
const itemRef = generateItemReference(parsed.identifier, itemReferenceSource, sourceFile);
|
|
27780
|
+
const itemRef = assetTransformContext?.finalItemReference ?? generateItemReference(parsed.identifier, itemReferenceSource, sourceFile);
|
|
27781
|
+
const transformContext = {
|
|
27782
|
+
finalItemReference: itemRef,
|
|
27783
|
+
preserveAssetFilenames: assetTransformContext?.preserveAssetFilenames ?? false,
|
|
27784
|
+
sourceHrefBase: assetTransformContext?.sourceHrefBase
|
|
27785
|
+
};
|
|
27539
27786
|
const questionRef = md5hex(itemRef);
|
|
27540
27787
|
const stimulus = transformAssetUrls(parsed.stimulusText ? `<p>${parsed.stimulusText}</p>` : "", {
|
|
27541
27788
|
organisationId,
|
|
27542
27789
|
mediaVault,
|
|
27543
|
-
customAssetUrl
|
|
27790
|
+
customAssetUrl,
|
|
27791
|
+
...transformContext
|
|
27544
27792
|
});
|
|
27545
27793
|
const possibleResponses = parsed.choices.map((c) => transformAssetUrls(c.text, {
|
|
27546
27794
|
organisationId,
|
|
27547
27795
|
mediaVault,
|
|
27548
|
-
customAssetUrl
|
|
27796
|
+
customAssetUrl,
|
|
27797
|
+
...transformContext
|
|
27549
27798
|
}));
|
|
27550
27799
|
const pairCount = validationValue.length > 0 ? validationValue.length : Math.round(parsed.maxAssociations ?? parsed.choices.length / 2);
|
|
27551
27800
|
const columnHeaders = Array.from({ length: pairCount }, (_, i) => `Pair ${i + 1}`);
|
|
@@ -27961,8 +28210,8 @@ function computeClosingTags(html) {
|
|
|
27961
28210
|
* Converters with different parameter orders are wrapped to normalize the signature.
|
|
27962
28211
|
*/
|
|
27963
28212
|
function getConverterMap() {
|
|
27964
|
-
const wrapSourceFirst = (fn) => (xml, diag, tags, orgId, sf, mv, cau, irs, stimuli) => fn(xml, diag, tags, sf, orgId, mv, cau, irs, stimuli);
|
|
27965
|
-
const hotspotConverter = (xml, diag, tags, orgId, sf, mv, cau, irs, _stimuli, fileAccess, packageRoot) => convertHotspotToLearnosity(xml, diag, tags, orgId, sf, mv, cau, irs, fileAccess, packageRoot);
|
|
28213
|
+
const wrapSourceFirst = (fn) => (xml, diag, tags, orgId, sf, mv, cau, irs, stimuli, assetTransformContext) => fn(xml, diag, tags, sf, orgId, mv, cau, irs, stimuli, assetTransformContext);
|
|
28214
|
+
const hotspotConverter = (xml, diag, tags, orgId, sf, mv, cau, irs, _stimuli, assetTransformContext, fileAccess, packageRoot) => convertHotspotToLearnosity(xml, diag, tags, orgId, sf, mv, cau, irs, fileAccess, packageRoot, assetTransformContext);
|
|
27966
28215
|
return {
|
|
27967
28216
|
choiceInteraction: wrapSourceFirst(convertMcqToLearnosity),
|
|
27968
28217
|
textEntryInteraction: wrapSourceFirst(convertTextEntryToLearnosity),
|
|
@@ -27985,8 +28234,14 @@ const CONVERTER_MAP = getConverterMap();
|
|
|
27985
28234
|
* Strategy: Call each individual converter for its interaction type,
|
|
27986
28235
|
* then combine all questions and widgets into a single composite item
|
|
27987
28236
|
*/
|
|
27988
|
-
function convertMixedInteractionsToLearnosity(inputXml, diagnostics, lomTags, organisationId, sourceFile, mediaVault, customAssetUrl, itemReferenceSource, fileAccess, packageRoot) {
|
|
28237
|
+
function convertMixedInteractionsToLearnosity(inputXml, diagnostics, lomTags, organisationId, sourceFile, mediaVault, customAssetUrl, itemReferenceSource, fileAccess, packageRoot, assetTransformContext) {
|
|
27989
28238
|
const metadata = extractItemMetadata(inputXml);
|
|
28239
|
+
const itemRef = assetTransformContext?.finalItemReference ?? generateItemReference(metadata.identifier ?? "mixed_item", itemReferenceSource, sourceFile);
|
|
28240
|
+
const transformContext = {
|
|
28241
|
+
finalItemReference: itemRef,
|
|
28242
|
+
preserveAssetFilenames: assetTransformContext?.preserveAssetFilenames ?? false,
|
|
28243
|
+
sourceHrefBase: assetTransformContext?.sourceHrefBase
|
|
28244
|
+
};
|
|
27990
28245
|
const { segments } = segmentItemBodyByInteractions(inputXml);
|
|
27991
28246
|
const stimuliByType = /* @__PURE__ */ new Map();
|
|
27992
28247
|
for (const segment of segments) {
|
|
@@ -28068,7 +28323,8 @@ function convertMixedInteractionsToLearnosity(inputXml, diagnostics, lomTags, or
|
|
|
28068
28323
|
const template = normalizeFinalText(transformAssetUrls(rawTemplate, {
|
|
28069
28324
|
organisationId,
|
|
28070
28325
|
mediaVault,
|
|
28071
|
-
customAssetUrl
|
|
28326
|
+
customAssetUrl,
|
|
28327
|
+
...transformContext
|
|
28072
28328
|
}));
|
|
28073
28329
|
if (groupEntries.length === 1 && /{{response}}(?:<\/[^>]+>|\s)*$/.test(rawTemplate.trim())) {
|
|
28074
28330
|
let stimulusRaw = rawTemplate.replace(/{{response}}(?:<\/[^>]+>|\s)*$/, "").trim();
|
|
@@ -28076,7 +28332,8 @@ function convertMixedInteractionsToLearnosity(inputXml, diagnostics, lomTags, or
|
|
|
28076
28332
|
const stimulus = normalizeFinalText(transformAssetUrls(stimulusRaw, {
|
|
28077
28333
|
organisationId,
|
|
28078
28334
|
mediaVault,
|
|
28079
|
-
customAssetUrl
|
|
28335
|
+
customAssetUrl,
|
|
28336
|
+
...transformContext
|
|
28080
28337
|
}));
|
|
28081
28338
|
const entry = groupEntries[0];
|
|
28082
28339
|
const allCorrectResponses = entry.correctResponses ?? (entry.correctResponse ? [entry.correctResponse] : []);
|
|
@@ -28202,7 +28459,7 @@ function convertMixedInteractionsToLearnosity(inputXml, diagnostics, lomTags, or
|
|
|
28202
28459
|
continue;
|
|
28203
28460
|
}
|
|
28204
28461
|
const converter = CONVERTER_MAP[group.type];
|
|
28205
|
-
if (converter) processResult(converter(inputXml, subDiagnostics, lomTags, organisationId, sourceFile, mediaVault, customAssetUrl, itemReferenceSource, group.stimuli, fileAccess, packageRoot), subDiagnostics);
|
|
28462
|
+
if (converter) processResult(converter(inputXml, subDiagnostics, lomTags, organisationId, sourceFile, mediaVault, customAssetUrl, itemReferenceSource, group.stimuli, transformContext, fileAccess, packageRoot), subDiagnostics);
|
|
28206
28463
|
}
|
|
28207
28464
|
if (allQuestions.length === 0) {
|
|
28208
28465
|
diagnostics.push({
|
|
@@ -28225,9 +28482,16 @@ function convertMixedInteractionsToLearnosity(inputXml, diagnostics, lomTags, or
|
|
|
28225
28482
|
passageContent = transformAssetUrls(rawContent, {
|
|
28226
28483
|
organisationId,
|
|
28227
28484
|
mediaVault,
|
|
28228
|
-
customAssetUrl
|
|
28485
|
+
customAssetUrl,
|
|
28486
|
+
...transformContext
|
|
28487
|
+
});
|
|
28488
|
+
} catch (error) {
|
|
28489
|
+
if (isUnsafeQtiAssetHrefError(error)) diagnostics.push({
|
|
28490
|
+
code: DiagnosticCode.QTI_ASSET_HREF_UNSAFE,
|
|
28491
|
+
level: "error",
|
|
28492
|
+
file: sourceFile ?? "passage",
|
|
28493
|
+
message: error.message
|
|
28229
28494
|
});
|
|
28230
|
-
} catch {
|
|
28231
28495
|
passageContent = rawContent;
|
|
28232
28496
|
}
|
|
28233
28497
|
allFeatures.push({
|
|
@@ -28259,7 +28523,7 @@ function convertMixedInteractionsToLearnosity(inputXml, diagnostics, lomTags, or
|
|
|
28259
28523
|
const content = `<div class="row"><div class="col-xs-12">${[...featureSpans, ...questionSpans].join("")}</div></div>`;
|
|
28260
28524
|
const item = {
|
|
28261
28525
|
item: {
|
|
28262
|
-
reference:
|
|
28526
|
+
reference: itemRef,
|
|
28263
28527
|
title: metadata.title ?? void 0,
|
|
28264
28528
|
content,
|
|
28265
28529
|
definition: { widgets: allWidgets },
|
|
@@ -28305,8 +28569,13 @@ function resolvePassageObjects(html, sourceFile, resolvePassageFile) {
|
|
|
28305
28569
|
/**
|
|
28306
28570
|
* Convert passage-only item to Learnosity format with sharedpassage feature
|
|
28307
28571
|
*/
|
|
28308
|
-
function convertPassageToLearnosity(parsed, diagnostics, lomTags, organisationId, sourceFile, mediaVault, customAssetUrl, itemReferenceSource, fileAccess) {
|
|
28309
|
-
const itemRef = generateItemReference(parsed.identifier, itemReferenceSource, sourceFile);
|
|
28572
|
+
function convertPassageToLearnosity(parsed, diagnostics, lomTags, organisationId, sourceFile, mediaVault, customAssetUrl, itemReferenceSource, fileAccess, assetTransformContext) {
|
|
28573
|
+
const itemRef = assetTransformContext?.finalItemReference ?? generateItemReference(parsed.identifier, itemReferenceSource, sourceFile);
|
|
28574
|
+
const transformContext = {
|
|
28575
|
+
finalItemReference: itemRef,
|
|
28576
|
+
preserveAssetFilenames: assetTransformContext?.preserveAssetFilenames ?? false,
|
|
28577
|
+
sourceHrefBase: assetTransformContext?.sourceHrefBase
|
|
28578
|
+
};
|
|
28310
28579
|
const featureRef = `passage-${md5hex(getPassageDataPath(parsed.content) ?? itemRef).substring(0, 8)}`;
|
|
28311
28580
|
const resolvedContent = resolvePassageObjects(parsed.content, sourceFile, fileAccess?.resolvePassageFile.bind(fileAccess));
|
|
28312
28581
|
let content;
|
|
@@ -28314,11 +28583,12 @@ function convertPassageToLearnosity(parsed, diagnostics, lomTags, organisationId
|
|
|
28314
28583
|
content = transformAssetUrls(resolvedContent, {
|
|
28315
28584
|
organisationId,
|
|
28316
28585
|
mediaVault,
|
|
28317
|
-
customAssetUrl
|
|
28586
|
+
customAssetUrl,
|
|
28587
|
+
...transformContext
|
|
28318
28588
|
});
|
|
28319
28589
|
} catch (error) {
|
|
28320
28590
|
diagnostics.push({
|
|
28321
|
-
code: DiagnosticCode.LRN_SCHEMA_INVALID,
|
|
28591
|
+
code: isUnsafeQtiAssetHrefError(error) ? DiagnosticCode.QTI_ASSET_HREF_UNSAFE : DiagnosticCode.LRN_SCHEMA_INVALID,
|
|
28322
28592
|
level: "error",
|
|
28323
28593
|
file: sourceFile ?? "assessmentItem",
|
|
28324
28594
|
message: error instanceof Error ? error.message : "Failed to transform asset URLs"
|
|
@@ -28708,20 +28978,28 @@ function readAssessmentItemUpload(inputXml) {
|
|
|
28708
28978
|
* and the file limit from `maxChoices` (see readAssessmentItemUpload / the
|
|
28709
28979
|
* serializer). fileupload questions are unscored, so there is no validation.
|
|
28710
28980
|
*/
|
|
28711
|
-
function convertUploadToLearnosity(inputXml, diagnostics, lomTags, organisationId, sourceFile, mediaVault, customAssetUrl, itemReferenceSource) {
|
|
28981
|
+
function convertUploadToLearnosity(inputXml, diagnostics, lomTags, organisationId, sourceFile, mediaVault, customAssetUrl, itemReferenceSource, _stimulusOverride, assetTransformContext) {
|
|
28712
28982
|
const parsed = readAssessmentItemUpload(inputXml);
|
|
28713
28983
|
diagnostics.push(...parsed.diagnostics);
|
|
28714
28984
|
if (parsed.diagnostics.some((d) => d.level === "error")) return { diagnostics };
|
|
28715
|
-
const
|
|
28985
|
+
const generatedItemRef = generateItemReference(parsed.identifier ?? "item", itemReferenceSource, sourceFile);
|
|
28986
|
+
const itemRef = assetTransformContext?.finalItemReference ?? parsed.identifier ?? generatedItemRef;
|
|
28987
|
+
const transformContext = {
|
|
28988
|
+
finalItemReference: itemRef,
|
|
28989
|
+
preserveAssetFilenames: assetTransformContext?.preserveAssetFilenames ?? false,
|
|
28990
|
+
sourceHrefBase: assetTransformContext?.sourceHrefBase
|
|
28991
|
+
};
|
|
28716
28992
|
const questionRef = md5hex(itemRef + (parsed.responseIdentifier ?? "fileupload"));
|
|
28717
28993
|
const questionData = { type: "fileupload" };
|
|
28718
28994
|
if (parsed.stimulus) try {
|
|
28719
28995
|
questionData.stimulus = transformAssetUrls(parsed.stimulus, {
|
|
28720
28996
|
organisationId,
|
|
28721
28997
|
mediaVault,
|
|
28722
|
-
customAssetUrl
|
|
28998
|
+
customAssetUrl,
|
|
28999
|
+
...transformContext
|
|
28723
29000
|
});
|
|
28724
|
-
} catch {
|
|
29001
|
+
} catch (error) {
|
|
29002
|
+
if (isUnsafeQtiAssetHrefError(error)) throw error;
|
|
28725
29003
|
questionData.stimulus = parsed.stimulus;
|
|
28726
29004
|
}
|
|
28727
29005
|
for (const suffix of parsed.allowedFileTypes) questionData[`allow_${suffix}`] = true;
|
|
@@ -28729,7 +29007,7 @@ function convertUploadToLearnosity(inputXml, diagnostics, lomTags, organisationI
|
|
|
28729
29007
|
const content = `<span class="learnosity-response question-${questionRef}"></span>`;
|
|
28730
29008
|
const item = {
|
|
28731
29009
|
item: {
|
|
28732
|
-
reference:
|
|
29010
|
+
reference: itemRef,
|
|
28733
29011
|
title: parsed.title ?? void 0,
|
|
28734
29012
|
content,
|
|
28735
29013
|
definition: { widgets: [{
|
|
@@ -28764,9 +29042,19 @@ function convertUploadToLearnosity(inputXml, diagnostics, lomTags, organisationI
|
|
|
28764
29042
|
* - Rejects DOCTYPE / ENTITY declarations up-front (DTD not allowed).
|
|
28765
29043
|
* - Uses streaming parsers for all interaction types.
|
|
28766
29044
|
*/
|
|
29045
|
+
function getAssetSourceHrefBase(opts) {
|
|
29046
|
+
if (opts.sourceHrefBase) return opts.sourceHrefBase;
|
|
29047
|
+
const source = opts.sourceFile ?? opts.inputPath;
|
|
29048
|
+
if (!source) return;
|
|
29049
|
+
const normalized = source.replaceAll("\\", "/");
|
|
29050
|
+
return normalized.startsWith("/") || /^[A-Za-z]:/.test(normalized) || /^[A-Za-z][A-Za-z\d+.-]*:/.test(normalized) ? normalized.slice(normalized.lastIndexOf("/") + 1) : normalized;
|
|
29051
|
+
}
|
|
28767
29052
|
/**
|
|
28768
29053
|
* Supported interaction type names for counting
|
|
28769
29054
|
*/
|
|
29055
|
+
function isUnsafeAssetHrefError(error) {
|
|
29056
|
+
return error instanceof Error && (error.message.startsWith("Unsafe QTI asset href:") || error.message.startsWith("QTI asset href has no filename:"));
|
|
29057
|
+
}
|
|
28770
29058
|
const INTERACTION_NAMES = [
|
|
28771
29059
|
"choiceInteraction",
|
|
28772
29060
|
"textEntryInteraction",
|
|
@@ -28832,19 +29120,71 @@ function countAllInteractions(xml) {
|
|
|
28832
29120
|
};
|
|
28833
29121
|
}
|
|
28834
29122
|
const SINGLE_INTERACTION_CONVERTERS = /* @__PURE__ */ new Map([
|
|
28835
|
-
["choiceInteraction", (xml, diag, lom, opts, stim) => convertMcqToLearnosity(xml, diag, lom, opts.sourceFile, opts.organisationId, opts.mediaVault, opts.customAssetUrl, opts.itemReferenceSource, stim
|
|
28836
|
-
|
|
28837
|
-
|
|
28838
|
-
|
|
28839
|
-
|
|
28840
|
-
["
|
|
28841
|
-
|
|
28842
|
-
|
|
28843
|
-
|
|
28844
|
-
|
|
28845
|
-
["
|
|
28846
|
-
|
|
28847
|
-
|
|
29123
|
+
["choiceInteraction", (xml, diag, lom, opts, stim) => convertMcqToLearnosity(xml, diag, lom, opts.sourceFile, opts.organisationId, opts.mediaVault, opts.customAssetUrl, opts.itemReferenceSource, stim, {
|
|
29124
|
+
finalItemReference: opts.finalItemReference,
|
|
29125
|
+
preserveAssetFilenames: opts.preserveAssetFilenames ?? false,
|
|
29126
|
+
sourceHrefBase: getAssetSourceHrefBase(opts)
|
|
29127
|
+
})],
|
|
29128
|
+
["textEntryInteraction", (xml, diag, lom, opts, stim) => convertTextEntryToLearnosity(xml, diag, lom, opts.sourceFile, opts.organisationId, opts.mediaVault, opts.customAssetUrl, opts.itemReferenceSource, stim, {
|
|
29129
|
+
finalItemReference: opts.finalItemReference,
|
|
29130
|
+
preserveAssetFilenames: opts.preserveAssetFilenames ?? false,
|
|
29131
|
+
sourceHrefBase: getAssetSourceHrefBase(opts)
|
|
29132
|
+
})],
|
|
29133
|
+
["extendedTextInteraction", (xml, diag, lom, opts, stim) => convertExtendedTextToLearnosity(xml, diag, lom, opts.sourceFile, opts.organisationId, opts.mediaVault, opts.customAssetUrl, opts.itemReferenceSource, stim, {
|
|
29134
|
+
finalItemReference: opts.finalItemReference,
|
|
29135
|
+
preserveAssetFilenames: opts.preserveAssetFilenames ?? false,
|
|
29136
|
+
sourceHrefBase: getAssetSourceHrefBase(opts)
|
|
29137
|
+
})],
|
|
29138
|
+
["inlineChoiceInteraction", (xml, diag, lom, opts) => convertInlineChoiceToLearnosity(xml, diag, lom, opts.organisationId, opts.sourceFile, opts.mediaVault, opts.customAssetUrl, opts.itemReferenceSource, void 0, {
|
|
29139
|
+
finalItemReference: opts.finalItemReference,
|
|
29140
|
+
preserveAssetFilenames: opts.preserveAssetFilenames ?? false,
|
|
29141
|
+
sourceHrefBase: getAssetSourceHrefBase(opts)
|
|
29142
|
+
})],
|
|
29143
|
+
["matchInteraction", (xml, diag, lom, opts) => convertMatchToLearnosity(xml, diag, lom, opts.organisationId, opts.sourceFile, opts.mediaVault, opts.customAssetUrl, opts.itemReferenceSource, void 0, {
|
|
29144
|
+
finalItemReference: opts.finalItemReference,
|
|
29145
|
+
preserveAssetFilenames: opts.preserveAssetFilenames ?? false,
|
|
29146
|
+
sourceHrefBase: getAssetSourceHrefBase(opts)
|
|
29147
|
+
})],
|
|
29148
|
+
["gapMatchInteraction", (xml, diag, lom, opts) => convertGapMatchToLearnosity(xml, diag, lom, opts.organisationId, opts.sourceFile, opts.mediaVault, opts.customAssetUrl, opts.itemReferenceSource, void 0, {
|
|
29149
|
+
finalItemReference: opts.finalItemReference,
|
|
29150
|
+
preserveAssetFilenames: opts.preserveAssetFilenames ?? false,
|
|
29151
|
+
sourceHrefBase: getAssetSourceHrefBase(opts)
|
|
29152
|
+
})],
|
|
29153
|
+
["orderInteraction", (xml, diag, lom, opts) => convertOrderToLearnosity(xml, diag, lom, opts.organisationId, opts.sourceFile, opts.mediaVault, opts.customAssetUrl, opts.itemReferenceSource, void 0, {
|
|
29154
|
+
finalItemReference: opts.finalItemReference,
|
|
29155
|
+
preserveAssetFilenames: opts.preserveAssetFilenames ?? false,
|
|
29156
|
+
sourceHrefBase: getAssetSourceHrefBase(opts)
|
|
29157
|
+
})],
|
|
29158
|
+
["hotspotInteraction", (xml, diag, lom, opts) => convertHotspotToLearnosity(xml, diag, lom, opts.organisationId, opts.sourceFile, opts.mediaVault, opts.customAssetUrl, opts.itemReferenceSource, opts.fileAccess, opts.packageRoot, {
|
|
29159
|
+
finalItemReference: opts.finalItemReference,
|
|
29160
|
+
preserveAssetFilenames: opts.preserveAssetFilenames ?? false,
|
|
29161
|
+
sourceHrefBase: getAssetSourceHrefBase(opts)
|
|
29162
|
+
})],
|
|
29163
|
+
["hottextInteraction", (xml, diag, lom, opts) => convertHottextToLearnosity(xml, diag, lom, opts.organisationId, opts.sourceFile, opts.mediaVault, opts.customAssetUrl, opts.itemReferenceSource, void 0, {
|
|
29164
|
+
finalItemReference: opts.finalItemReference,
|
|
29165
|
+
preserveAssetFilenames: opts.preserveAssetFilenames ?? false,
|
|
29166
|
+
sourceHrefBase: getAssetSourceHrefBase(opts)
|
|
29167
|
+
})],
|
|
29168
|
+
["graphicGapMatchInteraction", (xml, diag, lom, opts) => convertGraphicGapMatchToLearnosity(xml, diag, lom, opts.organisationId, opts.sourceFile, opts.mediaVault, opts.customAssetUrl, opts.itemReferenceSource, void 0, {
|
|
29169
|
+
finalItemReference: opts.finalItemReference,
|
|
29170
|
+
preserveAssetFilenames: opts.preserveAssetFilenames ?? false,
|
|
29171
|
+
sourceHrefBase: getAssetSourceHrefBase(opts)
|
|
29172
|
+
})],
|
|
29173
|
+
["drawingInteraction", (xml, diag, lom, opts) => convertDrawingToLearnosity(xml, diag, lom, opts.organisationId, opts.sourceFile, opts.mediaVault, opts.customAssetUrl, opts.itemReferenceSource, void 0, {
|
|
29174
|
+
finalItemReference: opts.finalItemReference,
|
|
29175
|
+
preserveAssetFilenames: opts.preserveAssetFilenames ?? false,
|
|
29176
|
+
sourceHrefBase: getAssetSourceHrefBase(opts)
|
|
29177
|
+
})],
|
|
29178
|
+
["associateInteraction", (xml, diag, lom, opts) => convertAssociationToLearnosity(xml, diag, lom, opts.organisationId, opts.sourceFile, opts.mediaVault, opts.customAssetUrl, opts.itemReferenceSource, void 0, {
|
|
29179
|
+
finalItemReference: opts.finalItemReference,
|
|
29180
|
+
preserveAssetFilenames: opts.preserveAssetFilenames ?? false,
|
|
29181
|
+
sourceHrefBase: getAssetSourceHrefBase(opts)
|
|
29182
|
+
})],
|
|
29183
|
+
["uploadInteraction", (xml, diag, lom, opts) => convertUploadToLearnosity(xml, diag, lom, opts.organisationId, opts.sourceFile, opts.mediaVault, opts.customAssetUrl, opts.itemReferenceSource, void 0, {
|
|
29184
|
+
finalItemReference: opts.finalItemReference,
|
|
29185
|
+
preserveAssetFilenames: opts.preserveAssetFilenames ?? false,
|
|
29186
|
+
sourceHrefBase: getAssetSourceHrefBase(opts)
|
|
29187
|
+
})]
|
|
28848
29188
|
]);
|
|
28849
29189
|
/**
|
|
28850
29190
|
* Dispatch to the appropriate single-interaction converter
|
|
@@ -28870,9 +29210,18 @@ function dispatchSingleInteractionConverter(interactionType, inputXml, count, di
|
|
|
28870
29210
|
passageContent = transformAssetUrls(rawContent, {
|
|
28871
29211
|
organisationId: opts.organisationId,
|
|
28872
29212
|
mediaVault: opts.mediaVault,
|
|
28873
|
-
customAssetUrl: opts.customAssetUrl
|
|
29213
|
+
customAssetUrl: opts.customAssetUrl,
|
|
29214
|
+
finalItemReference: opts.finalItemReference ?? result.item.item.reference,
|
|
29215
|
+
preserveAssetFilenames: opts.preserveAssetFilenames ?? false,
|
|
29216
|
+
sourceHrefBase: getAssetSourceHrefBase(opts)
|
|
29217
|
+
});
|
|
29218
|
+
} catch (error) {
|
|
29219
|
+
if (isUnsafeAssetHrefError(error)) diagnostics.push({
|
|
29220
|
+
code: DiagnosticCode.QTI_ASSET_HREF_UNSAFE,
|
|
29221
|
+
level: "error",
|
|
29222
|
+
file: opts.sourceFile ?? "passage",
|
|
29223
|
+
message: error.message
|
|
28874
29224
|
});
|
|
28875
|
-
} catch {
|
|
28876
29225
|
passageContent = rawContent;
|
|
28877
29226
|
}
|
|
28878
29227
|
result.item.features = [...result.item.features, {
|
|
@@ -28920,8 +29269,16 @@ function handleNoInteractions(inputXml, diagnostics, allInteractions, lomTags, o
|
|
|
28920
29269
|
}
|
|
28921
29270
|
const passageResult = readAssessmentItemPassage(inputXml);
|
|
28922
29271
|
diagnostics.push(...addFileContextIfProvided(passageResult.diagnostics, opts.sourceFile));
|
|
28923
|
-
if (passageResult.data) return convertPassageToLearnosity(passageResult.data, diagnostics, lomTags, opts.organisationId, opts.sourceFile, opts.mediaVault, opts.customAssetUrl, opts.itemReferenceSource, opts.fileAccess
|
|
28924
|
-
|
|
29272
|
+
if (passageResult.data) return convertPassageToLearnosity(passageResult.data, diagnostics, lomTags, opts.organisationId, opts.sourceFile, opts.mediaVault, opts.customAssetUrl, opts.itemReferenceSource, opts.fileAccess, {
|
|
29273
|
+
finalItemReference: opts.finalItemReference,
|
|
29274
|
+
preserveAssetFilenames: opts.preserveAssetFilenames ?? false,
|
|
29275
|
+
sourceHrefBase: getAssetSourceHrefBase(opts)
|
|
29276
|
+
});
|
|
29277
|
+
const mcqResult = convertMcqToLearnosity(inputXml, diagnostics, lomTags, opts.sourceFile, opts.organisationId, opts.mediaVault, opts.customAssetUrl, opts.itemReferenceSource, void 0, {
|
|
29278
|
+
finalItemReference: opts.finalItemReference,
|
|
29279
|
+
preserveAssetFilenames: opts.preserveAssetFilenames ?? false,
|
|
29280
|
+
sourceHrefBase: getAssetSourceHrefBase(opts)
|
|
29281
|
+
});
|
|
28925
29282
|
if (diagnostics.some((d) => d.code === DiagnosticCode.LRN_SCHEMA_INVALID)) return mcqResult;
|
|
28926
29283
|
return { diagnostics };
|
|
28927
29284
|
}
|
|
@@ -28967,14 +29324,18 @@ function convertQtiAssessmentItemToLearnosity(inputXml, opts = {}) {
|
|
|
28967
29324
|
const { counts, allInteractions } = countAllInteractions(inputXml);
|
|
28968
29325
|
const presentTypes = INTERACTION_NAMES.filter((name) => counts[name] > 0);
|
|
28969
29326
|
if (presentTypes.reduce((sum, name) => sum + counts[name], 0) === 0) return handleNoInteractions(inputXml, diagnostics, allInteractions, lomTags, opts);
|
|
28970
|
-
if (presentTypes.length > 1) return convertMixedInteractionsToLearnosity(inputXml, diagnostics, lomTags, opts.organisationId, opts.sourceFile, opts.mediaVault, opts.customAssetUrl, opts.itemReferenceSource, opts.fileAccess, opts.packageRoot
|
|
29327
|
+
if (presentTypes.length > 1) return convertMixedInteractionsToLearnosity(inputXml, diagnostics, lomTags, opts.organisationId, opts.sourceFile, opts.mediaVault, opts.customAssetUrl, opts.itemReferenceSource, opts.fileAccess, opts.packageRoot, {
|
|
29328
|
+
finalItemReference: opts.finalItemReference,
|
|
29329
|
+
preserveAssetFilenames: opts.preserveAssetFilenames ?? false,
|
|
29330
|
+
sourceHrefBase: getAssetSourceHrefBase(opts)
|
|
29331
|
+
});
|
|
28971
29332
|
return dispatchSingleInteractionConverter(presentTypes[0], inputXml, counts[presentTypes[0]], diagnostics, lomTags, opts);
|
|
28972
29333
|
} catch (error) {
|
|
28973
29334
|
diagnostics.push({
|
|
28974
|
-
code: DiagnosticCode.LRN_SCHEMA_INVALID,
|
|
29335
|
+
code: isUnsafeAssetHrefError(error) ? DiagnosticCode.QTI_ASSET_HREF_UNSAFE : DiagnosticCode.LRN_SCHEMA_INVALID,
|
|
28975
29336
|
level: "error",
|
|
28976
|
-
file: "root",
|
|
28977
|
-
message: `Failed to parse QTI XML: ${error instanceof Error ? error.message : "Unknown error"}`
|
|
29337
|
+
file: opts.sourceFile ?? "root",
|
|
29338
|
+
message: isUnsafeAssetHrefError(error) ? error.message : `Failed to parse QTI XML: ${error instanceof Error ? error.message : "Unknown error"}`
|
|
28978
29339
|
});
|
|
28979
29340
|
return { diagnostics };
|
|
28980
29341
|
}
|
|
@@ -31318,6 +31679,6 @@ function formatDiagnosticsSummaryTable(diagnostics) {
|
|
|
31318
31679
|
return table.toString();
|
|
31319
31680
|
}
|
|
31320
31681
|
//#endregion
|
|
31321
|
-
export { mapLearnosityToAst as _, require_cli_table3 as a,
|
|
31682
|
+
export { mapLearnosityToAst as C, DiagnosticCode as D, parseLearnosityItem as E, downgradeAssessmentTestToQti21 as S, sanitizeHtmlContent as T, md5hex as _, require_cli_table3 as a, serializeAssessmentItem as b, transformForwardAssetUrlsInXml as c, getAllPassageDataPaths as d, generateItemReference as f, serializeQtiAssetIdentity as g, selectQtiAssetFilename as h, chalk as i, convertQtiAssessmentItemToLearnosity as l, isSupportedQtiAssetPath as m, formatDiagnosticsSummaryTable as n, require_string_width as o, canonicalizeQtiAssetHref as p, formatDiagnosticsTable as r, writeDiagnostics as s, countErrors as t, parseMetadataTags as u, getAttr$3 as v, normalizeXhtmlVoidElements as w, escapeXml as x, require_saxes as y };
|
|
31322
31683
|
|
|
31323
|
-
//# sourceMappingURL=table-
|
|
31684
|
+
//# sourceMappingURL=table-D1ydwhbX.js.map
|