@patch-adams/core 1.5.7 → 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/index.cjs CHANGED
@@ -2693,15 +2693,37 @@ function generateLrsBridgeCode(options) {
2693
2693
  * Build activity object for questions in Xyleme format
2694
2694
  * Name format: "Assessment Name - Q#: Question text..."
2695
2695
  */
2696
+ /**
2697
+ * Simple string hash for generating short, stable IDs from long strings.
2698
+ * Returns a hex string (8 chars). Not cryptographic \u2014 just for uniqueness.
2699
+ */
2700
+ function hashString(str) {
2701
+ var hash = 0;
2702
+ for (var i = 0; i < str.length; i++) {
2703
+ var ch = str.charCodeAt(i);
2704
+ hash = ((hash << 5) - hash) + ch;
2705
+ hash = hash & hash; // Convert to 32-bit integer
2706
+ }
2707
+ return Math.abs(hash).toString(16).padStart(8, '0');
2708
+ }
2709
+
2696
2710
  function buildQuestionActivityObject(questionInfo) {
2697
- var questionGuid = questionInfo.questionGuid || questionInfo.id || generateUUID();
2711
+ var rawGuid = questionInfo.questionGuid || questionInfo.id || generateUUID();
2712
+
2713
+ // Ensure the object ID stays under 255 chars total to avoid Bravais aggregation failures.
2714
+ // Rise SCORM interaction IDs can be very long (full slugified question text).
2715
+ // Use a truncated prefix + hash to keep it short but unique and stable.
2716
+ var questionGuid = rawGuid;
2717
+ if (rawGuid.length > 80) {
2718
+ questionGuid = rawGuid.substring(0, 60) + '_' + hashString(rawGuid);
2719
+ }
2698
2720
 
2699
2721
  // Build human-readable display name
2700
2722
  var displayName = (questionInfo.assessmentName || 'Knowledge Check');
2701
2723
  if (questionInfo.questionNumber) {
2702
2724
  displayName += ' - Q' + questionInfo.questionNumber;
2703
2725
  }
2704
- var questionText = questionInfo.text || questionInfo.questionText || '';
2726
+ var questionText = decodeEntities(questionInfo.text || questionInfo.questionText || '');
2705
2727
  if (questionText.length > 50) {
2706
2728
  displayName += ': ' + questionText.substring(0, 47) + '...';
2707
2729
  } else if (questionText.length > 0) {
@@ -4078,10 +4100,12 @@ function generateLrsBridgeCode(options) {
4078
4100
  var interactionId = interaction.id || ('interaction-' + idx);
4079
4101
 
4080
4102
  // Try to make a readable question text from the interaction ID
4081
- var questionText = interactionId
4082
- .replace(/_\\d+$/, '') // remove trailing _0
4083
- .replace(/_/g, ' ') // underscores to spaces
4084
- .substring(0, 200);
4103
+ var questionText = decodeEntities(
4104
+ interactionId
4105
+ .replace(/_\\d+$/, '') // remove trailing _0
4106
+ .replace(/_/g, ' ') // underscores to spaces
4107
+ .substring(0, 200)
4108
+ );
4085
4109
 
4086
4110
  // Get lesson context
4087
4111
  var lessonInfo = getCachedLessonInfo();