@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.js
CHANGED
|
@@ -1676,15 +1676,11 @@ function generateLrsBridgeCode(options) {
|
|
|
1676
1676
|
}
|
|
1677
1677
|
|
|
1678
1678
|
/**
|
|
1679
|
-
* Fetch document metadata from Bravais API to get GUIDs
|
|
1680
|
-
*
|
|
1679
|
+
* Fetch document metadata from Bravais shared API to get GUIDs
|
|
1680
|
+
* PRIMARY endpoint: /api/shared/{token}/documents (does NOT require auth)
|
|
1681
|
+
* FALLBACK endpoint: /api/v3/documents/{documentId} (requires auth)
|
|
1681
1682
|
*/
|
|
1682
|
-
function fetchDocumentMetadata(
|
|
1683
|
-
if (!documentId) {
|
|
1684
|
-
callback(null);
|
|
1685
|
-
return;
|
|
1686
|
-
}
|
|
1687
|
-
|
|
1683
|
+
function fetchDocumentMetadata(documentIdOrToken, callback) {
|
|
1688
1684
|
if (documentApiFetched) {
|
|
1689
1685
|
callback(documentApiData);
|
|
1690
1686
|
return;
|
|
@@ -1698,8 +1694,24 @@ function generateLrsBridgeCode(options) {
|
|
|
1698
1694
|
return;
|
|
1699
1695
|
}
|
|
1700
1696
|
|
|
1701
|
-
|
|
1702
|
-
|
|
1697
|
+
// Determine which endpoint to use
|
|
1698
|
+
// If we have a shared link token, use /api/shared/{token}/documents (no auth required)
|
|
1699
|
+
// This is the same endpoint Xyleme Cloud Player uses
|
|
1700
|
+
var sharedToken = LRS.courseInfo ? LRS.courseInfo.sharedLinkToken : null;
|
|
1701
|
+
var apiUrl;
|
|
1702
|
+
|
|
1703
|
+
if (sharedToken) {
|
|
1704
|
+
apiUrl = coreUrl + '/api/shared/' + sharedToken + '/documents';
|
|
1705
|
+
log('Fetching document via shared API (no auth required):', apiUrl);
|
|
1706
|
+
} else if (documentIdOrToken) {
|
|
1707
|
+
apiUrl = coreUrl + '/api/v3/documents/' + documentIdOrToken;
|
|
1708
|
+
log('Fetching document via v3 API (requires auth):', apiUrl);
|
|
1709
|
+
} else {
|
|
1710
|
+
log('No shared token or document ID available for metadata fetch');
|
|
1711
|
+
documentApiFetched = true;
|
|
1712
|
+
callback(null);
|
|
1713
|
+
return;
|
|
1714
|
+
}
|
|
1703
1715
|
|
|
1704
1716
|
var xhr = new XMLHttpRequest();
|
|
1705
1717
|
xhr.open('GET', apiUrl, true);
|
|
@@ -2299,6 +2311,22 @@ function generateLrsBridgeCode(options) {
|
|
|
2299
2311
|
// This allows filtering by type (video, assessment, interaction) in Analytics
|
|
2300
2312
|
if (activityType) {
|
|
2301
2313
|
courseObj.definition.type = activityType;
|
|
2314
|
+
|
|
2315
|
+
// Also update resourceType extension to human-readable form for Bravais Type column
|
|
2316
|
+
courseObj.definition.extensions = courseObj.definition.extensions || {};
|
|
2317
|
+
var resourceTypeMap = {
|
|
2318
|
+
'https://w3id.org/xapi/video/activity-type/video': 'Video',
|
|
2319
|
+
'https://w3id.org/xapi/audio/activity-type/audio': 'Audio',
|
|
2320
|
+
'http://adlnet.gov/expapi/activities/media': 'Media',
|
|
2321
|
+
'http://adlnet.gov/expapi/activities/assessment': 'Assessment',
|
|
2322
|
+
'http://adlnet.gov/expapi/activities/question': 'Question',
|
|
2323
|
+
'http://adlnet.gov/expapi/activities/interaction': 'Interaction',
|
|
2324
|
+
'http://adlnet.gov/expapi/activities/lesson': 'Lesson',
|
|
2325
|
+
'http://adlnet.gov/expapi/activities/module': 'Module',
|
|
2326
|
+
'http://adlnet.gov/expapi/activities/course': 'Course',
|
|
2327
|
+
'http://xyleme.com/bravais/activities/document': 'Course'
|
|
2328
|
+
};
|
|
2329
|
+
courseObj.definition.extensions['resourceType'] = resourceTypeMap[activityType] || 'Course';
|
|
2302
2330
|
}
|
|
2303
2331
|
|
|
2304
2332
|
// Add activity-specific details to extensions
|
|
@@ -3634,32 +3662,25 @@ function generateLrsBridgeCode(options) {
|
|
|
3634
3662
|
}
|
|
3635
3663
|
|
|
3636
3664
|
if (!LRS.courseInfo.guid) {
|
|
3637
|
-
//
|
|
3638
|
-
//
|
|
3665
|
+
// When we have a shared link token, use /api/shared/{token}/documents directly
|
|
3666
|
+
// This endpoint does NOT require authentication and returns both document GUID and version GUID
|
|
3639
3667
|
if (sharedLinkToken) {
|
|
3640
|
-
log('
|
|
3641
|
-
|
|
3642
|
-
|
|
3643
|
-
|
|
3644
|
-
|
|
3645
|
-
|
|
3646
|
-
|
|
3647
|
-
|
|
3648
|
-
LRS.courseInfo.sharedLinkName = linkData.documentName;
|
|
3668
|
+
log('Have shared link token, fetching document data via shared API...');
|
|
3669
|
+
// fetchDocumentMetadata will use /api/shared/{token}/documents when sharedLinkToken is present
|
|
3670
|
+
fetchDocumentMetadata(null, function(docData) {
|
|
3671
|
+
if (docData) {
|
|
3672
|
+
updateCourseInfoFromApi(docData);
|
|
3673
|
+
// Also update document name if available
|
|
3674
|
+
if (docData.name) {
|
|
3675
|
+
LRS.courseInfo.sharedLinkName = docData.name;
|
|
3649
3676
|
}
|
|
3650
|
-
fetchDocDataAndSend(linkData.documentId);
|
|
3651
|
-
} else if (documentId) {
|
|
3652
|
-
// Fallback to extracted document ID (may be thin pack ID)
|
|
3653
|
-
warn('Could not get document ID from shared link, using extracted ID:', documentId);
|
|
3654
|
-
fetchDocDataAndSend(documentId);
|
|
3655
3677
|
} else {
|
|
3656
|
-
|
|
3657
|
-
warn('No document ID available - statements may fail aggregation');
|
|
3658
|
-
setTimeout(sendLaunchEvents, 100);
|
|
3678
|
+
warn('Could not fetch document data from shared API - statements may fail aggregation');
|
|
3659
3679
|
}
|
|
3680
|
+
setTimeout(sendLaunchEvents, 100);
|
|
3660
3681
|
});
|
|
3661
3682
|
} else if (documentId) {
|
|
3662
|
-
// No shared link token, try with extracted document ID
|
|
3683
|
+
// No shared link token, try with extracted document ID (requires auth)
|
|
3663
3684
|
log('No shared link token, fetching document data with ID:', documentId);
|
|
3664
3685
|
fetchDocDataAndSend(documentId);
|
|
3665
3686
|
} else {
|