@learnosity/lib-qti-converter 0.12.8 → 0.13.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/GETTING_STARTED.md +71 -18
- package/docs/LEARNOSITY_BUNDLE_FORMAT.md +23 -7
- package/package.json +1 -1
- package/packages/cli/dist/{batchProcessors-CUJoQD8a.js → batchProcessors-DgiDpfpP.js} +270 -76
- package/packages/cli/dist/batchProcessors-DgiDpfpP.js.map +1 -0
- package/packages/cli/dist/batchWorker.js +1 -1
- package/packages/cli/dist/{learnosityToQti-CvfVQ6Kl.js → learnosityToQti-CIj5603P.js} +4 -4
- package/packages/cli/dist/{learnosityToQti-CvfVQ6Kl.js.map → learnosityToQti-CIj5603P.js.map} +1 -1
- package/packages/cli/dist/{learnosityToQtiPackage-CXMsJNQD.js → learnosityToQtiPackage-n6nGGr32.js} +4 -4
- package/packages/cli/dist/{learnosityToQtiPackage-CXMsJNQD.js.map → learnosityToQtiPackage-n6nGGr32.js.map} +1 -1
- package/packages/cli/dist/main.js +4 -4
- package/packages/cli/dist/{pathUtils-DmtCfutO.js → pathUtils-mTQZ0wYS.js} +12 -2
- package/packages/cli/dist/{pathUtils-DmtCfutO.js.map → pathUtils-mTQZ0wYS.js.map} +1 -1
- package/packages/cli/dist/{qtiPackageToLearnosity-FhfNr7gf.js → qtiPackageToLearnosity-B4cD8jUw.js} +12 -6
- package/packages/cli/dist/qtiPackageToLearnosity-B4cD8jUw.js.map +1 -0
- package/packages/cli/dist/{qtiToLearnosity-5lQ5f3-t.js → qtiToLearnosity-DDjcpShJ.js} +6 -5
- package/packages/cli/dist/qtiToLearnosity-DDjcpShJ.js.map +1 -0
- package/packages/cli/dist/{resolveOptions-lHxSyq9F.js → resolveOptions-Czapkfc1.js} +20 -6
- package/packages/cli/dist/resolveOptions-Czapkfc1.js.map +1 -0
- package/packages/cli/dist/{table-7b-8MN2z.js → table-DTSv0atR.js} +529 -172
- package/packages/cli/dist/table-DTSv0atR.js.map +1 -0
- package/packages/core/dist/index.d.ts +13 -0
- package/packages/core/dist/index.js +768 -239
- package/packages/core/dist/node.d.ts +15 -0
- package/packages/core/dist/node.js +794 -244
- 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;
|
|
@@ -23261,23 +23406,30 @@ function mapCorrectPairsToValidation(correctPairs, stemIdToIndex, optionIdToInde
|
|
|
23261
23406
|
/**
|
|
23262
23407
|
* Convert matchInteraction to Learnosity choicematrix
|
|
23263
23408
|
*/
|
|
23264
|
-
function convertMatchToLearnosity(inputXml, diagnostics, lomTags, organisationId, sourceFile, mediaVault, customAssetUrl, itemReferenceSource) {
|
|
23409
|
+
function convertMatchToLearnosity(inputXml, diagnostics, lomTags, organisationId, sourceFile, mediaVault, customAssetUrl, itemReferenceSource, _stimulusOverride, assetTransformContext) {
|
|
23265
23410
|
const parsed = readAssessmentItemMatch(inputXml);
|
|
23266
23411
|
const updatedDiagnostics = addFileContextIfProvided(parsed.diagnostics, sourceFile);
|
|
23267
23412
|
diagnostics.push(...updatedDiagnostics);
|
|
23268
23413
|
if (hasErrors(diagnostics)) return { diagnostics };
|
|
23269
23414
|
if (!parsed.identifier || parsed.stems.length === 0 || parsed.options.length === 0) return { diagnostics };
|
|
23270
|
-
const itemRef = generateItemReference(parsed.identifier, itemReferenceSource, sourceFile);
|
|
23415
|
+
const itemRef = assetTransformContext?.finalItemReference ?? generateItemReference(parsed.identifier, itemReferenceSource, sourceFile);
|
|
23416
|
+
const transformContext = {
|
|
23417
|
+
finalItemReference: itemRef,
|
|
23418
|
+
preserveAssetFilenames: assetTransformContext?.preserveAssetFilenames ?? false,
|
|
23419
|
+
sourceHrefBase: assetTransformContext?.sourceHrefBase
|
|
23420
|
+
};
|
|
23271
23421
|
const questionRef = md5hex(itemRef);
|
|
23272
23422
|
const stems = parsed.stems.map((stem) => transformAssetUrls(stem.text, {
|
|
23273
23423
|
organisationId,
|
|
23274
23424
|
mediaVault,
|
|
23275
|
-
customAssetUrl
|
|
23425
|
+
customAssetUrl,
|
|
23426
|
+
...transformContext
|
|
23276
23427
|
}));
|
|
23277
23428
|
const options = parsed.options.map((option) => transformAssetUrls(option.text, {
|
|
23278
23429
|
organisationId,
|
|
23279
23430
|
mediaVault,
|
|
23280
|
-
customAssetUrl
|
|
23431
|
+
customAssetUrl,
|
|
23432
|
+
...transformContext
|
|
23281
23433
|
}));
|
|
23282
23434
|
const stemIdToIndex = /* @__PURE__ */ new Map();
|
|
23283
23435
|
parsed.stems.forEach((stem, index) => {
|
|
@@ -23295,7 +23447,8 @@ function convertMatchToLearnosity(inputXml, diagnostics, lomTags, organisationId
|
|
|
23295
23447
|
const stimulus = transformAssetUrls(parsed.stimulusText ? `<p>${parsed.stimulusText}</p>` : "", {
|
|
23296
23448
|
organisationId,
|
|
23297
23449
|
mediaVault,
|
|
23298
|
-
customAssetUrl
|
|
23450
|
+
customAssetUrl,
|
|
23451
|
+
...transformContext
|
|
23299
23452
|
});
|
|
23300
23453
|
const item = {
|
|
23301
23454
|
item: {
|
|
@@ -23675,25 +23828,32 @@ function buildGapValidation(gaps, gapIdToGapTextIds, gapTextIdToContent, sourceF
|
|
|
23675
23828
|
/**
|
|
23676
23829
|
* Convert gapMatchInteraction to Learnosity clozeassociation
|
|
23677
23830
|
*/
|
|
23678
|
-
function convertGapMatchToLearnosity(inputXml, diagnostics, lomTags, organisationId, sourceFile, mediaVault, customAssetUrl, itemReferenceSource) {
|
|
23831
|
+
function convertGapMatchToLearnosity(inputXml, diagnostics, lomTags, organisationId, sourceFile, mediaVault, customAssetUrl, itemReferenceSource, _stimulusOverride, assetTransformContext) {
|
|
23679
23832
|
const parsed = readAssessmentItemGapMatch(inputXml);
|
|
23680
23833
|
const updatedDiagnostics = addFileContextIfProvided(parsed.diagnostics, sourceFile);
|
|
23681
23834
|
diagnostics.push(...updatedDiagnostics);
|
|
23682
23835
|
if (hasErrors(diagnostics)) return { diagnostics };
|
|
23683
23836
|
if (!parsed.identifier || parsed.gapTexts.length === 0 || parsed.gaps.length === 0) return { diagnostics };
|
|
23684
|
-
const itemRef = generateItemReference(parsed.identifier, itemReferenceSource, sourceFile);
|
|
23837
|
+
const itemRef = assetTransformContext?.finalItemReference ?? generateItemReference(parsed.identifier, itemReferenceSource, sourceFile);
|
|
23838
|
+
const transformContext = {
|
|
23839
|
+
finalItemReference: itemRef,
|
|
23840
|
+
preserveAssetFilenames: assetTransformContext?.preserveAssetFilenames ?? false,
|
|
23841
|
+
sourceHrefBase: assetTransformContext?.sourceHrefBase
|
|
23842
|
+
};
|
|
23685
23843
|
const questionRef = md5hex(itemRef);
|
|
23686
23844
|
const possibleResponses = parsed.gapTexts.map((gt) => transformAssetUrls(gt.text, {
|
|
23687
23845
|
organisationId,
|
|
23688
23846
|
mediaVault,
|
|
23689
|
-
customAssetUrl
|
|
23847
|
+
customAssetUrl,
|
|
23848
|
+
...transformContext
|
|
23690
23849
|
}));
|
|
23691
23850
|
const gapTextIdToContent = /* @__PURE__ */ new Map();
|
|
23692
23851
|
parsed.gapTexts.forEach((gt) => {
|
|
23693
23852
|
const transformedText = transformAssetUrls(gt.text, {
|
|
23694
23853
|
organisationId,
|
|
23695
23854
|
mediaVault,
|
|
23696
|
-
customAssetUrl
|
|
23855
|
+
customAssetUrl,
|
|
23856
|
+
...transformContext
|
|
23697
23857
|
});
|
|
23698
23858
|
gapTextIdToContent.set(gt.identifier, transformedText);
|
|
23699
23859
|
});
|
|
@@ -23711,7 +23871,8 @@ function convertGapMatchToLearnosity(inputXml, diagnostics, lomTags, organisatio
|
|
|
23711
23871
|
template: transformAssetUrls(parsed.templateHtml ?? "", {
|
|
23712
23872
|
organisationId,
|
|
23713
23873
|
mediaVault,
|
|
23714
|
-
customAssetUrl
|
|
23874
|
+
customAssetUrl,
|
|
23875
|
+
...transformContext
|
|
23715
23876
|
}),
|
|
23716
23877
|
possible_responses: possibleResponses,
|
|
23717
23878
|
shuffle_options: parsed.shuffle ?? false,
|
|
@@ -23726,7 +23887,8 @@ function convertGapMatchToLearnosity(inputXml, diagnostics, lomTags, organisatio
|
|
|
23726
23887
|
if (parsed.promptHtml) questionData.stimulus = transformAssetUrls(parsed.promptHtml, {
|
|
23727
23888
|
organisationId,
|
|
23728
23889
|
mediaVault,
|
|
23729
|
-
customAssetUrl
|
|
23890
|
+
customAssetUrl,
|
|
23891
|
+
...transformContext
|
|
23730
23892
|
});
|
|
23731
23893
|
if (maxResponsesPerZone > 1) questionData.max_response_per_zone = maxResponsesPerZone;
|
|
23732
23894
|
const choiceCounts = /* @__PURE__ */ new Map();
|
|
@@ -24131,19 +24293,22 @@ function buildValidationValues(interactions, responseDeclarations, diagnostics,
|
|
|
24131
24293
|
* Convert inlineChoiceInteraction to Learnosity clozedropdown
|
|
24132
24294
|
* TASK 036: Added stimulusOverride parameter for composite items
|
|
24133
24295
|
*/
|
|
24134
|
-
function convertInlineChoiceToLearnosity(inputXml, diagnostics, lomTags, organisationId, sourceFile, mediaVault, customAssetUrl, itemReferenceSource, stimulusOverride) {
|
|
24296
|
+
function convertInlineChoiceToLearnosity(inputXml, diagnostics, lomTags, organisationId, sourceFile, mediaVault, customAssetUrl, itemReferenceSource, stimulusOverride, assetTransformContext) {
|
|
24135
24297
|
const parsed = readAssessmentItemInlineChoice(inputXml);
|
|
24136
24298
|
const updatedDiagnostics = addFileContextIfProvided(parsed.diagnostics, sourceFile);
|
|
24137
24299
|
diagnostics.push(...updatedDiagnostics);
|
|
24138
24300
|
if (hasErrors(diagnostics)) return { diagnostics };
|
|
24139
24301
|
if (!parsed.identifier || parsed.interactions.length === 0) return { diagnostics };
|
|
24140
|
-
const itemRef = generateItemReference(parsed.identifier, itemReferenceSource, sourceFile);
|
|
24141
|
-
const questionRef = md5hex(itemRef);
|
|
24302
|
+
const itemRef = assetTransformContext?.finalItemReference ?? generateItemReference(parsed.identifier, itemReferenceSource, sourceFile);
|
|
24142
24303
|
const transformOpts = {
|
|
24143
24304
|
organisationId,
|
|
24144
24305
|
mediaVault,
|
|
24145
|
-
customAssetUrl
|
|
24306
|
+
customAssetUrl,
|
|
24307
|
+
finalItemReference: itemRef,
|
|
24308
|
+
preserveAssetFilenames: assetTransformContext?.preserveAssetFilenames ?? false,
|
|
24309
|
+
sourceHrefBase: assetTransformContext?.sourceHrefBase
|
|
24146
24310
|
};
|
|
24311
|
+
const questionRef = md5hex(itemRef);
|
|
24147
24312
|
const possibleResponses = parsed.interactions.map((interaction) => interaction.choices.map((choice) => transformAssetUrls(choice.text, transformOpts)));
|
|
24148
24313
|
const validationValue = buildValidationValues(parsed.interactions, parsed.responseDeclarations, diagnostics, transformOpts, sourceFile);
|
|
24149
24314
|
if (!validationValue) return { diagnostics };
|
|
@@ -24410,23 +24575,30 @@ function readAssessmentItemOrder(inputXml) {
|
|
|
24410
24575
|
/**
|
|
24411
24576
|
* Convert orderInteraction to Learnosity orderlist
|
|
24412
24577
|
*/
|
|
24413
|
-
function convertOrderToLearnosity(inputXml, diagnostics, lomTags, organisationId, sourceFile, mediaVault, customAssetUrl, itemReferenceSource) {
|
|
24578
|
+
function convertOrderToLearnosity(inputXml, diagnostics, lomTags, organisationId, sourceFile, mediaVault, customAssetUrl, itemReferenceSource, _stimulusOverride, assetTransformContext) {
|
|
24414
24579
|
const parsed = readAssessmentItemOrder(inputXml);
|
|
24415
24580
|
const updatedDiagnostics = addFileContextIfProvided(parsed.diagnostics, sourceFile);
|
|
24416
24581
|
diagnostics.push(...updatedDiagnostics);
|
|
24417
24582
|
if (hasErrors(diagnostics)) return { diagnostics };
|
|
24418
24583
|
if (!parsed.identifier || !parsed.responseIdentifier || parsed.choices.length === 0) return { diagnostics };
|
|
24419
|
-
const itemRef = generateItemReference(parsed.identifier, itemReferenceSource, sourceFile);
|
|
24584
|
+
const itemRef = assetTransformContext?.finalItemReference ?? generateItemReference(parsed.identifier, itemReferenceSource, sourceFile);
|
|
24585
|
+
const transformContext = {
|
|
24586
|
+
finalItemReference: itemRef,
|
|
24587
|
+
preserveAssetFilenames: assetTransformContext?.preserveAssetFilenames ?? false,
|
|
24588
|
+
sourceHrefBase: assetTransformContext?.sourceHrefBase
|
|
24589
|
+
};
|
|
24420
24590
|
const questionRef = md5hex(itemRef);
|
|
24421
24591
|
const stimulus = transformAssetUrls(parsed.stimulusText ?? "", {
|
|
24422
24592
|
organisationId,
|
|
24423
24593
|
mediaVault,
|
|
24424
|
-
customAssetUrl
|
|
24594
|
+
customAssetUrl,
|
|
24595
|
+
...transformContext
|
|
24425
24596
|
});
|
|
24426
24597
|
const list = parsed.choices.map((choice) => transformAssetUrls(choice.text, {
|
|
24427
24598
|
organisationId,
|
|
24428
24599
|
mediaVault,
|
|
24429
|
-
customAssetUrl
|
|
24600
|
+
customAssetUrl,
|
|
24601
|
+
...transformContext
|
|
24430
24602
|
}));
|
|
24431
24603
|
let validationValue;
|
|
24432
24604
|
if (parsed.correctOrder && parsed.correctOrder.length > 0) {
|
|
@@ -24801,17 +24973,19 @@ function convertShapeToPolygon(choice, imageWidth, imageHeight, diagnostics, sou
|
|
|
24801
24973
|
/**
|
|
24802
24974
|
* Build the combined stimulus HTML from parsed stimulusText and promptText
|
|
24803
24975
|
*/
|
|
24804
|
-
function buildHotspotStimulus(parsed, organisationId, mediaVault, customAssetUrl) {
|
|
24976
|
+
function buildHotspotStimulus(parsed, organisationId, mediaVault, customAssetUrl, assetTransformContext) {
|
|
24805
24977
|
let stimulus = "";
|
|
24806
24978
|
if (parsed.stimulusText) stimulus += transformAssetUrls(parsed.stimulusText, {
|
|
24807
24979
|
organisationId,
|
|
24808
24980
|
mediaVault,
|
|
24809
|
-
customAssetUrl
|
|
24981
|
+
customAssetUrl,
|
|
24982
|
+
...assetTransformContext
|
|
24810
24983
|
});
|
|
24811
24984
|
if (parsed.promptText) stimulus += `<p>${transformAssetUrls(parsed.promptText, {
|
|
24812
24985
|
organisationId,
|
|
24813
24986
|
mediaVault,
|
|
24814
|
-
customAssetUrl
|
|
24987
|
+
customAssetUrl,
|
|
24988
|
+
...assetTransformContext
|
|
24815
24989
|
})}</p>`;
|
|
24816
24990
|
return stimulus;
|
|
24817
24991
|
}
|
|
@@ -24836,7 +25010,7 @@ function buildHotspotValidation(correctResponses, choiceIdToIndex) {
|
|
|
24836
25010
|
/**
|
|
24837
25011
|
* Convert hotspotInteraction to Learnosity hotspot
|
|
24838
25012
|
*/
|
|
24839
|
-
function convertHotspotToLearnosity(inputXml, diagnostics, lomTags, organisationId, sourceFile, mediaVault, customAssetUrl, itemReferenceSource, fileAccess, packageRoot) {
|
|
25013
|
+
function convertHotspotToLearnosity(inputXml, diagnostics, lomTags, organisationId, sourceFile, mediaVault, customAssetUrl, itemReferenceSource, fileAccess, packageRoot, assetTransformContext) {
|
|
24840
25014
|
const parsed = readAssessmentItemHotspot(inputXml);
|
|
24841
25015
|
const updatedDiagnostics = addFileContextIfProvided(parsed.diagnostics, sourceFile);
|
|
24842
25016
|
diagnostics.push(...updatedDiagnostics);
|
|
@@ -24858,10 +25032,15 @@ function convertHotspotToLearnosity(inputXml, diagnostics, lomTags, organisation
|
|
|
24858
25032
|
return { diagnostics };
|
|
24859
25033
|
}
|
|
24860
25034
|
}
|
|
24861
|
-
const itemRef = generateItemReference(parsed.identifier, itemReferenceSource, sourceFile);
|
|
25035
|
+
const itemRef = assetTransformContext?.finalItemReference ?? generateItemReference(parsed.identifier, itemReferenceSource, sourceFile);
|
|
25036
|
+
const transformContext = {
|
|
25037
|
+
finalItemReference: itemRef,
|
|
25038
|
+
preserveAssetFilenames: assetTransformContext?.preserveAssetFilenames ?? false,
|
|
25039
|
+
sourceHrefBase: assetTransformContext?.sourceHrefBase
|
|
25040
|
+
};
|
|
24862
25041
|
const questionRef = md5hex(itemRef);
|
|
24863
|
-
const stimulus = buildHotspotStimulus(parsed, organisationId, mediaVault, customAssetUrl);
|
|
24864
|
-
const imageSource = organisationId ? transformUrl(parsed.imageSource, organisationId, mediaVault, customAssetUrl) : parsed.imageSource;
|
|
25042
|
+
const stimulus = buildHotspotStimulus(parsed, organisationId, mediaVault, customAssetUrl, transformContext);
|
|
25043
|
+
const imageSource = organisationId ? transformUrl(parsed.imageSource, organisationId, mediaVault, customAssetUrl, transformContext) : parsed.imageSource;
|
|
24865
25044
|
const areas = [];
|
|
24866
25045
|
const choiceIdToIndex = /* @__PURE__ */ new Map();
|
|
24867
25046
|
for (const choice of parsed.hotspotChoices) {
|
|
@@ -25144,14 +25323,19 @@ function readAssessmentItemHottext(inputXml) {
|
|
|
25144
25323
|
/**
|
|
25145
25324
|
* Convert hottextInteraction to Learnosity tokenhighlight
|
|
25146
25325
|
*/
|
|
25147
|
-
function convertHottextToLearnosity(inputXml, diagnostics, lomTags, organisationId, sourceFile, mediaVault, customAssetUrl, itemReferenceSource) {
|
|
25326
|
+
function convertHottextToLearnosity(inputXml, diagnostics, lomTags, organisationId, sourceFile, mediaVault, customAssetUrl, itemReferenceSource, _stimulusOverride, assetTransformContext) {
|
|
25148
25327
|
const parsed = readAssessmentItemHottext(inputXml);
|
|
25149
25328
|
const updatedDiagnostics = addFileContextIfProvided(parsed.diagnostics, sourceFile);
|
|
25150
25329
|
diagnostics.push(...updatedDiagnostics);
|
|
25151
25330
|
if (hasErrors(diagnostics)) return { diagnostics };
|
|
25152
25331
|
if (!parsed.identifier || !parsed.responseIdentifier || !parsed.templateHtml) return { diagnostics };
|
|
25153
25332
|
if (parsed.hottextElements.length === 0) return { diagnostics };
|
|
25154
|
-
const itemRef = generateItemReference(parsed.identifier, itemReferenceSource, sourceFile);
|
|
25333
|
+
const itemRef = assetTransformContext?.finalItemReference ?? generateItemReference(parsed.identifier, itemReferenceSource, sourceFile);
|
|
25334
|
+
const transformContext = {
|
|
25335
|
+
finalItemReference: itemRef,
|
|
25336
|
+
preserveAssetFilenames: assetTransformContext?.preserveAssetFilenames ?? false,
|
|
25337
|
+
sourceHrefBase: assetTransformContext?.sourceHrefBase
|
|
25338
|
+
};
|
|
25155
25339
|
const questionRef = md5hex(itemRef);
|
|
25156
25340
|
if (parsed.shuffle) diagnostics.push({
|
|
25157
25341
|
code: DiagnosticCode.QTI_SHUFFLE_NOT_SUPPORTED,
|
|
@@ -25163,7 +25347,8 @@ function convertHottextToLearnosity(inputXml, diagnostics, lomTags, organisation
|
|
|
25163
25347
|
if (stimulus) stimulus = transformAssetUrls(stimulus, {
|
|
25164
25348
|
organisationId,
|
|
25165
25349
|
mediaVault,
|
|
25166
|
-
customAssetUrl
|
|
25350
|
+
customAssetUrl,
|
|
25351
|
+
...transformContext
|
|
25167
25352
|
});
|
|
25168
25353
|
let template = parsed.templateHtml || "";
|
|
25169
25354
|
const identifierToIndex = /* @__PURE__ */ new Map();
|
|
@@ -25176,7 +25361,8 @@ function convertHottextToLearnosity(inputXml, diagnostics, lomTags, organisation
|
|
|
25176
25361
|
template = transformAssetUrls(template, {
|
|
25177
25362
|
organisationId,
|
|
25178
25363
|
mediaVault,
|
|
25179
|
-
customAssetUrl
|
|
25364
|
+
customAssetUrl,
|
|
25365
|
+
...transformContext
|
|
25180
25366
|
});
|
|
25181
25367
|
let validation = void 0;
|
|
25182
25368
|
if (parsed.correctResponses && parsed.correctResponses.length > 0) {
|
|
@@ -25643,7 +25829,7 @@ function readAssessmentItemMcq(inputXml, stimulusOverride) {
|
|
|
25643
25829
|
* Supports both single and composite (multiple) choiceInteractions
|
|
25644
25830
|
* TASK 036: Added stimulusOverride parameter for composite items
|
|
25645
25831
|
*/
|
|
25646
|
-
function convertMcqToLearnosity(inputXml, diagnostics, lomTags, sourceFile, organisationId, mediaVault, customAssetUrl, itemReferenceSource, stimulusOverride) {
|
|
25832
|
+
function convertMcqToLearnosity(inputXml, diagnostics, lomTags, sourceFile, organisationId, mediaVault, customAssetUrl, itemReferenceSource, stimulusOverride, assetTransformContext) {
|
|
25647
25833
|
const parsed = readAssessmentItemMcq(inputXml, stimulusOverride);
|
|
25648
25834
|
const contextualDiagnostics = sourceFile ? parsed.diagnostics.map((d) => ({
|
|
25649
25835
|
...d,
|
|
@@ -25652,7 +25838,12 @@ function convertMcqToLearnosity(inputXml, diagnostics, lomTags, sourceFile, orga
|
|
|
25652
25838
|
diagnostics.push(...contextualDiagnostics);
|
|
25653
25839
|
if (diagnostics.some((d) => d.level === "error")) return { diagnostics };
|
|
25654
25840
|
if (!parsed.identifier || parsed.interactions.length === 0) return { diagnostics };
|
|
25655
|
-
const itemRef = generateItemReference(parsed.identifier, itemReferenceSource, sourceFile);
|
|
25841
|
+
const itemRef = assetTransformContext?.finalItemReference ?? generateItemReference(parsed.identifier, itemReferenceSource, sourceFile);
|
|
25842
|
+
const transformContext = {
|
|
25843
|
+
finalItemReference: itemRef,
|
|
25844
|
+
preserveAssetFilenames: assetTransformContext?.preserveAssetFilenames ?? false,
|
|
25845
|
+
sourceHrefBase: assetTransformContext?.sourceHrefBase
|
|
25846
|
+
};
|
|
25656
25847
|
const isComposite = parsed.interactions.length > 1;
|
|
25657
25848
|
const questions = [];
|
|
25658
25849
|
const widgets = [];
|
|
@@ -25662,7 +25853,8 @@ function convertMcqToLearnosity(inputXml, diagnostics, lomTags, sourceFile, orga
|
|
|
25662
25853
|
const stimulus = interaction.stimulusText ? transformAssetUrls(interaction.stimulusText, {
|
|
25663
25854
|
organisationId,
|
|
25664
25855
|
mediaVault,
|
|
25665
|
-
customAssetUrl
|
|
25856
|
+
customAssetUrl,
|
|
25857
|
+
...transformContext
|
|
25666
25858
|
}) : void 0;
|
|
25667
25859
|
const choiceMapping = /* @__PURE__ */ new Map();
|
|
25668
25860
|
const options = interaction.choices.map((choice) => {
|
|
@@ -25671,7 +25863,8 @@ function convertMcqToLearnosity(inputXml, diagnostics, lomTags, sourceFile, orga
|
|
|
25671
25863
|
label: transformAssetUrls(choice.text, {
|
|
25672
25864
|
organisationId,
|
|
25673
25865
|
mediaVault,
|
|
25674
|
-
customAssetUrl
|
|
25866
|
+
customAssetUrl,
|
|
25867
|
+
...transformContext
|
|
25675
25868
|
}),
|
|
25676
25869
|
value: choice.identifier
|
|
25677
25870
|
};
|
|
@@ -25708,7 +25901,8 @@ function convertMcqToLearnosity(inputXml, diagnostics, lomTags, sourceFile, orga
|
|
|
25708
25901
|
const instructorStimulus = parsed.instructorStimulus ? transformAssetUrls(parsed.instructorStimulus, {
|
|
25709
25902
|
organisationId,
|
|
25710
25903
|
mediaVault,
|
|
25711
|
-
customAssetUrl
|
|
25904
|
+
customAssetUrl,
|
|
25905
|
+
...transformContext
|
|
25712
25906
|
}) : void 0;
|
|
25713
25907
|
questions.push({
|
|
25714
25908
|
reference: questionRef,
|
|
@@ -26076,7 +26270,7 @@ function stripWrapperDiv(html) {
|
|
|
26076
26270
|
* Convert textEntry (textEntryInteraction) to Learnosity clozetext or shorttext
|
|
26077
26271
|
* TASK 036: Added stimulusOverride parameter for composite items
|
|
26078
26272
|
*/
|
|
26079
|
-
function convertTextEntryToLearnosity(inputXml, diagnostics, lomTags, sourceFile, organisationId, mediaVault, customAssetUrl, itemReferenceSource, stimulusOverride) {
|
|
26273
|
+
function convertTextEntryToLearnosity(inputXml, diagnostics, lomTags, sourceFile, organisationId, mediaVault, customAssetUrl, itemReferenceSource, stimulusOverride, assetTransformContext) {
|
|
26080
26274
|
const parsed = readAssessmentItemTextEntry(inputXml, stimulusOverride);
|
|
26081
26275
|
const contextualDiagnostics = sourceFile ? parsed.diagnostics.map((d) => ({
|
|
26082
26276
|
...d,
|
|
@@ -26086,24 +26280,31 @@ function convertTextEntryToLearnosity(inputXml, diagnostics, lomTags, sourceFile
|
|
|
26086
26280
|
if (diagnostics.some((d) => d.level === "error")) return { diagnostics };
|
|
26087
26281
|
if (!parsed.identifier || parsed.textEntries.length === 0) return { diagnostics };
|
|
26088
26282
|
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);
|
|
26283
|
+
if (parsed.textEntries.length === 1 && /{{response}}(?:\s*<\/[^>]+>)*\s*$/.test(parsed.templateText.trim())) return convertShorttextToLearnosity(parsed, diagnostics, lomTags, organisationId, mediaVault, customAssetUrl, itemReferenceSource, sourceFile, assetTransformContext);
|
|
26284
|
+
else return convertClozetextToLearnosity(parsed, diagnostics, lomTags, organisationId, mediaVault, customAssetUrl, itemReferenceSource, sourceFile, assetTransformContext);
|
|
26091
26285
|
}
|
|
26092
26286
|
/**
|
|
26093
26287
|
* Convert single textEntry to Learnosity shorttext
|
|
26094
26288
|
*/
|
|
26095
|
-
function convertShorttextToLearnosity(parsed, diagnostics, lomTags, organisationId, mediaVault, customAssetUrl, itemReferenceSource, sourceFile) {
|
|
26096
|
-
const itemRef = generateItemReference(parsed.identifier, itemReferenceSource, sourceFile);
|
|
26289
|
+
function convertShorttextToLearnosity(parsed, diagnostics, lomTags, organisationId, mediaVault, customAssetUrl, itemReferenceSource, sourceFile, assetTransformContext) {
|
|
26290
|
+
const itemRef = assetTransformContext?.finalItemReference ?? generateItemReference(parsed.identifier, itemReferenceSource, sourceFile);
|
|
26291
|
+
const transformContext = {
|
|
26292
|
+
finalItemReference: itemRef,
|
|
26293
|
+
preserveAssetFilenames: assetTransformContext?.preserveAssetFilenames ?? false,
|
|
26294
|
+
sourceHrefBase: assetTransformContext?.sourceHrefBase
|
|
26295
|
+
};
|
|
26097
26296
|
const questionRef = md5hex(parsed.responseIdentifier ?? parsed.identifier);
|
|
26098
26297
|
const stimulus = normalizeFinalText(transformAssetUrls((parsed.templateText || "").replace(/{{response}}(?:\s*<\/[^>]+>)*\s*$/, "").trim(), {
|
|
26099
26298
|
organisationId,
|
|
26100
26299
|
mediaVault,
|
|
26101
|
-
customAssetUrl
|
|
26300
|
+
customAssetUrl,
|
|
26301
|
+
...transformContext
|
|
26102
26302
|
}));
|
|
26103
26303
|
const instructorStimulus = parsed.instructorStimulus ? transformAssetUrls(parsed.instructorStimulus, {
|
|
26104
26304
|
organisationId,
|
|
26105
26305
|
mediaVault,
|
|
26106
|
-
customAssetUrl
|
|
26306
|
+
customAssetUrl,
|
|
26307
|
+
...transformContext
|
|
26107
26308
|
}) : void 0;
|
|
26108
26309
|
const entry = parsed.textEntries[0];
|
|
26109
26310
|
const correctResponses = entry.correctResponses || (entry.correctResponse ? [entry.correctResponse] : []);
|
|
@@ -26177,25 +26378,33 @@ function convertShorttextToLearnosity(parsed, diagnostics, lomTags, organisation
|
|
|
26177
26378
|
/**
|
|
26178
26379
|
* Convert textEntry with template to Learnosity clozetext
|
|
26179
26380
|
*/
|
|
26180
|
-
function convertClozetextToLearnosity(parsed, diagnostics, lomTags, organisationId, mediaVault, customAssetUrl, itemReferenceSource, sourceFile) {
|
|
26381
|
+
function convertClozetextToLearnosity(parsed, diagnostics, lomTags, organisationId, mediaVault, customAssetUrl, itemReferenceSource, sourceFile, assetTransformContext) {
|
|
26181
26382
|
const correctResponses = [];
|
|
26182
26383
|
for (const entry of parsed.textEntries) if (entry.correctResponse) correctResponses.push(entry.correctResponse);
|
|
26183
|
-
const itemRef = generateItemReference(parsed.identifier, itemReferenceSource, sourceFile);
|
|
26384
|
+
const itemRef = assetTransformContext?.finalItemReference ?? generateItemReference(parsed.identifier, itemReferenceSource, sourceFile);
|
|
26385
|
+
const transformContext = {
|
|
26386
|
+
finalItemReference: itemRef,
|
|
26387
|
+
preserveAssetFilenames: assetTransformContext?.preserveAssetFilenames ?? false,
|
|
26388
|
+
sourceHrefBase: assetTransformContext?.sourceHrefBase
|
|
26389
|
+
};
|
|
26184
26390
|
const questionRef = md5hex(parsed.responseIdentifier ?? parsed.identifier);
|
|
26185
26391
|
const stimulus = parsed.stimulusText ? normalizeFinalText(transformAssetUrls(parsed.stimulusText, {
|
|
26186
26392
|
organisationId,
|
|
26187
26393
|
mediaVault,
|
|
26188
|
-
customAssetUrl
|
|
26394
|
+
customAssetUrl,
|
|
26395
|
+
...transformContext
|
|
26189
26396
|
})) : void 0;
|
|
26190
26397
|
const template = normalizeFinalText(transformAssetUrls(parsed.templateText, {
|
|
26191
26398
|
organisationId,
|
|
26192
26399
|
mediaVault,
|
|
26193
|
-
customAssetUrl
|
|
26400
|
+
customAssetUrl,
|
|
26401
|
+
...transformContext
|
|
26194
26402
|
}));
|
|
26195
26403
|
const instructorStimulus = parsed.instructorStimulus ? transformAssetUrls(parsed.instructorStimulus, {
|
|
26196
26404
|
organisationId,
|
|
26197
26405
|
mediaVault,
|
|
26198
|
-
customAssetUrl
|
|
26406
|
+
customAssetUrl,
|
|
26407
|
+
...transformContext
|
|
26199
26408
|
}) : void 0;
|
|
26200
26409
|
const validation = {
|
|
26201
26410
|
scoring_type: "exactMatch",
|
|
@@ -26428,8 +26637,13 @@ function readAssessmentItemExtendedText(inputXml) {
|
|
|
26428
26637
|
/**
|
|
26429
26638
|
* Build multi-interaction extended text item (multiple longtextV2 questions)
|
|
26430
26639
|
*/
|
|
26431
|
-
function buildMultiExtendedTextItem(parsed, inputXml, stimulusOverride, diagnostics, lomTags, organisationId, mediaVault, customAssetUrl, itemReferenceSource, sourceFile) {
|
|
26432
|
-
const itemRef = generateItemReference(parsed.identifier ?? "unknown", itemReferenceSource, sourceFile);
|
|
26640
|
+
function buildMultiExtendedTextItem(parsed, inputXml, stimulusOverride, diagnostics, lomTags, organisationId, mediaVault, customAssetUrl, itemReferenceSource, sourceFile, assetTransformContext) {
|
|
26641
|
+
const itemRef = assetTransformContext?.finalItemReference ?? generateItemReference(parsed.identifier ?? "unknown", itemReferenceSource, sourceFile);
|
|
26642
|
+
const transformContext = {
|
|
26643
|
+
finalItemReference: itemRef,
|
|
26644
|
+
preserveAssetFilenames: assetTransformContext?.preserveAssetFilenames ?? false,
|
|
26645
|
+
sourceHrefBase: assetTransformContext?.sourceHrefBase
|
|
26646
|
+
};
|
|
26433
26647
|
const questions = [];
|
|
26434
26648
|
const widgets = [];
|
|
26435
26649
|
const questionSpans = [];
|
|
@@ -26439,7 +26653,8 @@ function buildMultiExtendedTextItem(parsed, inputXml, stimulusOverride, diagnost
|
|
|
26439
26653
|
const stimulus = transformAssetUrls(stimulusOverride[i], {
|
|
26440
26654
|
organisationId,
|
|
26441
26655
|
mediaVault,
|
|
26442
|
-
customAssetUrl
|
|
26656
|
+
customAssetUrl,
|
|
26657
|
+
...transformContext
|
|
26443
26658
|
});
|
|
26444
26659
|
widgets.push({
|
|
26445
26660
|
reference: questionRef,
|
|
@@ -26489,19 +26704,25 @@ function extractResponseIdentifiers(inputXml, interactionTag) {
|
|
|
26489
26704
|
* Convert extended text (extendedTextInteraction) to Learnosity longtextV2
|
|
26490
26705
|
* TASK 036: Added stimulusOverride parameter for composite items
|
|
26491
26706
|
*/
|
|
26492
|
-
function convertExtendedTextToLearnosity(inputXml, diagnostics, lomTags, sourceFile, organisationId, mediaVault, customAssetUrl, itemReferenceSource, stimulusOverride) {
|
|
26707
|
+
function convertExtendedTextToLearnosity(inputXml, diagnostics, lomTags, sourceFile, organisationId, mediaVault, customAssetUrl, itemReferenceSource, stimulusOverride, assetTransformContext) {
|
|
26493
26708
|
const parsed = readAssessmentItemExtendedText(inputXml);
|
|
26494
26709
|
const contextualDiagnostics = addFileContextIfProvided(stimulusOverride ? filterOutCodes(parsed.diagnostics, [DiagnosticCode.QTI_EXTENDED_TEXT_MULTIPLE_INTERACTIONS]) : parsed.diagnostics, sourceFile);
|
|
26495
26710
|
diagnostics.push(...contextualDiagnostics);
|
|
26496
26711
|
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);
|
|
26712
|
+
if (stimulusOverride && stimulusOverride.length > 1) return buildMultiExtendedTextItem(parsed, inputXml, stimulusOverride, diagnostics, lomTags, organisationId, mediaVault, customAssetUrl, itemReferenceSource, sourceFile, assetTransformContext);
|
|
26713
|
+
const itemRef = assetTransformContext?.finalItemReference ?? generateItemReference(parsed.identifier ?? "unknown", itemReferenceSource, sourceFile);
|
|
26714
|
+
const transformContext = {
|
|
26715
|
+
finalItemReference: itemRef,
|
|
26716
|
+
preserveAssetFilenames: assetTransformContext?.preserveAssetFilenames ?? false,
|
|
26717
|
+
sourceHrefBase: assetTransformContext?.sourceHrefBase
|
|
26718
|
+
};
|
|
26499
26719
|
const questionRef = md5hex(parsed.responseIdentifier ?? parsed.identifier ?? "unknown");
|
|
26500
26720
|
const stimulusRaw = stimulusOverride && stimulusOverride.length === 1 ? stimulusOverride[0] : parsed.stimulusText;
|
|
26501
26721
|
const stimulus = stimulusRaw ? transformAssetUrls(stimulusRaw, {
|
|
26502
26722
|
organisationId,
|
|
26503
26723
|
mediaVault,
|
|
26504
|
-
customAssetUrl
|
|
26724
|
+
customAssetUrl,
|
|
26725
|
+
...transformContext
|
|
26505
26726
|
}) : void 0;
|
|
26506
26727
|
const instructorStimulus = parsed.instructorStimulus ? transformAssetUrls(parsed.instructorStimulus, {
|
|
26507
26728
|
organisationId,
|
|
@@ -26796,7 +27017,7 @@ function buildValidationValue$1(hotspots, correctPairs, gapImgIdToResponse) {
|
|
|
26796
27017
|
/**
|
|
26797
27018
|
* Convert QTI graphicGapMatchInteraction to Learnosity imageclozeassociationV2
|
|
26798
27019
|
*/
|
|
26799
|
-
function convertGraphicGapMatchToLearnosity(inputXml, diagnostics, _lomTags, organisationId, sourceFile, mediaVault, customAssetUrl, itemReferenceSource) {
|
|
27020
|
+
function convertGraphicGapMatchToLearnosity(inputXml, diagnostics, _lomTags, organisationId, sourceFile, mediaVault, customAssetUrl, itemReferenceSource, _stimulusOverride, assetTransformContext) {
|
|
26800
27021
|
const parsed = readAssessmentItemGraphicGapMatch(inputXml);
|
|
26801
27022
|
const contextualDiagnostics = addFileContextIfProvided(parsed.diagnostics, sourceFile);
|
|
26802
27023
|
diagnostics.push(...contextualDiagnostics);
|
|
@@ -26812,6 +27033,12 @@ function convertGraphicGapMatchToLearnosity(inputXml, diagnostics, _lomTags, org
|
|
|
26812
27033
|
}
|
|
26813
27034
|
const bgWidth = parsed.backgroundImage.width;
|
|
26814
27035
|
const bgHeight = parsed.backgroundImage.height;
|
|
27036
|
+
const itemRef = assetTransformContext?.finalItemReference ?? generateItemReference(parsed.identifier ?? "item", itemReferenceSource, sourceFile);
|
|
27037
|
+
const transformContext = {
|
|
27038
|
+
finalItemReference: itemRef,
|
|
27039
|
+
preserveAssetFilenames: assetTransformContext?.preserveAssetFilenames ?? false,
|
|
27040
|
+
sourceHrefBase: assetTransformContext?.sourceHrefBase
|
|
27041
|
+
};
|
|
26815
27042
|
const gapImgIdToResponse = /* @__PURE__ */ new Map();
|
|
26816
27043
|
const possible_responses = parsed.gapImages.map((g) => {
|
|
26817
27044
|
if (g.text !== void 0) {
|
|
@@ -26830,7 +27057,8 @@ function convertGraphicGapMatchToLearnosity(inputXml, diagnostics, _lomTags, org
|
|
|
26830
27057
|
const transformedImgTag = transformAssetUrls(imgTag, {
|
|
26831
27058
|
organisationId,
|
|
26832
27059
|
mediaVault,
|
|
26833
|
-
customAssetUrl
|
|
27060
|
+
customAssetUrl,
|
|
27061
|
+
...transformContext
|
|
26834
27062
|
});
|
|
26835
27063
|
gapImgIdToResponse.set(g.identifier, transformedImgTag);
|
|
26836
27064
|
return transformedImgTag;
|
|
@@ -26868,7 +27096,7 @@ function convertGraphicGapMatchToLearnosity(inputXml, diagnostics, _lomTags, org
|
|
|
26868
27096
|
const question = {
|
|
26869
27097
|
type: "imageclozeassociationV2",
|
|
26870
27098
|
image: {
|
|
26871
|
-
src: organisationId ? transformUrl(parsed.backgroundImage.src, organisationId, mediaVault, customAssetUrl) : parsed.backgroundImage.src,
|
|
27099
|
+
src: organisationId ? transformUrl(parsed.backgroundImage.src, organisationId, mediaVault, customAssetUrl, transformContext) : parsed.backgroundImage.src,
|
|
26872
27100
|
width: bgWidth,
|
|
26873
27101
|
height: bgHeight
|
|
26874
27102
|
},
|
|
@@ -26892,11 +27120,12 @@ function convertGraphicGapMatchToLearnosity(inputXml, diagnostics, _lomTags, org
|
|
|
26892
27120
|
if (parsed.stimulus) question.stimulus = transformAssetUrls(parsed.stimulus, {
|
|
26893
27121
|
organisationId,
|
|
26894
27122
|
mediaVault,
|
|
26895
|
-
customAssetUrl
|
|
27123
|
+
customAssetUrl,
|
|
27124
|
+
...transformContext
|
|
26896
27125
|
});
|
|
26897
27126
|
const item = {
|
|
26898
27127
|
item: {
|
|
26899
|
-
reference:
|
|
27128
|
+
reference: itemRef,
|
|
26900
27129
|
title: parsed.title ?? void 0,
|
|
26901
27130
|
definition: { widgets: [{
|
|
26902
27131
|
reference: questionRef,
|
|
@@ -27186,35 +27415,38 @@ const readAssessmentItemDrawing = createAssessmentItemReader({
|
|
|
27186
27415
|
/**
|
|
27187
27416
|
* Build drawing stimulus from parsed QTI data
|
|
27188
27417
|
*/
|
|
27189
|
-
function buildDrawingStimulus(parsed, organisationId, mediaVault, customAssetUrl) {
|
|
27418
|
+
function buildDrawingStimulus(parsed, organisationId, mediaVault, customAssetUrl, assetTransformContext) {
|
|
27190
27419
|
if (!parsed.stimulusText && !parsed.promptText) return;
|
|
27191
27420
|
const stimulus = parsed.promptText || parsed.stimulusText || "";
|
|
27192
27421
|
try {
|
|
27193
27422
|
return transformAssetUrls(stimulus, {
|
|
27194
27423
|
organisationId,
|
|
27195
27424
|
mediaVault,
|
|
27196
|
-
customAssetUrl
|
|
27425
|
+
customAssetUrl,
|
|
27426
|
+
...assetTransformContext
|
|
27197
27427
|
});
|
|
27198
|
-
} catch {
|
|
27428
|
+
} catch (error) {
|
|
27429
|
+
if (isUnsafeQtiAssetHrefError(error)) throw error;
|
|
27199
27430
|
return stimulus;
|
|
27200
27431
|
}
|
|
27201
27432
|
}
|
|
27202
27433
|
/**
|
|
27203
27434
|
* Transform a single image source URL
|
|
27204
27435
|
*/
|
|
27205
|
-
function transformImageSource(imageSource, organisationId, mediaVault, customAssetUrl) {
|
|
27436
|
+
function transformImageSource(imageSource, organisationId, mediaVault, customAssetUrl, assetTransformContext) {
|
|
27206
27437
|
try {
|
|
27207
|
-
return organisationId ? transformUrl(imageSource, organisationId, mediaVault, customAssetUrl) : imageSource;
|
|
27208
|
-
} catch {
|
|
27438
|
+
return organisationId ? transformUrl(imageSource, organisationId, mediaVault, customAssetUrl, assetTransformContext) : imageSource;
|
|
27439
|
+
} catch (error) {
|
|
27440
|
+
if (isUnsafeQtiAssetHrefError(error)) throw error;
|
|
27209
27441
|
return imageSource;
|
|
27210
27442
|
}
|
|
27211
27443
|
}
|
|
27212
27444
|
/**
|
|
27213
27445
|
* Build drawing image data from parsed QTI data
|
|
27214
27446
|
*/
|
|
27215
|
-
function buildDrawingImage(parsed, organisationId, mediaVault, customAssetUrl) {
|
|
27447
|
+
function buildDrawingImage(parsed, organisationId, mediaVault, customAssetUrl, assetTransformContext) {
|
|
27216
27448
|
if (!parsed.imageSource) return;
|
|
27217
|
-
const image = { source: transformImageSource(parsed.imageSource, organisationId, mediaVault, customAssetUrl) };
|
|
27449
|
+
const image = { source: transformImageSource(parsed.imageSource, organisationId, mediaVault, customAssetUrl, assetTransformContext) };
|
|
27218
27450
|
if (parsed.imageWidth) image.width = parsed.imageWidth;
|
|
27219
27451
|
if (parsed.imageHeight) image.height = parsed.imageHeight;
|
|
27220
27452
|
if (parsed.imageAlt) image.alt = parsed.imageAlt;
|
|
@@ -27223,21 +27455,27 @@ function buildDrawingImage(parsed, organisationId, mediaVault, customAssetUrl) {
|
|
|
27223
27455
|
/**
|
|
27224
27456
|
* Convert QTI drawingInteraction to Learnosity drawing question
|
|
27225
27457
|
*/
|
|
27226
|
-
function convertDrawingToLearnosity(inputXml, diagnostics, lomTags, organisationId, sourceFile, mediaVault, customAssetUrl, itemReferenceSource) {
|
|
27458
|
+
function convertDrawingToLearnosity(inputXml, diagnostics, lomTags, organisationId, sourceFile, mediaVault, customAssetUrl, itemReferenceSource, _stimulusOverride, assetTransformContext) {
|
|
27227
27459
|
const parsed = readAssessmentItemDrawing(inputXml);
|
|
27228
27460
|
diagnostics.push(...parsed.diagnostics);
|
|
27229
27461
|
if (parsed.diagnostics.some((d) => d.level === "error")) return { diagnostics };
|
|
27230
|
-
const
|
|
27462
|
+
const generatedItemRef = generateItemReference(parsed.identifier ?? "item", itemReferenceSource, sourceFile);
|
|
27463
|
+
const itemRef = assetTransformContext?.finalItemReference ?? parsed.identifier ?? generatedItemRef;
|
|
27464
|
+
const transformContext = {
|
|
27465
|
+
finalItemReference: itemRef,
|
|
27466
|
+
preserveAssetFilenames: assetTransformContext?.preserveAssetFilenames ?? false,
|
|
27467
|
+
sourceHrefBase: assetTransformContext?.sourceHrefBase
|
|
27468
|
+
};
|
|
27231
27469
|
const questionRef = md5hex(itemRef + (parsed.responseIdentifier ?? "drawing"));
|
|
27232
27470
|
const questionData = { type: "drawing" };
|
|
27233
|
-
const stimulus = buildDrawingStimulus(parsed, organisationId, mediaVault, customAssetUrl);
|
|
27471
|
+
const stimulus = buildDrawingStimulus(parsed, organisationId, mediaVault, customAssetUrl, transformContext);
|
|
27234
27472
|
if (stimulus !== void 0) questionData.stimulus = stimulus;
|
|
27235
|
-
const image = buildDrawingImage(parsed, organisationId, mediaVault, customAssetUrl);
|
|
27473
|
+
const image = buildDrawingImage(parsed, organisationId, mediaVault, customAssetUrl, transformContext);
|
|
27236
27474
|
if (image) questionData.image = image;
|
|
27237
27475
|
const content = `<span class="learnosity-response question-${questionRef}"></span>`;
|
|
27238
27476
|
const item = {
|
|
27239
27477
|
item: {
|
|
27240
|
-
reference:
|
|
27478
|
+
reference: itemRef,
|
|
27241
27479
|
title: parsed.title ?? void 0,
|
|
27242
27480
|
content,
|
|
27243
27481
|
definition: { widgets: [{
|
|
@@ -27527,7 +27765,7 @@ function buildValidationValue(choices, correctPairs, diagnostics, sourceFile) {
|
|
|
27527
27765
|
* This reflects the undirected-pair nature of associateInteraction: no choice is
|
|
27528
27766
|
* inherently a "category" or a "draggable" — both sides of a pair are equivalent.
|
|
27529
27767
|
*/
|
|
27530
|
-
function convertAssociationToLearnosity(inputXml, diagnostics, lomTags, organisationId, sourceFile, mediaVault, customAssetUrl, itemReferenceSource) {
|
|
27768
|
+
function convertAssociationToLearnosity(inputXml, diagnostics, lomTags, organisationId, sourceFile, mediaVault, customAssetUrl, itemReferenceSource, _stimulusOverride, assetTransformContext) {
|
|
27531
27769
|
const parsed = readAssessmentItemAssociation(inputXml);
|
|
27532
27770
|
const updatedDiagnostics = addFileContextIfProvided(parsed.diagnostics, sourceFile);
|
|
27533
27771
|
diagnostics.push(...updatedDiagnostics);
|
|
@@ -27535,17 +27773,24 @@ function convertAssociationToLearnosity(inputXml, diagnostics, lomTags, organisa
|
|
|
27535
27773
|
if (!parsed.identifier || parsed.choices.length === 0) return { diagnostics };
|
|
27536
27774
|
const validationValue = buildValidationValue(parsed.choices, parsed.correctPairs, diagnostics, sourceFile);
|
|
27537
27775
|
if (hasErrors(diagnostics)) return { diagnostics };
|
|
27538
|
-
const itemRef = generateItemReference(parsed.identifier, itemReferenceSource, sourceFile);
|
|
27776
|
+
const itemRef = assetTransformContext?.finalItemReference ?? generateItemReference(parsed.identifier, itemReferenceSource, sourceFile);
|
|
27777
|
+
const transformContext = {
|
|
27778
|
+
finalItemReference: itemRef,
|
|
27779
|
+
preserveAssetFilenames: assetTransformContext?.preserveAssetFilenames ?? false,
|
|
27780
|
+
sourceHrefBase: assetTransformContext?.sourceHrefBase
|
|
27781
|
+
};
|
|
27539
27782
|
const questionRef = md5hex(itemRef);
|
|
27540
27783
|
const stimulus = transformAssetUrls(parsed.stimulusText ? `<p>${parsed.stimulusText}</p>` : "", {
|
|
27541
27784
|
organisationId,
|
|
27542
27785
|
mediaVault,
|
|
27543
|
-
customAssetUrl
|
|
27786
|
+
customAssetUrl,
|
|
27787
|
+
...transformContext
|
|
27544
27788
|
});
|
|
27545
27789
|
const possibleResponses = parsed.choices.map((c) => transformAssetUrls(c.text, {
|
|
27546
27790
|
organisationId,
|
|
27547
27791
|
mediaVault,
|
|
27548
|
-
customAssetUrl
|
|
27792
|
+
customAssetUrl,
|
|
27793
|
+
...transformContext
|
|
27549
27794
|
}));
|
|
27550
27795
|
const pairCount = validationValue.length > 0 ? validationValue.length : Math.round(parsed.maxAssociations ?? parsed.choices.length / 2);
|
|
27551
27796
|
const columnHeaders = Array.from({ length: pairCount }, (_, i) => `Pair ${i + 1}`);
|
|
@@ -27961,8 +28206,8 @@ function computeClosingTags(html) {
|
|
|
27961
28206
|
* Converters with different parameter orders are wrapped to normalize the signature.
|
|
27962
28207
|
*/
|
|
27963
28208
|
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);
|
|
28209
|
+
const wrapSourceFirst = (fn) => (xml, diag, tags, orgId, sf, mv, cau, irs, stimuli, assetTransformContext) => fn(xml, diag, tags, sf, orgId, mv, cau, irs, stimuli, assetTransformContext);
|
|
28210
|
+
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
28211
|
return {
|
|
27967
28212
|
choiceInteraction: wrapSourceFirst(convertMcqToLearnosity),
|
|
27968
28213
|
textEntryInteraction: wrapSourceFirst(convertTextEntryToLearnosity),
|
|
@@ -27985,8 +28230,14 @@ const CONVERTER_MAP = getConverterMap();
|
|
|
27985
28230
|
* Strategy: Call each individual converter for its interaction type,
|
|
27986
28231
|
* then combine all questions and widgets into a single composite item
|
|
27987
28232
|
*/
|
|
27988
|
-
function convertMixedInteractionsToLearnosity(inputXml, diagnostics, lomTags, organisationId, sourceFile, mediaVault, customAssetUrl, itemReferenceSource, fileAccess, packageRoot) {
|
|
28233
|
+
function convertMixedInteractionsToLearnosity(inputXml, diagnostics, lomTags, organisationId, sourceFile, mediaVault, customAssetUrl, itemReferenceSource, fileAccess, packageRoot, assetTransformContext) {
|
|
27989
28234
|
const metadata = extractItemMetadata(inputXml);
|
|
28235
|
+
const itemRef = assetTransformContext?.finalItemReference ?? generateItemReference(metadata.identifier ?? "mixed_item", itemReferenceSource, sourceFile);
|
|
28236
|
+
const transformContext = {
|
|
28237
|
+
finalItemReference: itemRef,
|
|
28238
|
+
preserveAssetFilenames: assetTransformContext?.preserveAssetFilenames ?? false,
|
|
28239
|
+
sourceHrefBase: assetTransformContext?.sourceHrefBase
|
|
28240
|
+
};
|
|
27990
28241
|
const { segments } = segmentItemBodyByInteractions(inputXml);
|
|
27991
28242
|
const stimuliByType = /* @__PURE__ */ new Map();
|
|
27992
28243
|
for (const segment of segments) {
|
|
@@ -28068,7 +28319,8 @@ function convertMixedInteractionsToLearnosity(inputXml, diagnostics, lomTags, or
|
|
|
28068
28319
|
const template = normalizeFinalText(transformAssetUrls(rawTemplate, {
|
|
28069
28320
|
organisationId,
|
|
28070
28321
|
mediaVault,
|
|
28071
|
-
customAssetUrl
|
|
28322
|
+
customAssetUrl,
|
|
28323
|
+
...transformContext
|
|
28072
28324
|
}));
|
|
28073
28325
|
if (groupEntries.length === 1 && /{{response}}(?:<\/[^>]+>|\s)*$/.test(rawTemplate.trim())) {
|
|
28074
28326
|
let stimulusRaw = rawTemplate.replace(/{{response}}(?:<\/[^>]+>|\s)*$/, "").trim();
|
|
@@ -28076,7 +28328,8 @@ function convertMixedInteractionsToLearnosity(inputXml, diagnostics, lomTags, or
|
|
|
28076
28328
|
const stimulus = normalizeFinalText(transformAssetUrls(stimulusRaw, {
|
|
28077
28329
|
organisationId,
|
|
28078
28330
|
mediaVault,
|
|
28079
|
-
customAssetUrl
|
|
28331
|
+
customAssetUrl,
|
|
28332
|
+
...transformContext
|
|
28080
28333
|
}));
|
|
28081
28334
|
const entry = groupEntries[0];
|
|
28082
28335
|
const allCorrectResponses = entry.correctResponses ?? (entry.correctResponse ? [entry.correctResponse] : []);
|
|
@@ -28202,7 +28455,7 @@ function convertMixedInteractionsToLearnosity(inputXml, diagnostics, lomTags, or
|
|
|
28202
28455
|
continue;
|
|
28203
28456
|
}
|
|
28204
28457
|
const converter = CONVERTER_MAP[group.type];
|
|
28205
|
-
if (converter) processResult(converter(inputXml, subDiagnostics, lomTags, organisationId, sourceFile, mediaVault, customAssetUrl, itemReferenceSource, group.stimuli, fileAccess, packageRoot), subDiagnostics);
|
|
28458
|
+
if (converter) processResult(converter(inputXml, subDiagnostics, lomTags, organisationId, sourceFile, mediaVault, customAssetUrl, itemReferenceSource, group.stimuli, transformContext, fileAccess, packageRoot), subDiagnostics);
|
|
28206
28459
|
}
|
|
28207
28460
|
if (allQuestions.length === 0) {
|
|
28208
28461
|
diagnostics.push({
|
|
@@ -28225,9 +28478,16 @@ function convertMixedInteractionsToLearnosity(inputXml, diagnostics, lomTags, or
|
|
|
28225
28478
|
passageContent = transformAssetUrls(rawContent, {
|
|
28226
28479
|
organisationId,
|
|
28227
28480
|
mediaVault,
|
|
28228
|
-
customAssetUrl
|
|
28481
|
+
customAssetUrl,
|
|
28482
|
+
...transformContext
|
|
28483
|
+
});
|
|
28484
|
+
} catch (error) {
|
|
28485
|
+
if (isUnsafeQtiAssetHrefError(error)) diagnostics.push({
|
|
28486
|
+
code: DiagnosticCode.QTI_ASSET_HREF_UNSAFE,
|
|
28487
|
+
level: "error",
|
|
28488
|
+
file: sourceFile ?? "passage",
|
|
28489
|
+
message: error.message
|
|
28229
28490
|
});
|
|
28230
|
-
} catch {
|
|
28231
28491
|
passageContent = rawContent;
|
|
28232
28492
|
}
|
|
28233
28493
|
allFeatures.push({
|
|
@@ -28259,7 +28519,7 @@ function convertMixedInteractionsToLearnosity(inputXml, diagnostics, lomTags, or
|
|
|
28259
28519
|
const content = `<div class="row"><div class="col-xs-12">${[...featureSpans, ...questionSpans].join("")}</div></div>`;
|
|
28260
28520
|
const item = {
|
|
28261
28521
|
item: {
|
|
28262
|
-
reference:
|
|
28522
|
+
reference: itemRef,
|
|
28263
28523
|
title: metadata.title ?? void 0,
|
|
28264
28524
|
content,
|
|
28265
28525
|
definition: { widgets: allWidgets },
|
|
@@ -28305,8 +28565,13 @@ function resolvePassageObjects(html, sourceFile, resolvePassageFile) {
|
|
|
28305
28565
|
/**
|
|
28306
28566
|
* Convert passage-only item to Learnosity format with sharedpassage feature
|
|
28307
28567
|
*/
|
|
28308
|
-
function convertPassageToLearnosity(parsed, diagnostics, lomTags, organisationId, sourceFile, mediaVault, customAssetUrl, itemReferenceSource, fileAccess) {
|
|
28309
|
-
const itemRef = generateItemReference(parsed.identifier, itemReferenceSource, sourceFile);
|
|
28568
|
+
function convertPassageToLearnosity(parsed, diagnostics, lomTags, organisationId, sourceFile, mediaVault, customAssetUrl, itemReferenceSource, fileAccess, assetTransformContext) {
|
|
28569
|
+
const itemRef = assetTransformContext?.finalItemReference ?? generateItemReference(parsed.identifier, itemReferenceSource, sourceFile);
|
|
28570
|
+
const transformContext = {
|
|
28571
|
+
finalItemReference: itemRef,
|
|
28572
|
+
preserveAssetFilenames: assetTransformContext?.preserveAssetFilenames ?? false,
|
|
28573
|
+
sourceHrefBase: assetTransformContext?.sourceHrefBase
|
|
28574
|
+
};
|
|
28310
28575
|
const featureRef = `passage-${md5hex(getPassageDataPath(parsed.content) ?? itemRef).substring(0, 8)}`;
|
|
28311
28576
|
const resolvedContent = resolvePassageObjects(parsed.content, sourceFile, fileAccess?.resolvePassageFile.bind(fileAccess));
|
|
28312
28577
|
let content;
|
|
@@ -28314,11 +28579,12 @@ function convertPassageToLearnosity(parsed, diagnostics, lomTags, organisationId
|
|
|
28314
28579
|
content = transformAssetUrls(resolvedContent, {
|
|
28315
28580
|
organisationId,
|
|
28316
28581
|
mediaVault,
|
|
28317
|
-
customAssetUrl
|
|
28582
|
+
customAssetUrl,
|
|
28583
|
+
...transformContext
|
|
28318
28584
|
});
|
|
28319
28585
|
} catch (error) {
|
|
28320
28586
|
diagnostics.push({
|
|
28321
|
-
code: DiagnosticCode.LRN_SCHEMA_INVALID,
|
|
28587
|
+
code: isUnsafeQtiAssetHrefError(error) ? DiagnosticCode.QTI_ASSET_HREF_UNSAFE : DiagnosticCode.LRN_SCHEMA_INVALID,
|
|
28322
28588
|
level: "error",
|
|
28323
28589
|
file: sourceFile ?? "assessmentItem",
|
|
28324
28590
|
message: error instanceof Error ? error.message : "Failed to transform asset URLs"
|
|
@@ -28708,20 +28974,28 @@ function readAssessmentItemUpload(inputXml) {
|
|
|
28708
28974
|
* and the file limit from `maxChoices` (see readAssessmentItemUpload / the
|
|
28709
28975
|
* serializer). fileupload questions are unscored, so there is no validation.
|
|
28710
28976
|
*/
|
|
28711
|
-
function convertUploadToLearnosity(inputXml, diagnostics, lomTags, organisationId, sourceFile, mediaVault, customAssetUrl, itemReferenceSource) {
|
|
28977
|
+
function convertUploadToLearnosity(inputXml, diagnostics, lomTags, organisationId, sourceFile, mediaVault, customAssetUrl, itemReferenceSource, _stimulusOverride, assetTransformContext) {
|
|
28712
28978
|
const parsed = readAssessmentItemUpload(inputXml);
|
|
28713
28979
|
diagnostics.push(...parsed.diagnostics);
|
|
28714
28980
|
if (parsed.diagnostics.some((d) => d.level === "error")) return { diagnostics };
|
|
28715
|
-
const
|
|
28981
|
+
const generatedItemRef = generateItemReference(parsed.identifier ?? "item", itemReferenceSource, sourceFile);
|
|
28982
|
+
const itemRef = assetTransformContext?.finalItemReference ?? parsed.identifier ?? generatedItemRef;
|
|
28983
|
+
const transformContext = {
|
|
28984
|
+
finalItemReference: itemRef,
|
|
28985
|
+
preserveAssetFilenames: assetTransformContext?.preserveAssetFilenames ?? false,
|
|
28986
|
+
sourceHrefBase: assetTransformContext?.sourceHrefBase
|
|
28987
|
+
};
|
|
28716
28988
|
const questionRef = md5hex(itemRef + (parsed.responseIdentifier ?? "fileupload"));
|
|
28717
28989
|
const questionData = { type: "fileupload" };
|
|
28718
28990
|
if (parsed.stimulus) try {
|
|
28719
28991
|
questionData.stimulus = transformAssetUrls(parsed.stimulus, {
|
|
28720
28992
|
organisationId,
|
|
28721
28993
|
mediaVault,
|
|
28722
|
-
customAssetUrl
|
|
28994
|
+
customAssetUrl,
|
|
28995
|
+
...transformContext
|
|
28723
28996
|
});
|
|
28724
|
-
} catch {
|
|
28997
|
+
} catch (error) {
|
|
28998
|
+
if (isUnsafeQtiAssetHrefError(error)) throw error;
|
|
28725
28999
|
questionData.stimulus = parsed.stimulus;
|
|
28726
29000
|
}
|
|
28727
29001
|
for (const suffix of parsed.allowedFileTypes) questionData[`allow_${suffix}`] = true;
|
|
@@ -28729,7 +29003,7 @@ function convertUploadToLearnosity(inputXml, diagnostics, lomTags, organisationI
|
|
|
28729
29003
|
const content = `<span class="learnosity-response question-${questionRef}"></span>`;
|
|
28730
29004
|
const item = {
|
|
28731
29005
|
item: {
|
|
28732
|
-
reference:
|
|
29006
|
+
reference: itemRef,
|
|
28733
29007
|
title: parsed.title ?? void 0,
|
|
28734
29008
|
content,
|
|
28735
29009
|
definition: { widgets: [{
|
|
@@ -28764,9 +29038,19 @@ function convertUploadToLearnosity(inputXml, diagnostics, lomTags, organisationI
|
|
|
28764
29038
|
* - Rejects DOCTYPE / ENTITY declarations up-front (DTD not allowed).
|
|
28765
29039
|
* - Uses streaming parsers for all interaction types.
|
|
28766
29040
|
*/
|
|
29041
|
+
function getAssetSourceHrefBase(opts) {
|
|
29042
|
+
if (opts.sourceHrefBase) return opts.sourceHrefBase;
|
|
29043
|
+
const source = opts.sourceFile ?? opts.inputPath;
|
|
29044
|
+
if (!source) return;
|
|
29045
|
+
const normalized = source.replaceAll("\\", "/");
|
|
29046
|
+
return normalized.startsWith("/") || /^[A-Za-z]:/.test(normalized) || /^[A-Za-z][A-Za-z\d+.-]*:/.test(normalized) ? normalized.slice(normalized.lastIndexOf("/") + 1) : normalized;
|
|
29047
|
+
}
|
|
28767
29048
|
/**
|
|
28768
29049
|
* Supported interaction type names for counting
|
|
28769
29050
|
*/
|
|
29051
|
+
function isUnsafeAssetHrefError(error) {
|
|
29052
|
+
return error instanceof Error && (error.message.startsWith("Unsafe QTI asset href:") || error.message.startsWith("QTI asset href has no filename:"));
|
|
29053
|
+
}
|
|
28770
29054
|
const INTERACTION_NAMES = [
|
|
28771
29055
|
"choiceInteraction",
|
|
28772
29056
|
"textEntryInteraction",
|
|
@@ -28832,19 +29116,71 @@ function countAllInteractions(xml) {
|
|
|
28832
29116
|
};
|
|
28833
29117
|
}
|
|
28834
29118
|
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
|
-
|
|
29119
|
+
["choiceInteraction", (xml, diag, lom, opts, stim) => convertMcqToLearnosity(xml, diag, lom, opts.sourceFile, opts.organisationId, opts.mediaVault, opts.customAssetUrl, opts.itemReferenceSource, stim, {
|
|
29120
|
+
finalItemReference: opts.finalItemReference,
|
|
29121
|
+
preserveAssetFilenames: opts.preserveAssetFilenames ?? false,
|
|
29122
|
+
sourceHrefBase: getAssetSourceHrefBase(opts)
|
|
29123
|
+
})],
|
|
29124
|
+
["textEntryInteraction", (xml, diag, lom, opts, stim) => convertTextEntryToLearnosity(xml, diag, lom, opts.sourceFile, opts.organisationId, opts.mediaVault, opts.customAssetUrl, opts.itemReferenceSource, stim, {
|
|
29125
|
+
finalItemReference: opts.finalItemReference,
|
|
29126
|
+
preserveAssetFilenames: opts.preserveAssetFilenames ?? false,
|
|
29127
|
+
sourceHrefBase: getAssetSourceHrefBase(opts)
|
|
29128
|
+
})],
|
|
29129
|
+
["extendedTextInteraction", (xml, diag, lom, opts, stim) => convertExtendedTextToLearnosity(xml, diag, lom, opts.sourceFile, opts.organisationId, opts.mediaVault, opts.customAssetUrl, opts.itemReferenceSource, stim, {
|
|
29130
|
+
finalItemReference: opts.finalItemReference,
|
|
29131
|
+
preserveAssetFilenames: opts.preserveAssetFilenames ?? false,
|
|
29132
|
+
sourceHrefBase: getAssetSourceHrefBase(opts)
|
|
29133
|
+
})],
|
|
29134
|
+
["inlineChoiceInteraction", (xml, diag, lom, opts) => convertInlineChoiceToLearnosity(xml, diag, lom, opts.organisationId, opts.sourceFile, opts.mediaVault, opts.customAssetUrl, opts.itemReferenceSource, void 0, {
|
|
29135
|
+
finalItemReference: opts.finalItemReference,
|
|
29136
|
+
preserveAssetFilenames: opts.preserveAssetFilenames ?? false,
|
|
29137
|
+
sourceHrefBase: getAssetSourceHrefBase(opts)
|
|
29138
|
+
})],
|
|
29139
|
+
["matchInteraction", (xml, diag, lom, opts) => convertMatchToLearnosity(xml, diag, lom, opts.organisationId, opts.sourceFile, opts.mediaVault, opts.customAssetUrl, opts.itemReferenceSource, void 0, {
|
|
29140
|
+
finalItemReference: opts.finalItemReference,
|
|
29141
|
+
preserveAssetFilenames: opts.preserveAssetFilenames ?? false,
|
|
29142
|
+
sourceHrefBase: getAssetSourceHrefBase(opts)
|
|
29143
|
+
})],
|
|
29144
|
+
["gapMatchInteraction", (xml, diag, lom, opts) => convertGapMatchToLearnosity(xml, diag, lom, opts.organisationId, opts.sourceFile, opts.mediaVault, opts.customAssetUrl, opts.itemReferenceSource, void 0, {
|
|
29145
|
+
finalItemReference: opts.finalItemReference,
|
|
29146
|
+
preserveAssetFilenames: opts.preserveAssetFilenames ?? false,
|
|
29147
|
+
sourceHrefBase: getAssetSourceHrefBase(opts)
|
|
29148
|
+
})],
|
|
29149
|
+
["orderInteraction", (xml, diag, lom, opts) => convertOrderToLearnosity(xml, diag, lom, opts.organisationId, opts.sourceFile, opts.mediaVault, opts.customAssetUrl, opts.itemReferenceSource, void 0, {
|
|
29150
|
+
finalItemReference: opts.finalItemReference,
|
|
29151
|
+
preserveAssetFilenames: opts.preserveAssetFilenames ?? false,
|
|
29152
|
+
sourceHrefBase: getAssetSourceHrefBase(opts)
|
|
29153
|
+
})],
|
|
29154
|
+
["hotspotInteraction", (xml, diag, lom, opts) => convertHotspotToLearnosity(xml, diag, lom, opts.organisationId, opts.sourceFile, opts.mediaVault, opts.customAssetUrl, opts.itemReferenceSource, opts.fileAccess, opts.packageRoot, {
|
|
29155
|
+
finalItemReference: opts.finalItemReference,
|
|
29156
|
+
preserveAssetFilenames: opts.preserveAssetFilenames ?? false,
|
|
29157
|
+
sourceHrefBase: getAssetSourceHrefBase(opts)
|
|
29158
|
+
})],
|
|
29159
|
+
["hottextInteraction", (xml, diag, lom, opts) => convertHottextToLearnosity(xml, diag, lom, opts.organisationId, opts.sourceFile, opts.mediaVault, opts.customAssetUrl, opts.itemReferenceSource, void 0, {
|
|
29160
|
+
finalItemReference: opts.finalItemReference,
|
|
29161
|
+
preserveAssetFilenames: opts.preserveAssetFilenames ?? false,
|
|
29162
|
+
sourceHrefBase: getAssetSourceHrefBase(opts)
|
|
29163
|
+
})],
|
|
29164
|
+
["graphicGapMatchInteraction", (xml, diag, lom, opts) => convertGraphicGapMatchToLearnosity(xml, diag, lom, opts.organisationId, opts.sourceFile, opts.mediaVault, opts.customAssetUrl, opts.itemReferenceSource, void 0, {
|
|
29165
|
+
finalItemReference: opts.finalItemReference,
|
|
29166
|
+
preserveAssetFilenames: opts.preserveAssetFilenames ?? false,
|
|
29167
|
+
sourceHrefBase: getAssetSourceHrefBase(opts)
|
|
29168
|
+
})],
|
|
29169
|
+
["drawingInteraction", (xml, diag, lom, opts) => convertDrawingToLearnosity(xml, diag, lom, opts.organisationId, opts.sourceFile, opts.mediaVault, opts.customAssetUrl, opts.itemReferenceSource, void 0, {
|
|
29170
|
+
finalItemReference: opts.finalItemReference,
|
|
29171
|
+
preserveAssetFilenames: opts.preserveAssetFilenames ?? false,
|
|
29172
|
+
sourceHrefBase: getAssetSourceHrefBase(opts)
|
|
29173
|
+
})],
|
|
29174
|
+
["associateInteraction", (xml, diag, lom, opts) => convertAssociationToLearnosity(xml, diag, lom, opts.organisationId, opts.sourceFile, opts.mediaVault, opts.customAssetUrl, opts.itemReferenceSource, void 0, {
|
|
29175
|
+
finalItemReference: opts.finalItemReference,
|
|
29176
|
+
preserveAssetFilenames: opts.preserveAssetFilenames ?? false,
|
|
29177
|
+
sourceHrefBase: getAssetSourceHrefBase(opts)
|
|
29178
|
+
})],
|
|
29179
|
+
["uploadInteraction", (xml, diag, lom, opts) => convertUploadToLearnosity(xml, diag, lom, opts.organisationId, opts.sourceFile, opts.mediaVault, opts.customAssetUrl, opts.itemReferenceSource, void 0, {
|
|
29180
|
+
finalItemReference: opts.finalItemReference,
|
|
29181
|
+
preserveAssetFilenames: opts.preserveAssetFilenames ?? false,
|
|
29182
|
+
sourceHrefBase: getAssetSourceHrefBase(opts)
|
|
29183
|
+
})]
|
|
28848
29184
|
]);
|
|
28849
29185
|
/**
|
|
28850
29186
|
* Dispatch to the appropriate single-interaction converter
|
|
@@ -28870,9 +29206,18 @@ function dispatchSingleInteractionConverter(interactionType, inputXml, count, di
|
|
|
28870
29206
|
passageContent = transformAssetUrls(rawContent, {
|
|
28871
29207
|
organisationId: opts.organisationId,
|
|
28872
29208
|
mediaVault: opts.mediaVault,
|
|
28873
|
-
customAssetUrl: opts.customAssetUrl
|
|
29209
|
+
customAssetUrl: opts.customAssetUrl,
|
|
29210
|
+
finalItemReference: opts.finalItemReference ?? result.item.item.reference,
|
|
29211
|
+
preserveAssetFilenames: opts.preserveAssetFilenames ?? false,
|
|
29212
|
+
sourceHrefBase: getAssetSourceHrefBase(opts)
|
|
29213
|
+
});
|
|
29214
|
+
} catch (error) {
|
|
29215
|
+
if (isUnsafeAssetHrefError(error)) diagnostics.push({
|
|
29216
|
+
code: DiagnosticCode.QTI_ASSET_HREF_UNSAFE,
|
|
29217
|
+
level: "error",
|
|
29218
|
+
file: opts.sourceFile ?? "passage",
|
|
29219
|
+
message: error.message
|
|
28874
29220
|
});
|
|
28875
|
-
} catch {
|
|
28876
29221
|
passageContent = rawContent;
|
|
28877
29222
|
}
|
|
28878
29223
|
result.item.features = [...result.item.features, {
|
|
@@ -28920,8 +29265,16 @@ function handleNoInteractions(inputXml, diagnostics, allInteractions, lomTags, o
|
|
|
28920
29265
|
}
|
|
28921
29266
|
const passageResult = readAssessmentItemPassage(inputXml);
|
|
28922
29267
|
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
|
-
|
|
29268
|
+
if (passageResult.data) return convertPassageToLearnosity(passageResult.data, diagnostics, lomTags, opts.organisationId, opts.sourceFile, opts.mediaVault, opts.customAssetUrl, opts.itemReferenceSource, opts.fileAccess, {
|
|
29269
|
+
finalItemReference: opts.finalItemReference,
|
|
29270
|
+
preserveAssetFilenames: opts.preserveAssetFilenames ?? false,
|
|
29271
|
+
sourceHrefBase: getAssetSourceHrefBase(opts)
|
|
29272
|
+
});
|
|
29273
|
+
const mcqResult = convertMcqToLearnosity(inputXml, diagnostics, lomTags, opts.sourceFile, opts.organisationId, opts.mediaVault, opts.customAssetUrl, opts.itemReferenceSource, void 0, {
|
|
29274
|
+
finalItemReference: opts.finalItemReference,
|
|
29275
|
+
preserveAssetFilenames: opts.preserveAssetFilenames ?? false,
|
|
29276
|
+
sourceHrefBase: getAssetSourceHrefBase(opts)
|
|
29277
|
+
});
|
|
28925
29278
|
if (diagnostics.some((d) => d.code === DiagnosticCode.LRN_SCHEMA_INVALID)) return mcqResult;
|
|
28926
29279
|
return { diagnostics };
|
|
28927
29280
|
}
|
|
@@ -28967,14 +29320,18 @@ function convertQtiAssessmentItemToLearnosity(inputXml, opts = {}) {
|
|
|
28967
29320
|
const { counts, allInteractions } = countAllInteractions(inputXml);
|
|
28968
29321
|
const presentTypes = INTERACTION_NAMES.filter((name) => counts[name] > 0);
|
|
28969
29322
|
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
|
|
29323
|
+
if (presentTypes.length > 1) return convertMixedInteractionsToLearnosity(inputXml, diagnostics, lomTags, opts.organisationId, opts.sourceFile, opts.mediaVault, opts.customAssetUrl, opts.itemReferenceSource, opts.fileAccess, opts.packageRoot, {
|
|
29324
|
+
finalItemReference: opts.finalItemReference,
|
|
29325
|
+
preserveAssetFilenames: opts.preserveAssetFilenames ?? false,
|
|
29326
|
+
sourceHrefBase: getAssetSourceHrefBase(opts)
|
|
29327
|
+
});
|
|
28971
29328
|
return dispatchSingleInteractionConverter(presentTypes[0], inputXml, counts[presentTypes[0]], diagnostics, lomTags, opts);
|
|
28972
29329
|
} catch (error) {
|
|
28973
29330
|
diagnostics.push({
|
|
28974
|
-
code: DiagnosticCode.LRN_SCHEMA_INVALID,
|
|
29331
|
+
code: isUnsafeAssetHrefError(error) ? DiagnosticCode.QTI_ASSET_HREF_UNSAFE : DiagnosticCode.LRN_SCHEMA_INVALID,
|
|
28975
29332
|
level: "error",
|
|
28976
|
-
file: "root",
|
|
28977
|
-
message: `Failed to parse QTI XML: ${error instanceof Error ? error.message : "Unknown error"}`
|
|
29333
|
+
file: opts.sourceFile ?? "root",
|
|
29334
|
+
message: isUnsafeAssetHrefError(error) ? error.message : `Failed to parse QTI XML: ${error instanceof Error ? error.message : "Unknown error"}`
|
|
28978
29335
|
});
|
|
28979
29336
|
return { diagnostics };
|
|
28980
29337
|
}
|
|
@@ -31318,6 +31675,6 @@ function formatDiagnosticsSummaryTable(diagnostics) {
|
|
|
31318
31675
|
return table.toString();
|
|
31319
31676
|
}
|
|
31320
31677
|
//#endregion
|
|
31321
|
-
export { mapLearnosityToAst as _, require_cli_table3 as a,
|
|
31678
|
+
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
31679
|
|
|
31323
|
-
//# sourceMappingURL=table-
|
|
31680
|
+
//# sourceMappingURL=table-DTSv0atR.js.map
|