@learnosity/lib-qti-converter 0.16.0 → 0.16.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/package.json +10 -10
- package/packages/cli/dist/{batchProcessors-C7czhqX0.js → batchProcessors-BGdELwug.js} +75 -102
- package/packages/cli/dist/batchProcessors-BGdELwug.js.map +1 -0
- package/packages/cli/dist/batchWorker.js +2 -3
- package/packages/cli/dist/{configOutput-FwkFyQmk.js → configOutput-DYPwNQf7.js} +5 -9
- package/packages/cli/dist/{configOutput-FwkFyQmk.js.map → configOutput-DYPwNQf7.js.map} +1 -1
- package/packages/cli/dist/{create-prompt-dWckcotJ.js → create-prompt-C3XKo-s3.js} +95 -71
- package/packages/cli/dist/create-prompt-C3XKo-s3.js.map +1 -0
- package/packages/cli/dist/{dist-DXDR2peT.js → dist-D7b9-VIt.js} +8 -11
- package/packages/cli/dist/dist-D7b9-VIt.js.map +1 -0
- package/packages/cli/dist/{learnosityToQti-D4ddrXaz.js → learnosityToQti-CN6KKSmF.js} +5 -6
- package/packages/cli/dist/{learnosityToQti-D4ddrXaz.js.map → learnosityToQti-CN6KKSmF.js.map} +1 -1
- package/packages/cli/dist/{learnosityToQtiPackage-Bwzm-uLX.js → learnosityToQtiPackage-CMOQRiCV.js} +29 -21
- package/packages/cli/dist/learnosityToQtiPackage-CMOQRiCV.js.map +1 -0
- package/packages/cli/dist/main.js +22 -29
- package/packages/cli/dist/main.js.map +1 -1
- package/packages/cli/dist/{nodeFileAccess-BhCoGDOi.js → nodeFileAccess-_jRCd340.js} +6 -10
- package/packages/cli/dist/{nodeFileAccess-BhCoGDOi.js.map → nodeFileAccess-_jRCd340.js.map} +1 -1
- package/packages/cli/dist/pathUtils-I2bRHUwu.js +2922 -0
- package/packages/cli/dist/pathUtils-I2bRHUwu.js.map +1 -0
- package/packages/cli/dist/{qtiPackageToLearnosity-CX9htPId.js → qtiPackageToLearnosity-JRb3TTyC.js} +7 -8
- package/packages/cli/dist/{qtiPackageToLearnosity-CX9htPId.js.map → qtiPackageToLearnosity-JRb3TTyC.js.map} +1 -1
- package/packages/cli/dist/{qtiToLearnosity-JQYOkNbM.js → qtiToLearnosity-C-jQYKqR.js} +6 -7
- package/packages/cli/dist/{qtiToLearnosity-JQYOkNbM.js.map → qtiToLearnosity-C-jQYKqR.js.map} +1 -1
- package/packages/cli/dist/{resolveOptions-BuNN2KMA.js → resolveOptions-ikupjaRQ.js} +322 -359
- package/packages/cli/dist/resolveOptions-ikupjaRQ.js.map +1 -0
- package/packages/cli/dist/{rolldown-runtime-DktXgydw.js → rolldown-runtime-BuRBZLzk.js} +13 -12
- package/packages/cli/dist/{table-DsKq-B4-.js → table-6SiZD7aK.js} +9944 -2294
- package/packages/cli/dist/table-6SiZD7aK.js.map +1 -0
- package/packages/core/dist/index.d.ts +8 -58
- package/packages/core/dist/index.js +9923 -2267
- package/packages/core/dist/node.d.ts +10 -80
- package/packages/core/dist/node.js +9951 -2311
- package/packages/cli/dist/batchProcessors-C7czhqX0.js.map +0 -1
- package/packages/cli/dist/create-prompt-dWckcotJ.js.map +0 -1
- package/packages/cli/dist/dist-DXDR2peT.js.map +0 -1
- package/packages/cli/dist/learnosityToQtiPackage-Bwzm-uLX.js.map +0 -1
- package/packages/cli/dist/pathUtils-D_VsVde8.js +0 -2272
- package/packages/cli/dist/pathUtils-D_VsVde8.js.map +0 -1
- package/packages/cli/dist/resolveOptions-BuNN2KMA.js.map +0 -1
- package/packages/cli/dist/table-DsKq-B4-.js.map +0 -1
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@learnosity/lib-qti-converter",
|
|
3
|
-
"version": "0.16.
|
|
3
|
+
"version": "0.16.2",
|
|
4
4
|
"type": "module",
|
|
5
5
|
"description": "QTI ↔ Learnosity JSON converter",
|
|
6
6
|
"license": "MIT",
|
|
@@ -73,19 +73,19 @@
|
|
|
73
73
|
},
|
|
74
74
|
"devDependencies": {
|
|
75
75
|
"@arethetypeswrong/cli": "^0.18.5",
|
|
76
|
-
"@types/node": "^26.6.
|
|
77
|
-
"@typescript-eslint/eslint-plugin": "^8.
|
|
78
|
-
"@typescript-eslint/parser": "^8.
|
|
76
|
+
"@types/node": "^26.6.10",
|
|
77
|
+
"@typescript-eslint/eslint-plugin": "^8.74.0",
|
|
78
|
+
"@typescript-eslint/parser": "^8.74.0",
|
|
79
79
|
"@typescript/native": "npm:typescript@^7.0.2",
|
|
80
|
-
"@vitest/coverage-v8": "^
|
|
81
|
-
"eslint": "^10.
|
|
82
|
-
"glob": "^
|
|
80
|
+
"@vitest/coverage-v8": "^5.1.2",
|
|
81
|
+
"eslint": "^10.15.0",
|
|
82
|
+
"glob": "^14.0.6",
|
|
83
83
|
"publint": "^0.3.25",
|
|
84
|
-
"tsdown": "^0.23.
|
|
84
|
+
"tsdown": "^0.23.7",
|
|
85
85
|
"tsx": "^4.23.15",
|
|
86
86
|
"typescript": "npm:@typescript/typescript6@^6.0.2",
|
|
87
|
-
"vite": "^8.3.
|
|
88
|
-
"vitest": "^
|
|
87
|
+
"vite": "^8.3.8",
|
|
88
|
+
"vitest": "^5.1.2"
|
|
89
89
|
},
|
|
90
90
|
"engines": {
|
|
91
91
|
"node": ">=22.0.0"
|
|
@@ -1,13 +1,13 @@
|
|
|
1
|
-
import
|
|
2
|
-
import { t as nodeFileAccess } from "./nodeFileAccess-BhCoGDOi.js";
|
|
3
|
-
import * as path$1 from "node:path";
|
|
4
|
-
import { join, relative, sep } from "node:path";
|
|
5
|
-
import * as fs$1 from "node:fs";
|
|
1
|
+
import * as fs from "node:fs";
|
|
6
2
|
import { existsSync, readFileSync, readdirSync, statSync, writeFileSync } from "node:fs";
|
|
3
|
+
import * as path from "node:path";
|
|
4
|
+
import { join, relative, sep } from "node:path";
|
|
7
5
|
import * as crypto from "node:crypto";
|
|
6
|
+
import { C as escapeXml$3, D as DiagnosticCode, E as parseLearnosityItem, S as buildGapImageSvgFromText, T as normalizeXhtmlVoidElements, _ as getAttr$2, b as downgradeAssessmentTestToQti21, c as convertQtiAssessmentItemToLearnosity, d as generateItemReference, f as canonicalizeQtiAssetHref, g as md5hex, h as serializeQtiAssetIdentity, l as parseMetadataTags, m as selectQtiAssetFilename, n as formatDiagnosticsSummaryTable, o as writeDiagnostics, p as isSupportedQtiAssetPath, s as transformForwardAssetUrlsInXml, u as getAllPassageDataPaths, v as require_saxes, w as sanitizeHtmlContent, x as mapLearnosityToAst, y as serializeAssessmentItem } from "./table-6SiZD7aK.js";
|
|
8
7
|
import { createRequire } from "module";
|
|
9
8
|
import { mkdir, writeFile } from "node:fs/promises";
|
|
10
|
-
|
|
9
|
+
import { t as nodeFileAccess } from "./nodeFileAccess-_jRCd340.js";
|
|
10
|
+
// ../core/src/qti-package/pathSafety.ts
|
|
11
11
|
var import_saxes = require_saxes();
|
|
12
12
|
/**
|
|
13
13
|
* ZIP entry path safety validation (zip-slip protection)
|
|
@@ -30,8 +30,7 @@ function validateZipEntryPath(entryPath) {
|
|
|
30
30
|
if (normalized.includes("..")) return null;
|
|
31
31
|
return normalized;
|
|
32
32
|
}
|
|
33
|
-
|
|
34
|
-
//#region ../core/src/qti-package/parseManifest.ts
|
|
33
|
+
// ../core/src/qti-package/parseManifest.ts
|
|
35
34
|
/**
|
|
36
35
|
* IMS manifest XML parsing using saxes
|
|
37
36
|
*/
|
|
@@ -159,8 +158,7 @@ function parseManifest(manifestXml, zipPath) {
|
|
|
159
158
|
diagnostics
|
|
160
159
|
};
|
|
161
160
|
}
|
|
162
|
-
|
|
163
|
-
//#region ../core/src/qti-package/uuid.ts
|
|
161
|
+
// ../core/src/qti-package/uuid.ts
|
|
164
162
|
/**
|
|
165
163
|
* Dependency-free RFC 4122 version-4 UUID generator.
|
|
166
164
|
*
|
|
@@ -177,8 +175,7 @@ function uuidv4() {
|
|
|
177
175
|
bytes[8] = bytes[8] & 63 | 128;
|
|
178
176
|
return HEX[bytes[0]] + HEX[bytes[1]] + HEX[bytes[2]] + HEX[bytes[3]] + "-" + HEX[bytes[4]] + HEX[bytes[5]] + "-" + HEX[bytes[6]] + HEX[bytes[7]] + "-" + HEX[bytes[8]] + HEX[bytes[9]] + "-" + HEX[bytes[10]] + HEX[bytes[11]] + HEX[bytes[12]] + HEX[bytes[13]] + HEX[bytes[14]] + HEX[bytes[15]];
|
|
179
177
|
}
|
|
180
|
-
|
|
181
|
-
//#region ../core/src/qti-package/buildManifest.ts
|
|
178
|
+
// ../core/src/qti-package/buildManifest.ts
|
|
182
179
|
/**
|
|
183
180
|
* IMS manifest XML generation
|
|
184
181
|
*/
|
|
@@ -236,8 +233,7 @@ function buildManifest(resources, version = "2.2") {
|
|
|
236
233
|
function escapeXml$2(str) {
|
|
237
234
|
return str.replace(/&/g, "&").replace(/</g, "<").replace(/>/g, ">").replace(/"/g, """).replace(/'/g, "'");
|
|
238
235
|
}
|
|
239
|
-
|
|
240
|
-
//#region ../core/src/qti-package/testDependencies.ts
|
|
236
|
+
// ../core/src/qti-package/testDependencies.ts
|
|
241
237
|
/**
|
|
242
238
|
* Extract item and stimulus dependencies from QTI assessmentTest XML,
|
|
243
239
|
* and map hrefs to manifest resource identifiers.
|
|
@@ -300,8 +296,7 @@ function mapHrefToResourceId(href) {
|
|
|
300
296
|
}
|
|
301
297
|
return null;
|
|
302
298
|
}
|
|
303
|
-
|
|
304
|
-
//#region ../core/src/learnosity-mapper/mapActivityToTest.ts
|
|
299
|
+
// ../core/src/learnosity-mapper/mapActivityToTest.ts
|
|
305
300
|
/**
|
|
306
301
|
* Maps Learnosity Activity to QTI 2.2 assessmentTest AST (TASK 005)
|
|
307
302
|
*/
|
|
@@ -418,8 +413,7 @@ function mapSectionsToQti(learnositySections, activityTitle, diagnostics) {
|
|
|
418
413
|
navigationMode: hasLinearSection ? "linear" : "nonlinear"
|
|
419
414
|
};
|
|
420
415
|
}
|
|
421
|
-
|
|
422
|
-
//#region ../core/src/learnosity-mapper/mapStimulusToAst.ts
|
|
416
|
+
// ../core/src/learnosity-mapper/mapStimulusToAst.ts
|
|
423
417
|
/**
|
|
424
418
|
* Convert Learnosity sharedpassage to QTI assessmentStimulus
|
|
425
419
|
*/
|
|
@@ -520,8 +514,7 @@ function sanitizeIdentifier(ref) {
|
|
|
520
514
|
function escapeXml$1(text) {
|
|
521
515
|
return text.replace(/&/g, "&").replace(/</g, "<").replace(/>/g, ">").replace(/"/g, """).replace(/'/g, "'");
|
|
522
516
|
}
|
|
523
|
-
|
|
524
|
-
//#region ../core/src/qti-serializer/serializeAssessmentStimulus.ts
|
|
517
|
+
// ../core/src/qti-serializer/serializeAssessmentStimulus.ts
|
|
525
518
|
/**
|
|
526
519
|
* Serialize QtiAssessmentStimulus to HTML (for embedding via object element)
|
|
527
520
|
* Returns just the stimulus body HTML without QTI XML wrapper
|
|
@@ -552,8 +545,7 @@ ${bodyContent}
|
|
|
552
545
|
function escapeXml(text) {
|
|
553
546
|
return text.replace(/&/g, "&").replace(/</g, "<").replace(/>/g, ">").replace(/"/g, """).replace(/'/g, "'");
|
|
554
547
|
}
|
|
555
|
-
|
|
556
|
-
//#region ../core/src/qti-serializer/serializeAssessmentTest.ts
|
|
548
|
+
// ../core/src/qti-serializer/serializeAssessmentTest.ts
|
|
557
549
|
/**
|
|
558
550
|
* Serializes QTI 2.2/2.1 assessmentTest AST to XML (TASK 005, TASK 008)
|
|
559
551
|
*/
|
|
@@ -638,8 +630,7 @@ function buildAssessmentTestXml(test, pretty, version) {
|
|
|
638
630
|
if (pretty) parts.push("\n");
|
|
639
631
|
return parts.join("");
|
|
640
632
|
}
|
|
641
|
-
|
|
642
|
-
//#region ../core/src/learnosity-mapper/convertActivity.ts
|
|
633
|
+
// ../core/src/learnosity-mapper/convertActivity.ts
|
|
643
634
|
/**
|
|
644
635
|
* Convert Learnosity Activity to QTI (TASK 005, TASK 008, TASK 023)
|
|
645
636
|
*
|
|
@@ -898,8 +889,7 @@ function extractSections(rawSections, convertedItems) {
|
|
|
898
889
|
}
|
|
899
890
|
return sections;
|
|
900
891
|
}
|
|
901
|
-
|
|
902
|
-
//#region ../core/src/learnosity-mapper/sanitizeFolderName.ts
|
|
892
|
+
// ../core/src/learnosity-mapper/sanitizeFolderName.ts
|
|
903
893
|
/**
|
|
904
894
|
* Sanitize activity reference for use as folder name
|
|
905
895
|
*/
|
|
@@ -943,8 +933,7 @@ function ensureUniqueFolderName(desiredName, usedNames) {
|
|
|
943
933
|
usedNames.add(uniqueName);
|
|
944
934
|
return uniqueName;
|
|
945
935
|
}
|
|
946
|
-
|
|
947
|
-
//#region ../core/src/learnosity-mapper/mergeActivityPackage.ts
|
|
936
|
+
// ../core/src/learnosity-mapper/mergeActivityPackage.ts
|
|
948
937
|
/**
|
|
949
938
|
* Rewrite item/stimulus/asset hrefs inside an assessmentTest that has been moved
|
|
950
939
|
* into tests/<folderName>/ (two levels deep) so they resolve against the package root.
|
|
@@ -1008,8 +997,7 @@ function mergeActivityPackage(pkg, folderName, packageResult, addedResourceIds)
|
|
|
1008
997
|
pkg.items.push(...actPackage.items);
|
|
1009
998
|
for (const asset of actPackage.assets) if (!pkg.assets.some((a) => a.identifier === asset.identifier)) pkg.assets.push(asset);
|
|
1010
999
|
}
|
|
1011
|
-
|
|
1012
|
-
//#region ../core/src/qti-to-learnosity/convertAssessmentTestToActivity.ts
|
|
1000
|
+
// ../core/src/qti-to-learnosity/convertAssessmentTestToActivity.ts
|
|
1013
1001
|
/**
|
|
1014
1002
|
* QTI assessmentTest → Learnosity Activity converter (streaming-safe, v1)
|
|
1015
1003
|
* TASK 013
|
|
@@ -1150,8 +1138,7 @@ function convertAssessmentTestToLearnosityActivity(inputXml) {
|
|
|
1150
1138
|
return { diagnostics };
|
|
1151
1139
|
}
|
|
1152
1140
|
}
|
|
1153
|
-
|
|
1154
|
-
//#region ../../node_modules/.pnpm/fflate@0.8.3/node_modules/fflate/esm/index.mjs
|
|
1141
|
+
// ../../node_modules/.pnpm/fflate@0.8.3/node_modules/fflate/esm/index.mjs
|
|
1155
1142
|
var require = createRequire("/");
|
|
1156
1143
|
var _a;
|
|
1157
1144
|
try {
|
|
@@ -1892,7 +1879,7 @@ function strToU8(str, latin1) {
|
|
|
1892
1879
|
var c = str.charCodeAt(i);
|
|
1893
1880
|
if (c < 128 || latin1) w(c);
|
|
1894
1881
|
else if (c < 2048) w(192 | c >> 6), w(128 | c & 63);
|
|
1895
|
-
else if (c > 55295 && c < 57344) c = 65536 + (c &
|
|
1882
|
+
else if (c > 55295 && c < 57344) c = 65536 + (c & 0xffc00) | str.charCodeAt(++i) & 1023, w(240 | c >> 18), w(128 | c >> 12 & 63), w(128 | c >> 6 & 63), w(128 | c & 63);
|
|
1896
1883
|
else w(224 | c >> 12), w(128 | c >> 6 & 63), w(128 | c & 63);
|
|
1897
1884
|
}
|
|
1898
1885
|
return slc(ar, 0, ai);
|
|
@@ -1932,7 +1919,7 @@ var zh = function(d, b, z) {
|
|
|
1932
1919
|
];
|
|
1933
1920
|
};
|
|
1934
1921
|
var z64hs = function(d, b, l, z, sc, su, off) {
|
|
1935
|
-
var nsc = sc ==
|
|
1922
|
+
var nsc = sc == 0xffffffff, nsu = su == 0xffffffff, noff = off == 0xffffffff, e = b + l;
|
|
1936
1923
|
var nf = nsc + nsu + noff;
|
|
1937
1924
|
if (z && nf) {
|
|
1938
1925
|
for (; b + 4 < e; b += 4 + b2(d, b + 2)) if (b2(d, b) == 1) return [
|
|
@@ -1994,7 +1981,7 @@ var wzh = function(d, b, f, fn, u, c, ce, co) {
|
|
|
1994
1981
|
return b;
|
|
1995
1982
|
};
|
|
1996
1983
|
var wzf = function(o, b, c, d, e) {
|
|
1997
|
-
wbytes(o, b,
|
|
1984
|
+
wbytes(o, b, 0x6054b50);
|
|
1998
1985
|
wbytes(o, b + 8, c);
|
|
1999
1986
|
wbytes(o, b + 10, c);
|
|
2000
1987
|
wbytes(o, b + 12, d);
|
|
@@ -2058,14 +2045,14 @@ function zipSync(data, opts) {
|
|
|
2058
2045
|
function unzipSync(data, opts) {
|
|
2059
2046
|
var files = {};
|
|
2060
2047
|
var e = data.length - 22;
|
|
2061
|
-
for (; b4(data, e) !=
|
|
2048
|
+
for (; b4(data, e) != 0x6054b50; --e) if (!e || data.length - e > 65558) err(13);
|
|
2062
2049
|
var c = b2(data, e + 8);
|
|
2063
2050
|
if (!c) return {};
|
|
2064
2051
|
var o = b4(data, e + 16);
|
|
2065
|
-
var z = b4(data, e - 20) ==
|
|
2052
|
+
var z = b4(data, e - 20) == 0x7064b50;
|
|
2066
2053
|
if (z) {
|
|
2067
2054
|
var ze = b4(data, e - 12);
|
|
2068
|
-
z = b4(data, ze) ==
|
|
2055
|
+
z = b4(data, ze) == 0x6064b50;
|
|
2069
2056
|
if (z) {
|
|
2070
2057
|
c = b4(data, ze + 32);
|
|
2071
2058
|
o = b4(data, ze + 48);
|
|
@@ -2073,7 +2060,7 @@ function unzipSync(data, opts) {
|
|
|
2073
2060
|
}
|
|
2074
2061
|
var fltr = opts && opts.filter;
|
|
2075
2062
|
for (var i = 0; i < c; ++i) {
|
|
2076
|
-
var _a = zh(data, o, z), c_2 = _a[0], sc = _a[1], su = _a[2], fn = _a[3], no = _a[4],
|
|
2063
|
+
var _a = zh(data, o, z), c_2 = _a[0], sc = _a[1], su = _a[2], fn = _a[3], no = _a[4], b = slzh(data, _a[5]);
|
|
2077
2064
|
o = no;
|
|
2078
2065
|
if (!fltr || fltr({
|
|
2079
2066
|
name: fn,
|
|
@@ -2088,8 +2075,7 @@ function unzipSync(data, opts) {
|
|
|
2088
2075
|
}
|
|
2089
2076
|
return files;
|
|
2090
2077
|
}
|
|
2091
|
-
|
|
2092
|
-
//#region ../core/src/qti-package/zipCodec.ts
|
|
2078
|
+
// ../core/src/qti-package/zipCodec.ts
|
|
2093
2079
|
/**
|
|
2094
2080
|
* Pure ZIP codec backed by fflate.
|
|
2095
2081
|
*
|
|
@@ -2171,8 +2157,7 @@ function zipEntriesToBytes(files) {
|
|
|
2171
2157
|
function textToBytes(text) {
|
|
2172
2158
|
return strToU8(text);
|
|
2173
2159
|
}
|
|
2174
|
-
|
|
2175
|
-
//#region ../core/src/qti-to-learnosity/utils/assetFilenameRegistry.ts
|
|
2160
|
+
// ../core/src/qti-to-learnosity/utils/assetFilenameRegistry.ts
|
|
2176
2161
|
/**
|
|
2177
2162
|
* Browser-safe registry for item-scoped QTI asset filenames.
|
|
2178
2163
|
*
|
|
@@ -2273,8 +2258,7 @@ var AssetFilenameRegistry = class {
|
|
|
2273
2258
|
this.byFilename.clear();
|
|
2274
2259
|
}
|
|
2275
2260
|
};
|
|
2276
|
-
|
|
2277
|
-
//#region ../core/src/qti-to-learnosity/convertQtiPackageToLearnosityBundle.ts
|
|
2261
|
+
// ../core/src/qti-to-learnosity/convertQtiPackageToLearnosityBundle.ts
|
|
2278
2262
|
/**
|
|
2279
2263
|
* QTI Content Package → Learnosity Bundle converter (v1)
|
|
2280
2264
|
* TASK 014
|
|
@@ -2863,8 +2847,7 @@ function convertQtiPackageToLearnosityBundle(input, opts) {
|
|
|
2863
2847
|
return { diagnostics };
|
|
2864
2848
|
}
|
|
2865
2849
|
}
|
|
2866
|
-
|
|
2867
|
-
//#region ../core/src/qti-package/writeZip.ts
|
|
2850
|
+
// ../core/src/qti-package/writeZip.ts
|
|
2868
2851
|
/**
|
|
2869
2852
|
* Deterministic ZIP writing (Node.js file-path entry point).
|
|
2870
2853
|
*
|
|
@@ -2890,8 +2873,7 @@ function writeZip(zipPath, files) {
|
|
|
2890
2873
|
}));
|
|
2891
2874
|
writeFileSync(zipPath, zipEntriesToBytes(entries));
|
|
2892
2875
|
}
|
|
2893
|
-
|
|
2894
|
-
//#region ../core/src/qti-package/savePackage.ts
|
|
2876
|
+
// ../core/src/qti-package/savePackage.ts
|
|
2895
2877
|
/**
|
|
2896
2878
|
* QTI Content Package saving to ZIP or directory
|
|
2897
2879
|
*/
|
|
@@ -2937,21 +2919,20 @@ function saveQtiContentPackage(pkg, outputPath) {
|
|
|
2937
2919
|
* @param files Array of files to write
|
|
2938
2920
|
*/
|
|
2939
2921
|
function writeDirectory(dirPath, files) {
|
|
2940
|
-
if (!fs
|
|
2922
|
+
if (!fs.existsSync(dirPath)) fs.mkdirSync(dirPath, { recursive: true });
|
|
2941
2923
|
for (const file of files) {
|
|
2942
|
-
const fullPath = path
|
|
2924
|
+
const fullPath = path.join(dirPath, file.path);
|
|
2943
2925
|
if (file.path.endsWith("/")) {
|
|
2944
|
-
if (!fs
|
|
2926
|
+
if (!fs.existsSync(fullPath)) fs.mkdirSync(fullPath, { recursive: true });
|
|
2945
2927
|
continue;
|
|
2946
2928
|
}
|
|
2947
|
-
const dir = path
|
|
2948
|
-
if (!fs
|
|
2929
|
+
const dir = path.dirname(fullPath);
|
|
2930
|
+
if (!fs.existsSync(dir)) fs.mkdirSync(dir, { recursive: true });
|
|
2949
2931
|
const content = typeof file.content === "string" ? file.content : file.content;
|
|
2950
|
-
fs
|
|
2932
|
+
fs.writeFileSync(fullPath, content);
|
|
2951
2933
|
}
|
|
2952
2934
|
}
|
|
2953
|
-
|
|
2954
|
-
//#region ../core/src/learnosity-bundle/pathSafetyFs.ts
|
|
2935
|
+
// ../core/src/learnosity-bundle/pathSafetyFs.ts
|
|
2955
2936
|
/**
|
|
2956
2937
|
* Path safety validation for filesystem operations
|
|
2957
2938
|
* Part of TASK 004D - prevents directory traversal attacks similar to zip-slip protection
|
|
@@ -2970,13 +2951,13 @@ function writeDirectory(dirPath, files) {
|
|
|
2970
2951
|
* @returns true if safe, false otherwise
|
|
2971
2952
|
*/
|
|
2972
2953
|
function isPathSafe(relativePath, baseDir) {
|
|
2973
|
-
if (path
|
|
2974
|
-
const normalized = path
|
|
2954
|
+
if (path.isAbsolute(relativePath)) return false;
|
|
2955
|
+
const normalized = path.normalize(relativePath);
|
|
2975
2956
|
if (normalized.includes("..")) return false;
|
|
2976
|
-
const fullPath = path
|
|
2977
|
-
const resolvedBase = path
|
|
2978
|
-
const resolvedFull = path
|
|
2979
|
-
if (!resolvedFull.startsWith(resolvedBase + path
|
|
2957
|
+
const fullPath = path.join(baseDir, normalized);
|
|
2958
|
+
const resolvedBase = path.resolve(baseDir);
|
|
2959
|
+
const resolvedFull = path.resolve(fullPath);
|
|
2960
|
+
if (!resolvedFull.startsWith(resolvedBase + path.sep) && resolvedFull !== resolvedBase) return false;
|
|
2980
2961
|
return true;
|
|
2981
2962
|
}
|
|
2982
2963
|
/**
|
|
@@ -2987,7 +2968,7 @@ function isPathSafe(relativePath, baseDir) {
|
|
|
2987
2968
|
*/
|
|
2988
2969
|
function isSymlink(fullPath) {
|
|
2989
2970
|
try {
|
|
2990
|
-
return fs
|
|
2971
|
+
return fs.lstatSync(fullPath).isSymbolicLink();
|
|
2991
2972
|
} catch {
|
|
2992
2973
|
return false;
|
|
2993
2974
|
}
|
|
@@ -3002,12 +2983,11 @@ function isSymlink(fullPath) {
|
|
|
3002
2983
|
*/
|
|
3003
2984
|
function safeResolve(relativePath, baseDir) {
|
|
3004
2985
|
if (!isPathSafe(relativePath, baseDir)) return null;
|
|
3005
|
-
const fullPath = path
|
|
2986
|
+
const fullPath = path.join(baseDir, relativePath);
|
|
3006
2987
|
if (isSymlink(fullPath)) return null;
|
|
3007
2988
|
return fullPath;
|
|
3008
2989
|
}
|
|
3009
|
-
|
|
3010
|
-
//#region ../core/src/learnosity-bundle/loadLearnosityBundle.ts
|
|
2990
|
+
// ../core/src/learnosity-bundle/loadLearnosityBundle.ts
|
|
3011
2991
|
/**
|
|
3012
2992
|
* Learnosity bundle loader (manifest.json + activities + items + assets)
|
|
3013
2993
|
* Part of TASK 004D
|
|
@@ -3020,7 +3000,7 @@ function safeResolve(relativePath, baseDir) {
|
|
|
3020
3000
|
*/
|
|
3021
3001
|
function loadLearnosityBundle(bundleDir) {
|
|
3022
3002
|
const diagnostics = [];
|
|
3023
|
-
if (!fs
|
|
3003
|
+
if (!fs.existsSync(bundleDir)) {
|
|
3024
3004
|
diagnostics.push({
|
|
3025
3005
|
code: DiagnosticCode.LRN_BUNDLE_DIR_NOT_FOUND,
|
|
3026
3006
|
level: "error",
|
|
@@ -3029,7 +3009,7 @@ function loadLearnosityBundle(bundleDir) {
|
|
|
3029
3009
|
});
|
|
3030
3010
|
return { diagnostics };
|
|
3031
3011
|
}
|
|
3032
|
-
if (!fs
|
|
3012
|
+
if (!fs.statSync(bundleDir).isDirectory()) {
|
|
3033
3013
|
diagnostics.push({
|
|
3034
3014
|
code: DiagnosticCode.LRN_BUNDLE_DIR_NOT_FOUND,
|
|
3035
3015
|
level: "error",
|
|
@@ -3038,8 +3018,8 @@ function loadLearnosityBundle(bundleDir) {
|
|
|
3038
3018
|
});
|
|
3039
3019
|
return { diagnostics };
|
|
3040
3020
|
}
|
|
3041
|
-
const manifestPath = path
|
|
3042
|
-
if (!fs
|
|
3021
|
+
const manifestPath = path.join(bundleDir, "manifest.json");
|
|
3022
|
+
if (!fs.existsSync(manifestPath)) {
|
|
3043
3023
|
diagnostics.push({
|
|
3044
3024
|
code: DiagnosticCode.LRN_MANIFEST_MISSING,
|
|
3045
3025
|
level: "error",
|
|
@@ -3050,7 +3030,7 @@ function loadLearnosityBundle(bundleDir) {
|
|
|
3050
3030
|
}
|
|
3051
3031
|
let manifestRaw;
|
|
3052
3032
|
try {
|
|
3053
|
-
const manifestContent = fs
|
|
3033
|
+
const manifestContent = fs.readFileSync(manifestPath, "utf-8");
|
|
3054
3034
|
manifestRaw = JSON.parse(manifestContent);
|
|
3055
3035
|
} catch (err) {
|
|
3056
3036
|
diagnostics.push({
|
|
@@ -3063,10 +3043,10 @@ function loadLearnosityBundle(bundleDir) {
|
|
|
3063
3043
|
}
|
|
3064
3044
|
const manifest = validateManifest(manifestRaw, diagnostics);
|
|
3065
3045
|
if (!manifest) return { diagnostics };
|
|
3066
|
-
const itemsDir = path
|
|
3046
|
+
const itemsDir = path.join(bundleDir, "items");
|
|
3067
3047
|
const autoCreatedActivities = /* @__PURE__ */ new Set();
|
|
3068
|
-
if (Object.keys(manifest.activities).length === 0 && fs
|
|
3069
|
-
const itemFiles = fs
|
|
3048
|
+
if (Object.keys(manifest.activities).length === 0 && fs.existsSync(itemsDir) && fs.statSync(itemsDir).isDirectory()) {
|
|
3049
|
+
const itemFiles = fs.readdirSync(itemsDir).filter((f) => f.endsWith(".json"));
|
|
3070
3050
|
if (itemFiles.length > 0) {
|
|
3071
3051
|
const defaultActivityRef = "default_activity";
|
|
3072
3052
|
const items = itemFiles.map((f) => ({ reference: f.replace(/\.json$/, "") }));
|
|
@@ -3113,7 +3093,7 @@ function loadLearnosityBundle(bundleDir) {
|
|
|
3113
3093
|
activityItemRefs.set(activityRef, itemRefs);
|
|
3114
3094
|
let activityFilePath = `activities/${activityRef}.json`;
|
|
3115
3095
|
let activityFullPath = safeResolve(activityFilePath, bundleDir);
|
|
3116
|
-
if (!activityFullPath || !fs
|
|
3096
|
+
if (!activityFullPath || !fs.existsSync(activityFullPath)) {
|
|
3117
3097
|
activityFilePath = `activities/${`${md5Hash(activityRef)}.json`}`;
|
|
3118
3098
|
activityFullPath = safeResolve(activityFilePath, bundleDir);
|
|
3119
3099
|
}
|
|
@@ -3126,7 +3106,7 @@ function loadLearnosityBundle(bundleDir) {
|
|
|
3126
3106
|
});
|
|
3127
3107
|
continue;
|
|
3128
3108
|
}
|
|
3129
|
-
if (!fs
|
|
3109
|
+
if (!fs.existsSync(activityFullPath)) {
|
|
3130
3110
|
if (!autoCreatedActivities.has(activityRef)) diagnostics.push({
|
|
3131
3111
|
code: DiagnosticCode.LRN_ACTIVITY_FILE_MISSING,
|
|
3132
3112
|
level: "warning",
|
|
@@ -3136,7 +3116,7 @@ function loadLearnosityBundle(bundleDir) {
|
|
|
3136
3116
|
continue;
|
|
3137
3117
|
}
|
|
3138
3118
|
try {
|
|
3139
|
-
const activityContent = fs
|
|
3119
|
+
const activityContent = fs.readFileSync(activityFullPath, "utf-8");
|
|
3140
3120
|
const activityJson = JSON.parse(activityContent);
|
|
3141
3121
|
activitiesJsonByRef.set(activityRef, activityJson);
|
|
3142
3122
|
if (itemRefs.length === 0 && activityJson && typeof activityJson === "object" && "data" in activityJson) {
|
|
@@ -3174,11 +3154,11 @@ function loadLearnosityBundle(bundleDir) {
|
|
|
3174
3154
|
const originalItemFilePath = `items/${itemRef}.json`;
|
|
3175
3155
|
let itemFilePath = originalItemFilePath;
|
|
3176
3156
|
let itemFullPath = safeResolve(itemFilePath, bundleDir);
|
|
3177
|
-
if (!itemFullPath || !fs
|
|
3157
|
+
if (!itemFullPath || !fs.existsSync(itemFullPath)) {
|
|
3178
3158
|
itemFilePath = `items/${`${md5Hash(itemRef)}.json`}`;
|
|
3179
3159
|
itemFullPath = safeResolve(itemFilePath, bundleDir);
|
|
3180
3160
|
}
|
|
3181
|
-
if ((!itemFullPath || !fs
|
|
3161
|
+
if ((!itemFullPath || !fs.existsSync(itemFullPath)) && itemRefToId.has(itemRef)) {
|
|
3182
3162
|
itemFilePath = `items/${`${md5Hash(itemRefToId.get(itemRef))}.json`}`;
|
|
3183
3163
|
itemFullPath = safeResolve(itemFilePath, bundleDir);
|
|
3184
3164
|
}
|
|
@@ -3191,7 +3171,7 @@ function loadLearnosityBundle(bundleDir) {
|
|
|
3191
3171
|
});
|
|
3192
3172
|
continue;
|
|
3193
3173
|
}
|
|
3194
|
-
if (!fs
|
|
3174
|
+
if (!fs.existsSync(itemFullPath)) {
|
|
3195
3175
|
diagnostics.push({
|
|
3196
3176
|
code: DiagnosticCode.LRN_ITEM_FILE_MISSING,
|
|
3197
3177
|
level: "error",
|
|
@@ -3201,7 +3181,7 @@ function loadLearnosityBundle(bundleDir) {
|
|
|
3201
3181
|
continue;
|
|
3202
3182
|
}
|
|
3203
3183
|
try {
|
|
3204
|
-
const itemContent = fs
|
|
3184
|
+
const itemContent = fs.readFileSync(itemFullPath, "utf-8");
|
|
3205
3185
|
const itemJson = JSON.parse(itemContent);
|
|
3206
3186
|
itemsJsonByRef.set(itemRef, itemJson);
|
|
3207
3187
|
itemRefToFilename.set(itemRef, itemFilePath);
|
|
@@ -3342,8 +3322,7 @@ function validateManifest(raw, diagnostics) {
|
|
|
3342
3322
|
function md5Hash(str) {
|
|
3343
3323
|
return crypto.createHash("md5").update(str).digest("hex");
|
|
3344
3324
|
}
|
|
3345
|
-
|
|
3346
|
-
//#region ../core/src/learnosity-bundle/writeLearnosityBundle.ts
|
|
3325
|
+
// ../core/src/learnosity-bundle/writeLearnosityBundle.ts
|
|
3347
3326
|
/**
|
|
3348
3327
|
* Write Learnosity Bundle to directory with deterministic JSON
|
|
3349
3328
|
* TASK 014
|
|
@@ -3444,8 +3423,7 @@ async function writeLearnosityBundle(bundle, options) {
|
|
|
3444
3423
|
return { diagnostics };
|
|
3445
3424
|
}
|
|
3446
3425
|
}
|
|
3447
|
-
|
|
3448
|
-
//#region ../core/src/qti-serializer/serializeLomMetadata.ts
|
|
3426
|
+
// ../core/src/qti-serializer/serializeLomMetadata.ts
|
|
3449
3427
|
/**
|
|
3450
3428
|
* Serialize LOM metadata to XML
|
|
3451
3429
|
*
|
|
@@ -3493,8 +3471,7 @@ function serializeLomMetadata(metadata) {
|
|
|
3493
3471
|
parts.push("</imsmd:lom>");
|
|
3494
3472
|
return parts.join("\n");
|
|
3495
3473
|
}
|
|
3496
|
-
|
|
3497
|
-
//#region ../core/src/qti-package/assets/lrnNormalizeCss.ts
|
|
3474
|
+
// ../core/src/qti-package/assets/lrnNormalizeCss.ts
|
|
3498
3475
|
/**
|
|
3499
3476
|
* Embedded lrn-normalize.css content.
|
|
3500
3477
|
*
|
|
@@ -3547,8 +3524,7 @@ object[type='text/html'] {
|
|
|
3547
3524
|
box-sizing: border-box; /* so padding/border don't overflow the wrapper */
|
|
3548
3525
|
}
|
|
3549
3526
|
`;
|
|
3550
|
-
|
|
3551
|
-
//#region ../core/src/learnosity-mapper/buildPackageFromActivity.ts
|
|
3527
|
+
// ../core/src/learnosity-mapper/buildPackageFromActivity.ts
|
|
3552
3528
|
/**
|
|
3553
3529
|
* Build IMS Content Package from converted Activity (TASK 005, TASK 008)
|
|
3554
3530
|
*/
|
|
@@ -3646,15 +3622,15 @@ function buildPackageFromActivity(conversion, options) {
|
|
|
3646
3622
|
};
|
|
3647
3623
|
pkg.resources.push(stimulusResource);
|
|
3648
3624
|
}
|
|
3649
|
-
const assetsDir = path
|
|
3650
|
-
if (fs
|
|
3651
|
-
const assetFiles = fs
|
|
3625
|
+
const assetsDir = path.join(options.bundleDir, "assets");
|
|
3626
|
+
if (fs.existsSync(assetsDir) && fs.statSync(assetsDir).isDirectory()) {
|
|
3627
|
+
const assetFiles = fs.readdirSync(assetsDir, {
|
|
3652
3628
|
recursive: true,
|
|
3653
3629
|
withFileTypes: true
|
|
3654
3630
|
});
|
|
3655
3631
|
for (const entry of assetFiles) if (entry.isFile()) {
|
|
3656
|
-
const entryPath = entry.parentPath ? path
|
|
3657
|
-
const relativePath = path
|
|
3632
|
+
const entryPath = entry.parentPath ? path.join(entry.parentPath, entry.name) : entry.name;
|
|
3633
|
+
const relativePath = path.relative(assetsDir, entryPath);
|
|
3658
3634
|
const safeRelativePath = relativePath.replace(/\\/g, "/");
|
|
3659
3635
|
const assetPath = `assets/${safeRelativePath}`;
|
|
3660
3636
|
const resolvedPath = safeResolve(relativePath, assetsDir);
|
|
@@ -3668,7 +3644,7 @@ function buildPackageFromActivity(conversion, options) {
|
|
|
3668
3644
|
continue;
|
|
3669
3645
|
}
|
|
3670
3646
|
try {
|
|
3671
|
-
const data = fs
|
|
3647
|
+
const data = fs.readFileSync(resolvedPath);
|
|
3672
3648
|
pkg.entries.set(assetPath, {
|
|
3673
3649
|
file: assetPath,
|
|
3674
3650
|
size: data.length,
|
|
@@ -3760,8 +3736,7 @@ function collectGapImgs(ast) {
|
|
|
3760
3736
|
for (const column of ast.layout?.columns ?? []) for (const widget of column.widgets) if (widget.interaction) interactions.push(widget.interaction);
|
|
3761
3737
|
return interactions.flatMap((interaction) => interaction.type === "graphicGapMatch" ? interaction.gapImgs : []);
|
|
3762
3738
|
}
|
|
3763
|
-
|
|
3764
|
-
//#region ../core/src/qti-to-learnosity/loadPackageDirectory.ts
|
|
3739
|
+
// ../core/src/qti-to-learnosity/loadPackageDirectory.ts
|
|
3765
3740
|
/**
|
|
3766
3741
|
* Node.js-only loader that reads a QTI Content Package **directory** from disk
|
|
3767
3742
|
* into an in-memory entries map, for feeding into the (pure)
|
|
@@ -3817,8 +3792,7 @@ function loadPackageDirectory(dirPath) {
|
|
|
3817
3792
|
diagnostics
|
|
3818
3793
|
};
|
|
3819
3794
|
}
|
|
3820
|
-
|
|
3821
|
-
//#region src/utils/batchProcessors.ts
|
|
3795
|
+
// src/utils/batchProcessors.ts
|
|
3822
3796
|
/**
|
|
3823
3797
|
* Per-package conversion tasks, shared by the serial batch path
|
|
3824
3798
|
* (`processBatch`) and the parallel worker path (`processBatchParallel` via
|
|
@@ -4030,7 +4004,6 @@ async function processLearnosityToQtiPackage(pkg, packageOutputPath, options, qu
|
|
|
4030
4004
|
function itemRefsToFilenames(bundle, itemRefs) {
|
|
4031
4005
|
return [...itemRefs].map((itemRef) => bundle.itemRefToFilename.get(itemRef) ?? itemRef);
|
|
4032
4006
|
}
|
|
4033
|
-
//#endregion
|
|
4034
4007
|
export { buildPackageFromActivity as a, saveQtiContentPackage as c, ensureUniqueFolderName as d, sanitizeFolderName as f, loadPackageDirectory as i, convertQtiPackageToLearnosityBundle as l, processQtiPackageToLearnosity as n, writeLearnosityBundle as o, convertActivity as p, runBatchTask as r, loadLearnosityBundle as s, processLearnosityToQtiPackage as t, mergeActivityPackage as u };
|
|
4035
4008
|
|
|
4036
|
-
//# sourceMappingURL=batchProcessors-
|
|
4009
|
+
//# sourceMappingURL=batchProcessors-BGdELwug.js.map
|