@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.js CHANGED
@@ -4142,8 +4142,9 @@ function generateLrsBridgeCode(options) {
4142
4142
  });
4143
4143
  }
4144
4144
 
4145
- // Track submitted Knowledge Check blocks to avoid duplicates
4145
+ // Track submitted Knowledge Check questions to avoid duplicates
4146
4146
  var submittedKnowledgeChecks = {};
4147
+ var kcQuestionCounter = 0;
4147
4148
 
4148
4149
  /**
4149
4150
  * Set up interceptors specifically for Rise Knowledge Check blocks
@@ -4175,16 +4176,26 @@ function generateLrsBridgeCode(options) {
4175
4176
  * Extract and send xAPI statement for a Knowledge Check submission
4176
4177
  */
4177
4178
  function extractKnowledgeCheckResult(kcBlock) {
4178
- // Get block ID for deduplication
4179
+ // Get block ID for context
4179
4180
  var blockContainer = kcBlock.closest('[data-block-id]');
4180
4181
  var blockId = blockContainer ? blockContainer.getAttribute('data-block-id') : null;
4181
4182
 
4183
+ // Get question text first \u2014 needed for per-question dedup key
4184
+ var questionText = '';
4185
+ var questionTextEl = kcBlock.querySelector('.quiz-card__title .fr-view, .quiz-card__title');
4186
+ if (questionTextEl) {
4187
+ questionText = questionTextEl.textContent.trim();
4188
+ }
4189
+
4182
4190
  // Get question ID from the title element
4183
4191
  var questionTitleEl = kcBlock.querySelector('.quiz-card__title');
4184
- var questionId = questionTitleEl ? questionTitleEl.id : (blockId ? 'q-' + blockId : 'q-' + generateUUID());
4192
+ var questionId = questionTitleEl ? questionTitleEl.id : null;
4193
+
4194
+ // Build a question-specific dedup key using question text hash
4195
+ // This ensures each question in a multi-question quiz block gets its own key
4196
+ var questionHash = questionText ? questionText.substring(0, 100) : (questionId || blockId || generateUUID());
4197
+ var submissionKey = 'kc-' + questionHash;
4185
4198
 
4186
- // Check if we already processed this submission (avoid duplicates)
4187
- var submissionKey = blockId || questionId;
4188
4199
  var feedbackLabel = kcBlock.querySelector('.quiz-card__feedback-label');
4189
4200
  if (!feedbackLabel) {
4190
4201
  log('Knowledge Check: No feedback visible yet');
@@ -4200,11 +4211,9 @@ function generateLrsBridgeCode(options) {
4200
4211
  }
4201
4212
  submittedKnowledgeChecks[submissionId] = true;
4202
4213
 
4203
- // Get question text
4204
- var questionText = '';
4205
- var questionTextEl = kcBlock.querySelector('.quiz-card__title .fr-view, .quiz-card__title');
4206
- if (questionTextEl) {
4207
- questionText = questionTextEl.textContent.trim();
4214
+ // Use question-specific ID for the statement (not the shared block ID)
4215
+ if (!questionId) {
4216
+ questionId = blockId ? 'q-' + blockId + '-' + questionHash.substring(0, 20) : 'q-' + generateUUID();
4208
4217
  }
4209
4218
 
4210
4219
  // Determine question type from aria-label
@@ -4233,11 +4242,14 @@ function generateLrsBridgeCode(options) {
4233
4242
  correct: isCorrect
4234
4243
  });
4235
4244
 
4245
+ // Increment question counter for this session
4246
+ kcQuestionCounter++;
4247
+
4236
4248
  // Send question answered statement using existing LRS method
4237
4249
  LRS.questionAnswered({
4238
4250
  questionId: questionId,
4239
4251
  questionGuid: blockId || generateUUID(),
4240
- questionNumber: 1,
4252
+ questionNumber: kcQuestionCounter,
4241
4253
  questionText: questionText.substring(0, 500),
4242
4254
  questionType: questionType,
4243
4255
  answer: answerText.substring(0, 500),
@@ -5086,8 +5098,9 @@ function generateSkinCssLoader(options) {
5086
5098
  }
5087
5099
  function buildSkinCssOptions(config) {
5088
5100
  if (!config.skin) return null;
5101
+ const cacheBuster = Date.now().toString(36) + Math.random().toString(36).slice(2, 6);
5089
5102
  return {
5090
- remoteUrl: `${config.remoteDomain}/skin/${config.skin}/style.css`,
5103
+ remoteUrl: `${config.remoteDomain}/skin/${config.skin}/style.css?v=${cacheBuster}`,
5091
5104
  localPath: `skin/${config.skin}/style.css`,
5092
5105
  timeout: config.cssAfter.timeout
5093
5106
  // reuse cssAfter timeout
@@ -5187,8 +5200,9 @@ function generateSkinJsLoader(options) {
5187
5200
  }
5188
5201
  function buildSkinJsOptions(config) {
5189
5202
  if (!config.skin) return null;
5203
+ const cacheBuster = Date.now().toString(36) + Math.random().toString(36).slice(2, 6);
5190
5204
  return {
5191
- remoteUrl: `${config.remoteDomain}/skin/${config.skin}/script.js`,
5205
+ remoteUrl: `${config.remoteDomain}/skin/${config.skin}/script.js?v=${cacheBuster}`,
5192
5206
  localPath: `skin/${config.skin}/script.js`,
5193
5207
  timeout: config.jsAfter.timeout
5194
5208
  // reuse jsAfter timeout