@patch-adams/core 1.5.7 → 1.5.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 +52 -10
- package/dist/cli.cjs.map +1 -1
- package/dist/cli.js +52 -10
- package/dist/cli.js.map +1 -1
- package/dist/index.cjs +52 -10
- package/dist/index.cjs.map +1 -1
- package/dist/index.js +52 -10
- package/dist/index.js.map +1 -1
- package/package.json +1 -1
package/dist/cli.js
CHANGED
|
@@ -948,12 +948,30 @@ function generateLrsBridgeCode(options) {
|
|
|
948
948
|
});
|
|
949
949
|
}
|
|
950
950
|
|
|
951
|
-
//
|
|
951
|
+
// Clean HTML entities from text \u2014 handles both proper (") and broken (quot;) forms
|
|
952
|
+
// Rise strips the & from entities in SCORM interaction IDs, so we need both
|
|
952
953
|
function decodeEntities(str) {
|
|
953
954
|
if (!str || typeof str !== 'string') return str;
|
|
954
|
-
|
|
955
|
-
|
|
956
|
-
|
|
955
|
+
// 1. Replace known broken entities (without &) that Rise leaves behind
|
|
956
|
+
str = str
|
|
957
|
+
.replace(/quot;/g, '"')
|
|
958
|
+
.replace(/apos;/g, "'")
|
|
959
|
+
.replace(/amp;/g, '&')
|
|
960
|
+
.replace(/lt;/g, '<')
|
|
961
|
+
.replace(/gt;/g, '>')
|
|
962
|
+
.replace(/nbsp;/g, ' ');
|
|
963
|
+
// 2. Replace numeric entities like " ' " etc.
|
|
964
|
+
str = str.replace(/&#(x?[0-9a-fA-F]+);/g, function(match, code) {
|
|
965
|
+
var num = code.charAt(0) === 'x' ? parseInt(code.substring(1), 16) : parseInt(code, 10);
|
|
966
|
+
return isNaN(num) ? match : String.fromCharCode(num);
|
|
967
|
+
});
|
|
968
|
+
// 3. Catch any remaining standard &entities; via textarea decode
|
|
969
|
+
try {
|
|
970
|
+
var txt = document.createElement('textarea');
|
|
971
|
+
txt.innerHTML = str;
|
|
972
|
+
str = txt.value;
|
|
973
|
+
} catch (e) {}
|
|
974
|
+
return str;
|
|
957
975
|
}
|
|
958
976
|
|
|
959
977
|
LRS.sessionId = generateUUID();
|
|
@@ -3016,15 +3034,37 @@ function generateLrsBridgeCode(options) {
|
|
|
3016
3034
|
* Build activity object for questions in Xyleme format
|
|
3017
3035
|
* Name format: "Assessment Name - Q#: Question text..."
|
|
3018
3036
|
*/
|
|
3037
|
+
/**
|
|
3038
|
+
* Simple string hash for generating short, stable IDs from long strings.
|
|
3039
|
+
* Returns a hex string (8 chars). Not cryptographic \u2014 just for uniqueness.
|
|
3040
|
+
*/
|
|
3041
|
+
function hashString(str) {
|
|
3042
|
+
var hash = 0;
|
|
3043
|
+
for (var i = 0; i < str.length; i++) {
|
|
3044
|
+
var ch = str.charCodeAt(i);
|
|
3045
|
+
hash = ((hash << 5) - hash) + ch;
|
|
3046
|
+
hash = hash & hash; // Convert to 32-bit integer
|
|
3047
|
+
}
|
|
3048
|
+
return Math.abs(hash).toString(16).padStart(8, '0');
|
|
3049
|
+
}
|
|
3050
|
+
|
|
3019
3051
|
function buildQuestionActivityObject(questionInfo) {
|
|
3020
|
-
var
|
|
3052
|
+
var rawGuid = questionInfo.questionGuid || questionInfo.id || generateUUID();
|
|
3053
|
+
|
|
3054
|
+
// Ensure the object ID stays under 255 chars total to avoid Bravais aggregation failures.
|
|
3055
|
+
// Rise SCORM interaction IDs can be very long (full slugified question text).
|
|
3056
|
+
// Use a truncated prefix + hash to keep it short but unique and stable.
|
|
3057
|
+
var questionGuid = rawGuid;
|
|
3058
|
+
if (rawGuid.length > 80) {
|
|
3059
|
+
questionGuid = rawGuid.substring(0, 60) + '_' + hashString(rawGuid);
|
|
3060
|
+
}
|
|
3021
3061
|
|
|
3022
3062
|
// Build human-readable display name
|
|
3023
3063
|
var displayName = (questionInfo.assessmentName || 'Knowledge Check');
|
|
3024
3064
|
if (questionInfo.questionNumber) {
|
|
3025
3065
|
displayName += ' - Q' + questionInfo.questionNumber;
|
|
3026
3066
|
}
|
|
3027
|
-
var questionText = questionInfo.text || questionInfo.questionText || '';
|
|
3067
|
+
var questionText = decodeEntities(questionInfo.text || questionInfo.questionText || '');
|
|
3028
3068
|
if (questionText.length > 50) {
|
|
3029
3069
|
displayName += ': ' + questionText.substring(0, 47) + '...';
|
|
3030
3070
|
} else if (questionText.length > 0) {
|
|
@@ -4401,10 +4441,12 @@ function generateLrsBridgeCode(options) {
|
|
|
4401
4441
|
var interactionId = interaction.id || ('interaction-' + idx);
|
|
4402
4442
|
|
|
4403
4443
|
// Try to make a readable question text from the interaction ID
|
|
4404
|
-
var questionText =
|
|
4405
|
-
|
|
4406
|
-
|
|
4407
|
-
|
|
4444
|
+
var questionText = decodeEntities(
|
|
4445
|
+
interactionId
|
|
4446
|
+
.replace(/_\\d+$/, '') // remove trailing _0
|
|
4447
|
+
.replace(/_/g, ' ') // underscores to spaces
|
|
4448
|
+
.substring(0, 200)
|
|
4449
|
+
);
|
|
4408
4450
|
|
|
4409
4451
|
// Get lesson context
|
|
4410
4452
|
var lessonInfo = getCachedLessonInfo();
|