@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/cli.js CHANGED
@@ -3016,15 +3016,37 @@ function generateLrsBridgeCode(options) {
3016
3016
  * Build activity object for questions in Xyleme format
3017
3017
  * Name format: "Assessment Name - Q#: Question text..."
3018
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
+
3019
3033
  function buildQuestionActivityObject(questionInfo) {
3020
- 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
+ }
3021
3043
 
3022
3044
  // Build human-readable display name
3023
3045
  var displayName = (questionInfo.assessmentName || 'Knowledge Check');
3024
3046
  if (questionInfo.questionNumber) {
3025
3047
  displayName += ' - Q' + questionInfo.questionNumber;
3026
3048
  }
3027
- var questionText = questionInfo.text || questionInfo.questionText || '';
3049
+ var questionText = decodeEntities(questionInfo.text || questionInfo.questionText || '');
3028
3050
  if (questionText.length > 50) {
3029
3051
  displayName += ': ' + questionText.substring(0, 47) + '...';
3030
3052
  } else if (questionText.length > 0) {
@@ -4401,10 +4423,12 @@ function generateLrsBridgeCode(options) {
4401
4423
  var interactionId = interaction.id || ('interaction-' + idx);
4402
4424
 
4403
4425
  // Try to make a readable question text from the interaction ID
4404
- var questionText = interactionId
4405
- .replace(/_\\d+$/, '') // remove trailing _0
4406
- .replace(/_/g, ' ') // underscores to spaces
4407
- .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
+ );
4408
4432
 
4409
4433
  // Get lesson context
4410
4434
  var lessonInfo = getCachedLessonInfo();