@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/index.cjs CHANGED
@@ -3819,8 +3819,9 @@ function generateLrsBridgeCode(options) {
3819
3819
  });
3820
3820
  }
3821
3821
 
3822
- // Track submitted Knowledge Check blocks to avoid duplicates
3822
+ // Track submitted Knowledge Check questions to avoid duplicates
3823
3823
  var submittedKnowledgeChecks = {};
3824
+ var kcQuestionCounter = 0;
3824
3825
 
3825
3826
  /**
3826
3827
  * Set up interceptors specifically for Rise Knowledge Check blocks
@@ -3852,16 +3853,26 @@ function generateLrsBridgeCode(options) {
3852
3853
  * Extract and send xAPI statement for a Knowledge Check submission
3853
3854
  */
3854
3855
  function extractKnowledgeCheckResult(kcBlock) {
3855
- // Get block ID for deduplication
3856
+ // Get block ID for context
3856
3857
  var blockContainer = kcBlock.closest('[data-block-id]');
3857
3858
  var blockId = blockContainer ? blockContainer.getAttribute('data-block-id') : null;
3858
3859
 
3860
+ // Get question text first \u2014 needed for per-question dedup key
3861
+ var questionText = '';
3862
+ var questionTextEl = kcBlock.querySelector('.quiz-card__title .fr-view, .quiz-card__title');
3863
+ if (questionTextEl) {
3864
+ questionText = questionTextEl.textContent.trim();
3865
+ }
3866
+
3859
3867
  // Get question ID from the title element
3860
3868
  var questionTitleEl = kcBlock.querySelector('.quiz-card__title');
3861
- var questionId = questionTitleEl ? questionTitleEl.id : (blockId ? 'q-' + blockId : 'q-' + generateUUID());
3869
+ var questionId = questionTitleEl ? questionTitleEl.id : null;
3870
+
3871
+ // Build a question-specific dedup key using question text hash
3872
+ // This ensures each question in a multi-question quiz block gets its own key
3873
+ var questionHash = questionText ? questionText.substring(0, 100) : (questionId || blockId || generateUUID());
3874
+ var submissionKey = 'kc-' + questionHash;
3862
3875
 
3863
- // Check if we already processed this submission (avoid duplicates)
3864
- var submissionKey = blockId || questionId;
3865
3876
  var feedbackLabel = kcBlock.querySelector('.quiz-card__feedback-label');
3866
3877
  if (!feedbackLabel) {
3867
3878
  log('Knowledge Check: No feedback visible yet');
@@ -3877,11 +3888,9 @@ function generateLrsBridgeCode(options) {
3877
3888
  }
3878
3889
  submittedKnowledgeChecks[submissionId] = true;
3879
3890
 
3880
- // Get question text
3881
- var questionText = '';
3882
- var questionTextEl = kcBlock.querySelector('.quiz-card__title .fr-view, .quiz-card__title');
3883
- if (questionTextEl) {
3884
- questionText = questionTextEl.textContent.trim();
3891
+ // Use question-specific ID for the statement (not the shared block ID)
3892
+ if (!questionId) {
3893
+ questionId = blockId ? 'q-' + blockId + '-' + questionHash.substring(0, 20) : 'q-' + generateUUID();
3885
3894
  }
3886
3895
 
3887
3896
  // Determine question type from aria-label
@@ -3910,11 +3919,14 @@ function generateLrsBridgeCode(options) {
3910
3919
  correct: isCorrect
3911
3920
  });
3912
3921
 
3922
+ // Increment question counter for this session
3923
+ kcQuestionCounter++;
3924
+
3913
3925
  // Send question answered statement using existing LRS method
3914
3926
  LRS.questionAnswered({
3915
3927
  questionId: questionId,
3916
3928
  questionGuid: blockId || generateUUID(),
3917
- questionNumber: 1,
3929
+ questionNumber: kcQuestionCounter,
3918
3930
  questionText: questionText.substring(0, 500),
3919
3931
  questionType: questionType,
3920
3932
  answer: answerText.substring(0, 500),
@@ -4763,8 +4775,9 @@ function generateSkinCssLoader(options) {
4763
4775
  }
4764
4776
  function buildSkinCssOptions(config) {
4765
4777
  if (!config.skin) return null;
4778
+ const cacheBuster = Date.now().toString(36) + Math.random().toString(36).slice(2, 6);
4766
4779
  return {
4767
- remoteUrl: `${config.remoteDomain}/skin/${config.skin}/style.css`,
4780
+ remoteUrl: `${config.remoteDomain}/skin/${config.skin}/style.css?v=${cacheBuster}`,
4768
4781
  localPath: `skin/${config.skin}/style.css`,
4769
4782
  timeout: config.cssAfter.timeout
4770
4783
  // reuse cssAfter timeout
@@ -4864,8 +4877,9 @@ function generateSkinJsLoader(options) {
4864
4877
  }
4865
4878
  function buildSkinJsOptions(config) {
4866
4879
  if (!config.skin) return null;
4880
+ const cacheBuster = Date.now().toString(36) + Math.random().toString(36).slice(2, 6);
4867
4881
  return {
4868
- remoteUrl: `${config.remoteDomain}/skin/${config.skin}/script.js`,
4882
+ remoteUrl: `${config.remoteDomain}/skin/${config.skin}/script.js?v=${cacheBuster}`,
4869
4883
  localPath: `skin/${config.skin}/script.js`,
4870
4884
  timeout: config.jsAfter.timeout
4871
4885
  // reuse jsAfter timeout