@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.js CHANGED
@@ -948,6 +948,14 @@ function generateLrsBridgeCode(options) {
948
948
  });
949
949
  }
950
950
 
951
+ // Decode HTML entities (e.g., " " & ') to clean text
952
+ function decodeEntities(str) {
953
+ if (!str || typeof str !== 'string') return str;
954
+ var txt = document.createElement('textarea');
955
+ txt.innerHTML = str;
956
+ return txt.value;
957
+ }
958
+
951
959
  LRS.sessionId = generateUUID();
952
960
  LRS.courseAttemptId = generateUUID(); // Unique per session for Xyleme correlation
953
961
  LRS.launchTime = new Date().toISOString();
@@ -2539,6 +2547,10 @@ function generateLrsBridgeCode(options) {
2539
2547
  info.id = window.location.href.split('#')[0].split('?')[0];
2540
2548
  }
2541
2549
 
2550
+ // Decode any HTML entities in title/description
2551
+ if (info.title) info.title = decodeEntities(info.title);
2552
+ if (info.description) info.description = decodeEntities(info.description);
2553
+
2542
2554
  // Build shared link name if not provided
2543
2555
  if (!info.sharedLinkName && info.title && info.sharedLinkToken) {
2544
2556
  info.sharedLinkName = info.title + ' - LMS Thin Pack';
@@ -2718,7 +2730,7 @@ function generateLrsBridgeCode(options) {
2718
2730
  id: window.location.href.split('#')[0].split('?')[0],
2719
2731
  definition: {
2720
2732
  type: 'http://xyleme.com/bravais/activities/document',
2721
- name: { 'en-US': document.title || 'Rise Course' }
2733
+ name: { 'en-US': decodeEntities(document.title) || 'Rise Course' }
2722
2734
  }
2723
2735
  };
2724
2736
  }
@@ -2749,10 +2761,11 @@ function generateLrsBridgeCode(options) {
2749
2761
  courseObj.definition.extensions = courseObj.definition.extensions || {};
2750
2762
 
2751
2763
  if (activityDetails) {
2752
- // Merge activity details into extensions
2764
+ // Merge activity details into extensions, decoding any HTML entities in string values
2753
2765
  for (var key in activityDetails) {
2754
2766
  if (activityDetails.hasOwnProperty(key)) {
2755
- courseObj.definition.extensions[key] = activityDetails[key];
2767
+ var val = activityDetails[key];
2768
+ courseObj.definition.extensions[key] = typeof val === 'string' ? decodeEntities(val) : val;
2756
2769
  }
2757
2770
  }
2758
2771
  }
@@ -2831,7 +2844,7 @@ function generateLrsBridgeCode(options) {
2831
2844
  id: LRS.courseInfo.id,
2832
2845
  definition: {
2833
2846
  type: 'http://xyleme.com/bravais/activities/document',
2834
- name: { 'en-US': LRS.courseInfo.title }
2847
+ name: { 'en-US': decodeEntities(LRS.courseInfo.title) }
2835
2848
  }
2836
2849
  };
2837
2850
 
@@ -2881,7 +2894,7 @@ function generateLrsBridgeCode(options) {
2881
2894
  objectType: 'Activity',
2882
2895
  definition: {
2883
2896
  type: 'http://xyleme.com/bravais/activities/document',
2884
- name: { 'en-US': LRS.courseInfo.title || 'Rise Course' }
2897
+ name: { 'en-US': decodeEntities(LRS.courseInfo.title) || 'Rise Course' }
2885
2898
  }
2886
2899
  };
2887
2900
 
@@ -3003,15 +3016,37 @@ function generateLrsBridgeCode(options) {
3003
3016
  * Build activity object for questions in Xyleme format
3004
3017
  * Name format: "Assessment Name - Q#: Question text..."
3005
3018
  */
3019
+ /**
3020
+ * Simple string hash for generating short, stable IDs from long strings.
3021
+ * Returns a hex string (8 chars). Not cryptographic \u2014 just for uniqueness.
3022
+ */
3023
+ function hashString(str) {
3024
+ var hash = 0;
3025
+ for (var i = 0; i < str.length; i++) {
3026
+ var ch = str.charCodeAt(i);
3027
+ hash = ((hash << 5) - hash) + ch;
3028
+ hash = hash & hash; // Convert to 32-bit integer
3029
+ }
3030
+ return Math.abs(hash).toString(16).padStart(8, '0');
3031
+ }
3032
+
3006
3033
  function buildQuestionActivityObject(questionInfo) {
3007
- var questionGuid = questionInfo.questionGuid || questionInfo.id || generateUUID();
3034
+ var rawGuid = questionInfo.questionGuid || questionInfo.id || generateUUID();
3035
+
3036
+ // Ensure the object ID stays under 255 chars total to avoid Bravais aggregation failures.
3037
+ // Rise SCORM interaction IDs can be very long (full slugified question text).
3038
+ // Use a truncated prefix + hash to keep it short but unique and stable.
3039
+ var questionGuid = rawGuid;
3040
+ if (rawGuid.length > 80) {
3041
+ questionGuid = rawGuid.substring(0, 60) + '_' + hashString(rawGuid);
3042
+ }
3008
3043
 
3009
3044
  // Build human-readable display name
3010
3045
  var displayName = (questionInfo.assessmentName || 'Knowledge Check');
3011
3046
  if (questionInfo.questionNumber) {
3012
3047
  displayName += ' - Q' + questionInfo.questionNumber;
3013
3048
  }
3014
- var questionText = questionInfo.text || questionInfo.questionText || '';
3049
+ var questionText = decodeEntities(questionInfo.text || questionInfo.questionText || '');
3015
3050
  if (questionText.length > 50) {
3016
3051
  displayName += ': ' + questionText.substring(0, 47) + '...';
3017
3052
  } else if (questionText.length > 0) {
@@ -4388,10 +4423,12 @@ function generateLrsBridgeCode(options) {
4388
4423
  var interactionId = interaction.id || ('interaction-' + idx);
4389
4424
 
4390
4425
  // Try to make a readable question text from the interaction ID
4391
- var questionText = interactionId
4392
- .replace(/_\\d+$/, '') // remove trailing _0
4393
- .replace(/_/g, ' ') // underscores to spaces
4394
- .substring(0, 200);
4426
+ var questionText = decodeEntities(
4427
+ interactionId
4428
+ .replace(/_\\d+$/, '') // remove trailing _0
4429
+ .replace(/_/g, ' ') // underscores to spaces
4430
+ .substring(0, 200)
4431
+ );
4395
4432
 
4396
4433
  // Get lesson context
4397
4434
  var lessonInfo = getCachedLessonInfo();