@patch-adams/core 1.5.1 → 1.5.3

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 CHANGED
@@ -4152,8 +4152,9 @@ function generateLrsBridgeCode(options) {
4152
4152
  });
4153
4153
  }
4154
4154
 
4155
- // Track submitted Knowledge Check blocks to avoid duplicates
4155
+ // Track submitted Knowledge Check questions to avoid duplicates
4156
4156
  var submittedKnowledgeChecks = {};
4157
+ var kcQuestionCounter = 0;
4157
4158
 
4158
4159
  /**
4159
4160
  * Set up interceptors specifically for Rise Knowledge Check blocks
@@ -4185,16 +4186,26 @@ function generateLrsBridgeCode(options) {
4185
4186
  * Extract and send xAPI statement for a Knowledge Check submission
4186
4187
  */
4187
4188
  function extractKnowledgeCheckResult(kcBlock) {
4188
- // Get block ID for deduplication
4189
+ // Get block ID for context
4189
4190
  var blockContainer = kcBlock.closest('[data-block-id]');
4190
4191
  var blockId = blockContainer ? blockContainer.getAttribute('data-block-id') : null;
4191
4192
 
4193
+ // Get question text first \u2014 needed for per-question dedup key
4194
+ var questionText = '';
4195
+ var questionTextEl = kcBlock.querySelector('.quiz-card__title .fr-view, .quiz-card__title');
4196
+ if (questionTextEl) {
4197
+ questionText = questionTextEl.textContent.trim();
4198
+ }
4199
+
4192
4200
  // Get question ID from the title element
4193
4201
  var questionTitleEl = kcBlock.querySelector('.quiz-card__title');
4194
- var questionId = questionTitleEl ? questionTitleEl.id : (blockId ? 'q-' + blockId : 'q-' + generateUUID());
4202
+ var questionId = questionTitleEl ? questionTitleEl.id : null;
4203
+
4204
+ // Build a question-specific dedup key using question text hash
4205
+ // This ensures each question in a multi-question quiz block gets its own key
4206
+ var questionHash = questionText ? questionText.substring(0, 100) : (questionId || blockId || generateUUID());
4207
+ var submissionKey = 'kc-' + questionHash;
4195
4208
 
4196
- // Check if we already processed this submission (avoid duplicates)
4197
- var submissionKey = blockId || questionId;
4198
4209
  var feedbackLabel = kcBlock.querySelector('.quiz-card__feedback-label');
4199
4210
  if (!feedbackLabel) {
4200
4211
  log('Knowledge Check: No feedback visible yet');
@@ -4210,11 +4221,9 @@ function generateLrsBridgeCode(options) {
4210
4221
  }
4211
4222
  submittedKnowledgeChecks[submissionId] = true;
4212
4223
 
4213
- // Get question text
4214
- var questionText = '';
4215
- var questionTextEl = kcBlock.querySelector('.quiz-card__title .fr-view, .quiz-card__title');
4216
- if (questionTextEl) {
4217
- questionText = questionTextEl.textContent.trim();
4224
+ // Use question-specific ID for the statement (not the shared block ID)
4225
+ if (!questionId) {
4226
+ questionId = blockId ? 'q-' + blockId + '-' + questionHash.substring(0, 20) : 'q-' + generateUUID();
4218
4227
  }
4219
4228
 
4220
4229
  // Determine question type from aria-label
@@ -4243,11 +4252,14 @@ function generateLrsBridgeCode(options) {
4243
4252
  correct: isCorrect
4244
4253
  });
4245
4254
 
4255
+ // Increment question counter for this session
4256
+ kcQuestionCounter++;
4257
+
4246
4258
  // Send question answered statement using existing LRS method
4247
4259
  LRS.questionAnswered({
4248
4260
  questionId: questionId,
4249
4261
  questionGuid: blockId || generateUUID(),
4250
- questionNumber: 1,
4262
+ questionNumber: kcQuestionCounter,
4251
4263
  questionText: questionText.substring(0, 500),
4252
4264
  questionType: questionType,
4253
4265
  answer: answerText.substring(0, 500),
@@ -5096,8 +5108,9 @@ function generateSkinCssLoader(options) {
5096
5108
  }
5097
5109
  function buildSkinCssOptions(config) {
5098
5110
  if (!config.skin) return null;
5111
+ const cacheBuster = Date.now().toString(36) + Math.random().toString(36).slice(2, 6);
5099
5112
  return {
5100
- remoteUrl: `${config.remoteDomain}/skin/${config.skin}/style.css`,
5113
+ remoteUrl: `${config.remoteDomain}/skin/${config.skin}/style.css?v=${cacheBuster}`,
5101
5114
  localPath: `skin/${config.skin}/style.css`,
5102
5115
  timeout: config.cssAfter.timeout
5103
5116
  // reuse cssAfter timeout
@@ -5197,8 +5210,9 @@ function generateSkinJsLoader(options) {
5197
5210
  }
5198
5211
  function buildSkinJsOptions(config) {
5199
5212
  if (!config.skin) return null;
5213
+ const cacheBuster = Date.now().toString(36) + Math.random().toString(36).slice(2, 6);
5200
5214
  return {
5201
- remoteUrl: `${config.remoteDomain}/skin/${config.skin}/script.js`,
5215
+ remoteUrl: `${config.remoteDomain}/skin/${config.skin}/script.js?v=${cacheBuster}`,
5202
5216
  localPath: `skin/${config.skin}/script.js`,
5203
5217
  timeout: config.jsAfter.timeout
5204
5218
  // reuse jsAfter timeout