@patch-adams/core 1.5.14 → 1.5.16

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 CHANGED
@@ -2574,7 +2574,56 @@ function generateLrsBridgeCode(options) {
2574
2574
  info.versionId = paMeta.versionId || info.versionId;
2575
2575
  }
2576
2576
 
2577
- // 8. Build the course ID in Xyleme IRI format
2577
+ // 8. Extract Bravais document name from launch environment (runtime)
2578
+ // This is the name shown in Bravais Analytics and used for search.
2579
+ // Overrides packageName so the statement object name matches the Bravais document.
2580
+ if (!info.packageName) {
2581
+ var bravaisDocName = null;
2582
+
2583
+ // Strategy 1: Walk parent frames for PARAMS.documentName
2584
+ try {
2585
+ var win = window;
2586
+ for (var i = 0; i < 10; i++) {
2587
+ try {
2588
+ if (win.PARAMS && win.PARAMS.documentName) {
2589
+ bravaisDocName = win.PARAMS.documentName;
2590
+ log('Bravais document name from PARAMS:', bravaisDocName);
2591
+ break;
2592
+ }
2593
+ } catch (e) {}
2594
+ if (win === win.parent) break;
2595
+ win = win.parent;
2596
+ }
2597
+ } catch (e) {}
2598
+
2599
+ // Strategy 2: Walk parent frames checking window.name
2600
+ // Bravais sets the iframe name attribute to the document name
2601
+ if (!bravaisDocName) {
2602
+ try {
2603
+ var win = window;
2604
+ for (var i = 0; i < 10; i++) {
2605
+ try {
2606
+ var frameName = win.name;
2607
+ // Document names have hyphens and are long; skip generic frame names
2608
+ if (frameName && frameName.length > 20 && frameName.indexOf('-') > -1 &&
2609
+ frameName.indexOf('scorm') === -1 && frameName.indexOf('API') === -1) {
2610
+ bravaisDocName = frameName;
2611
+ log('Bravais document name from frame name:', bravaisDocName);
2612
+ break;
2613
+ }
2614
+ } catch (e) {}
2615
+ if (win === win.parent) break;
2616
+ win = win.parent;
2617
+ }
2618
+ } catch (e) {}
2619
+ }
2620
+
2621
+ if (bravaisDocName) {
2622
+ info.packageName = bravaisDocName;
2623
+ }
2624
+ }
2625
+
2626
+ // 9. Build the course ID in Xyleme IRI format
2578
2627
  // Native format: http://xyleme.com/bravais/document/{guid}
2579
2628
  if (info.guid) {
2580
2629
  info.id = 'http://xyleme.com/bravais/document/' + info.guid;
@@ -2877,12 +2926,19 @@ function generateLrsBridgeCode(options) {
2877
2926
  warn('Missing version GUID - statement may fail Bravais aggregation (document_version_id will be null)');
2878
2927
  }
2879
2928
 
2929
+ // Use packageName (Bravais document name) as the object name when available,
2930
+ // so statements match the searchable document name in Bravais Analytics.
2931
+ // Strip .zip extension to match Bravais convention. Fall back to Rise course title.
2932
+ var objectName = LRS.courseInfo.packageName
2933
+ ? LRS.courseInfo.packageName.replace(/.zip$/i, '')
2934
+ : decodeEntities(LRS.courseInfo.title);
2935
+
2880
2936
  var obj = {
2881
2937
  objectType: 'Activity',
2882
2938
  id: LRS.courseInfo.id,
2883
2939
  definition: {
2884
2940
  type: 'http://xyleme.com/bravais/activities/document',
2885
- name: { 'en-US': decodeEntities(LRS.courseInfo.title) }
2941
+ name: { 'en-US': objectName }
2886
2942
  }
2887
2943
  };
2888
2944