@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/index.cjs CHANGED
@@ -2242,7 +2242,56 @@ function generateLrsBridgeCode(options) {
2242
2242
  info.versionId = paMeta.versionId || info.versionId;
2243
2243
  }
2244
2244
 
2245
- // 8. Build the course ID in Xyleme IRI format
2245
+ // 8. Extract Bravais document name from launch environment (runtime)
2246
+ // This is the name shown in Bravais Analytics and used for search.
2247
+ // Overrides packageName so the statement object name matches the Bravais document.
2248
+ if (!info.packageName) {
2249
+ var bravaisDocName = null;
2250
+
2251
+ // Strategy 1: Walk parent frames for PARAMS.documentName
2252
+ try {
2253
+ var win = window;
2254
+ for (var i = 0; i < 10; i++) {
2255
+ try {
2256
+ if (win.PARAMS && win.PARAMS.documentName) {
2257
+ bravaisDocName = win.PARAMS.documentName;
2258
+ log('Bravais document name from PARAMS:', bravaisDocName);
2259
+ break;
2260
+ }
2261
+ } catch (e) {}
2262
+ if (win === win.parent) break;
2263
+ win = win.parent;
2264
+ }
2265
+ } catch (e) {}
2266
+
2267
+ // Strategy 2: Walk parent frames checking window.name
2268
+ // Bravais sets the iframe name attribute to the document name
2269
+ if (!bravaisDocName) {
2270
+ try {
2271
+ var win = window;
2272
+ for (var i = 0; i < 10; i++) {
2273
+ try {
2274
+ var frameName = win.name;
2275
+ // Document names have hyphens and are long; skip generic frame names
2276
+ if (frameName && frameName.length > 20 && frameName.indexOf('-') > -1 &&
2277
+ frameName.indexOf('scorm') === -1 && frameName.indexOf('API') === -1) {
2278
+ bravaisDocName = frameName;
2279
+ log('Bravais document name from frame name:', bravaisDocName);
2280
+ break;
2281
+ }
2282
+ } catch (e) {}
2283
+ if (win === win.parent) break;
2284
+ win = win.parent;
2285
+ }
2286
+ } catch (e) {}
2287
+ }
2288
+
2289
+ if (bravaisDocName) {
2290
+ info.packageName = bravaisDocName;
2291
+ }
2292
+ }
2293
+
2294
+ // 9. Build the course ID in Xyleme IRI format
2246
2295
  // Native format: http://xyleme.com/bravais/document/{guid}
2247
2296
  if (info.guid) {
2248
2297
  info.id = 'http://xyleme.com/bravais/document/' + info.guid;
@@ -2545,12 +2594,19 @@ function generateLrsBridgeCode(options) {
2545
2594
  warn('Missing version GUID - statement may fail Bravais aggregation (document_version_id will be null)');
2546
2595
  }
2547
2596
 
2597
+ // Use packageName (Bravais document name) as the object name when available,
2598
+ // so statements match the searchable document name in Bravais Analytics.
2599
+ // Strip .zip extension to match Bravais convention. Fall back to Rise course title.
2600
+ var objectName = LRS.courseInfo.packageName
2601
+ ? LRS.courseInfo.packageName.replace(/.zip$/i, '')
2602
+ : decodeEntities(LRS.courseInfo.title);
2603
+
2548
2604
  var obj = {
2549
2605
  objectType: 'Activity',
2550
2606
  id: LRS.courseInfo.id,
2551
2607
  definition: {
2552
2608
  type: 'http://xyleme.com/bravais/activities/document',
2553
- name: { 'en-US': decodeEntities(LRS.courseInfo.title) }
2609
+ name: { 'en-US': objectName }
2554
2610
  }
2555
2611
  };
2556
2612