@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.js CHANGED
@@ -2233,7 +2233,56 @@ function generateLrsBridgeCode(options) {
2233
2233
  info.versionId = paMeta.versionId || info.versionId;
2234
2234
  }
2235
2235
 
2236
- // 8. Build the course ID in Xyleme IRI format
2236
+ // 8. Extract Bravais document name from launch environment (runtime)
2237
+ // This is the name shown in Bravais Analytics and used for search.
2238
+ // Overrides packageName so the statement object name matches the Bravais document.
2239
+ if (!info.packageName) {
2240
+ var bravaisDocName = null;
2241
+
2242
+ // Strategy 1: Walk parent frames for PARAMS.documentName
2243
+ try {
2244
+ var win = window;
2245
+ for (var i = 0; i < 10; i++) {
2246
+ try {
2247
+ if (win.PARAMS && win.PARAMS.documentName) {
2248
+ bravaisDocName = win.PARAMS.documentName;
2249
+ log('Bravais document name from PARAMS:', bravaisDocName);
2250
+ break;
2251
+ }
2252
+ } catch (e) {}
2253
+ if (win === win.parent) break;
2254
+ win = win.parent;
2255
+ }
2256
+ } catch (e) {}
2257
+
2258
+ // Strategy 2: Walk parent frames checking window.name
2259
+ // Bravais sets the iframe name attribute to the document name
2260
+ if (!bravaisDocName) {
2261
+ try {
2262
+ var win = window;
2263
+ for (var i = 0; i < 10; i++) {
2264
+ try {
2265
+ var frameName = win.name;
2266
+ // Document names have hyphens and are long; skip generic frame names
2267
+ if (frameName && frameName.length > 20 && frameName.indexOf('-') > -1 &&
2268
+ frameName.indexOf('scorm') === -1 && frameName.indexOf('API') === -1) {
2269
+ bravaisDocName = frameName;
2270
+ log('Bravais document name from frame name:', bravaisDocName);
2271
+ break;
2272
+ }
2273
+ } catch (e) {}
2274
+ if (win === win.parent) break;
2275
+ win = win.parent;
2276
+ }
2277
+ } catch (e) {}
2278
+ }
2279
+
2280
+ if (bravaisDocName) {
2281
+ info.packageName = bravaisDocName;
2282
+ }
2283
+ }
2284
+
2285
+ // 9. Build the course ID in Xyleme IRI format
2237
2286
  // Native format: http://xyleme.com/bravais/document/{guid}
2238
2287
  if (info.guid) {
2239
2288
  info.id = 'http://xyleme.com/bravais/document/' + info.guid;
@@ -2536,12 +2585,19 @@ function generateLrsBridgeCode(options) {
2536
2585
  warn('Missing version GUID - statement may fail Bravais aggregation (document_version_id will be null)');
2537
2586
  }
2538
2587
 
2588
+ // Use packageName (Bravais document name) as the object name when available,
2589
+ // so statements match the searchable document name in Bravais Analytics.
2590
+ // Strip .zip extension to match Bravais convention. Fall back to Rise course title.
2591
+ var objectName = LRS.courseInfo.packageName
2592
+ ? LRS.courseInfo.packageName.replace(/.zip$/i, '')
2593
+ : decodeEntities(LRS.courseInfo.title);
2594
+
2539
2595
  var obj = {
2540
2596
  objectType: 'Activity',
2541
2597
  id: LRS.courseInfo.id,
2542
2598
  definition: {
2543
2599
  type: 'http://xyleme.com/bravais/activities/document',
2544
- name: { 'en-US': decodeEntities(LRS.courseInfo.title) }
2600
+ name: { 'en-US': objectName }
2545
2601
  }
2546
2602
  };
2547
2603