@patch-adams/core 1.4.7 → 1.4.9
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 +51 -30
- package/dist/cli.cjs.map +1 -1
- package/dist/cli.js +51 -30
- package/dist/cli.js.map +1 -1
- package/dist/index.cjs +51 -30
- package/dist/index.cjs.map +1 -1
- package/dist/index.js +51 -30
- package/dist/index.js.map +1 -1
- package/package.json +1 -1
package/dist/index.cjs
CHANGED
|
@@ -1684,15 +1684,11 @@ function generateLrsBridgeCode(options) {
|
|
|
1684
1684
|
}
|
|
1685
1685
|
|
|
1686
1686
|
/**
|
|
1687
|
-
* Fetch document metadata from Bravais API to get GUIDs
|
|
1688
|
-
*
|
|
1687
|
+
* Fetch document metadata from Bravais shared API to get GUIDs
|
|
1688
|
+
* PRIMARY endpoint: /api/shared/{token}/documents (does NOT require auth)
|
|
1689
|
+
* FALLBACK endpoint: /api/v3/documents/{documentId} (requires auth)
|
|
1689
1690
|
*/
|
|
1690
|
-
function fetchDocumentMetadata(
|
|
1691
|
-
if (!documentId) {
|
|
1692
|
-
callback(null);
|
|
1693
|
-
return;
|
|
1694
|
-
}
|
|
1695
|
-
|
|
1691
|
+
function fetchDocumentMetadata(documentIdOrToken, callback) {
|
|
1696
1692
|
if (documentApiFetched) {
|
|
1697
1693
|
callback(documentApiData);
|
|
1698
1694
|
return;
|
|
@@ -1706,8 +1702,24 @@ function generateLrsBridgeCode(options) {
|
|
|
1706
1702
|
return;
|
|
1707
1703
|
}
|
|
1708
1704
|
|
|
1709
|
-
|
|
1710
|
-
|
|
1705
|
+
// Determine which endpoint to use
|
|
1706
|
+
// If we have a shared link token, use /api/shared/{token}/documents (no auth required)
|
|
1707
|
+
// This is the same endpoint Xyleme Cloud Player uses
|
|
1708
|
+
var sharedToken = LRS.courseInfo ? LRS.courseInfo.sharedLinkToken : null;
|
|
1709
|
+
var apiUrl;
|
|
1710
|
+
|
|
1711
|
+
if (sharedToken) {
|
|
1712
|
+
apiUrl = coreUrl + '/api/shared/' + sharedToken + '/documents';
|
|
1713
|
+
log('Fetching document via shared API (no auth required):', apiUrl);
|
|
1714
|
+
} else if (documentIdOrToken) {
|
|
1715
|
+
apiUrl = coreUrl + '/api/v3/documents/' + documentIdOrToken;
|
|
1716
|
+
log('Fetching document via v3 API (requires auth):', apiUrl);
|
|
1717
|
+
} else {
|
|
1718
|
+
log('No shared token or document ID available for metadata fetch');
|
|
1719
|
+
documentApiFetched = true;
|
|
1720
|
+
callback(null);
|
|
1721
|
+
return;
|
|
1722
|
+
}
|
|
1711
1723
|
|
|
1712
1724
|
var xhr = new XMLHttpRequest();
|
|
1713
1725
|
xhr.open('GET', apiUrl, true);
|
|
@@ -2307,6 +2319,22 @@ function generateLrsBridgeCode(options) {
|
|
|
2307
2319
|
// This allows filtering by type (video, assessment, interaction) in Analytics
|
|
2308
2320
|
if (activityType) {
|
|
2309
2321
|
courseObj.definition.type = activityType;
|
|
2322
|
+
|
|
2323
|
+
// Also update resourceType extension to human-readable form for Bravais Type column
|
|
2324
|
+
courseObj.definition.extensions = courseObj.definition.extensions || {};
|
|
2325
|
+
var resourceTypeMap = {
|
|
2326
|
+
'https://w3id.org/xapi/video/activity-type/video': 'Video',
|
|
2327
|
+
'https://w3id.org/xapi/audio/activity-type/audio': 'Audio',
|
|
2328
|
+
'http://adlnet.gov/expapi/activities/media': 'Media',
|
|
2329
|
+
'http://adlnet.gov/expapi/activities/assessment': 'Assessment',
|
|
2330
|
+
'http://adlnet.gov/expapi/activities/question': 'Question',
|
|
2331
|
+
'http://adlnet.gov/expapi/activities/interaction': 'Interaction',
|
|
2332
|
+
'http://adlnet.gov/expapi/activities/lesson': 'Lesson',
|
|
2333
|
+
'http://adlnet.gov/expapi/activities/module': 'Module',
|
|
2334
|
+
'http://adlnet.gov/expapi/activities/course': 'Course',
|
|
2335
|
+
'http://xyleme.com/bravais/activities/document': 'Course'
|
|
2336
|
+
};
|
|
2337
|
+
courseObj.definition.extensions['resourceType'] = resourceTypeMap[activityType] || 'Course';
|
|
2310
2338
|
}
|
|
2311
2339
|
|
|
2312
2340
|
// Add activity-specific details to extensions
|
|
@@ -3642,32 +3670,25 @@ function generateLrsBridgeCode(options) {
|
|
|
3642
3670
|
}
|
|
3643
3671
|
|
|
3644
3672
|
if (!LRS.courseInfo.guid) {
|
|
3645
|
-
//
|
|
3646
|
-
//
|
|
3673
|
+
// When we have a shared link token, use /api/shared/{token}/documents directly
|
|
3674
|
+
// This endpoint does NOT require authentication and returns both document GUID and version GUID
|
|
3647
3675
|
if (sharedLinkToken) {
|
|
3648
|
-
log('
|
|
3649
|
-
|
|
3650
|
-
|
|
3651
|
-
|
|
3652
|
-
|
|
3653
|
-
|
|
3654
|
-
|
|
3655
|
-
|
|
3656
|
-
LRS.courseInfo.sharedLinkName = linkData.documentName;
|
|
3676
|
+
log('Have shared link token, fetching document data via shared API...');
|
|
3677
|
+
// fetchDocumentMetadata will use /api/shared/{token}/documents when sharedLinkToken is present
|
|
3678
|
+
fetchDocumentMetadata(null, function(docData) {
|
|
3679
|
+
if (docData) {
|
|
3680
|
+
updateCourseInfoFromApi(docData);
|
|
3681
|
+
// Also update document name if available
|
|
3682
|
+
if (docData.name) {
|
|
3683
|
+
LRS.courseInfo.sharedLinkName = docData.name;
|
|
3657
3684
|
}
|
|
3658
|
-
fetchDocDataAndSend(linkData.documentId);
|
|
3659
|
-
} else if (documentId) {
|
|
3660
|
-
// Fallback to extracted document ID (may be thin pack ID)
|
|
3661
|
-
warn('Could not get document ID from shared link, using extracted ID:', documentId);
|
|
3662
|
-
fetchDocDataAndSend(documentId);
|
|
3663
3685
|
} else {
|
|
3664
|
-
|
|
3665
|
-
warn('No document ID available - statements may fail aggregation');
|
|
3666
|
-
setTimeout(sendLaunchEvents, 100);
|
|
3686
|
+
warn('Could not fetch document data from shared API - statements may fail aggregation');
|
|
3667
3687
|
}
|
|
3688
|
+
setTimeout(sendLaunchEvents, 100);
|
|
3668
3689
|
});
|
|
3669
3690
|
} else if (documentId) {
|
|
3670
|
-
// No shared link token, try with extracted document ID
|
|
3691
|
+
// No shared link token, try with extracted document ID (requires auth)
|
|
3671
3692
|
log('No shared link token, fetching document data with ID:', documentId);
|
|
3672
3693
|
fetchDocDataAndSend(documentId);
|
|
3673
3694
|
} else {
|