@patch-adams/core 1.5.6 → 1.5.8
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/dist/cli.cjs +48 -11
- package/dist/cli.cjs.map +1 -1
- package/dist/cli.js +48 -11
- package/dist/cli.js.map +1 -1
- package/dist/index.cjs +48 -11
- package/dist/index.cjs.map +1 -1
- package/dist/index.js +48 -11
- package/dist/index.js.map +1 -1
- package/package.json +1 -1
package/dist/index.js
CHANGED
|
@@ -616,6 +616,14 @@ function generateLrsBridgeCode(options) {
|
|
|
616
616
|
});
|
|
617
617
|
}
|
|
618
618
|
|
|
619
|
+
// Decode HTML entities (e.g., " " & ') to clean text
|
|
620
|
+
function decodeEntities(str) {
|
|
621
|
+
if (!str || typeof str !== 'string') return str;
|
|
622
|
+
var txt = document.createElement('textarea');
|
|
623
|
+
txt.innerHTML = str;
|
|
624
|
+
return txt.value;
|
|
625
|
+
}
|
|
626
|
+
|
|
619
627
|
LRS.sessionId = generateUUID();
|
|
620
628
|
LRS.courseAttemptId = generateUUID(); // Unique per session for Xyleme correlation
|
|
621
629
|
LRS.launchTime = new Date().toISOString();
|
|
@@ -2207,6 +2215,10 @@ function generateLrsBridgeCode(options) {
|
|
|
2207
2215
|
info.id = window.location.href.split('#')[0].split('?')[0];
|
|
2208
2216
|
}
|
|
2209
2217
|
|
|
2218
|
+
// Decode any HTML entities in title/description
|
|
2219
|
+
if (info.title) info.title = decodeEntities(info.title);
|
|
2220
|
+
if (info.description) info.description = decodeEntities(info.description);
|
|
2221
|
+
|
|
2210
2222
|
// Build shared link name if not provided
|
|
2211
2223
|
if (!info.sharedLinkName && info.title && info.sharedLinkToken) {
|
|
2212
2224
|
info.sharedLinkName = info.title + ' - LMS Thin Pack';
|
|
@@ -2386,7 +2398,7 @@ function generateLrsBridgeCode(options) {
|
|
|
2386
2398
|
id: window.location.href.split('#')[0].split('?')[0],
|
|
2387
2399
|
definition: {
|
|
2388
2400
|
type: 'http://xyleme.com/bravais/activities/document',
|
|
2389
|
-
name: { 'en-US': document.title || 'Rise Course' }
|
|
2401
|
+
name: { 'en-US': decodeEntities(document.title) || 'Rise Course' }
|
|
2390
2402
|
}
|
|
2391
2403
|
};
|
|
2392
2404
|
}
|
|
@@ -2417,10 +2429,11 @@ function generateLrsBridgeCode(options) {
|
|
|
2417
2429
|
courseObj.definition.extensions = courseObj.definition.extensions || {};
|
|
2418
2430
|
|
|
2419
2431
|
if (activityDetails) {
|
|
2420
|
-
// Merge activity details into extensions
|
|
2432
|
+
// Merge activity details into extensions, decoding any HTML entities in string values
|
|
2421
2433
|
for (var key in activityDetails) {
|
|
2422
2434
|
if (activityDetails.hasOwnProperty(key)) {
|
|
2423
|
-
|
|
2435
|
+
var val = activityDetails[key];
|
|
2436
|
+
courseObj.definition.extensions[key] = typeof val === 'string' ? decodeEntities(val) : val;
|
|
2424
2437
|
}
|
|
2425
2438
|
}
|
|
2426
2439
|
}
|
|
@@ -2499,7 +2512,7 @@ function generateLrsBridgeCode(options) {
|
|
|
2499
2512
|
id: LRS.courseInfo.id,
|
|
2500
2513
|
definition: {
|
|
2501
2514
|
type: 'http://xyleme.com/bravais/activities/document',
|
|
2502
|
-
name: { 'en-US': LRS.courseInfo.title }
|
|
2515
|
+
name: { 'en-US': decodeEntities(LRS.courseInfo.title) }
|
|
2503
2516
|
}
|
|
2504
2517
|
};
|
|
2505
2518
|
|
|
@@ -2549,7 +2562,7 @@ function generateLrsBridgeCode(options) {
|
|
|
2549
2562
|
objectType: 'Activity',
|
|
2550
2563
|
definition: {
|
|
2551
2564
|
type: 'http://xyleme.com/bravais/activities/document',
|
|
2552
|
-
name: { 'en-US': LRS.courseInfo.title || 'Rise Course' }
|
|
2565
|
+
name: { 'en-US': decodeEntities(LRS.courseInfo.title) || 'Rise Course' }
|
|
2553
2566
|
}
|
|
2554
2567
|
};
|
|
2555
2568
|
|
|
@@ -2671,15 +2684,37 @@ function generateLrsBridgeCode(options) {
|
|
|
2671
2684
|
* Build activity object for questions in Xyleme format
|
|
2672
2685
|
* Name format: "Assessment Name - Q#: Question text..."
|
|
2673
2686
|
*/
|
|
2687
|
+
/**
|
|
2688
|
+
* Simple string hash for generating short, stable IDs from long strings.
|
|
2689
|
+
* Returns a hex string (8 chars). Not cryptographic \u2014 just for uniqueness.
|
|
2690
|
+
*/
|
|
2691
|
+
function hashString(str) {
|
|
2692
|
+
var hash = 0;
|
|
2693
|
+
for (var i = 0; i < str.length; i++) {
|
|
2694
|
+
var ch = str.charCodeAt(i);
|
|
2695
|
+
hash = ((hash << 5) - hash) + ch;
|
|
2696
|
+
hash = hash & hash; // Convert to 32-bit integer
|
|
2697
|
+
}
|
|
2698
|
+
return Math.abs(hash).toString(16).padStart(8, '0');
|
|
2699
|
+
}
|
|
2700
|
+
|
|
2674
2701
|
function buildQuestionActivityObject(questionInfo) {
|
|
2675
|
-
var
|
|
2702
|
+
var rawGuid = questionInfo.questionGuid || questionInfo.id || generateUUID();
|
|
2703
|
+
|
|
2704
|
+
// Ensure the object ID stays under 255 chars total to avoid Bravais aggregation failures.
|
|
2705
|
+
// Rise SCORM interaction IDs can be very long (full slugified question text).
|
|
2706
|
+
// Use a truncated prefix + hash to keep it short but unique and stable.
|
|
2707
|
+
var questionGuid = rawGuid;
|
|
2708
|
+
if (rawGuid.length > 80) {
|
|
2709
|
+
questionGuid = rawGuid.substring(0, 60) + '_' + hashString(rawGuid);
|
|
2710
|
+
}
|
|
2676
2711
|
|
|
2677
2712
|
// Build human-readable display name
|
|
2678
2713
|
var displayName = (questionInfo.assessmentName || 'Knowledge Check');
|
|
2679
2714
|
if (questionInfo.questionNumber) {
|
|
2680
2715
|
displayName += ' - Q' + questionInfo.questionNumber;
|
|
2681
2716
|
}
|
|
2682
|
-
var questionText = questionInfo.text || questionInfo.questionText || '';
|
|
2717
|
+
var questionText = decodeEntities(questionInfo.text || questionInfo.questionText || '');
|
|
2683
2718
|
if (questionText.length > 50) {
|
|
2684
2719
|
displayName += ': ' + questionText.substring(0, 47) + '...';
|
|
2685
2720
|
} else if (questionText.length > 0) {
|
|
@@ -4056,10 +4091,12 @@ function generateLrsBridgeCode(options) {
|
|
|
4056
4091
|
var interactionId = interaction.id || ('interaction-' + idx);
|
|
4057
4092
|
|
|
4058
4093
|
// Try to make a readable question text from the interaction ID
|
|
4059
|
-
var questionText =
|
|
4060
|
-
|
|
4061
|
-
|
|
4062
|
-
|
|
4094
|
+
var questionText = decodeEntities(
|
|
4095
|
+
interactionId
|
|
4096
|
+
.replace(/_\\d+$/, '') // remove trailing _0
|
|
4097
|
+
.replace(/_/g, ' ') // underscores to spaces
|
|
4098
|
+
.substring(0, 200)
|
|
4099
|
+
);
|
|
4063
4100
|
|
|
4064
4101
|
// Get lesson context
|
|
4065
4102
|
var lessonInfo = getCachedLessonInfo();
|