@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.cjs
CHANGED
|
@@ -958,12 +958,30 @@ function generateLrsBridgeCode(options) {
|
|
|
958
958
|
});
|
|
959
959
|
}
|
|
960
960
|
|
|
961
|
-
//
|
|
961
|
+
// Clean HTML entities from text \u2014 handles both proper (") and broken (quot;) forms
|
|
962
|
+
// Rise strips the & from entities in SCORM interaction IDs, so we need both
|
|
962
963
|
function decodeEntities(str) {
|
|
963
964
|
if (!str || typeof str !== 'string') return str;
|
|
964
|
-
|
|
965
|
-
|
|
966
|
-
|
|
965
|
+
// 1. Replace known broken entities (without &) that Rise leaves behind
|
|
966
|
+
str = str
|
|
967
|
+
.replace(/quot;/g, '"')
|
|
968
|
+
.replace(/apos;/g, "'")
|
|
969
|
+
.replace(/amp;/g, '&')
|
|
970
|
+
.replace(/lt;/g, '<')
|
|
971
|
+
.replace(/gt;/g, '>')
|
|
972
|
+
.replace(/nbsp;/g, ' ');
|
|
973
|
+
// 2. Replace numeric entities like " ' " etc.
|
|
974
|
+
str = str.replace(/&#(x?[0-9a-fA-F]+);/g, function(match, code) {
|
|
975
|
+
var num = code.charAt(0) === 'x' ? parseInt(code.substring(1), 16) : parseInt(code, 10);
|
|
976
|
+
return isNaN(num) ? match : String.fromCharCode(num);
|
|
977
|
+
});
|
|
978
|
+
// 3. Catch any remaining standard &entities; via textarea decode
|
|
979
|
+
try {
|
|
980
|
+
var txt = document.createElement('textarea');
|
|
981
|
+
txt.innerHTML = str;
|
|
982
|
+
str = txt.value;
|
|
983
|
+
} catch (e) {}
|
|
984
|
+
return str;
|
|
967
985
|
}
|
|
968
986
|
|
|
969
987
|
LRS.sessionId = generateUUID();
|
|
@@ -3026,15 +3044,37 @@ function generateLrsBridgeCode(options) {
|
|
|
3026
3044
|
* Build activity object for questions in Xyleme format
|
|
3027
3045
|
* Name format: "Assessment Name - Q#: Question text..."
|
|
3028
3046
|
*/
|
|
3047
|
+
/**
|
|
3048
|
+
* Simple string hash for generating short, stable IDs from long strings.
|
|
3049
|
+
* Returns a hex string (8 chars). Not cryptographic \u2014 just for uniqueness.
|
|
3050
|
+
*/
|
|
3051
|
+
function hashString(str) {
|
|
3052
|
+
var hash = 0;
|
|
3053
|
+
for (var i = 0; i < str.length; i++) {
|
|
3054
|
+
var ch = str.charCodeAt(i);
|
|
3055
|
+
hash = ((hash << 5) - hash) + ch;
|
|
3056
|
+
hash = hash & hash; // Convert to 32-bit integer
|
|
3057
|
+
}
|
|
3058
|
+
return Math.abs(hash).toString(16).padStart(8, '0');
|
|
3059
|
+
}
|
|
3060
|
+
|
|
3029
3061
|
function buildQuestionActivityObject(questionInfo) {
|
|
3030
|
-
var
|
|
3062
|
+
var rawGuid = questionInfo.questionGuid || questionInfo.id || generateUUID();
|
|
3063
|
+
|
|
3064
|
+
// Ensure the object ID stays under 255 chars total to avoid Bravais aggregation failures.
|
|
3065
|
+
// Rise SCORM interaction IDs can be very long (full slugified question text).
|
|
3066
|
+
// Use a truncated prefix + hash to keep it short but unique and stable.
|
|
3067
|
+
var questionGuid = rawGuid;
|
|
3068
|
+
if (rawGuid.length > 80) {
|
|
3069
|
+
questionGuid = rawGuid.substring(0, 60) + '_' + hashString(rawGuid);
|
|
3070
|
+
}
|
|
3031
3071
|
|
|
3032
3072
|
// Build human-readable display name
|
|
3033
3073
|
var displayName = (questionInfo.assessmentName || 'Knowledge Check');
|
|
3034
3074
|
if (questionInfo.questionNumber) {
|
|
3035
3075
|
displayName += ' - Q' + questionInfo.questionNumber;
|
|
3036
3076
|
}
|
|
3037
|
-
var questionText = questionInfo.text || questionInfo.questionText || '';
|
|
3077
|
+
var questionText = decodeEntities(questionInfo.text || questionInfo.questionText || '');
|
|
3038
3078
|
if (questionText.length > 50) {
|
|
3039
3079
|
displayName += ': ' + questionText.substring(0, 47) + '...';
|
|
3040
3080
|
} else if (questionText.length > 0) {
|
|
@@ -4411,10 +4451,12 @@ function generateLrsBridgeCode(options) {
|
|
|
4411
4451
|
var interactionId = interaction.id || ('interaction-' + idx);
|
|
4412
4452
|
|
|
4413
4453
|
// Try to make a readable question text from the interaction ID
|
|
4414
|
-
var questionText =
|
|
4415
|
-
|
|
4416
|
-
|
|
4417
|
-
|
|
4454
|
+
var questionText = decodeEntities(
|
|
4455
|
+
interactionId
|
|
4456
|
+
.replace(/_\\d+$/, '') // remove trailing _0
|
|
4457
|
+
.replace(/_/g, ' ') // underscores to spaces
|
|
4458
|
+
.substring(0, 200)
|
|
4459
|
+
);
|
|
4418
4460
|
|
|
4419
4461
|
// Get lesson context
|
|
4420
4462
|
var lessonInfo = getCachedLessonInfo();
|