@patch-adams/core 1.5.2 → 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.js CHANGED
@@ -3810,8 +3810,9 @@ function generateLrsBridgeCode(options) {
3810
3810
  });
3811
3811
  }
3812
3812
 
3813
- // Track submitted Knowledge Check blocks to avoid duplicates
3813
+ // Track submitted Knowledge Check questions to avoid duplicates
3814
3814
  var submittedKnowledgeChecks = {};
3815
+ var kcQuestionCounter = 0;
3815
3816
 
3816
3817
  /**
3817
3818
  * Set up interceptors specifically for Rise Knowledge Check blocks
@@ -3843,16 +3844,26 @@ function generateLrsBridgeCode(options) {
3843
3844
  * Extract and send xAPI statement for a Knowledge Check submission
3844
3845
  */
3845
3846
  function extractKnowledgeCheckResult(kcBlock) {
3846
- // Get block ID for deduplication
3847
+ // Get block ID for context
3847
3848
  var blockContainer = kcBlock.closest('[data-block-id]');
3848
3849
  var blockId = blockContainer ? blockContainer.getAttribute('data-block-id') : null;
3849
3850
 
3851
+ // Get question text first \u2014 needed for per-question dedup key
3852
+ var questionText = '';
3853
+ var questionTextEl = kcBlock.querySelector('.quiz-card__title .fr-view, .quiz-card__title');
3854
+ if (questionTextEl) {
3855
+ questionText = questionTextEl.textContent.trim();
3856
+ }
3857
+
3850
3858
  // Get question ID from the title element
3851
3859
  var questionTitleEl = kcBlock.querySelector('.quiz-card__title');
3852
- var questionId = questionTitleEl ? questionTitleEl.id : (blockId ? 'q-' + blockId : 'q-' + generateUUID());
3860
+ var questionId = questionTitleEl ? questionTitleEl.id : null;
3861
+
3862
+ // Build a question-specific dedup key using question text hash
3863
+ // This ensures each question in a multi-question quiz block gets its own key
3864
+ var questionHash = questionText ? questionText.substring(0, 100) : (questionId || blockId || generateUUID());
3865
+ var submissionKey = 'kc-' + questionHash;
3853
3866
 
3854
- // Check if we already processed this submission (avoid duplicates)
3855
- var submissionKey = blockId || questionId;
3856
3867
  var feedbackLabel = kcBlock.querySelector('.quiz-card__feedback-label');
3857
3868
  if (!feedbackLabel) {
3858
3869
  log('Knowledge Check: No feedback visible yet');
@@ -3868,11 +3879,9 @@ function generateLrsBridgeCode(options) {
3868
3879
  }
3869
3880
  submittedKnowledgeChecks[submissionId] = true;
3870
3881
 
3871
- // Get question text
3872
- var questionText = '';
3873
- var questionTextEl = kcBlock.querySelector('.quiz-card__title .fr-view, .quiz-card__title');
3874
- if (questionTextEl) {
3875
- questionText = questionTextEl.textContent.trim();
3882
+ // Use question-specific ID for the statement (not the shared block ID)
3883
+ if (!questionId) {
3884
+ questionId = blockId ? 'q-' + blockId + '-' + questionHash.substring(0, 20) : 'q-' + generateUUID();
3876
3885
  }
3877
3886
 
3878
3887
  // Determine question type from aria-label
@@ -3901,11 +3910,14 @@ function generateLrsBridgeCode(options) {
3901
3910
  correct: isCorrect
3902
3911
  });
3903
3912
 
3913
+ // Increment question counter for this session
3914
+ kcQuestionCounter++;
3915
+
3904
3916
  // Send question answered statement using existing LRS method
3905
3917
  LRS.questionAnswered({
3906
3918
  questionId: questionId,
3907
3919
  questionGuid: blockId || generateUUID(),
3908
- questionNumber: 1,
3920
+ questionNumber: kcQuestionCounter,
3909
3921
  questionText: questionText.substring(0, 500),
3910
3922
  questionType: questionType,
3911
3923
  answer: answerText.substring(0, 500),